Java Code Examples for org.apache.parquet.schema.PrimitiveType#getName()

The following examples show how to use org.apache.parquet.schema.PrimitiveType#getName() . 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: MetadataUtils.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
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[0]);
    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 2
Source File: CompressionConverter.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
private Statistics convertStatistics(String createdBy, PrimitiveType type, org.apache.parquet.format.Statistics pageStatistics,
                                     ColumnIndex columnIndex, int pageIndex, ParquetMetadataConverter converter) throws IOException {
  if (columnIndex != null) {
    if (columnIndex.getNullPages() == null) {
      throw new IOException("columnIndex has null variable 'nullPages' which indicates corrupted data for type: " +  type.getName());
    }
    if (pageIndex > columnIndex.getNullPages().size()) {
      throw new IOException("There are more pages " + pageIndex + " found in the column than in the columnIndex " + columnIndex.getNullPages().size());
    }
    org.apache.parquet.column.statistics.Statistics.Builder statsBuilder = org.apache.parquet.column.statistics.Statistics.getBuilderForReading(type);
    statsBuilder.withNumNulls(columnIndex.getNullCounts().get(pageIndex));

    if (!columnIndex.getNullPages().get(pageIndex)) {
      statsBuilder.withMin(columnIndex.getMinValues().get(pageIndex).array().clone());
      statsBuilder.withMax(columnIndex.getMaxValues().get(pageIndex).array().clone());
    }
    return statsBuilder.build();
  } else if (pageStatistics != null) {
    return converter.fromParquetStatistics(createdBy, pageStatistics, type);
  } else {
    return null;
  }
}
 
Example 3
Source File: MetadataUtils.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
private static void showDetails(PrettyPrintWriter out, PrimitiveType type, int depth, MessageType container, List<String> cpath, boolean showOriginalTypes) {
  String name = Strings.repeat(".", depth) + type.getName();
  Repetition rep = type.getRepetition();
  PrimitiveTypeName ptype = type.getPrimitiveTypeName();

  out.format("%s: %s %s", name, rep, ptype);
  if (showOriginalTypes) {
    OriginalType otype;
    try {
      otype = type.getOriginalType();
    } catch (Exception e) {
      otype = null;
    }
    if (otype != null) out.format(" O:%s", otype);
  } else {
    LogicalTypeAnnotation ltype = type.getLogicalTypeAnnotation();
    if (ltype != null) out.format(" L:%s", ltype);
  }

  if (container != null) {
    cpath.add(type.getName());
    String[] paths = cpath.toArray(new String[0]);
    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: TupleWriteSupport.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
private void writePrimitive(TupleEntry record, PrimitiveType field) {
  switch (field.getPrimitiveTypeName()) {
    case BINARY:
      recordConsumer.addBinary(Binary.fromString(record.getString(field.getName())));
      break;
    case BOOLEAN:
      recordConsumer.addBoolean(record.getBoolean(field.getName()));
      break;
    case INT32:
      recordConsumer.addInteger(record.getInteger(field.getName()));
      break;
    case INT64:
      recordConsumer.addLong(record.getLong(field.getName()));
      break;
    case DOUBLE:
      recordConsumer.addDouble(record.getDouble(field.getName()));
      break;
    case FLOAT:
      recordConsumer.addFloat(record.getFloat(field.getName()));
      break;
    case FIXED_LEN_BYTE_ARRAY:
      throw new UnsupportedOperationException("Fixed len byte array type not implemented");
    case INT96:
      throw new UnsupportedOperationException("Int96 type not implemented");
    default:
      throw new UnsupportedOperationException(field.getName() + " type not implemented");
  }
}