org.apache.flink.api.common.typeutils.base.ByteValueSerializer Java Examples

The following examples show how to use org.apache.flink.api.common.typeutils.base.ByteValueSerializer. 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
Source File: HashTableTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This tests the case where no additional partition buffers are used at the point when spilling
 * is triggered, testing that overflow bucket buffers are taken into account when deciding which
 * partition to spill.
 */
@Test
public void testSpillingFreesOnlyOverflowSegments() {
	final IOManager ioMan = new IOManagerAsync();
	
	final TypeSerializer<ByteValue> serializer = ByteValueSerializer.INSTANCE;
	final TypeComparator<ByteValue> buildComparator = new ValueComparator<>(true, ByteValue.class);
	final TypeComparator<ByteValue> probeComparator = new ValueComparator<>(true, ByteValue.class);
	
	@SuppressWarnings("unchecked")
	final TypePairComparator<ByteValue, ByteValue> pairComparator = Mockito.mock(TypePairComparator.class);
	
	try {
		final int pageSize = 32*1024;
		final int numSegments = 34;

		List<MemorySegment> memory = getMemory(numSegments, pageSize);

		MutableHashTable<ByteValue, ByteValue> table = new MutableHashTable<>(
				serializer, serializer, buildComparator, probeComparator,
				pairComparator, memory, ioMan, 1, false);

		table.open(new ByteValueIterator(100000000), new ByteValueIterator(1));
		
		table.close();
		
		checkNoTempFilesRemain(ioMan);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
	finally {
		ioMan.shutdown();
	}
}
 
Example #2
Source File: HashTableTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This tests the case where no additional partition buffers are used at the point when spilling
 * is triggered, testing that overflow bucket buffers are taken into account when deciding which
 * partition to spill.
 */
@Test
public void testSpillingFreesOnlyOverflowSegments() {
	final TypeSerializer<ByteValue> serializer = ByteValueSerializer.INSTANCE;
	final TypeComparator<ByteValue> buildComparator = new ValueComparator<>(true, ByteValue.class);
	final TypeComparator<ByteValue> probeComparator = new ValueComparator<>(true, ByteValue.class);
	
	@SuppressWarnings("unchecked")
	final TypePairComparator<ByteValue, ByteValue> pairComparator = Mockito.mock(TypePairComparator.class);
	
	try (final IOManager ioMan = new IOManagerAsync()) {
		final int pageSize = 32*1024;
		final int numSegments = 34;

		List<MemorySegment> memory = getMemory(numSegments, pageSize);

		MutableHashTable<ByteValue, ByteValue> table = new MutableHashTable<>(
				serializer, serializer, buildComparator, probeComparator,
				pairComparator, memory, ioMan, 1, false);

		table.open(new ByteValueIterator(100000000), new ByteValueIterator(1));
		
		table.close();
		
		checkNoTempFilesRemain(ioMan);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #3
Source File: HashTableTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This tests the case where no additional partition buffers are used at the point when spilling
 * is triggered, testing that overflow bucket buffers are taken into account when deciding which
 * partition to spill.
 */
@Test
public void testSpillingFreesOnlyOverflowSegments() {
	final TypeSerializer<ByteValue> serializer = ByteValueSerializer.INSTANCE;
	final TypeComparator<ByteValue> buildComparator = new ValueComparator<>(true, ByteValue.class);
	final TypeComparator<ByteValue> probeComparator = new ValueComparator<>(true, ByteValue.class);
	
	@SuppressWarnings("unchecked")
	final TypePairComparator<ByteValue, ByteValue> pairComparator = Mockito.mock(TypePairComparator.class);
	
	try (final IOManager ioMan = new IOManagerAsync()) {
		final int pageSize = 32*1024;
		final int numSegments = 34;

		List<MemorySegment> memory = getMemory(numSegments, pageSize);

		MutableHashTable<ByteValue, ByteValue> table = new MutableHashTable<>(
				serializer, serializer, buildComparator, probeComparator,
				pairComparator, memory, ioMan, 1, false);

		table.open(new ByteValueIterator(100000000), new ByteValueIterator(1));
		
		table.close();
		
		checkNoTempFilesRemain(ioMan);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #4
Source File: ValueTypeInfo.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}
 
Example #5
Source File: ValueTypeInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}
 
Example #6
Source File: ValueTypeInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}