本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}