org.apache.flink.api.java.typeutils.runtime.TupleComparator Java Examples
The following examples show how to use
org.apache.flink.api.java.typeutils.runtime.TupleComparator.
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: NonReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = new MemoryManager(MEMORY_SIZE, 1); this.ioManager = new IOManagerAsync(); }
Example #2
Source Project: Flink-CEPplus Author: ljygz File: ReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = new MemoryManager(MEMORY_SIZE, 1); this.ioManager = new IOManagerAsync(); }
Example #3
Source Project: flink Author: flink-tpc-ds File: NonReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = new MemoryManager(MEMORY_SIZE, 1); this.ioManager = new IOManagerAsync(); }
Example #4
Source Project: flink Author: flink-tpc-ds File: ReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = new MemoryManager(MEMORY_SIZE, 1); this.ioManager = new IOManagerAsync(); }
Example #5
Source Project: flink Author: apache File: NonReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = MemoryManagerBuilder.newBuilder().setMemorySize(MEMORY_SIZE).build(); this.ioManager = new IOManagerAsync(); }
Example #6
Source Project: flink Author: apache File: ReusingSortMergeInnerJoinIteratorITCase.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void beforeTest() { serializer1 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); serializer2 = new TupleSerializer<Tuple2<Integer, String>>( (Class<Tuple2<Integer, String>>) (Class<?>) Tuple2.class, new TypeSerializer<?>[] { IntSerializer.INSTANCE, StringSerializer.INSTANCE }); comparator1 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); comparator2 = new TupleComparator<Tuple2<Integer, String>>( new int[]{0}, new TypeComparator<?>[] { new IntComparator(true) }, new TypeSerializer<?>[] { IntSerializer.INSTANCE }); pairComparator = new GenericPairComparator<Tuple2<Integer, String>, Tuple2<Integer, String>>(comparator1, comparator2); this.memoryManager = MemoryManagerBuilder.newBuilder().setMemorySize(MEMORY_SIZE).build(); this.ioManager = new IOManagerAsync(); }
Example #7
Source Project: Flink-CEPplus Author: ljygz File: TupleTypeInfo.java License: Apache License 2.0 | 5 votes |
@Override public TypeComparator<T> createTypeComparator(ExecutionConfig config) { checkState( fieldComparators.size() > 0, "No field comparators were defined for the TupleTypeComparatorBuilder." ); checkState( logicalKeyFields.size() > 0, "No key fields were defined for the TupleTypeComparatorBuilder." ); checkState( fieldComparators.size() == logicalKeyFields.size(), "The number of field comparators and key fields is not equal." ); final int maxKey = Collections.max(logicalKeyFields); checkState( maxKey >= 0, "The maximum key field must be greater or equal than 0." ); TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1]; for (int i = 0; i <= maxKey; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new TupleComparator<T>( listToPrimitives(logicalKeyFields), fieldComparators.toArray(new TypeComparator[fieldComparators.size()]), fieldSerializers ); }
Example #8
Source Project: Flink-CEPplus Author: ljygz File: HashTableTest.java License: Apache License 2.0 | 5 votes |
public HashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, BytePrimitiveArraySerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, byte[]>> clazz = (Class<Tuple2<Long, byte[]>>) (Class<?>) Tuple2.class; this.buildSerializer = new TupleSerializer<Tuple2<Long, byte[]>>(clazz, fieldSerializers); this.probeSerializer = LongSerializer.INSTANCE; TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.buildComparator = new TupleComparator<Tuple2<Long, byte[]>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, byte[]>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, byte[]> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, byte[]> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #9
Source Project: Flink-CEPplus Author: ljygz File: InPlaceMutableHashTableTest.java License: Apache License 2.0 | 5 votes |
public InPlaceMutableHashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, StringSerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, String>> clazz = (Class<Tuple2<Long, String>>) (Class<?>) Tuple2.class; this.serializer = new TupleSerializer<Tuple2<Long, String>>(clazz, fieldSerializers); TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.comparator = new TupleComparator<Tuple2<Long, String>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, String>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, String> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, String> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #10
Source Project: flink Author: flink-tpc-ds File: RandomSortMergeInnerJoinTest.java License: Apache License 2.0 | 5 votes |
@Before public void before() { comparator1 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE}); comparator2 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE}); }
Example #11
Source Project: flink Author: flink-tpc-ds File: TupleTypeInfo.java License: Apache License 2.0 | 5 votes |
@Override public TypeComparator<T> createTypeComparator(ExecutionConfig config) { checkState( fieldComparators.size() > 0, "No field comparators were defined for the TupleTypeComparatorBuilder." ); checkState( logicalKeyFields.size() > 0, "No key fields were defined for the TupleTypeComparatorBuilder." ); checkState( fieldComparators.size() == logicalKeyFields.size(), "The number of field comparators and key fields is not equal." ); final int maxKey = Collections.max(logicalKeyFields); checkState( maxKey >= 0, "The maximum key field must be greater or equal than 0." ); TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1]; for (int i = 0; i <= maxKey; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new TupleComparator<T>( listToPrimitives(logicalKeyFields), fieldComparators.toArray(new TypeComparator[fieldComparators.size()]), fieldSerializers ); }
Example #12
Source Project: flink Author: flink-tpc-ds File: HashTableTest.java License: Apache License 2.0 | 5 votes |
public HashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, BytePrimitiveArraySerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, byte[]>> clazz = (Class<Tuple2<Long, byte[]>>) (Class<?>) Tuple2.class; this.buildSerializer = new TupleSerializer<Tuple2<Long, byte[]>>(clazz, fieldSerializers); this.probeSerializer = LongSerializer.INSTANCE; TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.buildComparator = new TupleComparator<Tuple2<Long, byte[]>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, byte[]>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, byte[]> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, byte[]> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #13
Source Project: flink Author: flink-tpc-ds File: InPlaceMutableHashTableTest.java License: Apache License 2.0 | 5 votes |
public InPlaceMutableHashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, StringSerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, String>> clazz = (Class<Tuple2<Long, String>>) (Class<?>) Tuple2.class; this.serializer = new TupleSerializer<Tuple2<Long, String>>(clazz, fieldSerializers); TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.comparator = new TupleComparator<Tuple2<Long, String>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, String>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, String> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, String> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #14
Source Project: flink Author: apache File: RandomSortMergeInnerJoinTest.java License: Apache License 2.0 | 5 votes |
@Before public void before() { comparator1 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE}); comparator2 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE}); }
Example #15
Source Project: flink Author: apache File: TupleTypeInfo.java License: Apache License 2.0 | 5 votes |
@Override public TypeComparator<T> createTypeComparator(ExecutionConfig config) { checkState( fieldComparators.size() > 0, "No field comparators were defined for the TupleTypeComparatorBuilder." ); checkState( logicalKeyFields.size() > 0, "No key fields were defined for the TupleTypeComparatorBuilder." ); checkState( fieldComparators.size() == logicalKeyFields.size(), "The number of field comparators and key fields is not equal." ); final int maxKey = Collections.max(logicalKeyFields); checkState( maxKey >= 0, "The maximum key field must be greater or equal than 0." ); TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1]; for (int i = 0; i <= maxKey; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new TupleComparator<T>( listToPrimitives(logicalKeyFields), fieldComparators.toArray(new TypeComparator[fieldComparators.size()]), fieldSerializers ); }
Example #16
Source Project: flink Author: apache File: HashTableTest.java License: Apache License 2.0 | 5 votes |
public HashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, BytePrimitiveArraySerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, byte[]>> clazz = (Class<Tuple2<Long, byte[]>>) (Class<?>) Tuple2.class; this.buildSerializer = new TupleSerializer<Tuple2<Long, byte[]>>(clazz, fieldSerializers); this.probeSerializer = LongSerializer.INSTANCE; TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.buildComparator = new TupleComparator<Tuple2<Long, byte[]>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, byte[]>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, byte[]> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, byte[]> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #17
Source Project: flink Author: apache File: InPlaceMutableHashTableTest.java License: Apache License 2.0 | 5 votes |
public InPlaceMutableHashTableTest() { TypeSerializer<?>[] fieldSerializers = { LongSerializer.INSTANCE, StringSerializer.INSTANCE }; @SuppressWarnings("unchecked") Class<Tuple2<Long, String>> clazz = (Class<Tuple2<Long, String>>) (Class<?>) Tuple2.class; this.serializer = new TupleSerializer<Tuple2<Long, String>>(clazz, fieldSerializers); TypeComparator<?>[] comparators = { new LongComparator(true) }; TypeSerializer<?>[] comparatorSerializers = { LongSerializer.INSTANCE }; this.comparator = new TupleComparator<Tuple2<Long, String>>(new int[] {0}, comparators, comparatorSerializers); this.probeComparator = new LongComparator(true); this.pairComparator = new TypePairComparator<Long, Tuple2<Long, String>>() { private long ref; @Override public void setReference(Long reference) { ref = reference; } @Override public boolean equalToReference(Tuple2<Long, String> candidate) { //noinspection UnnecessaryUnboxing return candidate.f0.longValue() == ref; } @Override public int compareToReference(Tuple2<Long, String> candidate) { long x = ref; long y = candidate.f0; return (x < y) ? -1 : ((x == y) ? 0 : 1); } }; }
Example #18
Source Project: Flink-CEPplus Author: ljygz File: TupleComparatorTestBase.java License: Apache License 2.0 | 4 votes |
@Override protected abstract TupleComparator<T> createComparator(boolean ascending);
Example #19
Source Project: flink Author: flink-tpc-ds File: RandomSortMergeOuterJoinTest.java License: Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked, rawtypes") protected void testOuterJoinWithHighNumberOfCommonKeys( FlinkJoinType outerJoinType, int input1Size, int input1Duplicates, int input1ValueLength, float input1KeyDensity, int input2Size, int input2Duplicates, int input2ValueLength, float input2KeyDensity) { TypeComparator<Tuple2<Integer, String>> comparator1 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE} ); TypeComparator<Tuple2<Integer, String>> comparator2 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE} ); final int duplicateKey = 13; try { final TupleGenerator generator1 = new TupleGenerator(SEED1, 500, input1KeyDensity, input1ValueLength, KeyMode.SORTED_SPARSE, ValueMode.RANDOM_LENGTH, null); final TupleGenerator generator2 = new TupleGenerator(SEED2, 500, input2KeyDensity, input2ValueLength, KeyMode.SORTED_SPARSE, ValueMode.RANDOM_LENGTH, null); final TupleGeneratorIterator gen1Iter = new TupleGeneratorIterator(generator1, input1Size); final TupleGeneratorIterator gen2Iter = new TupleGeneratorIterator(generator2, input2Size); final TupleConstantValueIterator const1Iter = new TupleConstantValueIterator(duplicateKey, "LEFT String for Duplicate Keys", input1Duplicates); final TupleConstantValueIterator const2Iter = new TupleConstantValueIterator(duplicateKey, "RIGHT String for Duplicate Keys", input2Duplicates); final List<MutableObjectIterator<Tuple2<Integer, String>>> inList1 = new ArrayList<>(); inList1.add(gen1Iter); inList1.add(const1Iter); final List<MutableObjectIterator<Tuple2<Integer, String>>> inList2 = new ArrayList<>(); inList2.add(gen2Iter); inList2.add(const2Iter); MutableObjectIterator<Tuple2<Integer, String>> input1 = new MergeIterator<>(inList1, comparator1.duplicate()); MutableObjectIterator<Tuple2<Integer, String>> input2 = new MergeIterator<>(inList2, comparator2.duplicate()); // collect expected data final Map<Integer, Collection<Match>> expectedMatchesMap = joinValues( RandomSortMergeInnerJoinTest.collectData(input1), RandomSortMergeInnerJoinTest.collectData(input2), outerJoinType); // re-create the whole thing for actual processing // reset the generators and iterators generator1.reset(); generator2.reset(); const1Iter.reset(); const2Iter.reset(); gen1Iter.reset(); gen2Iter.reset(); inList1.clear(); inList1.add(gen1Iter); inList1.add(const1Iter); inList2.clear(); inList2.add(gen2Iter); inList2.add(const2Iter); input1 = new MergeIterator<>(inList1, comparator1.duplicate()); input2 = new MergeIterator<>(inList2, comparator2.duplicate()); StreamOperator operator = getOperator(outerJoinType); RandomSortMergeInnerJoinTest.match(expectedMatchesMap, RandomSortMergeInnerJoinTest.transformToBinary(myJoin(operator, input1, input2))); // assert that each expected match was seen for (Entry<Integer, Collection<Match>> entry : expectedMatchesMap.entrySet()) { if (!entry.getValue().isEmpty()) { Assert.fail("Collection for key " + entry.getKey() + " is not empty"); } } } catch (Exception e) { e.printStackTrace(); Assert.fail("An exception occurred during the test: " + e.getMessage()); } }
Example #20
Source Project: flink Author: flink-tpc-ds File: TupleComparatorTestBase.java License: Apache License 2.0 | 4 votes |
@Override protected abstract TupleComparator<T> createComparator(boolean ascending);
Example #21
Source Project: flink Author: apache File: RandomSortMergeOuterJoinTest.java License: Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked, rawtypes") protected void testOuterJoinWithHighNumberOfCommonKeys( FlinkJoinType outerJoinType, int input1Size, int input1Duplicates, int input1ValueLength, float input1KeyDensity, int input2Size, int input2Duplicates, int input2ValueLength, float input2KeyDensity) { TypeComparator<Tuple2<Integer, String>> comparator1 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE} ); TypeComparator<Tuple2<Integer, String>> comparator2 = new TupleComparator<>( new int[]{0}, new TypeComparator<?>[]{new IntComparator(true)}, new TypeSerializer<?>[]{IntSerializer.INSTANCE} ); final int duplicateKey = 13; try { final TupleGenerator generator1 = new TupleGenerator(SEED1, 500, input1KeyDensity, input1ValueLength, KeyMode.SORTED_SPARSE, ValueMode.RANDOM_LENGTH, null); final TupleGenerator generator2 = new TupleGenerator(SEED2, 500, input2KeyDensity, input2ValueLength, KeyMode.SORTED_SPARSE, ValueMode.RANDOM_LENGTH, null); final TupleGeneratorIterator gen1Iter = new TupleGeneratorIterator(generator1, input1Size); final TupleGeneratorIterator gen2Iter = new TupleGeneratorIterator(generator2, input2Size); final TupleConstantValueIterator const1Iter = new TupleConstantValueIterator(duplicateKey, "LEFT String for Duplicate Keys", input1Duplicates); final TupleConstantValueIterator const2Iter = new TupleConstantValueIterator(duplicateKey, "RIGHT String for Duplicate Keys", input2Duplicates); final List<MutableObjectIterator<Tuple2<Integer, String>>> inList1 = new ArrayList<>(); inList1.add(gen1Iter); inList1.add(const1Iter); final List<MutableObjectIterator<Tuple2<Integer, String>>> inList2 = new ArrayList<>(); inList2.add(gen2Iter); inList2.add(const2Iter); MutableObjectIterator<Tuple2<Integer, String>> input1 = new MergeIterator<>(inList1, comparator1.duplicate()); MutableObjectIterator<Tuple2<Integer, String>> input2 = new MergeIterator<>(inList2, comparator2.duplicate()); // collect expected data final Map<Integer, Collection<Match>> expectedMatchesMap = joinValues( RandomSortMergeInnerJoinTest.collectData(input1), RandomSortMergeInnerJoinTest.collectData(input2), outerJoinType); // re-create the whole thing for actual processing // reset the generators and iterators generator1.reset(); generator2.reset(); const1Iter.reset(); const2Iter.reset(); gen1Iter.reset(); gen2Iter.reset(); inList1.clear(); inList1.add(gen1Iter); inList1.add(const1Iter); inList2.clear(); inList2.add(gen2Iter); inList2.add(const2Iter); input1 = new MergeIterator<>(inList1, comparator1.duplicate()); input2 = new MergeIterator<>(inList2, comparator2.duplicate()); StreamOperator operator = getOperator(outerJoinType); RandomSortMergeInnerJoinTest.match(expectedMatchesMap, RandomSortMergeInnerJoinTest.transformToBinary(myJoin(operator, input1, input2))); // assert that each expected match was seen for (Entry<Integer, Collection<Match>> entry : expectedMatchesMap.entrySet()) { if (!entry.getValue().isEmpty()) { Assert.fail("Collection for key " + entry.getKey() + " is not empty"); } } } catch (Exception e) { e.printStackTrace(); Assert.fail("An exception occurred during the test: " + e.getMessage()); } }
Example #22
Source Project: flink Author: apache File: TupleComparatorTestBase.java License: Apache License 2.0 | 4 votes |
@Override protected abstract TupleComparator<T> createComparator(boolean ascending);