Package parquet.schema

Examples of parquet.schema.PrimitiveType


        List<Mapping> mappings = computeMapping(descriptor, schema, configuration);
        List<Type> fields = new ArrayList<Type>();
        List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
        for (Mapping mapping : mappings) {
            if (mapping != null) {
                fields.add(new PrimitiveType(
                        Repetition.OPTIONAL,
                        mapping.source.getType(),
                        mapping.source.getPath()[0]));
                properties.add(mapping.target);
            }
View Full Code Here


  }

  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");
View Full Code Here

    }
  }

  private PrimitiveType primitive(String name,
                                  PrimitiveType.PrimitiveTypeName primitive) {
    return new PrimitiveType(Type.Repetition.OPTIONAL, primitive, name, null);
  }
View Full Code Here

  }

  private PrimitiveType primitive(String name,
                                  PrimitiveType.PrimitiveTypeName primitive,
                                  OriginalType originalType) {
    return new PrimitiveType(Type.Repetition.OPTIONAL, primitive, name,
                             originalType);
  }
View Full Code Here

public class ParquetSchemaMerge {
  public static void main(String[] args) {
    MessageType message1;
    MessageType message2;

    PrimitiveType c = new PrimitiveType(Repetition.OPTIONAL, PrimitiveTypeName.INT32, "c");
    GroupType b = new GroupType(Repetition.REQUIRED, "b");
    GroupType a = new GroupType(Repetition.OPTIONAL, "a", b);
    message1 = new MessageType("root", a);

    PrimitiveType c2 = new PrimitiveType(Repetition.OPTIONAL, PrimitiveTypeName.INT32, "d");
    GroupType b2 = new GroupType(Repetition.OPTIONAL, "b", c2);
    GroupType a2 = new GroupType(Repetition.OPTIONAL, "a", b2);
    message2 = new MessageType("root", a2);

    MessageType message3 = message1.union(message2);
View Full Code Here

        // listColumns contains partition columns which are metadata only
        if (fileSchema.containsField(col)) {
          typeListTable.add(fileSchema.getType(col));
        } else {
          // below allows schema evolution
          typeListTable.add(new PrimitiveType(Repetition.OPTIONAL, PrimitiveTypeName.BINARY, col));
        }
      }
      MessageType tableSchema = new MessageType(TABLE_SCHEMA, typeListTable);
      contextMetadata.put(HIVE_SCHEMA_KEY, tableSchema.toString());
View Full Code Here

  }

  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");
View Full Code Here

  }

  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, OriginalType.UTF8);
      } 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)) {
        return new PrimitiveType(repetition, PrimitiveTypeName.INT96, name);
      } else if (typeInfo.equals(TypeInfoFactory.voidTypeInfo)) {
        throw new UnsupportedOperationException("Void type not implemented");
      } else if (typeInfo.getTypeName().toLowerCase().startsWith(
          serdeConstants.CHAR_TYPE_NAME)) {
        return Types.optional(PrimitiveTypeName.BINARY).as(OriginalType.UTF8)
View Full Code Here

          if(index < fileSchema.getFieldCount()) {
            typeListTable.add(fileSchema.getType(index));
          } else {
            //prefixing with '_mask_' to ensure no conflict with named
            //columns in the file schema
            typeListTable.add(new PrimitiveType(Repetition.OPTIONAL, PrimitiveTypeName.BINARY, "_mask_"+listColumns.get(index)));
          }
        }
      } else {
        for (String col : listColumns) {
          col = col.toLowerCase();
          // listColumns contains partition columns which are metadata only
          if (lowerCaseFileSchemaColumns.containsKey(col)) {
            typeListTable.add(fileSchema.getType(lowerCaseFileSchemaColumns.get(col)));
          } else {
            // below allows schema evolution
            typeListTable.add(new PrimitiveType(Repetition.OPTIONAL, PrimitiveTypeName.BINARY, col));
          }
        }
      }
      MessageType tableSchema = new MessageType(TABLE_SCHEMA, typeListTable);
      contextMetadata.put(HIVE_SCHEMA_KEY, tableSchema.toString());
View Full Code Here

  }

  @Override
  void setLevels(int r, int d, String[] fieldPath, int[] fieldIndexPath, List<ColumnIO> repetition, List<ColumnIO> path) {
    super.setLevels(r, d, fieldPath, fieldIndexPath, repetition, path);
    PrimitiveType type = getType().asPrimitiveType();
    this.columnDescriptor = new ColumnDescriptor(
        fieldPath,
        type.getPrimitiveTypeName(),
        type.getTypeLength(),
        getRepetitionLevel(),
        getDefinitionLevel());
    this.path = path.toArray(new ColumnIO[path.size()]);
  }
View Full Code Here

TOP

Related Classes of parquet.schema.PrimitiveType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.