Package com.twitter.data.proto.tutorial.AddressBookProtos

Examples of com.twitter.data.proto.tutorial.AddressBookProtos.Person


    PhoneNumber pn2 = PhoneNumber.newBuilder().setNumber("pn0002").setType(PhoneType.WORK).build();
    PhoneNumber pn3 = PhoneNumber.newBuilder().setNumber("pn0003").build();
    test_pn = PhoneNumber.newBuilder().setNumber("pn0004").setType(PhoneType.MOBILE)
        .build();

    Person p1 = Person.newBuilder().setName("p1").setId(1).setEmail("p1@twitter").addPhone(pn1)
        .addPhone(pn2).addPhone(pn3).build();
    Person p2 = Person.newBuilder().setName("p2").setId(2).addPhone(test_pn).build();
    Person p3 = Person.newBuilder().setName("p3").setId(3).build();

    test_ab = AddressBook.newBuilder().addPerson(p1).addPerson(p2).addPerson(p3).setByteData(ByteString.copyFrom(new byte[] {16,32,64,(byte) 128})).build();
    deserializer = new ProtobufDeserializer();

    Properties properties = new Properties();
View Full Code Here


  static AddressBook referenceAb;
  static TypedProtobufWritable<AddressBook> referenceAbWritable;

  @BeforeClass
  public static void setUp() {
    Person p1 = Person.newBuilder()
    .setEmail("email1@example.com")
    .setId(74)
    .setName("Example Person")
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("2930423").build())
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.HOME).setNumber("214121").build())
    .build();

    Person p2 = Person.newBuilder()
    .setEmail("email2@example.com")
    .setId(7334)
    .setName("Another person")
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("030303").build())
    .build();
View Full Code Here

  static AddressBook referenceAb;
  static ProtobufWritable<AddressBook> referenceAbWritable;

  @BeforeClass
  public static void setUp() {
    Person p1 = Person.newBuilder()
    .setEmail("email1@example.com")
    .setId(74)
    .setName("Example Person")
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("2930423").build())
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.HOME).setNumber("214121").build())
    .build();

    Person p2 = Person.newBuilder()
    .setEmail("email2@example.com")
    .setId(7334)
    .setName("Another person")
    .addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("030303").build())
    .build();
View Full Code Here

                      Lists.<Object> newArrayList(phoneNumber, phoneType))))));
  }

  @Test
  public void testPerson() {
    Person expected = personMessage("Joe", 1, null, "123-456-7890", "HOME");
    Person actual = PigToProtobuf.tupleToMessage(Person.class,
        personTuple("Joe", 1, null, "123-456-7890", "HOME"));
    Assert.assertNotNull(actual);
    Assert.assertEquals(expected, actual);
  }
View Full Code Here

   */
  public static void main(String[] args) throws ExecException {
    int iterations = 100000;
    ProtobufToPig protoConv = new ProtobufToPig();
    for (int i = 0; i < iterations; i++) {
      Person proto = Fixtures.buildPersonProto();
      Tuple t = protoConv.toTuple(proto);
      t.get(0);
      t = new ProtobufTuple(proto);
      t.get(0);
    }
    StopWatch timer = new StopWatch();
    timer.start();
    for (int i = 0; i < iterations; i++) {
      Person proto = Fixtures.buildPersonProto();
      Tuple t = protoConv.toTuple(proto);
      t.get(0);
    }
    timer.split();
    System.err.println(timer.getSplitTime());
    timer.reset();
    timer.start();
    for (int i = 0; i < iterations; i++) {
      Person proto = Fixtures.buildPersonProto();
      Tuple t = new ProtobufTuple(proto);
      t.get(0);
    }
    timer.split();
    System.err.println(timer.getSplitTime());
View Full Code Here

        abTuple.toDelimitedString(","));
  }

  @Test
  public void testLazyProtoToPig() throws ExecException {
    Person personProto = Fixtures.buildPersonProto();
    Tuple protoTuple = new ProtobufTuple(personProto);
    Tuple normalTuple = Fixtures.buildPersonTuple();
    List<FieldDescriptor> fieldDescs = personProto.getDescriptorForType().getFields();

    TypeRef<Person> typeRef = PigUtil.getProtobufTypeRef(Person.class.getName());
    Tuple projectedTuple =
      new ProjectedProtobufTupleFactory<Person>(typeRef, evenFields(fieldDescs)).newTuple(personProto);
View Full Code Here

TOP

Related Classes of com.twitter.data.proto.tutorial.AddressBookProtos.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.