Package eu.stratosphere.test.recordJobs.util

Examples of eu.stratosphere.test.recordJobs.util.Tuple.project()


    /* Extract the year from the date element of the order relation: */
   
    /* pice = extendedprice * (1 - discount): */
    float price = Float.parseFloat(inputTuple.getStringValueAt(5)) * (1 - Float.parseFloat(inputTuple.getStringValueAt(6)));
    /* Project (orderkey | partkey, suppkey, linenumber, quantity, extendedprice, discount, tax, ...) to (partkey, suppkey, quantity): */
    inputTuple.project((0 << 0) | (1 << 1) | (1 << 2) | (0 << 3) | (1 << 4));
    inputTuple.addAttribute("" + price);
    record.setField(1, inputTuple);
    out.collect(record);
  }

View Full Code Here


  @Test
  public void testProject() {
   
    Tuple t = new Tuple();
   
    t.project(1);
    Assert.assertTrue(t.getNumberOfColumns() == 0);
   
    t.addAttribute("a");
    t.project(0);
    Assert.assertTrue(t.getNumberOfColumns() == 0);
View Full Code Here

   
    t.project(1);
    Assert.assertTrue(t.getNumberOfColumns() == 0);
   
    t.addAttribute("a");
    t.project(0);
    Assert.assertTrue(t.getNumberOfColumns() == 0);

    t.addAttribute("a");
    t.addAttribute("b");
    t.project(2);
View Full Code Here

    t.project(0);
    Assert.assertTrue(t.getNumberOfColumns() == 0);

    t.addAttribute("a");
    t.addAttribute("b");
    t.project(2);
    Assert.assertTrue(t.getNumberOfColumns() == 1);
    Assert.assertTrue(t.getStringValueAt(0).equals("b"));
   
    t.addAttribute("c");
    t.addAttribute("d");
View Full Code Here

    Assert.assertTrue(t.getNumberOfColumns() == 1);
    Assert.assertTrue(t.getStringValueAt(0).equals("b"));
   
    t.addAttribute("c");
    t.addAttribute("d");
    t.project(5);
    Assert.assertTrue(t.getNumberOfColumns() == 2);
    Assert.assertTrue(t.getStringValueAt(0).equals("b"));
    Assert.assertTrue(t.getStringValueAt(1).equals("d"));
   
    t.project(0);
View Full Code Here

    t.project(5);
    Assert.assertTrue(t.getNumberOfColumns() == 2);
    Assert.assertTrue(t.getStringValueAt(0).equals("b"));
    Assert.assertTrue(t.getStringValueAt(1).equals("d"));
   
    t.project(0);
    Assert.assertTrue(t.getNumberOfColumns() == 0);
   
    t.addAttribute("a");
    t.addAttribute("b");
    t.addAttribute("c");
View Full Code Here

   
    t.addAttribute("a");
    t.addAttribute("b");
    t.addAttribute("c");
    t.addAttribute("d");
    t.project(11);
    Assert.assertTrue(t.getNumberOfColumns() == 3);
    Assert.assertTrue(t.getStringValueAt(2).equals("d"));
   
    t.project(23);
    Assert.assertTrue(t.getNumberOfColumns() == 3);
View Full Code Here

    t.addAttribute("d");
    t.project(11);
    Assert.assertTrue(t.getNumberOfColumns() == 3);
    Assert.assertTrue(t.getStringValueAt(2).equals("d"));
   
    t.project(23);
    Assert.assertTrue(t.getNumberOfColumns() == 3);
    Assert.assertTrue(t.getStringValueAt(0).equals("a"));
    Assert.assertTrue(t.getStringValueAt(1).equals("b"));
    Assert.assertTrue(t.getStringValueAt(2).equals("d"));
   
View Full Code Here

    Assert.assertTrue(t.getNumberOfColumns() == 3);
    Assert.assertTrue(t.getStringValueAt(0).equals("a"));
    Assert.assertTrue(t.getStringValueAt(1).equals("b"));
    Assert.assertTrue(t.getStringValueAt(2).equals("d"));
   
    t.project(-1);
    Assert.assertTrue(t.getNumberOfColumns() == 3);
    Assert.assertTrue(t.getStringValueAt(0).equals("a"));
    Assert.assertTrue(t.getStringValueAt(1).equals("b"));
    Assert.assertTrue(t.getStringValueAt(2).equals("d"));
  }
View Full Code Here

    @Override
    public void join(Record order, Record line, Collector<Record> out)
        throws Exception {
      Tuple orderTuple = order.getField(1, Tuple.class);
     
      orderTuple.project(32);
      String newOrderKey = orderTuple.getStringValueAt(0);
     
      order.setField(0, new StringValue(newOrderKey));
      out.collect(order);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.