use of org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyObjectInspectorParameters in project hive by apache.
the class LazyObjectInspectorFactory method getLazySimpleStructObjectInspector.
public static LazySimpleStructObjectInspector getLazySimpleStructObjectInspector(List<String> structFieldNames, List<ObjectInspector> structFieldObjectInspectors, List<String> structFieldComments, byte separator, LazyObjectInspectorParameters lazyParams, ObjectInspectorOptions option) {
ArrayList<Object> signature = new ArrayList<Object>();
signature.add(structFieldNames);
signature.add(structFieldObjectInspectors);
signature.add(Byte.valueOf(separator));
signature.add(lazyParams.getNullSequence().toString());
signature.add(Boolean.valueOf(lazyParams.isLastColumnTakesRest()));
LazyObjectInspectorFactory.addCommonLazyParamsToSignature(lazyParams, signature);
signature.add(option);
if (structFieldComments != null) {
signature.add(structFieldComments);
}
LazySimpleStructObjectInspector result = cachedLazySimpleStructObjectInspector.get(signature);
if (result == null) {
switch(option) {
case JAVA:
result = new LazySimpleStructObjectInspector(structFieldNames, structFieldObjectInspectors, structFieldComments, separator, lazyParams);
break;
case AVRO:
result = new AvroLazyObjectInspector(structFieldNames, structFieldObjectInspectors, structFieldComments, separator, lazyParams);
break;
default:
throw new IllegalArgumentException("Illegal ObjectInspector type [" + option + "]");
}
LazySimpleStructObjectInspector prev = cachedLazySimpleStructObjectInspector.putIfAbsent(signature, result);
if (prev != null) {
result = prev;
}
}
return result;
}
use of org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyObjectInspectorParameters in project hive by apache.
the class LazyFactory method createLazyObjectInspector.
/**
* Create a hierarchical ObjectInspector for LazyObject with the given typeInfo.
*
* @param typeInfo The type information for the LazyObject
* @param separator The array of separators for delimiting each level
* @param separatorIndex The current level (for separators). List(array), struct uses 1 level of
* separator, and map uses 2 levels: the first one for delimiting entries, the second one
* for delimiting key and values.
* @param lazyParams Params for lazy types
* @param option the {@link ObjectInspectorOption}
* @return The ObjectInspector
* @throws SerDeException
*/
public static ObjectInspector createLazyObjectInspector(TypeInfo typeInfo, int separatorIndex, LazyObjectInspectorParameters lazyParams, ObjectInspectorOptions option) throws SerDeException {
ObjectInspector.Category c = typeInfo.getCategory();
switch(c) {
case PRIMITIVE:
return LazyPrimitiveObjectInspectorFactory.getLazyObjectInspector((PrimitiveTypeInfo) typeInfo, lazyParams);
case MAP:
return LazyObjectInspectorFactory.getLazySimpleMapObjectInspector(createLazyObjectInspector(((MapTypeInfo) typeInfo).getMapKeyTypeInfo(), separatorIndex + 2, lazyParams, option), createLazyObjectInspector(((MapTypeInfo) typeInfo).getMapValueTypeInfo(), separatorIndex + 2, lazyParams, option), LazyUtils.getSeparator(lazyParams.getSeparators(), separatorIndex), LazyUtils.getSeparator(lazyParams.getSeparators(), separatorIndex + 1), lazyParams);
case LIST:
return LazyObjectInspectorFactory.getLazySimpleListObjectInspector(createLazyObjectInspector(((ListTypeInfo) typeInfo).getListElementTypeInfo(), separatorIndex + 1, lazyParams, option), LazyUtils.getSeparator(lazyParams.getSeparators(), separatorIndex), lazyParams);
case STRUCT:
StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(fieldTypeInfos.size());
for (int i = 0; i < fieldTypeInfos.size(); i++) {
fieldObjectInspectors.add(createLazyObjectInspector(fieldTypeInfos.get(i), separatorIndex + 1, lazyParams, option));
}
return LazyObjectInspectorFactory.getLazySimpleStructObjectInspector(fieldNames, fieldObjectInspectors, null, LazyUtils.getSeparator(lazyParams.getSeparators(), separatorIndex), lazyParams, option);
case UNION:
UnionTypeInfo unionTypeInfo = (UnionTypeInfo) typeInfo;
List<ObjectInspector> lazyOIs = new ArrayList<ObjectInspector>();
for (TypeInfo uti : unionTypeInfo.getAllUnionObjectTypeInfos()) {
lazyOIs.add(createLazyObjectInspector(uti, separatorIndex + 1, lazyParams, option));
}
return LazyObjectInspectorFactory.getLazyUnionObjectInspector(lazyOIs, LazyUtils.getSeparator(lazyParams.getSeparators(), separatorIndex), lazyParams);
}
throw new RuntimeException("Hive LazySerDe Internal error.");
}
use of org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyObjectInspectorParameters in project hive by apache.
the class LazySimpleStructObjectInspector method init.
protected void init(List<String> structFieldNames, List<ObjectInspector> structFieldObjectInspectors, List<String> structFieldComments, byte separator, Text nullSequence, boolean lastColumnTakesRest, boolean escaped, byte escapeChar) {
LazyObjectInspectorParameters lazyParams = new LazyObjectInspectorParametersImpl(escaped, escapeChar, false, null, null, nullSequence, lastColumnTakesRest);
init(structFieldNames, structFieldObjectInspectors, structFieldComments, separator, lazyParams);
}
Aggregations