Package eu.stratosphere.types

Examples of eu.stratosphere.types.IntValue


   
    // wee need to do the final aggregation manually in the test, because the
    // combiner is not guaranteed to do that
    final HashMap<IntValue, IntValue> aggMap = new HashMap<IntValue, IntValue>();
    for (Record record : this.outList) {
      IntValue key = new IntValue();
      IntValue value = new IntValue();
      key = record.getField(0, key);
      value = record.getField(1, value);
      IntValue prevVal = aggMap.get(key);
      if (prevVal != null) {
        aggMap.put(key, new IntValue(prevVal.getValue() + value.getValue()));
      }
      else {
        aggMap.put(key, value);
      }
    }
View Full Code Here


  }
 
  public static List<Tuple2<StringValue, IntValue>> createReduceMutableDataGroupedResult() {
    List<Tuple2<StringValue, IntValue>> data = new ArrayList<Tuple2<StringValue, IntValue>>();
   
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("a"), new IntValue(1)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("b"), new IntValue(2)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("c"), new IntValue(3)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("dd"), new IntValue(9)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("eee"), new IntValue(21)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("ffff"), new IntValue(42)));
   
    return data;
  }
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

  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

TOP

Related Classes of eu.stratosphere.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.