Examples of StringWrapper


Examples of org.apache.crunch.test.StringWrapper

        strType));

    List<StringWrapper> recordList = Lists.newArrayList(stringValueCollection.materialize());

    assertEquals(1, recordList.size());
    StringWrapper stringWrapper = recordList.get(0);
    assertEquals("stringvalue", stringWrapper.getValue());
  }
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

    PCollection<StringWrapper> stringWrapperCollection = pipeline.readTextFile(tmpDir.copyResourceFileName("set1.txt"))
        .parallelDo(new MapFn<String, StringWrapper>() {

          @Override
          public StringWrapper map(String input) {
            StringWrapper stringWrapper = new StringWrapper();
            stringWrapper.setValue(input);
            return stringWrapper;
          }
        }, Avros.reflects(StringWrapper.class));

    List<StringWrapper> stringWrappers = Lists.newArrayList(stringWrapperCollection.materialize());

    pipeline.done();

    assertEquals(Lists.newArrayList(new StringWrapper("b"), new StringWrapper("c"), new StringWrapper("a"),
        new StringWrapper("e")), stringWrappers);

  }
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

        Person person = new Person();
        person.name = input;
        person.age = 42;
        person.siblingnames = Lists.<CharSequence> newArrayList(input);

        return Pair.of(new StringWrapper(input), person);
      }
    }, Avros.pairs(Avros.reflects(StringWrapper.class), Avros.records(Person.class)));

    PCollection<Pair<String, Long>> countCollection = Aggregate.count(hybridPairCollection).parallelDo(
        new MapFn<Pair<Pair<StringWrapper, Person>, Long>, Pair<String, Long>>() {
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

    PCollection<Person> genericCollection = pipeline.read(At.avroFile(avroFile.getAbsolutePath(),
        Avros.records(Person.class)));
    PTable<Long, StringWrapper> pt = genericCollection.parallelDo(new MapFn<Person, Pair<Long, StringWrapper>>() {
      @Override
      public Pair<Long, StringWrapper> map(Person input) {
        return Pair.of(1L, new StringWrapper(input.getName().toString()));
      }
    }, Avros.tableOf(Avros.longs(), Avros.reflects(StringWrapper.class)))
        .groupByKey()
        .ungroup();
    List<Pair<Long, StringWrapper>> ret = Lists.newArrayList(pt.materialize());
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

        Avros.reflects(StringWrapper.class)));

    List<StringWrapper> recordList = Lists.newArrayList(stringValueCollection.materialize());

    assertEquals(1, recordList.size());
    StringWrapper stringWrapper = recordList.get(0);
    assertEquals("stringvalue", stringWrapper.getValue());
  }
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

    AvroFileReaderFactory<StringWrapper> genericReader = createFileReaderFactory(Avros.reflects(StringWrapper.class));
    Iterator<StringWrapper> recordIterator = genericReader.read(FileSystem.getLocal(new Configuration()), new Path(
        this.avroFile.getAbsolutePath()));

    StringWrapper stringWrapper = recordIterator.next();

    assertEquals("stringvalue", stringWrapper.getValue());
    assertFalse(recordIterator.hasNext());
  }
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

  @Test
  public void testGetDetachedValue_MutableDerived() {
    PType<StringWrapper> jsonType = PTypes.jsonString(StringWrapper.class, WritableTypeFamily.getInstance());
    jsonType.initialize(new Configuration());

    StringWrapper stringWrapper = new StringWrapper();
    stringWrapper.setValue("test");

    StringWrapper detachedValue = jsonType.getDetachedValue(stringWrapper);

    assertNotSame(stringWrapper, detachedValue);
    assertEquals(stringWrapper, detachedValue);
  }
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

        Avros.reflects(StringWrapper.class));
    joinFn.setContext(CrunchTestSupport.getTestContext(new Configuration()));
    joinFn.initialize();
    Emitter<Pair<StringWrapper, Pair<StringWrapper, String>>> emitter = mock(Emitter.class);
   
    StringWrapper key = new StringWrapper();
    StringWrapper leftValue = new StringWrapper();
    key.setValue("left-only");
    leftValue.setValue("left-only-left");
    joinFn.join(key, 0, createValuePairList(leftValue, null), emitter);

    key.setValue("right-only");
    joinFn.join(key, 1, createValuePairList(null, "right-only-right"), emitter);
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

        Avros.reflects(StringWrapper.class));
    joinFn.setContext(CrunchTestSupport.getTestContext(new Configuration()));
    joinFn.initialize();
    Emitter<Pair<StringWrapper, Pair<StringWrapper, String>>> emitter = mock(Emitter.class);
   
    StringWrapper key = new StringWrapper();
    StringWrapper leftValue = new StringWrapper();
    key.setValue("left-only");
    leftValue.setValue("left-only-left");
    joinFn.join(key, 0, createValuePairList(leftValue, null), emitter);

    key.setValue("right-only");
    joinFn.join(key, 1, createValuePairList(null, "right-only-right"), emitter);
View Full Code Here

Examples of org.apache.crunch.test.StringWrapper

  }

  @Test
  public void testPairOutputMapFn_VerifyNoObjectReuse() {
    StringWrapper stringWrapper = new StringWrapper("Test");

    Pair<Integer, StringWrapper> pair = Pair.of(1, stringWrapper);

    AvroType<Pair<Integer, StringWrapper>> pairType = Avros.pairs(Avros.ints(), Avros.reflects(StringWrapper.class));
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.