Package org.apache.crunch

Examples of org.apache.crunch.TupleN


    assertThat(sapply(a, input), is(Tuple4.of(17.29f, 14.5, -0.98, 6)));
  }

  @Test
  public void testTupleN() {
    List<TupleN> input = ImmutableList.of(new TupleN(1, 3.0, 1, 2.0, 4L), new TupleN(4, 17.0, 1, 9.7, 12L));
    Aggregator<TupleN> a = Aggregators.tupleAggregator(
        MIN_INTS(), SUM_DOUBLES(), MAX_INTS(), MIN_DOUBLES(), MAX_LONGS());

    assertThat(sapply(a, input), is(new TupleN(1, 20.0, 1, 2.0, 12L)));
  }
View Full Code Here


      this.extractors = extractors;
    }
   
    @Override
    protected TupleN doCreate(Object[] values) {
      return new TupleN(values);
    }
View Full Code Here

  }
 
  @Test
  public void testTupleN() {
    TokenizerFactory sf = TokenizerFactory.builder().delimiter(",").build();
    assertEquals(new TupleN(1, false, true, 2, 3),
        xtupleN(sf, xint(), xboolean(), xboolean(), xint(), xint()).extract("1,false,true,2,3"));
  }
View Full Code Here

    Arrays.fill(types, typeFamily.strings());
    PCollection<TupleN> kv = input.parallelDo(new DoFn<String, TupleN>() {
      @Override
      public void process(String input, Emitter<TupleN> emitter) {
        String[] split = input.split("[\t]+");
        emitter.emit(new TupleN(split));
      }
    }, typeFamily.tuples(types));
    PCollection<TupleN> sorted = Sort.sortTuples(kv, orders);
    Iterable<TupleN> lines = sorted.materialize();
    TupleN l = lines.iterator().next();
    int i = 0;
    for (String field : fields) {
      assertEquals(field, l.get(i++));
    }
    pipeline.done();
  }
View Full Code Here

  @Test
  @SuppressWarnings("rawtypes")
  public void testTupleN() throws Exception {
    AvroType at = Avros.tuples(Avros.strings(), Avros.strings(), Avros.strings(), Avros.strings(), Avros.strings());
    TupleN j = new TupleN("a", "b", "c", "d", "e");
    GenericData.Record w = new GenericData.Record(at.getSchema());
    w.put(0, new Utf8("a"));
    w.put(1, new Utf8("b"));
    w.put(2, new Utf8("c"));
    w.put(3, new Utf8("d"));
View Full Code Here

 
  @Test
  public void testGetDetachedValue_TupleN(){
    Person person = createPerson();
    AvroType<TupleN> ptype = Avros.tuples(Avros.records(Person.class));
    TupleN tuple = new TupleN(person);
    TupleN detachedTuple = ptype.getDetachedValue(tuple);
   
    assertEquals(tuple, detachedTuple);
    assertNotSame(person, detachedTuple.get(0));
  }
View Full Code Here

TOP

Related Classes of org.apache.crunch.TupleN

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.