Package org.apache.flink.api.common.typeutils.record

Examples of org.apache.flink.api.common.typeutils.record.RecordComparator


  }
 
  @Test
  public void testBroadcast() {
    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.BROADCAST, intComp);

    int numChannels = 100;
    int numRecords = 50000;
   
    int[] hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      IntValue k = new IntValue(i);
      Record rec = new Record(k);
     
      int[] chans = oe1.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
    }

    for (int i = 0; i < hit.length; i++) {
      assertTrue(hit[i]+"", hit[i] == numRecords);
    }
   
    // Test for StringValue
    @SuppressWarnings("unchecked")
    final RecordComparator stringComp = new RecordComparator(new int[] {0}, new Class[] {StringValue.class});
    final ChannelSelector<Record> oe2 = new RecordOutputEmitter(ShipStrategyType.BROADCAST, stringComp);

    numChannels = 100;
    numRecords = 5000;
   
View Full Code Here


    }
  }
 
  @Test
  public void testMultiKeys() {
    @SuppressWarnings("unchecked")
    final RecordComparator multiComp = new RecordComparator(new int[] {0,1,3}, new Class[] {IntValue.class, StringValue.class, DoubleValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, multiComp);

    int numChannels = 100;
    int numRecords = 5000;
   
View Full Code Here

  }
 
  @Test
  public void testMissingKey() {
    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {1}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, intComp);

    Record rec = new Record(0);
    rec.setField(0, new IntValue(1));
   
View Full Code Here

  }
 
  @Test
  public void testNullKey() {
    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, intComp);

    Record rec = new Record(2);
    rec.setField(1, new IntValue(1));
View Full Code Here

 
  @Test
  public void testWrongKeyClass() {
   
    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator doubleComp = new RecordComparator(new int[] {0}, new Class[] {DoubleValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, doubleComp);

    PipedInputStream pipedInput = new PipedInputStream(1024*1024);
    DataInputStream in = new DataInputStream(pipedInput);
    DataOutputStream out;
View Full Code Here

   
    final int NUM_ELEMENTS = 10000000;
   
    final DataDistribution distri = new UniformIntegerDistribution(DISTR_MIN, DISTR_MAX);
   
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe = new RecordOutputEmitter(ShipStrategyType.PARTITION_RANGE, intComp, distri);
   
    final IntValue integer = new IntValue();
    final Record rec = new Record();
   
View Full Code Here

 
  @SuppressWarnings("unchecked")
  @Before
  public void setup() {
    this.serializer = RecordSerializer.get();
    this.comparator = new RecordComparator(new int[] {0}, new Class[] { TestData.Key.class});
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Before
  public void beforeTest() {
    this.serializer1 = RecordSerializer.get();
    this.serializer2 = RecordSerializer.get();
    this.comparator1 = new RecordComparator(new int[] {0}, new Class[]{TestData.Key.class});
    this.comparator2 = new RecordComparator(new int[] {0}, new Class[]{TestData.Key.class});
    this.pairComparator = new RecordPairComparator(new int[] {0}, new int[] {0}, new Class[]{TestData.Key.class});
  }
View Full Code Here

  public void beforeTest() {
    this.memoryManager = new DefaultMemoryManager(MEMORY_SIZE, 1);
    this.ioManager = new IOManager();
   
    this.serializerFactory = RecordSerializerFactory.get();
    this.comparator = new RecordComparator(new int[] {0}, new Class[] {TestData.Key.class});
  }
View Full Code Here

    }
  }

  private NormalizedKeySorter<Record> newSortBuffer(List<MemorySegment> memory) throws Exception
  {
    @SuppressWarnings("unchecked")
    RecordComparator accessors = new RecordComparator(new int[] {0}, new Class[]{Key.class});
    return new NormalizedKeySorter<Record>(RecordSerializer.get(), accessors, memory);
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.api.common.typeutils.record.RecordComparator

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.