Search in sources :

Example 1 with TestStructInMap

use of com.twitter.elephantbird.thrift.test.TestStructInMap in project parquet-mr by apache.

the class TestParquetReadProtocol method testStructInMap.

@Test
public void testStructInMap() throws Exception {
    final Map<String, TestPerson> map = new HashMap<String, TestPerson>();
    map.put("foo", new TestPerson(new TestName("john", "johnson"), new HashMap<TestPhoneType, String>()));
    final Map<String, Integer> stringToIntMap = Collections.singletonMap("bar", 10);
    TestStructInMap testMap = new TestStructInMap("map_name", map, stringToIntMap);
    validate(testMap);
}
Also used : TestName(com.twitter.elephantbird.thrift.test.TestName) HashMap(java.util.HashMap) TestPerson(com.twitter.elephantbird.thrift.test.TestPerson) TestStructInMap(com.twitter.elephantbird.thrift.test.TestStructInMap) Test(org.junit.Test)

Example 2 with TestStructInMap

use of com.twitter.elephantbird.thrift.test.TestStructInMap in project parquet-mr by apache.

the class TestThriftToPigCompatibility method testStructInMap.

@Test
public void testStructInMap() throws Exception {
    final Map<String, TestPerson> map = new HashMap<String, TestPerson>();
    map.put("foo", new TestPerson(new TestName("john", "johnson"), new HashMap<TestPhoneType, String>()));
    final Map<String, Integer> stringToIntMap = Collections.singletonMap("bar", 10);
    TestStructInMap testMap = new TestStructInMap("map_name", map, stringToIntMap);
    validateSameTupleAsEB(testMap);
}
Also used : TestName(com.twitter.elephantbird.thrift.test.TestName) HashMap(java.util.HashMap) TestPerson(com.twitter.elephantbird.thrift.test.TestPerson) TestStructInMap(com.twitter.elephantbird.thrift.test.TestStructInMap) Test(org.junit.Test)

Example 3 with TestStructInMap

use of com.twitter.elephantbird.thrift.test.TestStructInMap in project parquet-mr by apache.

the class TestParquetWriteProtocol method testStructInMap.

@Test
public void testStructInMap() throws Exception {
    String[] expectations = { "startMessage()", "startField(name, 0)", "addBinary(map_name)", "endField(name, 0)", "startField(names, 1)", "startGroup()", "startField(map, 0)", "startGroup()", "startField(key, 0)", "addBinary(foo)", "endField(key, 0)", "startField(value, 1)", "startGroup()", "startField(name, 0)", "startGroup()", "startField(first_name, 0)", "addBinary(john)", "endField(first_name, 0)", "startField(last_name, 1)", "addBinary(johnson)", "endField(last_name, 1)", "endGroup()", "endField(name, 0)", "startField(phones, 1)", "startGroup()", "endGroup()", "endField(phones, 1)", "endGroup()", "endField(value, 1)", "endGroup()", "endField(map, 0)", "endGroup()", "endField(names, 1)", "startField(name_to_id, 2)", "startGroup()", "startField(map, 0)", "startGroup()", "startField(key, 0)", "addBinary(bar)", "endField(key, 0)", "startField(value, 1)", "addInt(10)", "endField(value, 1)", "endGroup()", "endField(map, 0)", "endGroup()", "endField(name_to_id, 2)", "endMessage()" };
    final Map<String, TestPerson> map = new HashMap<String, TestPerson>();
    map.put("foo", new TestPerson(new TestName("john", "johnson"), new HashMap<TestPhoneType, String>()));
    final Map<String, Integer> stringToIntMap = Collections.singletonMap("bar", 10);
    TestStructInMap testMap = new TestStructInMap("map_name", map, stringToIntMap);
    validatePig(expectations, testMap);
    validateThrift(expectations, testMap);
}
Also used : TestName(com.twitter.elephantbird.thrift.test.TestName) HashMap(java.util.HashMap) TestPerson(com.twitter.elephantbird.thrift.test.TestPerson) TestStructInMap(com.twitter.elephantbird.thrift.test.TestStructInMap) Test(org.junit.Test)

Aggregations

TestName (com.twitter.elephantbird.thrift.test.TestName)3 TestPerson (com.twitter.elephantbird.thrift.test.TestPerson)3 TestStructInMap (com.twitter.elephantbird.thrift.test.TestStructInMap)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3