Package org.apache.flink.runtime.operators.testutils

Examples of org.apache.flink.runtime.operators.testutils.UniformIntPairGenerator


  @Test
  public void testMutableHashMapPerformance() {
    try {
      final int NUM_MEM_PAGES = SIZE * NUM_PAIRS / PAGE_SIZE;
     
      MutableObjectIterator<IntPair> buildInput = new UniformIntPairGenerator(NUM_PAIRS, 1, false);

      MutableObjectIterator<IntPair> probeInput = new UniformIntPairGenerator(0, 1, false);
     
      MutableObjectIterator<IntPair> probeTester = new UniformIntPairGenerator(NUM_PAIRS, 1, false);
     
      MutableObjectIterator<IntPair> updater = new UniformIntPairGenerator(NUM_PAIRS, 1, false);

      MutableObjectIterator<IntPair> updateTester = new UniformIntPairGenerator(NUM_PAIRS, 1, false);
     
      long start = 0L;
      long end = 0L;
     
      long first = System.currentTimeMillis();
     
      System.out.println("Creating and filling MutableHashMap...");
      start = System.currentTimeMillis();
      MutableHashTable<IntPair, IntPair> table = new MutableHashTable<IntPair, IntPair>(serializer, serializer, comparator, comparator, pairComparator, getMemory(NUM_MEM_PAGES, PAGE_SIZE), ioManager);       
      table.open(buildInput, probeInput);
      end = System.currentTimeMillis();
      System.out.println("HashMap ready. Time: " + (end-start) + " ms");
     
      System.out.println("Starting first probing run...");
      start = System.currentTimeMillis();
      IntPair compare = new IntPair();
      HashBucketIterator<IntPair, IntPair> iter;
      IntPair target = new IntPair();
      while(probeTester.next(compare) != null) {
        iter = table.getMatchesFor(compare);
        iter.next(target);
        assertEquals(target.getKey(), compare.getKey());
        assertEquals(target.getValue(), compare.getValue());
        assertTrue(iter.next(target) == null);
      }
      end = System.currentTimeMillis();
      System.out.println("Probing done. Time: " + (end-start) + " ms");
 
      System.out.println("Starting update...");
      start = System.currentTimeMillis();
      while(updater.next(compare) != null) {
        compare.setValue(compare.getValue()*-1);
        iter = table.getMatchesFor(compare);
        iter.next(target);
        iter.writeBack(compare);
        //assertFalse(iter.next(target));
      }
      end = System.currentTimeMillis();
      System.out.println("Update done. Time: " + (end-start) + " ms");
     
      System.out.println("Starting second probing run...");
      start = System.currentTimeMillis();
      while(updateTester.next(compare) != null) {
        compare.setValue(compare.getValue()*-1);
        iter = table.getMatchesFor(compare);
        iter.next(target);
        assertEquals(target.getKey(), compare.getKey());
        assertEquals(target.getValue(), compare.getValue());
View Full Code Here


  public void testCompare() throws Exception {
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    UniformIntPairGenerator generator = new UniformIntPairGenerator(Integer.MAX_VALUE, 1, true);
   
    // write the records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record) && num < 3354624);
   
    // compare random elements
View Full Code Here

  }
 
  @Test
  public void testBuildFirstWithMixedDataTypes() {
    try {
      MutableObjectIterator<IntPair> input1 = new UniformIntPairGenerator(500, 40, false);
     
      final Generator generator2 = new Generator(SEED2, 500, 2048, KeyMode.RANDOM, ValueMode.RANDOM_LENGTH);
      final TestData.GeneratorIterator input2 = new TestData.GeneratorIterator(generator2, INPUT_2_SIZE);
     
      // collect expected data
      final Map<TestData.Key, Collection<RecordIntPairMatch>> expectedMatchesMap = matchRecordIntPairValues(
        collectIntPairData(input1),
        collectRecordData(input2));
     
      final FlatJoinFunction<IntPair, Record, Record> matcher = new RecordIntPairMatchRemovingMatcher(expectedMatchesMap);
      final Collector<Record> collector = new DiscardingOutputCollector<Record>();
 
      // reset the generators
      input1 = new UniformIntPairGenerator(500, 40, false);
      generator2.reset();
      input2.reset();
 
      // compare with iterator values
      BuildSecondHashMatchIterator<IntPair, Record, Record> iterator =
View Full Code Here

  }
 
  @Test
  public void testBuildSecondWithMixedDataTypes() {
    try {
      MutableObjectIterator<IntPair> input1 = new UniformIntPairGenerator(500, 40, false);
     
      final Generator generator2 = new Generator(SEED2, 500, 2048, KeyMode.RANDOM, ValueMode.RANDOM_LENGTH);
      final TestData.GeneratorIterator input2 = new TestData.GeneratorIterator(generator2, INPUT_2_SIZE);
     
      // collect expected data
      final Map<TestData.Key, Collection<RecordIntPairMatch>> expectedMatchesMap = matchRecordIntPairValues(
        collectIntPairData(input1),
        collectRecordData(input2));
     
      final FlatJoinFunction<IntPair, Record, Record> matcher = new RecordIntPairMatchRemovingMatcher(expectedMatchesMap);
      final Collector<Record> collector = new DiscardingOutputCollector<Record>();
 
      // reset the generators
      input1 = new UniformIntPairGenerator(500, 40, false);
      generator2.reset();
      input2.reset();
 
      // compare with iterator values
      BuildFirstHashMatchIterator<IntPair, Record, Record> iterator =
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.operators.testutils.UniformIntPairGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.