Java Code Examples for org.apache.flink.runtime.operators.testutils.TestData#getIntIntTupleSerializerFactory()

The following examples show how to use org.apache.flink.runtime.operators.testutils.TestData#getIntIntTupleSerializerFactory() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@SuppressWarnings("unchecked")
@Before
public void beforeTest() {
	this.memoryManager = new MemoryManager(MEMORY_SIZE, 1);
	this.ioManager = new IOManagerAsync();
	
	this.serializerFactory1 = TestData.getIntStringTupleSerializerFactory();
	this.comparator1 = TestData.getIntStringTupleComparator();

	this.serializerFactory2 = TestData.getIntIntTupleSerializerFactory();
	this.comparator2 = TestData.getIntIntTupleComparator();
}
 
Example 2
@SuppressWarnings("unchecked")
@Before
public void beforeTest() {
	this.memoryManager = new MemoryManager(MEMORY_SIZE, 1);
	this.ioManager = new IOManagerAsync();
	
	this.serializerFactory1 = TestData.getIntStringTupleSerializerFactory();
	this.comparator1 = TestData.getIntStringTupleComparator();

	this.serializerFactory2 = TestData.getIntIntTupleSerializerFactory();
	this.comparator2 = TestData.getIntIntTupleComparator();
}
 
Example 3
@SuppressWarnings("unchecked")
@Before
public void beforeTest() {
	this.memoryManager = MemoryManagerBuilder.newBuilder().setMemorySize(MEMORY_SIZE).build();
	this.ioManager = new IOManagerAsync();
	
	this.serializerFactory1 = TestData.getIntStringTupleSerializerFactory();
	this.comparator1 = TestData.getIntStringTupleComparator();

	this.serializerFactory2 = TestData.getIntIntTupleSerializerFactory();
	this.comparator2 = TestData.getIntIntTupleComparator();
}
 
Example 4
@Test
public void testInMemorySorterDisposal() throws Exception {
	final TestingInMemorySorterFactory<Tuple2<Integer, Integer>> inMemorySorterFactory = new TestingInMemorySorterFactory<>();

	final int numPages = 32;
	final MemoryManager memoryManager = new MemoryManager(MemoryManager.DEFAULT_PAGE_SIZE * numPages, 1);
	final IOManagerAsync ioManager = new IOManagerAsync();
	final DummyInvokable parentTask = new DummyInvokable();

	try {
		final List<MemorySegment> memory = memoryManager.allocatePages(parentTask, numPages);
		final UnilateralSortMerger<Tuple2<Integer, Integer>> unilateralSortMerger = new UnilateralSortMerger<>(
			memoryManager,
			memory,
			ioManager,
			EmptyMutableObjectIterator.get(),
			parentTask,
			TestData.getIntIntTupleSerializerFactory(),
			TestData.getIntIntTupleComparator(),
			10,
			2,
			1.0f,
			true,
			false,
			false,
			inMemorySorterFactory);

		final Collection<TestingInMemorySorter<?>> inMemorySorters = inMemorySorterFactory.getInMemorySorters();

		assertThat(inMemorySorters, is(not(empty())));

		unilateralSortMerger.close();

		assertThat(unilateralSortMerger.closed, is(true));

		for (TestingInMemorySorter<?> inMemorySorter : inMemorySorters) {
			assertThat(inMemorySorter.isDisposed(), is(true));
		}
	} finally {
		ioManager.shutdown();
		memoryManager.shutdown();
	}
}
 
Example 5
Source Project: flink   File: UnilateralSortMergerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testInMemorySorterDisposal() throws Exception {
	final TestingInMemorySorterFactory<Tuple2<Integer, Integer>> inMemorySorterFactory = new TestingInMemorySorterFactory<>();

	final int numPages = 32;
	final MemoryManager memoryManager = new MemoryManager(MemoryManager.DEFAULT_PAGE_SIZE * numPages, 1);
	final DummyInvokable parentTask = new DummyInvokable();

	try (final IOManagerAsync ioManager = new IOManagerAsync()) {
		final List<MemorySegment> memory = memoryManager.allocatePages(parentTask, numPages);
		final UnilateralSortMerger<Tuple2<Integer, Integer>> unilateralSortMerger = new UnilateralSortMerger<>(
			memoryManager,
			memory,
			ioManager,
			EmptyMutableObjectIterator.get(),
			parentTask,
			TestData.getIntIntTupleSerializerFactory(),
			TestData.getIntIntTupleComparator(),
			10,
			2,
			1.0f,
			true,
			false,
			false,
			inMemorySorterFactory);

		final Collection<TestingInMemorySorter<?>> inMemorySorters = inMemorySorterFactory.getInMemorySorters();

		assertThat(inMemorySorters, is(not(empty())));

		unilateralSortMerger.close();

		assertThat(unilateralSortMerger.closed, is(true));

		for (TestingInMemorySorter<?> inMemorySorter : inMemorySorters) {
			assertThat(inMemorySorter.isDisposed(), is(true));
		}
	} finally {
		memoryManager.shutdown();
	}
}
 
Example 6
Source Project: flink   File: UnilateralSortMergerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testInMemorySorterDisposal() throws Exception {
	final TestingInMemorySorterFactory<Tuple2<Integer, Integer>> inMemorySorterFactory = new TestingInMemorySorterFactory<>();

	final int numPages = 32;
	final MemoryManager memoryManager = MemoryManagerBuilder
		.newBuilder()
		.setMemorySize(MemoryManager.DEFAULT_PAGE_SIZE * numPages)
		.build();
	final DummyInvokable parentTask = new DummyInvokable();

	try (final IOManagerAsync ioManager = new IOManagerAsync()) {
		final List<MemorySegment> memory = memoryManager.allocatePages(parentTask, numPages);
		final UnilateralSortMerger<Tuple2<Integer, Integer>> unilateralSortMerger = new UnilateralSortMerger<>(
			memoryManager,
			memory,
			ioManager,
			EmptyMutableObjectIterator.get(),
			parentTask,
			TestData.getIntIntTupleSerializerFactory(),
			TestData.getIntIntTupleComparator(),
			10,
			2,
			1.0f,
			true,
			false,
			false,
			inMemorySorterFactory);

		final Collection<TestingInMemorySorter<?>> inMemorySorters = inMemorySorterFactory.getInMemorySorters();

		assertThat(inMemorySorters, is(not(empty())));

		unilateralSortMerger.close();

		assertThat(unilateralSortMerger.closed, is(true));

		for (TestingInMemorySorter<?> inMemorySorter : inMemorySorters) {
			assertThat(inMemorySorter.isDisposed(), is(true));
		}
	} finally {
		memoryManager.shutdown();
	}
}