Package eu.stratosphere.test.recordJobs.util

Examples of eu.stratosphere.test.recordJobs.util.Tuple


  public void shouldNotFilterTuple() throws Exception, InterruptedException
  {
    LineItemFilter out = new LineItemFilter();
   
    String shipDate = "1996-03-13";
    Tuple input = createInputTuple(shipDate);
    IntValue inputKey = new IntValue();
    Record rec = new Record();
    rec.setField(0, inputKey);
    rec.setField(1, input);
   
View Full Code Here


  {
    LineItemFilter out = new LineItemFilter();
   
    String shipDate = "1999-03-13";
   
    Tuple input = createInputTuple(shipDate);
    IntValue inputKey = new IntValue();
    Record rec = new Record();
    rec.setField(0, inputKey);
    rec.setField(1, input);
   
View Full Code Here

  @Test
  public void shouldNotThrowExceptionWhenNullTuple() throws Exception
  {
    LineItemFilter out = new LineItemFilter();
   
    Tuple input = null;
    IntValue inputKey = new IntValue();
    Record rec = new Record();
    rec.setField(0, inputKey);
    rec.setField(1, input);
   
View Full Code Here

  {
    LineItemFilter out = new LineItemFilter();
   
    String shipDate = "foobarDate";
   
    Tuple input = createInputTuple(shipDate);
    IntValue inputKey = new IntValue();
    Record rec = new Record();
    rec.setField(0, inputKey);
    rec.setField(1, input);
   
View Full Code Here

  @Test
  public void shouldNoThrowExceptionOnTooShortTuple() throws Exception, InterruptedException
  {
    LineItemFilter out = new LineItemFilter();
   
    Tuple input = new Tuple();
    input.addAttribute("" +1);
    input.addAttribute("" + 155190);
    input.addAttribute("" + 7706);
    input.addAttribute("" + 1);
    input.addAttribute("" + 17);
    input.addAttribute("" + 21168.23);
    input.addAttribute("" + 0.04);
    input.addAttribute("" + 0.02);
    input.addAttribute(RETURN_FLAG);
    input.addAttribute("0");
    //the relevant column is missing now
   
    IntValue inputKey = new IntValue();
    Record rec = new Record();
    rec.setField(0, inputKey);
View Full Code Here

    /* (non-Javadoc)
     * @see eu.stratosphere.pact.common.stub.MapStub#map(eu.stratosphere.pact.common.type.Key, eu.stratosphere.pact.common.type.Value, eu.stratosphere.pact.common.stub.Collector)
     */
    @Override
    public void map(Record record, Collector<Record> out) throws Exception {
      Tuple tuple = record.getField(1, Tuple.class);
      Date orderDate;
     
      String orderStringDate = tuple.getStringValueAt(4);
     
      try {
        orderDate = sdf.parse(orderStringDate);
      } catch (ParseException e) {
        throw new RuntimeException(e);
View Full Code Here

   * 1155190|7706|1|17|21168.23|0.04|0.02|N|O|1996-03-13|1996-02-12|1996-03-22|DELIVER IN PERSON|TRUCK|egular courts above the|
   * @param shipDate the date the {@link LineItemFilter} filters for.
   * @return
   */
  private Tuple createInputTuple(String shipDate) {
    Tuple input = new Tuple();
    input.addAttribute("" +1);
    input.addAttribute("" + 155190);
    input.addAttribute("" + 7706);
    input.addAttribute("" + 1);
    input.addAttribute("" + 17);
    input.addAttribute("" + 21168.23);
    input.addAttribute("" + 0.04);
    input.addAttribute("" + 0.02);
    input.addAttribute(RETURN_FLAG);
    input.addAttribute("0");
    input.addAttribute(shipDate);
    return input;
  }
View Full Code Here

  }

  @Test
  public void testCompact() {
   
    Tuple t = new Tuple();
    t.addAttribute("Hello world!");
   
    Assert.assertTrue(t.getBytes().length == 256);
    t.compact();
    Assert.assertTrue(t.getBytes().length == 13);
   
    byte[] ba = new byte[1024];
    int[] of = {0};
    t = new Tuple(ba, of, 0);
   
    Assert.assertTrue(t.getBytes().length == 1024);
    t.compact();
    Assert.assertTrue(t.getBytes().length == 0);
   
    ba = "attr1|attr2|3|4|attr5|thisdoesnotbelongtothetuple".getBytes();
    int[] of2 = {0,6,12,14,16,22};
    t = new Tuple(ba, of2, 5);
   
    Assert.assertTrue(t.getBytes().length == ba.length);
    t.compact();
    Assert.assertTrue(t.getBytes().length == 22);
   
  }
View Full Code Here

    private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   
    @Override
    public void map(Record record, Collector<Record> out) throws Exception {
      Tuple tuple = record.getField(1, Tuple.class);
      String commitString = tuple.getStringValueAt(11);
      String receiptString = tuple.getStringValueAt(12);

      Date commitDate;
      Date receiptDate;
     
      try {
View Full Code Here

  public static class JoinLiO extends JoinFunction {
   
    @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

Related Classes of eu.stratosphere.test.recordJobs.util.Tuple

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.