本文整理汇总了Java中org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getMapTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:Java TypeInfoFactory.getMapTypeInfo方法的具体用法?Java TypeInfoFactory.getMapTypeInfo怎么用?Java TypeInfoFactory.getMapTypeInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory
的用法示例。
在下文中一共展示了TypeInfoFactory.getMapTypeInfo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readMapStringString
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
@Test
public void readMapStringString() throws IOException {
TypeInfo typeInfo = TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.stringTypeInfo);
Map<Object, Object> map = new HashMap<>();
map.put("hello", "world");
try (OrcWriter writer = getOrcWriter(typeInfo)) {
writer.addRow(map);
writer.addRow((Object) null);
}
List<Tuple> list = read(typeInfo);
assertThat(list.size(), is(2));
assertThat(list.get(0).getObject(0), is((Object) map));
assertThat(list.get(1).getObject(0), is(nullValue()));
}
示例2: readMapCharString
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
@Test
public void readMapCharString() throws IOException {
TypeInfo typeInfo = TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.getCharTypeInfo(1),
TypeInfoFactory.stringTypeInfo);
Map<Object, Object> map = new HashMap<>();
map.put(new HiveChar("h", 1), "world");
try (OrcWriter writer = getOrcWriter(typeInfo)) {
writer.addRow(map);
writer.addRow((Object) null);
}
Map<Object, Object> expected = new HashMap<>();
expected.put("h", "world");
List<Tuple> list = read(typeInfo);
assertThat(list.size(), is(2));
assertThat(list.get(0).getObject(0), is((Object) expected));
assertThat(list.get(1).getObject(0), is(nullValue()));
}
示例3: getTypeSupportData
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
/**
* Data provider for various type tests..
*
* @return the required arguments for the test
* {@link MonarchPredicateHandlerTest#testIsMonarchTypeSupported(TypeInfo, boolean)}
*/
@DataProvider
public static Object[][] getTypeSupportData() {
return new Object[][]{
{TypeInfoFactory.intTypeInfo, true},
{TypeInfoFactory.binaryTypeInfo, true},
{TypeInfoFactory.longTypeInfo, true},
{TypeInfoFactory.floatTypeInfo, true},
// {TypeInfoFactory.unknownTypeInfo, false},
{TypeInfoFactory.getDecimalTypeInfo(20, 10), true},
{TypeInfoFactory.getCharTypeInfo(200), true},
{TypeInfoFactory.getStructTypeInfo(Arrays.asList("c1", "c2"),
Arrays.asList(TypeInfoFactory.floatTypeInfo, TypeInfoFactory.getUnionTypeInfo(
Collections.singletonList(TypeInfoFactory.longTypeInfo)))), true},
{TypeInfoFactory.getStructTypeInfo(Arrays.asList("c1", "c2"),
Arrays.asList(TypeInfoFactory.dateTypeInfo, TypeInfoFactory.decimalTypeInfo)), true},
{TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.intTypeInfo,
TypeInfoFactory.timestampTypeInfo), true},
{TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.doubleTypeInfo,
TypeInfoFactory.getCharTypeInfo(100)), true},
{TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.doubleTypeInfo,
TypeInfoFactory.getVarcharTypeInfo(100)), true},
{TypeInfoFactory.getListTypeInfo(
TypeInfoFactory.getListTypeInfo(TypeInfoFactory.shortTypeInfo)), true},
{TypeInfoFactory.getStructTypeInfo(Arrays.asList("c1", "c2"),
Arrays.asList(TypeInfoFactory.floatTypeInfo, TypeInfoFactory.getUnionTypeInfo(
Arrays.asList(TypeInfoFactory.decimalTypeInfo,
TypeInfoFactory.getListTypeInfo(TypeInfoFactory.shortTypeInfo))))), true},
{TypeInfoFactory.getVarcharTypeInfo(200), true},
};
}
示例4: mapStringStringJava
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
@Test
public void mapStringStringJava() throws UnexpectedTypeException {
TypeInfo typeInfo = TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.stringTypeInfo);
Converter converter = getConverter(typeInfo);
Map<Text, Text> writableMap = new HashMap<>();
writableMap.put(new Text("hello"), new Text("world"));
Map<String, String> javaMap = new HashMap<>();
javaMap.put("hello", "world");
assertThat(converter.toJavaObject(writableMap), is((Object) javaMap));
}
示例5: mapStringStringWritable
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
@Test
public void mapStringStringWritable() throws UnexpectedTypeException {
TypeInfo typeInfo = TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.stringTypeInfo);
Converter converter = getConverter(typeInfo);
Map<Text, Text> writableMap = new HashMap<>();
writableMap.put(new Text("hello"), new Text("world"));
Map<String, String> javaMap = new HashMap<>();
javaMap.put("hello", "world");
assertThat(converter.toWritableObject(javaMap), is((Object) writableMap));
}
示例6: convertMap
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
static TypeInfo convertMap(Schema avroMap) {
Preconditions.checkArgument(
Schema.Type.MAP.equals(avroMap.getType()),
"Avro Schema must be a Map");
return TypeInfoFactory.getMapTypeInfo(
TypeInfoFactory.stringTypeInfo, convert(avroMap.getValueType()));
}
示例7: convertMap
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
public static TypeInfo convertMap(Schema schema) {
return TypeInfoFactory.getMapTypeInfo(
convert(schema.keySchema()), convert(schema.valueSchema()));
}
示例8: getComplexTypeDesc
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; //导入方法依赖的package包/类
private static TypeInfo getComplexTypeDesc(DataType type) {
TypeInfo resultTypeInfo = null;
switch (type.getCategory()) {
case Basic:
resultTypeInfo = ConverterUtils.ORCTYpeInfoMap.get(type.toString());
break;
case Struct:
StructType structObjectType = (StructType) type;
final DataType[] columnTypes = structObjectType.getColumnTypes();
List<TypeInfo> typeInfos = new ArrayList<>();
for (int i = 0; i < columnTypes.length; i++) {
typeInfos.add(getComplexTypeDesc(columnTypes[i]));
}
resultTypeInfo = TypeInfoFactory
.getStructTypeInfo(Arrays.asList(structObjectType.getColumnNames()), typeInfos);;
break;
case List:
ListType listObjectType = (ListType) type;
resultTypeInfo =
TypeInfoFactory.getListTypeInfo(getComplexTypeDesc(listObjectType.getTypeOfElement()));
break;
case Union:
final UnionType unionObjectType = (UnionType) type;
final DataType[] columnTypes1 = unionObjectType.getColumnTypes();
List<TypeInfo> unionTypeInfos = new ArrayList<>();
for (int i = 0; i < columnTypes1.length; i++) {
unionTypeInfos.add(getComplexTypeDesc(columnTypes1[i]));
}
resultTypeInfo = TypeInfoFactory.getUnionTypeInfo(unionTypeInfos);
break;
case Map:
MapType mapObjectType = (MapType) type;
resultTypeInfo =
TypeInfoFactory.getMapTypeInfo(getComplexTypeDesc(mapObjectType.getTypeOfKey()),
getComplexTypeDesc(mapObjectType.getTypeOfValue()));
break;
default:
break;
}
return resultTypeInfo;
}