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 File: HiveUtils.java From incubator-hivemall with 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 #2
Source File: HiveCoercionPolicy.java From presto with 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 File: HiveSchemaConverter.java From dremio-oss with 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 File: ArgsortUDF.java From incubator-hivemall with 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 #5
Source File: ArgrankUDF.java From incubator-hivemall with 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 #6
Source File: HiveUtils.java From incubator-hivemall with 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 #7
Source File: MapKeyValuesUDF.java From incubator-hivemall with 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 #8
Source File: TableMapping.java From Hive-Cassandra with 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 #9
Source File: HiveUtils.java From incubator-hivemall with 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 #10
Source File: HiveUtils.java From incubator-hivemall with 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 #11
Source File: HiveORCVectorizedReader.java From dremio-oss with 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 #12
Source File: HiveUtils.java From incubator-hivemall with 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 #13
Source File: ST_Bin.java From spatial-framework-for-hadoop with 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 #14
Source File: HiveTestUDFImpls.java From dremio-oss with 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 #15
Source File: ST_GeomFromJson.java From spatial-framework-for-hadoop with 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 #16
Source File: OrcFileWriter.java From presto with 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 #17
Source File: ST_GeomFromGeoJson.java From spatial-framework-for-hadoop with 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 #18
Source File: HiveUtils.java From incubator-hivemall with 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 #19
Source File: FMPredictGenericUDAF.java From incubator-hivemall with 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 #20
Source File: HdfsSerDeImportService.java From hadoop-etl-udfs with 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 #21
Source File: HdfsSerDeImportService.java From hadoop-etl-udfs with 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 #22
Source File: HiveUtils.java From incubator-hivemall with 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 #23
Source File: HiveORCVectorizedReader.java From dremio-oss with 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 #24
Source File: HiveUtils.java From incubator-hivemall with 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 #25
Source File: HiveUtils.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static ListTypeInfo asListTypeInfo(@Nonnull TypeInfo typeInfo) throws UDFArgumentException { if (!typeInfo.getCategory().equals(Category.LIST)) { throw new UDFArgumentException("Expected list type: " + typeInfo); } return (ListTypeInfo) typeInfo; }
Example #26
Source File: HiveUtils.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static PrimitiveObjectInspector asPrimitiveObjectInspector( @Nonnull final ObjectInspector[] argOIs, final int argIndex) throws UDFArgumentException { final ObjectInspector oi = getObjectInspector(argOIs, argIndex); if (oi.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentException("Expecting PrimitiveObjectInspector for argOIs[" + argIndex + "] but got " + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); } return (PrimitiveObjectInspector) oi; }
Example #27
Source File: HiveUtils.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nullable public static double[] getConstDoubleArray(@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)); } StandardConstantListObjectInspector listOI = (StandardConstantListObjectInspector) constOI; PrimitiveObjectInspector elemOI = HiveUtils.asDoubleCompatibleOI(listOI.getListElementObjectInspector()); final List<?> lst = listOI.getWritableConstantValue(); if (lst == null) { return null; } final int size = lst.size(); final double[] ary = new double[size]; for (int i = 0; i < size; i++) { Object o = lst.get(i); if (o == null) { ary[i] = Double.NaN; } else { ary[i] = PrimitiveObjectInspectorUtils.getDouble(o, elemOI); } } return ary; }
Example #28
Source File: ParquetHiveSerDe.java From parquet-mr with Apache License 2.0 | 5 votes |
@Override public Writable serialize(final Object obj, final ObjectInspector objInspector) throws SerDeException { if (!objInspector.getCategory().equals(Category.STRUCT)) { throw new SerDeException("Cannot serialize " + objInspector.getCategory() + ". Can only serialize a struct"); } final ArrayWritable serializeData = createStruct(obj, (StructObjectInspector) objInspector); serializedSize = serializeData.get().length; status = LAST_OPERATION.SERIALIZE; return serializeData; }
Example #29
Source File: HiveUtils.java From incubator-hivemall with Apache License 2.0 | 5 votes |
public static boolean isFloatingPointListTypeInfo(@Nonnull TypeInfo typeInfo) { if (typeInfo.getCategory() != Category.LIST) { return false; } TypeInfo elemTypeInfo = ((ListTypeInfo) typeInfo).getListElementTypeInfo(); return isFloatingPointTypeInfo(elemTypeInfo); }
Example #30
Source File: HiveSchemaConverter.java From parquet-mr with Apache License 2.0 | 5 votes |
private static Type convertType(final String name, final TypeInfo typeInfo, final Repetition repetition) { if (typeInfo.getCategory().equals(Category.PRIMITIVE)) { if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.BINARY, name); } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo) || typeInfo.equals(TypeInfoFactory.shortTypeInfo) || typeInfo.equals(TypeInfoFactory.byteTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.INT32, name); } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.INT64, name); } else if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.DOUBLE, name); } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.FLOAT, name); } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) { return new PrimitiveType(repetition, PrimitiveTypeName.BOOLEAN, name); } else if (typeInfo.equals(TypeInfoFactory.binaryTypeInfo)) { // TODO : binaryTypeInfo is a byte array. Need to map it throw new UnsupportedOperationException("Binary type not implemented"); } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) { throw new UnsupportedOperationException("Timestamp type not implemented"); } else if (typeInfo.equals(TypeInfoFactory.voidTypeInfo)) { throw new UnsupportedOperationException("Void type not implemented"); } else if (typeInfo.equals(TypeInfoFactory.unknownTypeInfo)) { throw new UnsupportedOperationException("Unknown type not implemented"); } else { throw new IllegalArgumentException("Unknown type: " + typeInfo); } } else if (typeInfo.getCategory().equals(Category.LIST)) { return convertArrayType(name, (ListTypeInfo) typeInfo); } else if (typeInfo.getCategory().equals(Category.STRUCT)) { return convertStructType(name, (StructTypeInfo) typeInfo); } else if (typeInfo.getCategory().equals(Category.MAP)) { return convertMapType(name, (MapTypeInfo) typeInfo); } else if (typeInfo.getCategory().equals(Category.UNION)) { throw new UnsupportedOperationException("Union type not implemented"); } else { throw new IllegalArgumentException("Unknown type: " + typeInfo); } }