Package org.apache.crunch.test

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


        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

    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

  @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

        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

        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

  }

  @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

    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

  private StringWrapper stringWrapper;
  private PType ptype;

  @Before
  public void setUp() {
    stringWrapper = new StringWrapper("test");
    ptype = spy(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

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.