Package org.apache.flink.types

Examples of org.apache.flink.types.IntValue


  public IntPair(IntValue first, IntValue second) {
    super(first, second);
  }

  public IntPair(int first, int second) {
    super(new IntValue(first), new IntValue(second));
  }
View Full Code Here


  @Override
  public void map(Record record, Collector<Record> out) throws Exception {
    Tuple inputTuple = record.getField(1, this.inputTuple);
   
    int year = Integer.parseInt(inputTuple.getStringValueAt(4).substring(0, 4));
    record.setField(1, new IntValue(year));
    out.collect(record);
  }
View Full Code Here

      throws Exception {
    IntPair partAndSupplierKey = value1.getField(0, this.partAndSupplierKey);
    StringValue supplyCostStr = value1.getField(1, this.supplyCostStr);
    Tuple ordersValue = value2.getField(1, this.ordersValue);
   
    IntValue year = new IntValue(Integer.parseInt(ordersValue.getStringValueAt(0)));
    float quantity = Float.parseFloat(ordersValue.getStringValueAt(1));
    float price = Float.parseFloat(ordersValue.getStringValueAt(2));
    float supplyCost = Float.parseFloat(supplyCostStr.toString());
    float amount = price - supplyCost * quantity;
   
 
View Full Code Here

   */
  @Override
  public void join(Record value1, Record value2, Collector<Record> out)
      throws Exception {

    IntValue year = value1.getField(1, IntValue.class);
    Tuple lineItem = value2.getField(1, Tuple.class);
   
    /* (partkey, suppkey) from lineItem: */
    IntPair newKey = new IntPair(new IntValue(Integer.parseInt(lineItem.getStringValueAt(0))), new IntValue(Integer.parseInt(lineItem.getStringValueAt(1))));
    Tuple newValue = new Tuple();
    newValue.addAttribute(year.toString()); // year
    newValue.addAttribute(lineItem.getStringValueAt(2)); // quantity
    newValue.addAttribute(lineItem.getStringValueAt(3)); // price
   
    value1.setField(0, newKey);
    value1.setField(1, newValue);
View Full Code Here

   */
  @Override
  public void join(Record value1, Record value2, Collector<Record> out)
      throws Exception {

    IntValue partKey = value1.getField(0, this.partKey);
    Tuple partSuppValue = value2.getField(1, this.partSuppValue);
   
    IntPair newKey = new IntPair(partKey, new IntValue(Integer.parseInt(partSuppValue.getStringValueAt(0))));
    String supplyCost = partSuppValue.getStringValueAt(1);
   
    value1.setField(0, newKey);
    value1.setField(1, new StringValue(supplyCost));
    out.collect(value1);
View Full Code Here

  public StringIntPair(StringValue first, IntValue second) {
    super(first, second);
  }

  public StringIntPair(String first, int second) {
    super(new StringValue(first), new IntValue(second));
  }
View Full Code Here

  public void map(Record record, Collector<Record> out) throws Exception {
    suppKey = record.getField(0, suppKey);
    inputTuple = record.getField(1, inputTuple);
   
    /* Project (suppkey | name, address, nationkey, phone, acctbal, comment): */
    IntValue nationKey = new IntValue(Integer.parseInt(inputTuple.getStringValueAt(3)));
   
    record.setField(0, nationKey);
    record.setField(1, suppKey);
   
    out.collect(record);
View Full Code Here

  public void join(Record value1, Record value2, Collector<Record> out) throws Exception
  {
    StringIntPair amountYearPair = value1.getField(1, this.amountYearPair);
    StringValue nationName = value2.getField(1, this.nationName);
   
    IntValue year = amountYearPair.getSecond();
    StringValue amount = amountYearPair.getFirst();
    StringIntPair key = new StringIntPair(nationName, year);
    value1.setField(0, key);
    value1.setField(1, amount);
    out.collect(value1);
View Full Code Here

  @Override
  public IntValue[] getBucketBoundary(int bucketNum, int totalNumBuckets) {
    long diff = ((long) max) - ((long) min) + 1;
    double bucketSize = diff / ((double) totalNumBuckets);
    return new IntValue[] {new IntValue(min + (int) ((bucketNum+1) * bucketSize)) };
  }
View Full Code Here

     
      byte[] tupleBytes = testTuples[i].getBytes();
     
      inFormat.readRecord(rec, tupleBytes, 0, tupleBytes.length);
     
      Assert.assertTrue("Expected Key: "+expectedKeys[i]+" != Returned Key: "+rec.getField(0, IntValue.class), rec.getField(0, IntValue.class).equals(new IntValue(expectedKeys[i])));
      Assert.assertTrue("Expected Attr Cnt: "+expectedAttrCnt[i]+" != Returned Attr Cnt: "+rec.getField(1, Tuple.class), rec.getField(1, Tuple.class).getNumberOfColumns() == expectedAttrCnt[i]);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.types.IntValue

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.