Java Code Examples for org.apache.flink.types.ShortValue
The following examples show how to use
org.apache.flink.types.ShortValue.
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
Source Project: Flink-CEPplus Author: ljygz File: SummaryAggregatorFactoryTest.java License: Apache License 2.0 | 6 votes |
@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 #2
Source Project: flink Author: apache File: ValueArrayFactory.java License: Apache License 2.0 | 6 votes |
/** * 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 #3
Source Project: flink Author: apache File: SummaryAggregatorFactoryTest.java License: Apache License 2.0 | 6 votes |
@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 #4
Source Project: flink Author: flink-tpc-ds File: ShortValueComparatorTest.java License: Apache License 2.0 | 6 votes |
@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 #5
Source Project: Flink-CEPplus Author: ljygz File: ValueArrayFactory.java License: Apache License 2.0 | 6 votes |
/** * 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 Project: flink Author: apache File: ShortValueArray.java License: Apache License 2.0 | 6 votes |
@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 #7
Source Project: flink Author: flink-tpc-ds File: ValueArrayFactory.java License: Apache License 2.0 | 6 votes |
/** * 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 #8
Source Project: Flink-CEPplus Author: ljygz File: CsvReaderITCase.java License: Apache License 2.0 | 5 votes |
@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 Project: flink Author: flink-tpc-ds File: GraphKeyTypeTransformTest.java License: Apache License 2.0 | 5 votes |
@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 #10
Source Project: flink Author: flink-tpc-ds File: ShortValueArray.java License: Apache License 2.0 | 5 votes |
@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 #11
Source Project: flink Author: apache File: ShortValueParserTest.java License: Apache License 2.0 | 5 votes |
@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 #12
Source Project: flink Author: flink-tpc-ds File: GraphKeyTypeTransformTest.java License: Apache License 2.0 | 5 votes |
@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 Project: flink Author: flink-tpc-ds File: ShortValueArrayComparatorTest.java License: Apache License 2.0 | 5 votes |
@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 #14
Source Project: Flink-CEPplus Author: ljygz File: ShortValueParserTest.java License: Apache License 2.0 | 5 votes |
@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 #15
Source Project: Flink-CEPplus Author: ljygz File: GraphKeyTypeTransform.java License: Apache License 2.0 | 5 votes |
@Override public LongValueWithProperHashCode translate(ShortValue value, LongValueWithProperHashCode reuse) throws Exception { if (reuse == null) { reuse = new LongValueWithProperHashCode(); } reuse.setValue(value.getValue() & 0xffff); return reuse; }
Example #16
Source Project: flink Author: apache File: ShortValueArrayComparatorTest.java License: Apache License 2.0 | 5 votes |
@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 #17
Source Project: Flink-CEPplus Author: ljygz File: GraphKeyTypeTransformTest.java License: Apache License 2.0 | 5 votes |
@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 #18
Source Project: flink Author: apache File: ValueArrayTypeInfo.java License: Apache License 2.0 | 5 votes |
@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 #19
Source Project: Flink-CEPplus Author: ljygz File: ShortValueArrayComparatorTest.java License: Apache License 2.0 | 5 votes |
@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 #20
Source Project: flink Author: apache File: CSVReaderTest.java License: Apache License 2.0 | 5 votes |
@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 #21
Source Project: flink Author: flink-tpc-ds File: CSVReaderTest.java License: Apache License 2.0 | 5 votes |
@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 Project: Flink-CEPplus Author: ljygz File: SumAggregationFunction.java License: Apache License 2.0 | 4 votes |
@Override public void aggregate(ShortValue value) { agg += value.getValue(); }
Example #23
Source Project: Flink-CEPplus Author: ljygz File: SumAggregationFunction.java License: Apache License 2.0 | 4 votes |
@Override public ShortValue getAggregate() { return new ShortValue((short) agg); }
Example #24
Source Project: Flink-CEPplus Author: ljygz File: SumAggregationFunction.java License: Apache License 2.0 | 4 votes |
@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."); } }
Example #25
Source Project: flink Author: apache File: ShortValueComparator.java License: Apache License 2.0 | 4 votes |
@Override public void setReference(ShortValue toCompare) { toCompare.copyTo(reference); }
Example #26
Source Project: flink Author: flink-tpc-ds File: ShortValueSerializer.java License: Apache License 2.0 | 4 votes |
@Override public ShortValue deserialize(ShortValue reuse, DataInputView source) throws IOException { reuse.read(source); return reuse; }
Example #27
Source Project: Flink-CEPplus Author: ljygz File: ValueTypeInfo.java License: Apache License 2.0 | 4 votes |
@PublicEvolving public boolean isBasicValueType() { return type.equals(StringValue.class) || type.equals(ByteValue.class) || type.equals(ShortValue.class) || type.equals(CharValue.class) || type.equals(DoubleValue.class) || type.equals(FloatValue.class) || type.equals(IntValue.class) || type.equals(LongValue.class) || type.equals(NullValue.class) || type.equals(BooleanValue.class); }
Example #28
Source Project: flink Author: apache File: ShortValueArraySerializerTest.java License: Apache License 2.0 | 4 votes |
@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 #29
Source Project: Flink-CEPplus Author: ljygz File: ValueTypeInfo.java License: Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override @PublicEvolving public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) { if (!isKeyType()) { throw new RuntimeException("The type " + type.getName() + " is not Comparable."); } if (BooleanValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new BooleanValueComparator(sortOrderAscending); } else if (ByteValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new ByteValueComparator(sortOrderAscending); } else if (CharValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new CharValueComparator(sortOrderAscending); } else if (DoubleValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new DoubleValueComparator(sortOrderAscending); } else if (FloatValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new FloatValueComparator(sortOrderAscending); } else if (IntValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new IntValueComparator(sortOrderAscending); } else if (LongValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new LongValueComparator(sortOrderAscending); } else if (NullValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) NullValueComparator.getInstance(); } else if (ShortValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new ShortValueComparator(sortOrderAscending); } else if (StringValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new StringValueComparator(sortOrderAscending); } else if (CopyableValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new CopyableValueComparator(sortOrderAscending, type); } else { return (TypeComparator<T>) new ValueComparator(sortOrderAscending, type); } }
Example #30
Source Project: Flink-CEPplus Author: ljygz File: ShortValueComparator.java License: Apache License 2.0 | 4 votes |
@Override public int hash(ShortValue record) { return record.hashCode(); }