Package org.apache.crunch.test

Examples of org.apache.crunch.test.Person


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

    Person expectedPerson = new Person();
    expectedPerson.age = 42;
    expectedPerson.name = "John Doe";
    List<CharSequence> siblingNames = Lists.newArrayList();
    siblingNames.add("Jimmy");
    siblingNames.add("Jane");
    expectedPerson.siblingnames = siblingNames;

    Person person = recordIterator.next();

    assertEquals(expectedPerson, person);
    assertFalse(recordIterator.hasNext());
  }
View Full Code Here


public class TupleDeepCopierTest {

  @Test
  public void testDeepCopy_Pair() {
    Person person = new Person();
    person.name = "John Doe";
    person.age = 42;
    person.siblingnames = Lists.<CharSequence> newArrayList();

    Pair<Integer, Person> inputPair = Pair.of(1, person);
View Full Code Here

  static class StringToStringWrapperPersonPairMapFn extends MapFn<String, Pair<StringWrapper, Person>> {

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

public class AvroGroupedTableTypeTest {

  @Test
  public void testGetDetachedValue() {
    Integer integerValue = 42;
    Person person = new Person();
    person.name = "John Doe";
    person.age = 42;
    person.siblingnames = Lists.<CharSequence> newArrayList();

    Iterable<Person> inputPersonIterable = Lists.newArrayList(person);
View Full Code Here

public class CollectionDeepCopierTest {

  @Test
  public void testDeepCopy() {
    Person person = new Person();
    person.age = 42;
    person.name = "John Smith";
    person.siblingnames = Lists.<CharSequence> newArrayList();

    Collection<Person> personCollection = Lists.newArrayList(person);
View Full Code Here

    pipeline.done();
  }

  private void createPersonAvroFile(File avroFile) throws IOException {

    Person person = new Person();
    person.age = 40;
    person.name = "Bob";
    List<CharSequence> siblingNames = Lists.newArrayList();
    siblingNames.add("Bob" + "1");
    siblingNames.add("Bob" + "2");
View Full Code Here

  @Test
  public void testSortAvroTypesBySelectedFields() throws Exception {

    MRPipeline pipeline = new MRPipeline(AvroTypeSortIT.class, tmpDir.getDefaultConfiguration());

    Person ccc10 = createPerson("CCC", 10);
    Person bbb20 = createPerson("BBB", 20);
    Person aaa30 = createPerson("AAA", 30);

    writeAvroFile(Lists.newArrayList(ccc10, bbb20, aaa30), avroFile);

    PCollection<Person> unsorted = pipeline.read(At.avroFile(avroFile.getAbsolutePath(), records(Person.class)));
View Full Code Here

    outputStream.close();
  }

  private Person createPerson(String name, int age) throws IOException {

    Person person = new Person();
    person.age = age;
    person.name = name;
    List<CharSequence> siblingNames = Lists.newArrayList();
    person.siblingnames = siblingNames;
View Full Code Here

    this.employeeFile = File.createTempFile("employee", ".avro");

    DatumWriter<Person> pdw = new SpecificDatumWriter<Person>();
    DataFileWriter<Person> pfw = new DataFileWriter<Person>(pdw);
    pfw.create(Person.SCHEMA$, personFile);
    Person p1 = new Person();
    p1.name = "Josh";
    p1.age = 19;
    p1.siblingnames = ImmutableList.<CharSequence> of("Kate", "Mike");
    pfw.append(p1);
    Person p2 = new Person();
    p2.name = "Kate";
    p2.age = 17;;
    p2.siblingnames = ImmutableList.<CharSequence> of("Josh", "Mike");
    pfw.append(p2);
    Person p3 = new Person();
    p3.name = "Mike";
    p3.age = 12;
    p3.siblingnames = ImmutableList.<CharSequence> of("Josh", "Kate");
    pfw.append(p3);
    pfw.close();
View Full Code Here

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

      @Override
      public Pair<StringWrapper, Person> map(String input) {
        Person person = new Person();
        person.name = input;
        person.age = 42;
        person.siblingnames = Lists.<CharSequence> newArrayList(input);

        return Pair.of(new StringWrapper(input), person);
View Full Code Here

TOP

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

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.