use of com.twitter.elephantbird.thrift.test.TestMap in project parquet-mr by apache.
the class TestParquetReadProtocol method testMap.
@Test
public void testMap() throws Exception {
final Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
TestMap testMap = new TestMap("map_name", map);
validate(testMap);
}
use of com.twitter.elephantbird.thrift.test.TestMap in project parquet-mr by apache.
the class TestParquetWriteProtocol method testMap.
@Test
public void testMap() 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)", "addBinary(bar)", "endField(value, 1)", "endGroup()", "startGroup()", "startField(key, 0)", "addBinary(foo2)", "endField(key, 0)", "startField(value, 1)", "addBinary(bar2)", "endField(value, 1)", "endGroup()", "endField(map, 0)", "endGroup()", "endField(names, 1)", "endMessage()" };
String[] expectationsAlt = { "startMessage()", "startField(name, 0)", "addBinary(map_name)", "endField(name, 0)", "startField(names, 1)", "startGroup()", "startField(map, 0)", "startGroup()", "startField(key, 0)", "addBinary(foo2)", "endField(key, 0)", "startField(value, 1)", "addBinary(bar2)", "endField(value, 1)", "endGroup()", "startGroup()", "startField(key, 0)", "addBinary(foo)", "endField(key, 0)", "startField(value, 1)", "addBinary(bar)", "endField(value, 1)", "endGroup()", "endField(map, 0)", "endGroup()", "endField(names, 1)", "endMessage()" };
final Map<String, String> map = new TreeMap<String, String>();
map.put("foo", "bar");
map.put("foo2", "bar2");
TestMap testMap = new TestMap("map_name", map);
try {
validatePig(expectations, testMap);
} catch (ComparisonFailure e) {
// This can happen despite using a stable TreeMap, since ThriftToPig#toPigMap
// in com.twitter.elephantbird.pig.util creates a HashMap.
// So we test with the map elements in reverse order
validatePig(expectationsAlt, testMap);
}
validateThrift(expectations, testMap);
}
use of com.twitter.elephantbird.thrift.test.TestMap in project parquet-mr by apache.
the class TestThriftToPigCompatibility method testMap.
public void testMap() throws Exception {
Map<String, String> map = new TreeMap<String, String>();
map.put("foo", "bar");
map.put("foo2", "bar2");
TestMap testMap = new TestMap("map_name", map);
validateSameTupleAsEB(testMap);
}
use of com.twitter.elephantbird.thrift.test.TestMap in project elephant-bird by twitter.
the class TestThriftToPig method testMapValueFieldAlias.
/**
* Tests that thrift map field value has no field schema alias.
* @throws FrontendException
*/
@Test
public void testMapValueFieldAlias() throws FrontendException {
ThriftToPig<TestMap> thriftToPig = new ThriftToPig<TestMap>(TestMap.class);
Schema schema = thriftToPig.toSchema();
Assert.assertEquals("{name: chararray,names: map[chararray]}", schema.toString());
Assert.assertNull(schema.getField(1).schema.getField(0).alias);
schema = ThriftToPig.toSchema(TestMap.class);
Assert.assertEquals("{name: chararray,names: map[chararray]}", schema.toString());
Assert.assertNull(schema.getField(1).schema.getField(0).alias);
}
Aggregations