org.apache.flink.types.ShortValue Java Examples

The following examples show how to use org.apache.flink.types.ShortValue. 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: ShortValueArray.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean add(ShortValue value) {
	int newPosition = position + 1;

	if (newPosition > data.length) {
		if (isBounded) {
			return false;
		} else {
			ensureCapacity(newPosition);
		}
	}

	data[position] = value.getValue();
	position = newPosition;

	return true;
}
 
Example #2
Source File: ValueArrayFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type.
 *
 * @param cls {@code Value} class
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray();
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray();
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray();
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray();
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray();
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray();
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray();
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray();
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray();
	} else {
		throw new IllegalArgumentException("Unable to create unbounded ValueArray for type " + cls);
	}
}
 
Example #3
Source File: ValueArrayFactory.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type with the
 * given bounded size.
 *
 * @param cls {@code Value} class
 * @param bytes limit the array to the given number of bytes
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls, int bytes) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray(bytes);
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray(bytes);
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray(bytes);
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray(bytes);
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray(bytes);
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray(bytes);
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray(bytes);
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray(bytes);
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray(bytes);
	} else {
		throw new IllegalArgumentException("Unable to create bounded ValueArray for type " + cls);
	}
}
 
Example #4
Source File: SummaryAggregatorFactoryTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreate() throws Exception {
	// supported primitive types
	Assert.assertEquals(StringSummaryAggregator.class, SummaryAggregatorFactory.create(String.class).getClass());
	Assert.assertEquals(ShortSummaryAggregator.class, SummaryAggregatorFactory.create(Short.class).getClass());
	Assert.assertEquals(IntegerSummaryAggregator.class, SummaryAggregatorFactory.create(Integer.class).getClass());
	Assert.assertEquals(LongSummaryAggregator.class, SummaryAggregatorFactory.create(Long.class).getClass());
	Assert.assertEquals(FloatSummaryAggregator.class, SummaryAggregatorFactory.create(Float.class).getClass());
	Assert.assertEquals(DoubleSummaryAggregator.class, SummaryAggregatorFactory.create(Double.class).getClass());
	Assert.assertEquals(BooleanSummaryAggregator.class, SummaryAggregatorFactory.create(Boolean.class).getClass());

	// supported value types
	Assert.assertEquals(ValueSummaryAggregator.StringValueSummaryAggregator.class, SummaryAggregatorFactory.create(StringValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.ShortValueSummaryAggregator.class, SummaryAggregatorFactory.create(ShortValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.IntegerValueSummaryAggregator.class, SummaryAggregatorFactory.create(IntValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.LongValueSummaryAggregator.class, SummaryAggregatorFactory.create(LongValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.FloatValueSummaryAggregator.class, SummaryAggregatorFactory.create(FloatValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.DoubleValueSummaryAggregator.class, SummaryAggregatorFactory.create(DoubleValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.BooleanValueSummaryAggregator.class, SummaryAggregatorFactory.create(BooleanValue.class).getClass());

	// some not well supported types - these fallback to ObjectSummaryAggregator
	Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(Object.class).getClass());
	Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(List.class).getClass());
}
 
Example #5
Source File: ValueArrayFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type with the
 * given bounded size.
 *
 * @param cls {@code Value} class
 * @param bytes limit the array to the given number of bytes
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls, int bytes) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray(bytes);
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray(bytes);
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray(bytes);
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray(bytes);
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray(bytes);
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray(bytes);
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray(bytes);
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray(bytes);
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray(bytes);
	} else {
		throw new IllegalArgumentException("Unable to create bounded ValueArray for type " + cls);
	}
}
 
Example #6
Source File: ShortValueComparatorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected ShortValue[] getSortedTestData() {
	Random rnd = new Random(874597969123412338L);
	short rndShort = Integer.valueOf(rnd.nextInt()).shortValue();
	if (rndShort < 0) {
		rndShort = Integer.valueOf(-rndShort).shortValue();
	}
	if (rndShort == Short.MAX_VALUE) {
		rndShort -= 3;
	}
	if (rndShort <= 2) {
		rndShort += 3;
	}
	return new ShortValue[]{
		new ShortValue(Short.MIN_VALUE),
		new ShortValue(Integer.valueOf(-rndShort).shortValue()),
		new ShortValue(Integer.valueOf(-1).shortValue()),
		new ShortValue(Integer.valueOf(0).shortValue()),
		new ShortValue(Integer.valueOf(1).shortValue()),
		new ShortValue(Integer.valueOf(2).shortValue()),
		new ShortValue(Integer.valueOf(rndShort).shortValue()),
		new ShortValue(Short.MAX_VALUE)};
}
 
Example #7
Source File: SummaryAggregatorFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreate() throws Exception {
	// supported primitive types
	Assert.assertEquals(StringSummaryAggregator.class, SummaryAggregatorFactory.create(String.class).getClass());
	Assert.assertEquals(ShortSummaryAggregator.class, SummaryAggregatorFactory.create(Short.class).getClass());
	Assert.assertEquals(IntegerSummaryAggregator.class, SummaryAggregatorFactory.create(Integer.class).getClass());
	Assert.assertEquals(LongSummaryAggregator.class, SummaryAggregatorFactory.create(Long.class).getClass());
	Assert.assertEquals(FloatSummaryAggregator.class, SummaryAggregatorFactory.create(Float.class).getClass());
	Assert.assertEquals(DoubleSummaryAggregator.class, SummaryAggregatorFactory.create(Double.class).getClass());
	Assert.assertEquals(BooleanSummaryAggregator.class, SummaryAggregatorFactory.create(Boolean.class).getClass());

	// supported value types
	Assert.assertEquals(ValueSummaryAggregator.StringValueSummaryAggregator.class, SummaryAggregatorFactory.create(StringValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.ShortValueSummaryAggregator.class, SummaryAggregatorFactory.create(ShortValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.IntegerValueSummaryAggregator.class, SummaryAggregatorFactory.create(IntValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.LongValueSummaryAggregator.class, SummaryAggregatorFactory.create(LongValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.FloatValueSummaryAggregator.class, SummaryAggregatorFactory.create(FloatValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.DoubleValueSummaryAggregator.class, SummaryAggregatorFactory.create(DoubleValue.class).getClass());
	Assert.assertEquals(ValueSummaryAggregator.BooleanValueSummaryAggregator.class, SummaryAggregatorFactory.create(BooleanValue.class).getClass());

	// some not well supported types - these fallback to ObjectSummaryAggregator
	Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(Object.class).getClass());
	Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(List.class).getClass());
}
 
Example #8
Source File: CsvReaderITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testValueTypes() throws Exception {
	final String inputData = "ABC,true,1,2,3,4,5.0,6.0\nBCD,false,1,2,3,4,5.0,6.0";
	final String dataPath = createInputData(inputData);
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> data =
			env.readCsvFile(dataPath).types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	List<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> result = data.collect();

	expected = inputData;
	compareResultAsTuples(result, expected);
}
 
Example #9
Source File: ShortValueArrayComparatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected ShortValueArray[] getSortedTestData() {
	ShortValueArray lva0 = new ShortValueArray();

	ShortValueArray lva1 = new ShortValueArray();
	lva1.add(new ShortValue((short) 5));

	ShortValueArray lva2 = new ShortValueArray();
	lva2.add(new ShortValue((short) 5));
	lva2.add(new ShortValue((short) 10));

	return new ShortValueArray[]{ lva0, lva1 };
}
 
Example #10
Source File: ValueArrayTypeInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public TypeSerializer<ValueArray<T>> createSerializer(ExecutionConfig executionConfig) {
	Preconditions.checkNotNull(type, "TypeInformation type class is required");

	if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ByteValueArraySerializer();
	} else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new CharValueArraySerializer();
	} else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new DoubleValueArraySerializer();
	} else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new FloatValueArraySerializer();
	} else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new IntValueArraySerializer();
	} else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new LongValueArraySerializer();
	} else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new NullValueArraySerializer();
	} else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ShortValueArraySerializer();
	} else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new StringValueArraySerializer();
	} else {
		throw new InvalidTypesException("No ValueArray class exists for " + type);
	}
}
 
Example #11
Source File: CSVReaderTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithValueType() throws Exception {
	CsvReader reader = getCsvReader();
	DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items =
			reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	TypeInformation<?> info = items.getType();

	Assert.assertEquals(true, info.isTupleType());
	Assert.assertEquals(Tuple8.class, info.getTypeClass());
}
 
Example #12
Source File: GraphKeyTypeTransformTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testToShortValue() throws Exception {
	TranslateFunction<LongValue, ShortValue> translator = new LongValueToUnsignedShortValue();

	Assert.assertEquals(new ShortValue((short) 0),
		translator.translate(new LongValue(0L), shortValue));

	Assert.assertEquals(new ShortValue(Short.MIN_VALUE),
		translator.translate(new LongValue((long) Short.MAX_VALUE + 1), shortValue));

	Assert.assertEquals(new ShortValue((short) -1),
		translator.translate(new LongValue(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1), shortValue));
}
 
Example #13
Source File: ShortValueParserTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ShortValue[] getValidTestResults() {
	return new ShortValue[] {
		new ShortValue((short) 0), new ShortValue((short) 1), new ShortValue((short) 576),
		new ShortValue((short) -8778), new ShortValue(Short.MAX_VALUE), new ShortValue(Short.MIN_VALUE),
		new ShortValue((short)1239)
	};
}
 
Example #14
Source File: ShortValueArray.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copyTo(ValueArray<ShortValue> target) {
	ShortValueArray other = (ShortValueArray) target;

	other.position = position;
	other.mark = mark;

	other.ensureCapacity(position);
	System.arraycopy(data, 0, other.data, 0, position);
}
 
Example #15
Source File: ShortValueArrayComparatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected ShortValueArray[] getSortedTestData() {
	ShortValueArray lva0 = new ShortValueArray();

	ShortValueArray lva1 = new ShortValueArray();
	lva1.add(new ShortValue((short) 5));

	ShortValueArray lva2 = new ShortValueArray();
	lva2.add(new ShortValue((short) 5));
	lva2.add(new ShortValue((short) 10));

	return new ShortValueArray[]{ lva0, lva1 };
}
 
Example #16
Source File: ShortValueParserTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public ShortValue[] getValidTestResults() {
	return new ShortValue[] {
		new ShortValue((short) 0), new ShortValue((short) 1), new ShortValue((short) 576),
		new ShortValue((short) -8778), new ShortValue(Short.MAX_VALUE), new ShortValue(Short.MIN_VALUE),
		new ShortValue((short)1239)
	};
}
 
Example #17
Source File: GraphKeyTypeTransform.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public LongValueWithProperHashCode translate(ShortValue value, LongValueWithProperHashCode reuse)
		throws Exception {
	if (reuse == null) {
		reuse = new LongValueWithProperHashCode();
	}

	reuse.setValue(value.getValue() & 0xffff);
	return reuse;
}
 
Example #18
Source File: ShortValueArrayComparatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected ShortValueArray[] getSortedTestData() {
	ShortValueArray lva0 = new ShortValueArray();

	ShortValueArray lva1 = new ShortValueArray();
	lva1.add(new ShortValue((short) 5));

	ShortValueArray lva2 = new ShortValueArray();
	lva2.add(new ShortValue((short) 5));
	lva2.add(new ShortValue((short) 10));

	return new ShortValueArray[]{ lva0, lva1 };
}
 
Example #19
Source File: GraphKeyTypeTransformTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFromShortValue() throws Exception {
	TranslateFunction<ShortValue, LongValueWithProperHashCode> translator = new UnsignedShortValueToLongValueWithProperHashCode();

	Assert.assertEquals(new LongValueWithProperHashCode(0L),
		translator.translate(new ShortValue((short) 0), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1),
		translator.translate(new ShortValue(Short.MIN_VALUE), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1),
		translator.translate(new ShortValue((short) -1), longValueWithProperHashCode));
}
 
Example #20
Source File: GraphKeyTypeTransformTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFromShortValue() throws Exception {
	TranslateFunction<ShortValue, LongValueWithProperHashCode> translator = new UnsignedShortValueToLongValueWithProperHashCode();

	Assert.assertEquals(new LongValueWithProperHashCode(0L),
		translator.translate(new ShortValue((short) 0), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1),
		translator.translate(new ShortValue(Short.MIN_VALUE), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1),
		translator.translate(new ShortValue((short) -1), longValueWithProperHashCode));
}
 
Example #21
Source File: CSVReaderTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithValueType() throws Exception {
	CsvReader reader = getCsvReader();
	DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items =
			reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	TypeInformation<?> info = items.getType();

	Assert.assertEquals(true, info.isTupleType());
	Assert.assertEquals(Tuple8.class, info.getTypeClass());
}
 
Example #22
Source File: ShortValueComparator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void setReference(ShortValue toCompare) {
	toCompare.copyTo(reference);
}
 
Example #23
Source File: ValueSummaryAggregator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected Short getValue(ShortValue value) {
	return value.getValue();
}
 
Example #24
Source File: ShortValueArrayTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testBoundedArray() {
	int count = ShortValueArray.DEFAULT_CAPACITY_IN_BYTES / ShortValueArray.ELEMENT_LENGTH_IN_BYTES;

	ValueArray<ShortValue> lva = new ShortValueArray(ShortValueArray.DEFAULT_CAPACITY_IN_BYTES);

	// fill the array
	for (int i = 0; i < count; i++) {
		assertFalse(lva.isFull());
		assertEquals(i, lva.size());

		assertTrue(lva.add(new ShortValue((short) i)));

		assertEquals(i + 1, lva.size());
	}

	// array is now full
	assertTrue(lva.isFull());
	assertEquals(count, lva.size());

	// verify the array values
	int idx = 0;
	for (ShortValue lv : lva) {
		assertEquals((short) idx++, lv.getValue());
	}

	// add element past end of array
	assertFalse(lva.add(new ShortValue((short) count)));
	assertFalse(lva.addAll(lva));

	// test copy
	assertEquals(lva, lva.copy());

	// test copyTo
	ShortValueArray lvaTo = new ShortValueArray();
	lva.copyTo(lvaTo);
	assertEquals(lva, lvaTo);

	// test clear
	lva.clear();
	assertEquals(0, lva.size());
}
 
Example #25
Source File: ShortValueArraySerializerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortValueArray[] getTestData() {
	int defaultElements = ShortValueArray.DEFAULT_CAPACITY_IN_BYTES / ShortValueArray.ELEMENT_LENGTH_IN_BYTES;

	Random rnd = new Random(874597969123412341L);
	int rndLong = rnd.nextInt();

	ShortValueArray lva0 = new ShortValueArray();

	ShortValueArray lva1 = new ShortValueArray();
	lva1.addAll(lva0);
	lva1.add(new ShortValue((short) 0));

	ShortValueArray lva2 = new ShortValueArray();
	lva2.addAll(lva1);
	lva2.add(new ShortValue((short) 1));

	ShortValueArray lva3 = new ShortValueArray();
	lva3.addAll(lva2);
	lva3.add(new ShortValue((short) -1));

	ShortValueArray lva4 = new ShortValueArray();
	lva4.addAll(lva3);
	lva4.add(new ShortValue(Short.MAX_VALUE));

	ShortValueArray lva5 = new ShortValueArray();
	lva5.addAll(lva4);
	lva5.add(new ShortValue(Short.MIN_VALUE));

	ShortValueArray lva6 = new ShortValueArray();
	lva6.addAll(lva5);
	lva6.add(new ShortValue((short) rndLong));

	ShortValueArray lva7 = new ShortValueArray();
	lva7.addAll(lva6);
	lva7.add(new ShortValue((short) -rndLong));

	ShortValueArray lva8 = new ShortValueArray();
	lva8.addAll(lva7);
	for (int i = 0; i < 1.5 * defaultElements; i++) {
		lva8.add(new ShortValue((short) i));
	}
	lva8.addAll(lva8);

	return new ShortValueArray[] {lva0, lva1, lva2, lva3, lva4, lva5, lva6, lva7, lva8};
}
 
Example #26
Source File: ShortValueComparatorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected TypeSerializer<ShortValue> createSerializer() {
	return new ShortValueSerializer();
}
 
Example #27
Source File: ShortValueParserTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Class<ShortValue> getTypeClass() {
	return ShortValue.class;
}
 
Example #28
Source File: ShortValueSerializerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected TypeSerializer<ShortValue> createSerializer() {
	return new ShortValueSerializer();
}
 
Example #29
Source File: ShortValueComparator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public int compareToReference(TypeComparator<ShortValue> referencedComparator) {
	ShortValue otherRef = ((ShortValueComparator) referencedComparator).reference;
	int comp = otherRef.compareTo(reference);
	return ascendingComparison ? comp : -comp;
}
 
Example #30
Source File: SumAggregationFunction.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> AggregationFunction<T> createAggregationFunction(Class<T> type) {
	if (type == Long.class) {
		return (AggregationFunction<T>) new LongSumAgg();
	}
	else if (type == LongValue.class) {
		return (AggregationFunction<T>) new LongValueSumAgg();
	}
	else if (type == Integer.class) {
		return (AggregationFunction<T>) new IntSumAgg();
	}
	else if (type == IntValue.class) {
		return (AggregationFunction<T>) new IntValueSumAgg();
	}
	else if (type == Double.class) {
		return (AggregationFunction<T>) new DoubleSumAgg();
	}
	else if (type == DoubleValue.class) {
		return (AggregationFunction<T>) new DoubleValueSumAgg();
	}
	else if (type == Float.class) {
		return (AggregationFunction<T>) new FloatSumAgg();
	}
	else if (type == FloatValue.class) {
		return (AggregationFunction<T>) new FloatValueSumAgg();
	}
	else if (type == Byte.class) {
		return (AggregationFunction<T>) new ByteSumAgg();
	}
	else if (type == ByteValue.class) {
		return (AggregationFunction<T>) new ByteValueSumAgg();
	}
	else if (type == Short.class) {
		return (AggregationFunction<T>) new ShortSumAgg();
	}
	else if (type == ShortValue.class) {
		return (AggregationFunction<T>) new ShortValueSumAgg();
	}
	else {
		throw new UnsupportedAggregationTypeException("The type " + type.getName() +
			" is currently not supported for built-in sum aggregations.");
	}
}