Package org.apache.hadoop.hive.hbase.avro

Examples of org.apache.hadoop.hive.hbase.avro.Employee


    out.close();
    return data;
  }

  private byte[] getTestAvroBytesFromClass1(int i) throws IOException {
    Employee employee = new Employee();

    employee.setEmployeeName("Avro Employee" + i);
    employee.setEmployeeID(11111L);
    employee.setGender(Gender.FEMALE);
    employee.setAge(25L);

    Address address = new Address();

    address.setAddress1("Avro First Address" + i);
    address.setAddress2("Avro Second Address" + i);
    address.setCity("Avro City" + i);
    address.setZipcode(123456L);

    Map<CharSequence, CharSequence> metadata = new HashMap<CharSequence, CharSequence>();

    metadata.put("testkey", "testvalue");

    address.setMetadata(metadata);

    HomePhone hPhone = new HomePhone();

    hPhone.setAreaCode(999L);
    hPhone.setNumber(1234567890L);

    OfficePhone oPhone = new OfficePhone();

    oPhone.setAreaCode(999L);
    oPhone.setNumber(1234455555L);

    ContactInfo contact = new ContactInfo();

    List<Address> addresses = new ArrayList<Address>();
    address.setCounty(hPhone); // set value for the union type
    addresses.add(address);
    addresses.add(address);

    contact.setAddress(addresses);

    contact.setHomePhone(hPhone);
    contact.setOfficePhone(oPhone);

    employee.setContactInfo(contact);

    DatumWriter<Employee> datumWriter = new SpecificDatumWriter<Employee>(Employee.class);
    DataFileWriter<Employee> dataFileWriter = new DataFileWriter<Employee>(datumWriter);

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    dataFileWriter.create(employee.getSchema(), out);
    dataFileWriter.append(employee);
    dataFileWriter.close();

    return out.toByteArray();
  }
View Full Code Here


    return out.toByteArray();
  }

  private byte[] getTestAvroBytesFromClass2(int i) throws IOException {
    Employee employee = new Employee();

    employee.setEmployeeName("Avro Employee" + i);
    employee.setEmployeeID(11111L);
    employee.setGender(Gender.FEMALE);
    employee.setAge(25L);

    Address address = new Address();

    address.setAddress1("Avro First Address" + i);
    address.setAddress2("Avro Second Address" + i);
    address.setCity("Avro City" + i);
    address.setZipcode(123456L);

    Map<CharSequence, CharSequence> metadata = new HashMap<CharSequence, CharSequence>();

    metadata.put("testkey", "testvalue");

    address.setMetadata(metadata);

    HomePhone hPhone = new HomePhone();

    hPhone.setAreaCode(999L);
    hPhone.setNumber(1234567890L);

    OfficePhone oPhone = new OfficePhone();

    oPhone.setAreaCode(999L);
    oPhone.setNumber(1234455555L);

    ContactInfo contact = new ContactInfo();

    List<Address> addresses = new ArrayList<Address>();
    address.setCounty(hPhone); // set value for the union type
    addresses.add(address);
    addresses.add(address);

    contact.setAddress(addresses);

    contact.setHomePhone(hPhone);
    contact.setOfficePhone(oPhone);

    employee.setContactInfo(contact);

    DatumWriter<Employee> employeeWriter = new SpecificDatumWriter<Employee>(Employee.class);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.hbase.avro.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.