org.apache.flink.runtime.testutils.recordutils.RecordComparator Java Examples

The following examples show how to use org.apache.flink.runtime.testutils.recordutils.RecordComparator. 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: HashTableITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Before
public void setup()
{
	final int[] keyPos = new int[] {0};
	@SuppressWarnings("unchecked")
	final Class<? extends Value>[] keyType = (Class<? extends Value>[]) new Class[] { IntValue.class };
	
	this.recordBuildSideAccesssor = RecordSerializer.get();
	this.recordProbeSideAccesssor = RecordSerializer.get();
	this.recordBuildSideComparator = new RecordComparator(keyPos, keyType);
	this.recordProbeSideComparator = new RecordComparator(keyPos, keyType);
	this.pactRecordComparator = new RecordPairComparatorFirstInt();
	
	this.pairBuildSideAccesssor = new IntPairSerializer();
	this.pairProbeSideAccesssor = new IntPairSerializer();
	this.pairBuildSideComparator = new IntPairComparator();
	this.pairProbeSideComparator = new IntPairComparator();
	this.pairComparator = new IntPairPairComparator();
	
	this.memManager = new MemoryManager(32 * 1024 * 1024,1);
	this.ioManager = new IOManagerAsync();
}
 
Example #2
Source File: HashTableITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void setup()
{
	final int[] keyPos = new int[] {0};
	@SuppressWarnings("unchecked")
	final Class<? extends Value>[] keyType = (Class<? extends Value>[]) new Class[] { IntValue.class };
	
	this.recordBuildSideAccesssor = RecordSerializer.get();
	this.recordProbeSideAccesssor = RecordSerializer.get();
	this.recordBuildSideComparator = new RecordComparator(keyPos, keyType);
	this.recordProbeSideComparator = new RecordComparator(keyPos, keyType);
	this.pactRecordComparator = new RecordPairComparatorFirstInt();
	
	this.pairBuildSideAccesssor = new IntPairSerializer();
	this.pairProbeSideAccesssor = new IntPairSerializer();
	this.pairBuildSideComparator = new IntPairComparator();
	this.pairProbeSideComparator = new IntPairComparator();
	this.pairComparator = new IntPairPairComparator();
	
	this.memManager = new MemoryManager(32 * 1024 * 1024,1);
	this.ioManager = new IOManagerAsync();
}
 
Example #3
Source File: HashTableITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void setup()
{
	final int[] keyPos = new int[] {0};
	@SuppressWarnings("unchecked")
	final Class<? extends Value>[] keyType = (Class<? extends Value>[]) new Class[] { IntValue.class };
	
	this.recordBuildSideAccesssor = RecordSerializer.get();
	this.recordProbeSideAccesssor = RecordSerializer.get();
	this.recordBuildSideComparator = new RecordComparator(keyPos, keyType);
	this.recordProbeSideComparator = new RecordComparator(keyPos, keyType);
	this.pactRecordComparator = new RecordPairComparatorFirstInt();
	
	this.pairBuildSideAccesssor = new IntPairSerializer();
	this.pairProbeSideAccesssor = new IntPairSerializer();
	this.pairBuildSideComparator = new IntPairComparator();
	this.pairProbeSideComparator = new IntPairComparator();
	this.pairComparator = new IntPairPairComparator();

	this.memManager = MemoryManagerBuilder.newBuilder().setMemorySize(32 * 1024 * 1024).build();
	this.ioManager = new IOManagerAsync();
}
 
Example #4
Source File: DriverTestBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void addInputSorted(MutableObjectIterator<Record> input, RecordComparator comp) throws Exception {
	UnilateralSortMerger<Record> sorter = new UnilateralSortMerger<Record>(
			this.memManager, this.ioManager, input, this.owner, RecordSerializerFactory.get(), comp,
			this.perSortFractionMem, 32, 0.8f, true /*use large record handler*/, true);
	this.sorters.add(sorter);
	this.inputs.add(null);
}
 
Example #5
Source File: DriverTestBase.java    From flink with Apache License 2.0 5 votes vote down vote up
public void addInputSorted(MutableObjectIterator<Record> input, RecordComparator comp) throws Exception {
	UnilateralSortMerger<Record> sorter = new UnilateralSortMerger<Record>(
			this.memManager, this.ioManager, input, this.owner, RecordSerializerFactory.get(), comp,
			this.perSortFractionMem, 32, 0.8f, true /*use large record handler*/, true);
	this.sorters.add(sorter);
	this.inputs.add(null);
}
 
Example #6
Source File: DriverTestBase.java    From flink with Apache License 2.0 5 votes vote down vote up
public void addInputSorted(MutableObjectIterator<Record> input, RecordComparator comp) throws Exception {
	UnilateralSortMerger<Record> sorter = new UnilateralSortMerger<Record>(
			this.memManager, this.ioManager, input, this.owner, RecordSerializerFactory.get(), comp,
			this.perSortFractionMem, 32, 0.8f, true /*use large record handler*/, true);
	this.sorters.add(sorter);
	this.inputs.add(null);
}
 
Example #7
Source File: DriverTestBase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public void addDriverComparator(RecordComparator comparator) {
	this.comparators.add(comparator);
}
 
Example #8
Source File: NonReusingKeyGroupedIteratorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Before
public void setup()
{
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}
	};
	
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new NonReusingKeyGroupedIterator<Record>(this.sourceIter, comparator);
}
 
Example #9
Source File: ReusingKeyGroupedIteratorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}

	};
	
	final RecordSerializer serializer = RecordSerializer.get();
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new ReusingKeyGroupedIterator<Record>(this.sourceIter, serializer, comparator);
}
 
Example #10
Source File: DriverTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public void addDriverComparator(RecordComparator comparator) {
	this.comparators.add(comparator);
}
 
Example #11
Source File: NonReusingKeyGroupedIteratorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Before
public void setup()
{
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}
	};
	
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new NonReusingKeyGroupedIterator<Record>(this.sourceIter, comparator);
}
 
Example #12
Source File: ReusingKeyGroupedIteratorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}

	};
	
	final RecordSerializer serializer = RecordSerializer.get();
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new ReusingKeyGroupedIterator<Record>(this.sourceIter, serializer, comparator);
}
 
Example #13
Source File: DriverTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public void addDriverComparator(RecordComparator comparator) {
	this.comparators.add(comparator);
}
 
Example #14
Source File: NonReusingKeyGroupedIteratorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Before
public void setup()
{
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}
	};
	
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new NonReusingKeyGroupedIterator<Record>(this.sourceIter, comparator);
}
 
Example #15
Source File: ReusingKeyGroupedIteratorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
	
	// add elements to the source
	source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
	source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
	source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
	source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
	source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
	
	
	this.sourceIter = new MutableObjectIterator<Record>() {
		final Iterator<IntStringPair> it = source.iterator();
		
		@Override
		public Record next(Record reuse) throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				reuse.setField(0, pair.getInteger());
				reuse.setField(1, pair.getString());
				return reuse;
			}
			else {
				return null;
			}
		}

		@Override
		public Record next() throws IOException {
			if (it.hasNext()) {
				IntStringPair pair = it.next();
				Record result = new Record(2);
				result.setField(0, pair.getInteger());
				result.setField(1, pair.getString());
				return result;
			}
			else {
				return null;
			}
		}

	};
	
	final RecordSerializer serializer = RecordSerializer.get();
	@SuppressWarnings("unchecked")
	final RecordComparator comparator = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
	
	this.psi = new ReusingKeyGroupedIterator<Record>(this.sourceIter, serializer, comparator);
}