Package org.apache.crunch.test

Examples of org.apache.crunch.test.Employee


        .parallelDo(mapFn, Avros.tableOf(Avros.ints(), Avros.records(Employee.class))).collectValues()
        .materializeToMap();

    assertEquals(1, collectionMap.size());

    Employee empC = mapFn.map("c").second();
    Employee empD = mapFn.map("d").second();
    Employee empA = mapFn.map("a").second();

    assertTrue(collectionMap.get(1).containsAll(Lists.newArrayList(empC, empD, empA)));
  }
View Full Code Here


  }

  private static class MapStringToEmployeePair extends MapFn<String, Pair<Integer, Employee>> {
    @Override
    public Pair<Integer, Employee> map(String input) {
      Employee emp = new Employee();
      emp.name = input;
      emp.salary = 0;
      emp.department = "";
      return Pair.of(1, emp);
    }
View Full Code Here

        Avros.records(Person.class)));

    PCollection<Employee> employees = genericCollection.parallelDo(new DoFn<Person, Employee>() {
      @Override
      public void process(Person person, Emitter<Employee> emitter) {
        emitter.emit(new Employee(person.getName(), 0, "Eng"));
      }
    }, Avros.records(Employee.class));

    File output1File = tmpDir.getFile("output1");
    File output2File = tmpDir.getFile("output2");
    pipeline.write(genericCollection, new AvroParquetFileTarget(output1File.getAbsolutePath()));
    pipeline.write(employees, new AvroParquetFileSourceTarget(new Path(output2File.getAbsolutePath()),
        Avros.records(Employee.class)));
    pipeline.run();

    Person person = genericCollection.materialize().iterator().next();
    Employee employee = employees.materialize().iterator().next();

    Path parquet1File = new Path(new File(output1File, "part-m-00000.parquet").getPath());
    Path parquet2File = new Path(new File(output2File, "part-m-00000.parquet").getPath());

    AvroParquetReader<Person> personReader = new AvroParquetReader<Person>(parquet1File);

    try {
      Person readPerson = personReader.read();
      assertThat(readPerson, is(person));
    } finally {
      personReader.close();
    }

    AvroParquetReader<Employee> employeeReader = new AvroParquetReader<Employee>(parquet2File);

    try {
      Employee readEmployee = employeeReader.read();
      assertThat(readEmployee, is(employee));
    } finally {
      employeeReader.close();
    }
View Full Code Here

        .parallelDo(mapFn, Avros.tableOf(Avros.ints(), Avros.records(Employee.class))).collectValues()
        .materializeToMap();

    assertEquals(1, collectionMap.size());

    Employee empC = mapFn.map("c").second();
    Employee empD = mapFn.map("d").second();
    Employee empA = mapFn.map("a").second();

    assertTrue(collectionMap.get(1).containsAll(Lists.newArrayList(empC, empD, empA)));
  }
View Full Code Here

  }

  private static class MapStringToEmployeePair extends MapFn<String, Pair<Integer, Employee>> {
    @Override
    public Pair<Integer, Employee> map(String input) {
      Employee emp = new Employee();
      emp.name = input;
      emp.salary = 0;
      emp.department = "";
      return Pair.of(1, emp);
    }
View Full Code Here

        .parallelDo(mapFn, Avros.tableOf(Avros.ints(), Avros.records(Employee.class))).collectValues()
        .materializeToMap();

    assertEquals(1, collectionMap.size());

    Employee empC = mapFn.map("c").second();
    Employee empD = mapFn.map("d").second();
    Employee empA = mapFn.map("a").second();

    assertTrue(collectionMap.get(1).containsAll(Lists.newArrayList(empC, empD, empA)));
  }
View Full Code Here

  }

  private static class MapStringToEmployeePair extends MapFn<String, Pair<Integer, Employee>> {
    @Override
    public Pair<Integer, Employee> map(String input) {
      Employee emp = new Employee();
      emp.name = input;
      emp.salary = 0;
      emp.department = "";
      return Pair.of(1, emp);
    }
View Full Code Here

    pfw.close();

    DatumWriter<Employee> edw = new SpecificDatumWriter<Employee>();
    DataFileWriter<Employee> efw = new DataFileWriter<Employee>(edw);
    efw.create(Employee.SCHEMA$, employeeFile);
    Employee e1 = new Employee();
    e1.name = "Kate";
    e1.salary = 100000;
    e1.department = "Marketing";
    efw.append(e1);
    efw.close();
View Full Code Here

        .parallelDo(mapFn, Avros.tableOf(Avros.ints(), Avros.records(Employee.class))).collectValues()
        .materializeToMap();

    assertEquals(1, collectionMap.size());

    Employee empC = mapFn.map("c").second();
    Employee empD = mapFn.map("d").second();
    Employee empA = mapFn.map("a").second();

    assertTrue(collectionMap.get(1).containsAll(Lists.newArrayList(empC, empD, empA)));
  }
View Full Code Here

  }

  private static class MapStringToEmployeePair extends MapFn<String, Pair<Integer, Employee>> {
    @Override
    public Pair<Integer, Employee> map(String input) {
      Employee emp = new Employee();
      emp.name = input;
      emp.salary = 0;
      emp.department = "";
      return Pair.of(1, emp);
    }
View Full Code Here

TOP

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

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.