Exemplo n.º 1
0
  /**
   * It writes the field value to the Parquet RecordConsumer. It detects the field type, and writes
   * the correct write function.
   *
   * @param value The writable object that contains the value.
   * @param type Type that contains information about the type schema.
   */
  private void writeValue(final Writable value, final Type type) {
    if (type.isPrimitive()) {
      writePrimitive(value);
    } else if (value instanceof ArrayWritable) {
      GroupType groupType = type.asGroupType();
      OriginalType originalType = type.getOriginalType();

      if (originalType != null && originalType.equals(OriginalType.LIST)) {
        writeArray((ArrayWritable) value, groupType);
      } else if (originalType != null && originalType.equals(OriginalType.MAP)) {
        writeMap((ArrayWritable) value, groupType);
      } else {
        writeGroup((ArrayWritable) value, groupType);
      }
    } else {
      throw new RuntimeException("Field value is not an ArrayWritable object: " + type);
    }
  }