org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category Java Examples
The following examples show how to use
org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: presto Author: prestosql File: OrcFileWriter.java License: Apache License 2.0 | 6 votes |
private static ObjectInspector getJavaObjectInspector(TypeInfo typeInfo) { Category category = typeInfo.getCategory(); if (category == PRIMITIVE) { return getPrimitiveJavaObjectInspector(getPrimitiveTypeInfo(typeInfo.getTypeName())); } if (category == LIST) { ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; return getStandardListObjectInspector(getJavaObjectInspector(listTypeInfo.getListElementTypeInfo())); } if (category == MAP) { MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo; return getStandardMapObjectInspector( getJavaObjectInspector(mapTypeInfo.getMapKeyTypeInfo()), getJavaObjectInspector(mapTypeInfo.getMapValueTypeInfo())); } throw new PrestoException(GENERIC_INTERNAL_ERROR, "Unhandled storage type: " + category); }
Example #2
Source Project: presto Author: prestosql File: HiveCoercionPolicy.java License: Apache License 2.0 | 6 votes |
private boolean canCoerceForStruct(HiveType fromHiveType, HiveType toHiveType) { if (fromHiveType.getCategory() != Category.STRUCT || toHiveType.getCategory() != Category.STRUCT) { return false; } List<String> fromFieldNames = ((StructTypeInfo) fromHiveType.getTypeInfo()).getAllStructFieldNames(); List<String> toFieldNames = ((StructTypeInfo) toHiveType.getTypeInfo()).getAllStructFieldNames(); List<HiveType> fromFieldTypes = extractStructFieldTypes(fromHiveType); List<HiveType> toFieldTypes = extractStructFieldTypes(toHiveType); // Rule: // * Fields may be added or dropped from the end. // * For all other field indices, the corresponding fields must have // the same name, and the type must be coercible. for (int i = 0; i < min(fromFieldTypes.size(), toFieldTypes.size()); i++) { if (!fromFieldNames.get(i).equals(toFieldNames.get(i))) { return false; } if (!fromFieldTypes.get(i).equals(toFieldTypes.get(i)) && !canCoerce(fromFieldTypes.get(i), toFieldTypes.get(i))) { return false; } } return true; }
Example #3
Source Project: dremio-oss Author: dremio File: HiveSchemaConverter.java License: Apache License 2.0 | 6 votes |
private static boolean isTypeNotSupported(InputFormat<?,?> format, Category category, boolean includeParquetComplexTypes) { // No restrictions on primitive types if (category.equals(PRIMITIVE)) { return false; } // Don't support map anywhere. if (category.equals(MAP)) { return true; } // All complex types supported in Orc if (format instanceof OrcInputFormat) { return false; } // Support only list and struct in Parquet along with primitive types. // MapRedParquetInputFormat, VectorizedParquetInputformat if (includeParquetComplexTypes && MapredParquetInputFormat.class.isAssignableFrom(format.getClass()) && PARQUET_SUPPORTED_TYPES.contains(category)) { return false; } return true; }
Example #4
Source Project: dremio-oss Author: dremio File: HiveORCVectorizedReader.java License: Apache License 2.0 | 6 votes |
private ColumnVector getColumnVector(ObjectInspector oi) { Category category = oi.getCategory(); switch (category) { case PRIMITIVE: return getPrimitiveColumnVector((PrimitiveObjectInspector)oi); case LIST: return getListColumnVector((ListObjectInspector)oi); case STRUCT: return getStructColumnVector((StructObjectInspector)oi); case MAP: return getMapColumnVector((MapObjectInspector)oi); case UNION: return getUnionColumnVector((UnionObjectInspector)oi); default: throw UserException.unsupportedError() .message("Vectorized ORC reader is not supported for datatype: %s", category) .build(logger); } }
Example #5
Source Project: dremio-oss Author: dremio File: HiveTestUDFImpls.java License: Apache License 2.0 | 6 votes |
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 1) { throw new UDFArgumentLengthException(String.format("%s needs 1 argument, got %d", udfName, arguments.length)); } if (arguments[0].getCategory() != Category.PRIMITIVE || ((PrimitiveObjectInspector) arguments[0]).getPrimitiveCategory() != inputType) { String actual = arguments[0].getCategory() + (arguments[0].getCategory() == Category.PRIMITIVE ? "[" + ((PrimitiveObjectInspector) arguments[0]).getPrimitiveCategory() + "]" : ""); throw new UDFArgumentException( String.format("%s only takes primitive type %s, got %s", udfName, inputType, actual)); } argumentOI = arguments[0]; return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(outputType); }
Example #6
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_Bin.java License: Apache License 2.0 | 6 votes |
@Override public ObjectInspector initialize(ObjectInspector[] OIs) throws UDFArgumentException { if (OIs.length != 2) { throw new UDFArgumentException("Function takes exactly 2 arguments"); } if (OIs[0].getCategory() != Category.PRIMITIVE) { throw new UDFArgumentException("Argument 0 must be a number - got: " + OIs[0].getCategory()); } oiBinSize = (PrimitiveObjectInspector)OIs[0]; if (!EnumSet.of(PrimitiveCategory.DECIMAL,PrimitiveCategory.DOUBLE,PrimitiveCategory.INT,PrimitiveCategory.LONG,PrimitiveCategory.SHORT, PrimitiveCategory.FLOAT).contains(oiBinSize.getPrimitiveCategory())) { throw new UDFArgumentException("Argument 0 must be a number - got: " + oiBinSize.getPrimitiveCategory()); } geomHelper = HiveGeometryOIHelper.create(OIs[1], 1); binSizeIsConstant = ObjectInspectorUtils.isConstantObjectInspector(OIs[0]); return PrimitiveObjectInspectorFactory.javaLongObjectInspector; }
Example #7
Source Project: dremio-oss Author: dremio File: HiveORCVectorizedReader.java License: Apache License 2.0 | 6 votes |
private ColumnVector getColumnVector(ObjectInspector oi) { Category category = oi.getCategory(); switch (category) { case PRIMITIVE: return getPrimitiveColumnVector((PrimitiveObjectInspector)oi); case LIST: return getListColumnVector((ListObjectInspector)oi); case STRUCT: return getStructColumnVector((StructObjectInspector)oi); case MAP: return getMapColumnVector((MapObjectInspector)oi); case UNION: return getUnionColumnVector((UnionObjectInspector)oi); default: throw UserException.unsupportedError() .message("Vectorized ORC reader is not supported for datatype: %s", category) .build(logger); } }
Example #8
Source Project: hadoop-etl-udfs Author: exasol File: HdfsSerDeImportService.java License: MIT License | 6 votes |
private static Object getJavaObjectFromPrimitiveData(Object data, ObjectInspector objInsp) { assert(objInsp.getCategory() == Category.PRIMITIVE); if (data == null) { return null; } if (data instanceof BytesWritable && objInsp instanceof WritableHiveDecimalObjectInspector) { // BytesWritable cannot be directly cast to HiveDecimalWritable WritableHiveDecimalObjectInspector oi = (WritableHiveDecimalObjectInspector) objInsp; data = oi.create(((BytesWritable) data).getBytes(), oi.scale()); } Object obj = ObjectInspectorUtils.copyToStandardJavaObject(data, objInsp); if (obj instanceof HiveDecimal) { obj = ((HiveDecimal) obj).bigDecimalValue(); } else if (obj instanceof HiveVarchar || obj instanceof HiveChar) { obj = obj.toString(); } else if (obj instanceof byte[]) { obj = Hex.encodeHexString((byte[]) obj); } return obj; }
Example #9
Source Project: hadoop-etl-udfs Author: exasol File: HdfsSerDeImportService.java License: MIT License | 6 votes |
private static Object getJavaObjectFromFieldData(Object data, ObjectInspector objInsp) { if (data == null) { return null; } if (objInsp.getCategory() == Category.PRIMITIVE) { Object obj = ObjectInspectorUtils.copyToStandardJavaObject(data, objInsp); if (obj instanceof HiveDecimal) { obj = ((HiveDecimal) obj).bigDecimalValue(); } else if (obj instanceof HiveVarchar || obj instanceof HiveChar) { obj = obj.toString(); } else if (obj instanceof byte[]) { obj = Hex.encodeHexString((byte[]) obj); } return obj; } else if (objInsp.getCategory() == Category.LIST) { return getJsonArrayFromFieldData(data, objInsp, Json.createBuilderFactory(null)).build().toString(); } else { return getJsonObjectFromFieldData(data, objInsp, Json.createBuilderFactory(null)).build().toString(); } }
Example #10
Source Project: incubator-hivemall Author: apache File: FMPredictGenericUDAF.java License: Apache License 2.0 | 6 votes |
@Override public Evaluator getEvaluator(TypeInfo[] typeInfo) throws SemanticException { if (typeInfo.length != 3) { throw new UDFArgumentLengthException( "Expected argument length is 3 but given argument length was " + typeInfo.length); } if (!HiveUtils.isNumberTypeInfo(typeInfo[0])) { throw new UDFArgumentTypeException(0, "Number type is expected for the first argument Wj: " + typeInfo[0].getTypeName()); } if (typeInfo[1].getCategory() != Category.LIST) { throw new UDFArgumentTypeException(1, "List type is expected for the second argument Vjf: " + typeInfo[1].getTypeName()); } ListTypeInfo typeInfo1 = (ListTypeInfo) typeInfo[1]; if (!HiveUtils.isNumberTypeInfo(typeInfo1.getListElementTypeInfo())) { throw new UDFArgumentTypeException(1, "Number type is expected for the element type of list Vjf: " + typeInfo1.getTypeName()); } if (!HiveUtils.isNumberTypeInfo(typeInfo[2])) { throw new UDFArgumentTypeException(2, "Number type is expected for the third argument Xj: " + typeInfo[2].getTypeName()); } return new Evaluator(); }
Example #11
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_GeomFromJson.java License: Apache License 2.0 | 6 votes |
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { DeferredObject jsonDeferredObject = arguments[0]; String json = null; if (jsonOI.getCategory() == Category.STRUCT){ //StructObjectInspector structOI = (StructObjectInspector)jsonOI; // TODO support structs } else { PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI; json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get()); } try { OGCGeometry ogcGeom = OGCGeometry.fromJson(json); return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom); } catch (Exception e) { } return null; }
Example #12
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
public static boolean isNumberTypeInfo(@Nonnull TypeInfo typeInfo) { if (typeInfo.getCategory() != ObjectInspector.Category.PRIMITIVE) { return false; } switch (((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory()) { case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case DECIMAL: return true; default: return false; } }
Example #13
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_GeomFromGeoJson.java License: Apache License 2.0 | 6 votes |
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { DeferredObject jsonDeferredObject = arguments[0]; String json = null; if (jsonOI.getCategory() == Category.STRUCT){ //StructObjectInspector structOI = (StructObjectInspector)jsonOI; // TODO support structs } else { PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI; json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get()); } try { OGCGeometry ogcGeom = OGCGeometry.fromGeoJson(json); return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom); } catch (Exception e) { LogUtils.Log_InvalidText(LOG, json); } return null; }
Example #14
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nullable public static String[] getConstStringArray(@Nonnull final ObjectInspector oi) throws UDFArgumentException { if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) { throw new UDFArgumentException("argument must be a constant value: " + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); } ConstantObjectInspector constOI = (ConstantObjectInspector) oi; if (constOI.getCategory() != Category.LIST) { throw new UDFArgumentException( "argument must be an array: " + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); } final List<?> lst = (List<?>) constOI.getWritableConstantValue(); if (lst == null) { return null; } final int size = lst.size(); final String[] ary = new String[size]; for (int i = 0; i < size; i++) { Object o = lst.get(i); if (o != null) { ary[i] = o.toString(); } } return ary; }
Example #15
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asIntCompatibleOI(@Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case INT: case SHORT: case LONG: case FLOAT: case DOUBLE: case DECIMAL: case BOOLEAN: case BYTE: case STRING: break; default: throw new UDFArgumentTypeException(0, "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; }
Example #16
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asIntegerOI(@Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case INT: case SHORT: case LONG: case BYTE: break; default: throw new UDFArgumentTypeException(0, "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; }
Example #17
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asIntegerOI(@Nonnull final ObjectInspector[] argOIs, final int argIndex) throws UDFArgumentException { final ObjectInspector argOI = getObjectInspector(argOIs, argIndex); if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(argIndex, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case INT: case SHORT: case LONG: case BYTE: break; default: throw new UDFArgumentTypeException(argIndex, "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; }
Example #18
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asDoubleCompatibleOI( @Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case DECIMAL: case STRING: case TIMESTAMP: break; default: throw new UDFArgumentTypeException(0, "Only numeric or string type arguments are accepted but " + argOI.getTypeName() + " is passed."); } return oi; }
Example #19
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asFloatingPointOI(@Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case FLOAT: case DOUBLE: case DECIMAL: break; default: throw new UDFArgumentTypeException(0, "Only floating point number is accepted but " + argOI.getTypeName() + " is passed."); } return oi; }
Example #20
Source Project: incubator-hivemall Author: apache File: HiveUtils.java License: Apache License 2.0 | 6 votes |
@Nonnull public static PrimitiveObjectInspector asNumberOI(@Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); } final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI; switch (oi.getPrimitiveCategory()) { case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case DECIMAL: break; default: throw new UDFArgumentTypeException(0, "Only numeric argument is accepted but " + argOI.getTypeName() + " is passed."); } return oi; }
Example #21
Source Project: incubator-hivemall Author: apache File: ArgsortUDF.java License: Apache License 2.0 | 6 votes |
@Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length != 1) { throw new UDFArgumentLengthException( "argsort(array<ANY> a) takes exactly 1 argument: " + argOIs.length); } ObjectInspector argOI0 = argOIs[0]; if (argOI0.getCategory() != Category.LIST) { throw new UDFArgumentException( "argsort(array<ANY> a) expects array<ANY> for the first argument: " + argOI0.getTypeName()); } this.listOI = HiveUtils.asListOI(argOI0); this.elemOI = listOI.getListElementObjectInspector(); return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
Example #22
Source Project: incubator-hivemall Author: apache File: ArgrankUDF.java License: Apache License 2.0 | 6 votes |
@Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length != 1) { throw new UDFArgumentLengthException( "argrank(array<ANY> a) takes exactly 1 argument: " + argOIs.length); } ObjectInspector argOI0 = argOIs[0]; if (argOI0.getCategory() != Category.LIST) { throw new UDFArgumentException( "argrank(array<ANY> a) expects array<ANY> for the first argument: " + argOI0.getTypeName()); } this.listOI = HiveUtils.asListOI(argOI0); this.elemOI = listOI.getListElementObjectInspector(); return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
Example #23
Source Project: incubator-hivemall Author: apache File: MapKeyValuesUDF.java License: Apache License 2.0 | 6 votes |
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 1) { throw new UDFArgumentLengthException( "The function MAP_KEYS only accepts one argument."); } else if (!(arguments[0] instanceof MapObjectInspector)) { throw new UDFArgumentTypeException(0, "\"" + Category.MAP.toString().toLowerCase() + "\" is expected at function MAP_KEYS, " + "but \"" + arguments[0].getTypeName() + "\" is found"); } this.mapOI = (MapObjectInspector) arguments[0]; List<String> structFieldNames = new ArrayList<String>(); List<ObjectInspector> structFieldObjectInspectors = new ArrayList<ObjectInspector>(); structFieldNames.add("key"); structFieldObjectInspectors.add(mapOI.getMapKeyObjectInspector()); structFieldNames.add("value"); structFieldObjectInspectors.add(mapOI.getMapValueObjectInspector()); return ObjectInspectorFactory.getStandardListObjectInspector( ObjectInspectorFactory.getStandardStructObjectInspector(structFieldNames, structFieldObjectInspectors)); }
Example #24
Source Project: Hive-Cassandra Author: dvasilen File: TableMapping.java License: Apache License 2.0 | 6 votes |
/** * Serialize a object into bytes. * @param foi object inspector * @param decalred output object inspector * @param obj object to be serialized * @param useJsonSerialize true to use json serialization * @return object in serialized bytes * @throws IOException when error happens */ protected byte[] serializeToBytes(ObjectInspector foi, ObjectInspector doi, Object obj, boolean useJsonSerialize) throws IOException { serializeStream.reset(); boolean isNotNull; if (!foi.getCategory().equals(Category.PRIMITIVE) && useJsonSerialize) { isNotNull = serialize(SerDeUtils.getJSONString(obj, foi), PrimitiveObjectInspectorFactory.javaStringObjectInspector, doi, 1); } else { isNotNull = serialize(obj, foi, doi, 1); } if (!isNotNull) { return null; } byte[] key = new byte[serializeStream.getCount()]; System.arraycopy(serializeStream.getData(), 0, key, 0, serializeStream.getCount()); return key; }
Example #25
Source Project: presto Author: prestosql File: HiveCoercionPolicy.java License: Apache License 2.0 | 5 votes |
private boolean canCoerceForMap(HiveType fromHiveType, HiveType toHiveType) { if (fromHiveType.getCategory() != Category.MAP || toHiveType.getCategory() != Category.MAP) { return false; } HiveType fromKeyType = HiveType.valueOf(((MapTypeInfo) fromHiveType.getTypeInfo()).getMapKeyTypeInfo().getTypeName()); HiveType fromValueType = HiveType.valueOf(((MapTypeInfo) fromHiveType.getTypeInfo()).getMapValueTypeInfo().getTypeName()); HiveType toKeyType = HiveType.valueOf(((MapTypeInfo) toHiveType.getTypeInfo()).getMapKeyTypeInfo().getTypeName()); HiveType toValueType = HiveType.valueOf(((MapTypeInfo) toHiveType.getTypeInfo()).getMapValueTypeInfo().getTypeName()); return (fromKeyType.equals(toKeyType) || canCoerce(fromKeyType, toKeyType)) && (fromValueType.equals(toValueType) || canCoerce(fromValueType, toValueType)); }
Example #26
Source Project: presto Author: prestosql File: HiveCoercionPolicy.java License: Apache License 2.0 | 5 votes |
private boolean canCoerceForList(HiveType fromHiveType, HiveType toHiveType) { if (fromHiveType.getCategory() != Category.LIST || toHiveType.getCategory() != Category.LIST) { return false; } HiveType fromElementType = HiveType.valueOf(((ListTypeInfo) fromHiveType.getTypeInfo()).getListElementTypeInfo().getTypeName()); HiveType toElementType = HiveType.valueOf(((ListTypeInfo) toHiveType.getTypeInfo()).getListElementTypeInfo().getTypeName()); return fromElementType.equals(toElementType) || canCoerce(fromElementType, toElementType); }
Example #27
Source Project: presto Author: prestosql File: TestSerDeUtils.java License: Apache License 2.0 | 5 votes |
private static Block toBinaryBlock(io.prestosql.spi.type.Type type, Object object, ObjectInspector inspector) { if (inspector.getCategory() == Category.PRIMITIVE) { return getPrimitiveBlock(type, object, inspector); } return getBlockObject(type, object, inspector); }
Example #28
Source Project: pxf Author: greenplum-db File: HiveORCVectorizedResolver.java License: Apache License 2.0 | 5 votes |
@Override public List<List<OneField>> getFieldsForBatch(OneRow batch) { VectorizedRowBatch vectorizedBatch = (VectorizedRowBatch) batch.getData(); /* Allocate empty result set */ int columnsNumber = context.getColumns(); resolvedBatch = new ArrayList<>(vectorizedBatch.size); /* Create empty template row */ ArrayList<OneField> templateRow = new ArrayList<OneField>(columnsNumber); ArrayList<OneField> currentRow; for (int j = 0; j < context.getColumns(); j++) { templateRow.add(null); } /* Replicate template row*/ for (int i = 0; i < vectorizedBatch.size; i++) { currentRow = new ArrayList<>(templateRow); resolvedBatch.add(currentRow); } /* process all columns*/ List<? extends StructField> allStructFieldRefs = soi.getAllStructFieldRefs(); for (int columnIndex = 0; columnIndex < vectorizedBatch.numCols; columnIndex++) { ObjectInspector oi = allStructFieldRefs.get(columnIndex).getFieldObjectInspector(); if (oi.getCategory() == Category.PRIMITIVE) { resolvePrimitiveColumn(columnIndex, oi, vectorizedBatch); } else { throw new UnsupportedTypeException("Unable to resolve column index:" + columnIndex + ". Only primitive types are supported."); } } return resolvedBatch; }
Example #29
Source Project: multiple-dimension-spread Author: yahoojapan File: TestMDSMapObjectInspector.java License: Apache License 2.0 | 5 votes |
@Test public void T_getCategory_1(){ MapTypeInfo info = new MapTypeInfo(); info.setMapKeyTypeInfo( TypeInfoFactory.stringTypeInfo ); info.setMapValueTypeInfo( TypeInfoFactory.stringTypeInfo ); MDSMapObjectInspector inspector = new MDSMapObjectInspector( info ); assertEquals( Category.MAP , inspector.getCategory() ); }
Example #30
Source Project: multiple-dimension-spread Author: yahoojapan File: TestMDSListObjectInspector.java License: Apache License 2.0 | 5 votes |
@Test public void T_getCategory_1() throws IOException{ ListTypeInfo info = new ListTypeInfo(); info.setListElementTypeInfo( TypeInfoFactory.stringTypeInfo ); MDSListObjectInspector inspector = new MDSListObjectInspector( info ); assertEquals( Category.LIST , inspector.getCategory() ); }