parquet.schema.PrimitiveType Java Examples
The following examples show how to use
parquet.schema.PrimitiveType.
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: ExaParquetWriterImpl.java From hadoop-etl-udfs with MIT License | 6 votes |
static private List<Type> typeInfoToParquetTypes(final List<ExaParquetTypeInfo> exaParquetTypeInfos) { List<Type> types = new ArrayList<>(); for (ExaParquetTypeInfo exaType: exaParquetTypeInfos) { if (exaType.length != 0) { types.add(new PrimitiveType( Type.Repetition.valueOf(exaType.typeRepitition), PrimitiveType.PrimitiveTypeName.valueOf(exaType.primitiveTypeName), exaType.length, exaType.name)); } else { types.add(new PrimitiveType( Type.Repetition.valueOf(exaType.typeRepitition), PrimitiveType.PrimitiveTypeName.valueOf(exaType.primitiveTypeName), exaType.name, exaType.originalType == null ? null : OriginalType.valueOf(exaType.originalType))); } } return types; }
Example #2
Source File: TupleWriter.java From hadoop-etl-udfs with MIT License | 6 votes |
private void writeTuple(Tuple tuple, GroupType type) { for (int index = 0; index < type.getFieldCount(); index++) { Type fieldType = type.getType(index); String fieldName = fieldType.getName(); // empty fields have to be omitted if (tuple.isNull(index)) continue; recordConsumer.startField(fieldName, index); if (fieldType.isPrimitive()) { tuple.writePrimitiveValue(recordConsumer, index, (PrimitiveType)fieldType); } else { recordConsumer.startGroup(); writeTuple(tuple.getTuple(index), fieldType.asGroupType()); recordConsumer.endGroup(); } recordConsumer.endField(fieldName, index); } }
Example #3
Source File: MetadataUtils.java From parquet-tools with Apache License 2.0 | 6 votes |
private static void showDetails(PrettyPrintWriter out, PrimitiveType type, int depth, MessageType container, List<String> cpath) { String name = Strings.repeat(".", depth) + type.getName(); OriginalType otype = type.getOriginalType(); Repetition rep = type.getRepetition(); PrimitiveTypeName ptype = type.getPrimitiveTypeName(); out.format("%s: %s %s", name, rep, ptype); if (otype != null) out.format(" O:%s", otype); if (container != null) { cpath.add(type.getName()); String[] paths = cpath.toArray(new String[cpath.size()]); cpath.remove(cpath.size() - 1); ColumnDescriptor desc = container.getColumnDescription(paths); int defl = desc.getMaxDefinitionLevel(); int repl = desc.getMaxRepetitionLevel(); out.format(" R:%d D:%d", repl, defl); } out.println(); }
Example #4
Source File: MetadataUtils.java From parquet-tools with Apache License 2.0 | 5 votes |
private static void showDetails(PrettyPrintWriter out, Type type, int depth, MessageType container, List<String> cpath) { if (type instanceof GroupType) { showDetails(out, type.asGroupType(), depth, container, cpath); return; } else if (type instanceof PrimitiveType) { showDetails(out, type.asPrimitiveType(), depth, container, cpath); return; } }
Example #5
Source File: JsonElementConversionFactory.java From incubator-gobblin with Apache License 2.0 | 4 votes |
protected Type buildSchema() { return new PrimitiveType(this.repeated ? REPEATED : optionalOrRequired(this.jsonSchema), this.outputType, this.jsonSchema.getColumnName()); }
Example #6
Source File: PentahoParquetWriteSupport.java From pentaho-hadoop-shims with Apache License 2.0 | 4 votes |
private PrimitiveType convertToPrimitiveType( IParquetOutputField f ) { Type.Repetition rep = f.getAllowNull() ? Type.Repetition.OPTIONAL : Type.Repetition.REQUIRED; String formatFieldName = f.getFormatFieldName(); switch ( f.getParquetType() ) { case BINARY: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.BINARY, formatFieldName ); case BOOLEAN: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.BOOLEAN, formatFieldName ); case DOUBLE: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.DOUBLE, formatFieldName ); case FLOAT: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.FLOAT, formatFieldName ); case INT_32: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.INT32, formatFieldName ); case UTF8: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.BINARY, formatFieldName, OriginalType.UTF8 ); case INT_64: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.INT64, formatFieldName, OriginalType.INT_64 ); case INT_96: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.INT96, formatFieldName ); case DATE: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.INT32, formatFieldName, OriginalType.DATE ); case DECIMAL: if ( f.getAllowNull() ) { return Types.optional( PrimitiveType.PrimitiveTypeName.BINARY ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.BINARY ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } case DECIMAL_INT_32: if ( f.getAllowNull() ) { return Types.optional( PrimitiveType.PrimitiveTypeName.INT32 ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.INT32 ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } case DECIMAL_INT_64: if ( f.getAllowNull() ) { return Types.optional( PrimitiveType.PrimitiveTypeName.INT64 ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.INT64 ).as( OriginalType.DECIMAL ) .precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } case TIMESTAMP_MILLIS: return new PrimitiveType( rep, PrimitiveType.PrimitiveTypeName.INT64, formatFieldName, OriginalType.TIMESTAMP_MILLIS ); default: throw new RuntimeException( "Unsupported output type: " + f.getParquetType() ); } }
Example #7
Source File: MetadataUtils.java From parquet-tools with Apache License 2.0 | 4 votes |
public static void showDetails(PrettyPrintWriter out, PrimitiveType type) { showDetails(out, type, 0, null, null); }