Java Code Examples for org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName#INT32
The following examples show how to use
org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName#INT32 .
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: ParquetRecordWriter.java From Bats with Apache License 2.0 | 6 votes |
protected PrimitiveType getPrimitiveType(MaterializedField field) { MinorType minorType = field.getType().getMinorType(); String name = field.getName(); int length = ParquetTypeHelper.getLengthForMinorType(minorType); PrimitiveTypeName primitiveTypeName = ParquetTypeHelper.getPrimitiveTypeNameForMinorType(minorType); if (Types.isDecimalType(minorType)) { primitiveTypeName = logicalTypeForDecimals; if (usePrimitiveTypesForDecimals) { if (field.getPrecision() <= ParquetTypeHelper.getMaxPrecisionForPrimitiveType(PrimitiveTypeName.INT32)) { primitiveTypeName = PrimitiveTypeName.INT32; } else if (field.getPrecision() <= ParquetTypeHelper.getMaxPrecisionForPrimitiveType(PrimitiveTypeName.INT64)) { primitiveTypeName = PrimitiveTypeName.INT64; } } length = DecimalUtility.getMaxBytesSizeForPrecision(field.getPrecision()); } Repetition repetition = ParquetTypeHelper.getRepetitionForDataMode(field.getDataMode()); OriginalType originalType = ParquetTypeHelper.getOriginalTypeForMinorType(minorType); DecimalMetadata decimalMetadata = ParquetTypeHelper.getDecimalMetadataForField(field); return new PrimitiveType(repetition, primitiveTypeName, length, name, originalType, decimalMetadata, null); }
Example 2
Source File: MetadataReader.java From presto with Apache License 2.0 | 6 votes |
private static PrimitiveTypeName getTypeName(Type type) { switch (type) { case BYTE_ARRAY: return PrimitiveTypeName.BINARY; case INT64: return PrimitiveTypeName.INT64; case INT32: return PrimitiveTypeName.INT32; case BOOLEAN: return PrimitiveTypeName.BOOLEAN; case FLOAT: return PrimitiveTypeName.FLOAT; case DOUBLE: return PrimitiveTypeName.DOUBLE; case INT96: return PrimitiveTypeName.INT96; case FIXED_LEN_BYTE_ARRAY: return PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY; default: throw new IllegalArgumentException("Unknown type " + type); } }
Example 3
Source File: ParquetMetadataConverter.java From parquet-mr with Apache License 2.0 | 6 votes |
public PrimitiveTypeName getPrimitive(Type type) { switch (type) { case BYTE_ARRAY: // TODO: rename BINARY and remove this switch return PrimitiveTypeName.BINARY; case INT64: return PrimitiveTypeName.INT64; case INT32: return PrimitiveTypeName.INT32; case BOOLEAN: return PrimitiveTypeName.BOOLEAN; case FLOAT: return PrimitiveTypeName.FLOAT; case DOUBLE: return PrimitiveTypeName.DOUBLE; case INT96: return PrimitiveTypeName.INT96; case FIXED_LEN_BYTE_ARRAY: return PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY; default: throw new RuntimeException("Unknown type " + type); } }
Example 4
Source File: TestParquetMetadataConverter.java From parquet-mr with Apache License 2.0 | 5 votes |
private static ParquetMetadata createParquetMetaData(Encoding dicEncoding, Encoding dataEncoding) { MessageType schema = parseMessageType("message schema { optional int32 col (INT_32); }"); org.apache.parquet.hadoop.metadata.FileMetaData fileMetaData = new org.apache.parquet.hadoop.metadata.FileMetaData(schema, new HashMap<String, String>(), null); List<BlockMetaData> blockMetaDataList = new ArrayList<BlockMetaData>(); BlockMetaData blockMetaData = new BlockMetaData(); EncodingStats.Builder builder = new EncodingStats.Builder(); if (dicEncoding!= null) { builder.addDictEncoding(dicEncoding).build(); } builder.addDataEncoding(dataEncoding); EncodingStats es = builder.build(); Set<org.apache.parquet.column.Encoding> e = new HashSet<org.apache.parquet.column.Encoding>(); PrimitiveTypeName t = PrimitiveTypeName.INT32; ColumnPath p = ColumnPath.get("col"); CompressionCodecName c = CompressionCodecName.UNCOMPRESSED; BinaryStatistics s = new BinaryStatistics(); ColumnChunkMetaData md = ColumnChunkMetaData.get(p, t, c, es, e, s, 20, 30, 0, 0, 0); blockMetaData.addColumn(md); blockMetaDataList.add(blockMetaData); return new ParquetMetadata(fileMetaData, blockMetaDataList); }
Example 5
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); } }