public java.lang.Object getFieldValue(_Fields field) { switch (field) { case TYPE: return getType(); case TYPE_LENGTH: return getType_length(); case REPETITION_TYPE: return getRepetition_type(); case NAME: return getName(); case NUM_CHILDREN: return getNum_children(); case CONVERTED_TYPE: return getConverted_type(); case SCALE: return getScale(); case PRECISION: return getPrecision(); case FIELD_ID: return getField_id(); case LOGICAL_TYPE: return getLogicalType(); } throw new java.lang.IllegalStateException(); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TYPE: return isSetType(); case TYPE_LENGTH: return isSetType_length(); case REPETITION_TYPE: return isSetRepetition_type(); case NAME: return isSetName(); case NUM_CHILDREN: return isSetNum_children(); case CONVERTED_TYPE: return isSetConverted_type(); case SCALE: return isSetScale(); case PRECISION: return isSetPrecision(); case FIELD_ID: return isSetField_id(); case LOGICAL_TYPE: return isSetLogicalType(); } throw new IllegalStateException(); }
@Override public void visit(GroupType groupType) { SchemaElement element = new SchemaElement(groupType.getName()); element.setRepetition_type(toParquetRepetition(groupType.getRepetition())); if (groupType.getOriginalType() != null) { element.setConverted_type(getConvertedType(groupType.getOriginalType())); } if (groupType.getId() != null) { element.setField_id(groupType.getId().intValue()); } visitChildren(result, groupType, element); }
/** * Performs a deep copy on <i>other</i>. */ public SchemaElement(SchemaElement other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetType()) { this.type = other.type; } this.type_length = other.type_length; if (other.isSetRepetition_type()) { this.repetition_type = other.repetition_type; } if (other.isSetName()) { this.name = other.name; } this.num_children = other.num_children; if (other.isSetConverted_type()) { this.converted_type = other.converted_type; } this.scale = other.scale; this.precision = other.precision; this.field_id = other.field_id; if (other.isSetLogicalType()) { this.logicalType = new LogicalType(other.logicalType); } }
if (element.isSetType_length()) { primitiveBuilder.length(element.type_length); if (element.isSetPrecision()) { primitiveBuilder.precision(element.precision); if (element.isSetScale()) { primitiveBuilder.scale(element.scale); if (element.isSetConverted_type()) { typeBuilder.as(getOriginalType(element.converted_type)); if (element.isSetField_id()) { typeBuilder.id(element.field_id);
@Override public void visit(PrimitiveType primitiveType) { SchemaElement element = new SchemaElement(primitiveType.getName()); element.setRepetition_type(toParquetRepetition(primitiveType.getRepetition())); element.setType(getType(primitiveType.getPrimitiveTypeName())); if (primitiveType.getOriginalType() != null) { element.setConverted_type(getConvertedType(primitiveType.getOriginalType())); } if (primitiveType.getDecimalMetadata() != null) { element.setPrecision(primitiveType.getDecimalMetadata().getPrecision()); element.setScale(primitiveType.getDecimalMetadata().getScale()); } if (primitiveType.getTypeLength() > 0) { element.setType_length(primitiveType.getTypeLength()); } if (primitiveType.getId() != null) { element.setField_id(primitiveType.getId().intValue()); } result.add(element); }
MessageType fromParquetSchema(List<SchemaElement> schema, List<ColumnOrder> columnOrders) { Iterator<SchemaElement> iterator = schema.iterator(); SchemaElement root = iterator.next(); Types.MessageTypeBuilder builder = Types.buildMessage(); if (root.isSetField_id()) { builder.id(root.field_id); } buildChildren(builder, iterator, root.getNum_children(), columnOrders, 0); return builder.named(root.name); }
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, TypeProtos.DataMode mode, SchemaElement schemaElement, OptionManager options) { ConvertedType convertedType = schemaElement.getConverted_type(); MinorType minorType = getMinorType(primitiveTypeName, length, convertedType, options); TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode); if (Types.isDecimalType(minorType)) { int precision = schemaElement.getPrecision(); int scale = schemaElement.getScale(); typeBuilder.setPrecision(precision).setScale(scale); } return typeBuilder.build(); }
/** * Populate full path to SchemaElement map by recursively traversing schema elements referenced by the given iterator * * @param iter file schema values iterator * @param path parent schema element path * @param schemaElements schema elements map to insert next iterator element into */ private static void addSchemaElementMapping(Iterator<SchemaElement> iter, StringBuilder path, Map<String, SchemaElement> schemaElements) { SchemaElement schemaElement = iter.next(); path.append('`').append(schemaElement.getName().toLowerCase()).append('`'); schemaElements.put(path.toString(), schemaElement); // for each element that has children we need to maintain remaining children count // to exit current recursion level when no more children is left int remainingChildren = schemaElement.getNum_children(); while (remainingChildren > 0 && iter.hasNext()) { addSchemaElementMapping(iter, new StringBuilder(path).append('.'), schemaElements); remainingChildren--; } return; }
final boolean readInt96AsTimeStamp) { ConvertedType convertedType = schemaElement.getConverted_type();
for (int _i110 = 0; _i110 < _list108.size; ++_i110) _elem109 = new SchemaElement(); _elem109.read(iprot); struct.schema.add(_elem109);
@Override public void visit(MessageType messageType) { SchemaElement element = new SchemaElement(messageType.getName()); if (messageType.getId() != null) { element.setField_id(messageType.getId().intValue()); } visitChildren(result, messageType.asGroupType(), element); }
final SchemaPath schemaPath = SchemaPath.getSimplePath(se.getName()); if (fields.contains(schemaPath)) { schemaElementMap.put(schemaPath, se); ColumnChunkMetaData metaData = columnChkMetaMap.get(path); TypeProtos.MajorType type = ParquetToDrillTypeConverter.toMajorType(columnDesc.getType(), se.getType_length(), getDataMode(columnDesc), se, options);
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, TypeProtos.DataMode mode, SchemaElement schemaElement, OptionManager options, Field arrowField, final boolean readInt96AsTimeStamp) { MinorType minorType = getMinorType(primitiveTypeName, length, schemaElement, options, arrowField, readInt96AsTimeStamp); TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode); if (CoreDecimalUtility.isDecimalType(minorType)) { typeBuilder.setPrecision(schemaElement.getPrecision()).setScale(schemaElement.getScale()); } return typeBuilder.build(); } }
private static MessageType readParquetSchema(List<SchemaElement> schema) { Iterator<SchemaElement> schemaIterator = schema.iterator(); SchemaElement rootSchema = schemaIterator.next(); Types.MessageTypeBuilder builder = Types.buildMessage(); readTypeSchema(builder, schemaIterator, rootSchema.getNum_children()); return builder.named(rootSchema.name); }
public static Map<String, SchemaElement> getColNameToSchemaElementMapping(ParquetMetadata footer) { HashMap<String, SchemaElement> schemaElements = new HashMap<>(); FileMetaData fileMetaData = new ParquetMetadataConverter().toParquetMetadata(ParquetFileWriter.CURRENT_VERSION, footer); for (SchemaElement se : fileMetaData.getSchema()) { schemaElements.put(se.getName(), se); } return schemaElements; }
public SchemaElement deepCopy() { return new SchemaElement(this); }
if (element.isSetType_length()) { primitiveBuilder.length(element.type_length); if (element.isSetPrecision()) { primitiveBuilder.precision(element.precision); if (element.isSetScale()) { primitiveBuilder.scale(element.scale); if (element.isSetConverted_type()) { typeBuilder.as(getOriginalType(element.converted_type)); if (element.isSetField_id()) { typeBuilder.id(element.field_id);
@Override public void visit(PrimitiveType primitiveType) { SchemaElement element = new SchemaElement(primitiveType.getName()); element.setRepetition_type(toParquetRepetition(primitiveType.getRepetition())); element.setType(getType(primitiveType.getPrimitiveTypeName())); if (primitiveType.getLogicalTypeAnnotation() != null) { element.setConverted_type(convertToConvertedType(primitiveType.getLogicalTypeAnnotation())); element.setLogicalType(convertToLogicalType(primitiveType.getLogicalTypeAnnotation())); } if (primitiveType.getDecimalMetadata() != null) { element.setPrecision(primitiveType.getDecimalMetadata().getPrecision()); element.setScale(primitiveType.getDecimalMetadata().getScale()); } if (primitiveType.getTypeLength() > 0) { element.setType_length(primitiveType.getTypeLength()); } if (primitiveType.getId() != null) { element.setField_id(primitiveType.getId().intValue()); } result.add(element); }