Package org.apache.crunch.test

Examples of org.apache.crunch.test.StringWrapper


  @Test
  public void testGetDetachedValue_MutableDerived() {
    PType<StringWrapper> jsonType = PTypes.jsonString(StringWrapper.class, AvroTypeFamily.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


  }

  @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

public class MapDeepCopierTest {

  @Test
  public void testDeepCopy() {
    StringWrapper stringWrapper = new StringWrapper("value");
    String key = "key";
    Map<String, StringWrapper> map = Maps.newHashMap();
    map.put(key, stringWrapper);

    MapDeepCopier<StringWrapper> deepCopier = new MapDeepCopier<StringWrapper>(
View Full Code Here

    public Pair<StringWrapper, Person> map(String input) {
      Person person = new Person();
      person.name = input;
      person.age = 42;
      person.siblingnames = Lists.<CharSequence> newArrayList();
      return Pair.of(new StringWrapper(input), person);
    }
View Full Code Here

  @Test
  public void testGetDetachedValue_MutableDerived() {
    PType<StringWrapper> jsonType = PTypes.jsonString(StringWrapper.class, AvroTypeFamily.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

  private StringWrapper stringWrapper;
  private PType ptype;

  @Before
  public void setUp() {
    stringWrapper = new StringWrapper("test");
    ptype = spy(Avros.reflects(StringWrapper.class));
  }
View Full Code Here

  }

  @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

        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

    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

        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

TOP

Related Classes of org.apache.crunch.test.StringWrapper

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.