Examples of TupleN


Examples of org.apache.crunch.TupleN

    testInputOutputFn(wt, j, w);
  }

  @Test
  public void testTupleN() throws Exception {
    TupleN j = new TupleN("a", "b", "c", "d", "e");
    Text[] t = new Text[] { new Text("a"), new Text("b"), new Text("c"), new Text("d"),
        new Text("e"), };
    BytesWritable[] b = new BytesWritable[t.length];
    for (int i = 0; i < t.length; i++) {
      b[i] = new BytesWritable(WritableUtils.toByteArray(t[i]));
View Full Code Here

Examples of org.apache.crunch.TupleN

  @Test
  public void testTupleObjectInspector() {
    // test get
    TupleObjectInspector<TupleN> toi = new TupleObjectInspector<TupleN>(TupleFactory.TUPLEN,
        Writables.strings(), Writables.ints(), Writables.floats());
    TupleN tuple = new TupleN("Alice", 28, 165.2f);
    List<Object> values = toi.getStructFieldsDataAsList(tuple);
    assertEquals("Alice", values.get(0));
    assertEquals(28, values.get(1));
    assertEquals(165.2f, values.get(2));
   
    // test create
    TupleN newTuple = toi.create("Alice", 28, 165.2f);
    assertEquals(tuple, newTuple);
    TupleObjectInspector<Pair> poi = new TupleObjectInspector<Pair>(TupleFactory.PAIR,
        Writables.strings(), Writables.ints());
    Pair pair = poi.create("word", 29);
    assertEquals("word", pair.first());
View Full Code Here

Examples of org.apache.crunch.TupleN

  @Test
  public void testTuples() {
    PType<TupleN> ptype = Orcs.tuples(Writables.ints(), Writables.strings(), Orcs.reflects(Person.class),
        Writables.tableOf(Writables.strings(), Orcs.reflects(Person.class)));
   
    TupleN t = new TupleN(1, "John Smith", new Person("Alice", 23, Arrays.asList("666-677-9999")),
        new Pair<String, Person>("Bob", new Person("Bob", 26, Arrays.asList("999-888-1132", "000-222-9934"))));
   
    String typeStr = "struct<a:int,b:string,c:" + Person.TYPE_STR + ",d:struct<d1:string,d2:" + Person.TYPE_STR + ">>";
    TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeStr);
    String tableTypeStr = "struct<a:string,b:" + Person.TYPE_STR + ">";
View Full Code Here

Examples of org.apache.crunch.TupleN

  }
 
  @Test
  public void testTuples() throws IOException {
    generateInputData();
    TupleN expected = new TupleN("Alice", 23, Arrays.asList("919-342-5555", "650-333-2913"));
    testSourceTarget(Orcs.tuples(Writables.strings(), Writables.ints(), Writables.collections(Writables.strings())),
        expected);
  }
View Full Code Here

Examples of org.apache.crunch.TupleN

  @Test
  public void testGetDetachedValue_TupleN() {
    Person person = createPerson();
    AvroType<TupleN> ptype = Avros.tuples(Avros.records(Person.class));
    ptype.initialize(new Configuration());
    TupleN tuple = new TupleN(person);
    TupleN detachedTuple = ptype.getDetachedValue(tuple);

    assertEquals(tuple, detachedTuple);
    assertNotSame(person, detachedTuple.get(0));
  }
View Full Code Here

Examples of org.apache.crunch.TupleN

    testInputOutputFn(wt, j, w);
  }

  @Test
  public void testTupleN() throws Exception {
    TupleN j = new TupleN("a", "b", "c", "d", "e");
    Text[] t = new Text[] { new Text("a"), new Text("b"), new Text("c"), new Text("d"),
        new Text("e"), };
    TupleWritable w = new TupleWritable(t);
    WritableType<?, ?> wt = Writables.tuples(Writables.strings(), Writables.strings(), Writables.strings(),
        Writables.strings(), Writables.strings());
View Full Code Here

Examples of org.apache.crunch.TupleN

  @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

Examples of org.apache.crunch.TupleN

  }
 
  @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

Examples of org.apache.crunch.TupleN

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

Examples of org.apache.crunch.TupleN

    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
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.