當前位置: 首頁>>代碼示例>>Java>>正文


Java Person類代碼示例

本文整理匯總了Java中com.twitter.data.proto.tutorial.thrift.Person的典型用法代碼示例。如果您正苦於以下問題:Java Person類的具體用法?Java Person怎麽用?Java Person使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Person類屬於com.twitter.data.proto.tutorial.thrift包,在下文中一共展示了Person類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPullingInRequiredStructWithFilter

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testPullingInRequiredStructWithFilter() throws Exception {
  final String projectionFilterDesc = "persons/{id};persons/email";
  TBase toWrite = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("Bob", "Roberts"),
                          0,
                          "[email protected]",
                          Arrays.asList(new PhoneNumber("1234567890")))));

  //Name is a required field, but is projected out. To make the thrift record pass validation, the name field is filled
  //with empty string
  TBase toRead = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("", ""),
                          0,
                          "[email protected]",
                          null)));
  shouldDoProjectionWithThriftColumnFilter(projectionFilterDesc, toWrite, toRead, AddressBook.class);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:23,代碼來源:TestParquetToThriftReadWriteAndProjection.java

示例2: testProjectOutOptionalFields

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testProjectOutOptionalFields() throws Exception {

  final String projectionFilterDesc = "persons/name/*";

  TBase toWrite = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("Bob", "Roberts"),
                          0,
                          "[email protected]",
                          Arrays.asList(new PhoneNumber("1234567890")))));

  //emails and phones are optional fields that do not match the projection filter
  TBase toRead = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("Bob", "Roberts"),
                          0,
                          null,
                          null))
  );

  shouldDoProjectionWithThriftColumnFilter(projectionFilterDesc, toWrite, toRead, AddressBook.class);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:26,代碼來源:TestParquetToThriftReadWriteAndProjection.java

示例3: testWriteFile

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testWriteFile() throws IOException, InterruptedException, TException {
  final AddressBook a = new AddressBook(
      Arrays.asList(
          new Person(
              new Name("Bob", "Roberts"),
              0,
              "[email protected]",
              Arrays.asList(new PhoneNumber("1234567890")))));

  final Path fileToCreate = createFile(a);

  ParquetReader<Group> reader = createRecordReader(fileToCreate);

  Group g = null;
  int i = 0;
  while((g = reader.read()) != null) {
    assertEquals(a.persons.size(), g.getFieldRepetitionCount("persons"));
    assertEquals(a.persons.get(0).email, g.getGroup("persons", 0).getGroup(0, 0).getString("email", 0));
    // just some sanity check, we're testing the various layers somewhere else
    ++i;
  }
  assertEquals("read 1 record", 1, i);

}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:26,代碼來源:TestThriftToParquetFileWriter.java

示例4: testFieldsPath

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testFieldsPath() {
  StructType person = ThriftSchemaConverter.toStructType(Person.class);

  List<String> paths = PrimitivePathVisitor.visit(person, ".");
  assertEquals(Arrays.asList("name.first_name", "name.last_name", "id", "email", "phones.number", "phones.type"),
      paths);

  paths = PrimitivePathVisitor.visit(person, "/");
  assertEquals(Arrays.asList("name/first_name", "name/last_name", "id", "email", "phones/number", "phones/type"),
      paths);

  StructType structInMap = ThriftSchemaConverter.toStructType(TestStructInMap.class);

  paths = PrimitivePathVisitor.visit(structInMap, ".");
  assertEquals(Arrays.asList("name", "names.key", "names.value.name.first_name", "names.value.name.last_name",
          "names.value.phones.key", "names.value.phones.value", "name_to_id.key", "name_to_id.value"), paths);

  paths = PrimitivePathVisitor.visit(structInMap, "/");
  assertEquals(Arrays.asList("name", "names/key", "names/value/name/first_name", "names/value/name/last_name",
      "names/value/phones/key", "names/value/phones/value", "name_to_id/key", "name_to_id/value"), paths);

}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:24,代碼來源:TestFieldsPath.java

示例5: testRead

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testRead() throws Exception {
  final PhoneNumber phoneNumber = new PhoneNumber("5555555555");
  phoneNumber.type = MOBILE;
  List<Person> persons = Arrays.asList(
      new Person(
          new Name("john", "johson"),
          1,
          "[email protected]",
          Arrays.asList(phoneNumber)
          ),
      new Person(
          new Name("jack", "jackson"),
          2,
          "[email protected]",
          Arrays.asList(new PhoneNumber("5555555556"))
          )
      );
  AddressBook expected = new AddressBook(persons);
  validate(expected);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:22,代碼來源:TestParquetReadProtocol.java

示例6: testProtocolAddressBook

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testProtocolAddressBook() throws Exception {
  ArrayList<Person> persons = new ArrayList<Person>();
  final PhoneNumber phoneNumber = new PhoneNumber("555 999 9998");
  phoneNumber.type = PhoneType.HOME;
  persons.add(
      new Person(
          new Name("Bob", "Roberts"),
          1,
          "[email protected]",
          Arrays.asList(new PhoneNumber("555 999 9999"), phoneNumber)));
  persons.add(
      new Person(
          new Name("Dick", "Richardson"),
          2,
          "[email protected]",
          Arrays.asList(new PhoneNumber("555 999 9997"), new PhoneNumber("555 999 9996"))));
  AddressBook a = new AddressBook(persons);
  validateSameTupleAsEB(a);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:21,代碼來源:TestThriftToPigCompatibility.java

示例7: testThriftOptionalFieldsWithReadProjectionUsingParquetSchema

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testThriftOptionalFieldsWithReadProjectionUsingParquetSchema() throws Exception {
  // test with projection
  Configuration conf = new Configuration();
  final String readProjectionSchema = "message AddressBook {\n" +
          "  optional group persons {\n" +
          "    repeated group persons_tuple {\n" +
          "      required group name {\n" +
          "        optional binary first_name;\n" +
          "        optional binary last_name;\n" +
          "      }\n" +
          "      optional int32 id;\n" +
          "    }\n" +
          "  }\n" +
          "}";
  conf.set(ReadSupport.PARQUET_READ_SCHEMA, readProjectionSchema);
  TBase toWrite = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("Bob", "Roberts"),
                          0,
                          "[email protected]",
                          Arrays.asList(new PhoneNumber("1234567890")))));

  TBase toRead = new AddressBook(
          Arrays.asList(
                  new Person(
                          new Name("Bob", "Roberts"),
                          0,
                          null,
                          null)));
  shouldDoProjection(conf, toWrite, toRead, AddressBook.class);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:34,代碼來源:TestParquetToThriftReadWriteAndProjection.java

示例8: nextAddressbook

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
public static AddressBook nextAddressbook(int i) {
  final ArrayList<Person> persons = new ArrayList<Person>();
  for (int j = 0; j < i % 3; j++) {
    final ArrayList<PhoneNumber> phones = new ArrayList<PhoneNumber>();
    for (int k = 0; k < i%4; k++) {
      phones.add(new PhoneNumber("12345"+i));
    }
    persons.add(new Person(new Name("John"+i, "Roberts"), i, "[email protected]" + i, phones));
  }
  AddressBook a = new AddressBook(persons);
  return a;
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:13,代碼來源:TestInputOutputFormat.java

示例9: testProtocolEmptyAdressBook

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testProtocolEmptyAdressBook() throws Exception {
  String[] expectations = {
      "startMessage()",
      "startField(persons, 0)",
      "startGroup()",
      "endGroup()",
      "endField(persons, 0)",
      "endMessage()"
  };
  AddressBook a = new AddressBook(new ArrayList<Person>());
  validatePig(expectations, a);
  validateThrift(expectations, a);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:15,代碼來源:TestParquetWriteProtocol.java

示例10: testToProjectedThriftType

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testToProjectedThriftType() {

  shouldGetProjectedSchema("name/first_name", "name.first_name", "message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "  }}", Person.class);

  shouldGetProjectedSchema("name/first_name;name/last_name", "name.first_name;name.last_name" ,"message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "    optional binary last_name (UTF8) = 2;" +
          "  }}", Person.class);

  shouldGetProjectedSchema("name/{first,last}_name;", "name.{first,last}_name;", "message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "    optional binary last_name (UTF8) = 2;" +
          "  }}", Person.class);

  shouldGetProjectedSchema("name/*", "name" ,"message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "    optional binary last_name (UTF8) = 2;" +
          "  }" +
          "}", Person.class);

  shouldGetProjectedSchema("*/*_name", "*.*_name" ,"message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "    optional binary last_name (UTF8) = 2;" +
          "  }" +
          "}", Person.class);

  shouldGetProjectedSchema("name/first_*", "name.first_*","message ParquetSchema {" +
          "  required group name = 1 {" +
          "    optional binary first_name (UTF8) = 1;" +
          "  }" +
          "}", Person.class);

  shouldGetProjectedSchema("*/*", "*.*", "message ParquetSchema {" +
          "  required group name = 1 {" +
          "  optional binary first_name (UTF8) = 1;" +
          "  optional binary last_name (UTF8) = 2;" +
          "} " +
          "  optional group phones (LIST) = 4 {" +
          "    repeated group phones_tuple {" +
          "      optional binary number (UTF8) = 1;" +
          "      optional binary type (ENUM) = 2;" +
          "    }" +
          "}}", Person.class);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:53,代碼來源:TestThriftSchemaConverter.java

示例11: testProtocolEmptyAdressBook

import com.twitter.data.proto.tutorial.thrift.Person; //導入依賴的package包/類
@Test
public void testProtocolEmptyAdressBook() throws Exception {

  AddressBook a = new AddressBook(new ArrayList<Person>());
  validateSameTupleAsEB(a);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:7,代碼來源:TestThriftToPigCompatibility.java


注:本文中的com.twitter.data.proto.tutorial.thrift.Person類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。