• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GroupType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.parquet.schema.GroupType的典型用法代码示例。如果您正苦于以下问题:Java GroupType类的具体用法?Java GroupType怎么用?Java GroupType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GroupType类属于org.apache.parquet.schema包,在下文中一共展示了GroupType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ParquetGroupConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
ParquetGroupConverter(
    OutputMutator mutator,
    GroupType schema,
    Collection<SchemaPath> columns,
    OptionManager options,
    List<Field> arrowSchema,
    Function<String, String> childNameResolver,
    ParquetReaderUtility.DateCorruptionStatus containsCorruptedDates,
    boolean readInt96AsTimeStamp) {
  this.converters = Lists.newArrayList();
  this.mutator = mutator;
  this.schema = schema;
  this.columns = columns;
  this.options = options;
  this.containsCorruptedDates = containsCorruptedDates;
  this.arrowSchema = arrowSchema;
  this.childNameResolver = childNameResolver;
  this.readInt96AsTimeStamp = readInt96AsTimeStamp;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:ParquetGroupConverter.java


示例2: groupConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private Converter groupConverter(OutputMutator mutator,
    List<Field> arrowSchema, GroupType groupType, PathSegment colNextChild, final String nameForChild) {
  Collection<SchemaPath> c = new ArrayList<>();

  while (colNextChild != null) {
    if (colNextChild.isNamed()) {
      break;
    }
    colNextChild = colNextChild.getChild();
  }

  if (colNextChild != null) {
    SchemaPath s = new SchemaPath(colNextChild.getNameSegment());
    c.add(s);
  }

  if (arrowSchema != null) {
    return groupConverterFromArrowSchema(nameForChild, groupType.getName(), groupType, c);
  }

  return defaultGroupConverter(mutator, groupType, nameForChild, c, null);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:ParquetGroupConverter.java


示例3: renameChildTypeToElement

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
/**
 * Changes the list inner '$data$' vector name to 'element' in the schema
 */
private Type renameChildTypeToElement(Type childType) {
  if (childType.isPrimitive()) {
    PrimitiveType childPrimitiveType = childType.asPrimitiveType();
    return new PrimitiveType(childType.getRepetition(),
      childPrimitiveType.getPrimitiveTypeName(),
      childPrimitiveType.getTypeLength(),
      "element",
      childPrimitiveType.getOriginalType(),
      childPrimitiveType.getDecimalMetadata(),
      null);
  } else {
    GroupType childGroupType = childType.asGroupType();
    return new GroupType(childType.getRepetition(),
      "element",
      childType.getOriginalType(),
      childGroupType.getFields());
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:ParquetRecordWriter.java


示例4: ParquetValueConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
public ParquetValueConverter(GroupType schema, ParentContainerUpdater updater)
{
    super(updater);

    ArrayList<String> fieldNames = new ArrayList<>();
    for (Type type : schema.getFields()) {
        fieldNames.add(type.getName());
    }
    this.currentMap = new InternalMap(fieldNames);

    this.fieldConverters = new Converter[schema.getFieldCount()];
    int i = 0;
    for (Type field : schema.getFields()) {
        InternalMapUpdater update = new InternalMapUpdater(currentMap, i);
        fieldConverters[i++] = newFieldConverter(field, update);
    }
}
 
开发者ID:CyberAgent,项目名称:embulk-input-parquet_hadoop,代码行数:18,代码来源:ParquetValueConverter.java


示例5: ParquetArrayConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private ParquetArrayConverter(GroupType schema, ParentContainerUpdater updater)
{
    super(updater);

    Type repeatedType = schema.getType(0);
    if (isElementType(repeatedType, schema.getName())) {
        // If the repeated field corresponds to the element type, creates a new converter using the
        // type of the repeated field.
        elementConverter = newConverter(repeatedType, new ParentContainerUpdater.Noop() {
            @Override
            public void set(Value value)
            {
                ParquetArrayConverter.this.currentArray.add(value);
            }
        });
    }
    else {
        // If the repeated field corresponds to the syntactic group in the standard 3-level Parquet
        // LIST layout, creates a new converter using the only child field of the repeated field.
        elementConverter = new ElementConverter(repeatedType.asGroupType().getType(0));
    }
}
 
开发者ID:CyberAgent,项目名称:embulk-input-parquet_hadoop,代码行数:23,代码来源:ParquetValueConverter.java


示例6: getColTypeInfo

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private ColTypeInfo getColTypeInfo(MessageType schema, Type type, String[] path, int depth) {
  if (type.isPrimitive()) {
    PrimitiveType primitiveType = (PrimitiveType) type;
    int precision = 0;
    int scale = 0;
    if (primitiveType.getDecimalMetadata() != null) {
      precision = primitiveType.getDecimalMetadata().getPrecision();
      scale = primitiveType.getDecimalMetadata().getScale();
    }

    int repetitionLevel = schema.getMaxRepetitionLevel(path);
    int definitionLevel = schema.getMaxDefinitionLevel(path);

    return new ColTypeInfo(type.getOriginalType(), precision, scale, repetitionLevel, definitionLevel);
  }
  Type t = ((GroupType) type).getType(path[depth]);
  return getColTypeInfo(schema, t, path, depth + 1);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:Metadata.java


示例7: getType

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private Type getType(MaterializedField field) {
  MinorType minorType = field.getType().getMinorType();
  DataMode dataMode = field.getType().getMode();
  switch(minorType) {
    case MAP:
      List<Type> types = Lists.newArrayList();
      for (MaterializedField childField : field.getChildren()) {
        types.add(getType(childField));
      }
      return new GroupType(dataMode == DataMode.REPEATED ? Repetition.REPEATED : Repetition.OPTIONAL, field.getName(), types);
    case LIST:
      throw new UnsupportedOperationException("Unsupported type " + minorType);
    default:
      return getPrimitiveType(field);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:17,代码来源:ParquetRecordWriter.java


示例8: buildFieldToConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private Map<Integer, Converter> buildFieldToConverter(final GroupType schema) {
    final Map<Integer, Converter> fieldToConverter = new HashMap<>(fieldCount);
    int i = 0;
    for (final Type field : schema.getFields()) {
        final String[] newColumnPath = new String[columnPath.length + 1];
        int j = 0;
        for (final String part : columnPath) {
            newColumnPath[j] = part;
            j++;
        }
        newColumnPath[j] = field.getName();
        if (field.isPrimitive()) {
            fieldToConverter.put(i, new PrimitiveConverter(parquetColumnToObject, field.asPrimitiveType().getPrimitiveTypeName().javaType.getSimpleName(), newColumnPath, field.getOriginalType()));
        } else {
            fieldToConverter.put(i, new BypassGroupConverter(parquetColumnToObject, field.asGroupType(), newColumnPath));
        }
        i++;
    }
    return fieldToConverter;
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:21,代码来源:BypassGroupConverter.java


示例9: writeRecordFields

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private void writeRecordFields(GroupType schema, Schema tajoSchema,
                               Tuple tuple) {
  List<Type> fields = schema.getFields();
  // Parquet ignores Tajo NULL_TYPE columns, so the index may differ.
  int index = 0;
  for (int tajoIndex = 0; tajoIndex < tajoSchema.size(); ++tajoIndex) {
    Column column = tajoSchema.getColumn(tajoIndex);
    if (column.getDataType().getType() == TajoDataTypes.Type.NULL_TYPE) {
      continue;
    }
    Type fieldType = fields.get(index);
    if (!tuple.isBlankOrNull(tajoIndex)) {
      recordConsumer.startField(fieldType.getName(), index);
      writeValue(column, tuple, tajoIndex);
      recordConsumer.endField(fieldType.getName(), index);
    } else if (fieldType.isRepetition(Type.Repetition.REQUIRED)) {
      throw new RuntimeException("Null-value for required field: " +
          column.getSimpleName());
    }
    ++index;
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:23,代码来源:TajoWriteSupport.java


示例10: writeGroup

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private void writeGroup(Group group, GroupType type) {
  int fieldCount = type.getFieldCount();
  for (int field = 0; field < fieldCount; ++field) {
    int valueCount = group.getFieldRepetitionCount(field);
    if (valueCount > 0) {
      Type fieldType = type.getType(field);
      String fieldName = fieldType.getName();
      recordConsumer.startField(fieldName, field);
      for (int index = 0; index < valueCount; ++index) {
        if (fieldType.isPrimitive()) {
          group.writeValue(field, index, recordConsumer);
        } else {
          recordConsumer.startGroup();
          writeGroup(group.getGroup(field, index), fieldType.asGroupType());
          recordConsumer.endGroup();
        }
      }
      recordConsumer.endField(fieldName, field);
    }
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:22,代码来源:GroupWriter.java


示例11: SimpleGroupConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
SimpleGroupConverter(SimpleGroupConverter parent, int index, GroupType schema) {
  this.parent = parent;
  this.index = index;

  converters = new Converter[schema.getFieldCount()];

  for (int i = 0; i < converters.length; i++) {
    final Type type = schema.getType(i);
    if (type.isPrimitive()) {
      converters[i] = new SimplePrimitiveConverter(this, i);
    } else {
      converters[i] = new SimpleGroupConverter(this, i, type.asGroupType());
    }

  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:17,代码来源:SimpleGroupConverter.java


示例12: visitChildren

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private void visitChildren(GroupColumnIO newIO, GroupType groupType, GroupType requestedGroupType) {
  GroupColumnIO oldIO = current;
  current = newIO;
  for (Type type : groupType.getFields()) {
    // if the file schema does not contain the field it will just stay null
    if (requestedGroupType.containsField(type.getName())) {
      currentRequestedIndex = requestedGroupType.getFieldIndex(type.getName());
      currentRequestedType = requestedGroupType.getType(currentRequestedIndex);
      if (currentRequestedType.getRepetition().isMoreRestrictiveThan(type.getRepetition())) {
        incompatibleSchema(type, currentRequestedType);
      }
      type.accept(this);
    }
  }
  current = oldIO;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:17,代码来源:ColumnIOFactory.java


示例13: testBadWriteSchema

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
@Test
public void testBadWriteSchema() throws IOException {
  final File file = temp.newFile("test.parquet");
  file.delete();

  TestUtils.assertThrows("Should reject a schema with an empty group",
      InvalidSchemaException.class, new Callable<Void>() {
        @Override
        public Void call() throws IOException {
          ExampleParquetWriter.builder(new Path(file.toString()))
              .withType(Types.buildMessage()
                  .addField(new GroupType(REQUIRED, "invalid_group"))
                  .named("invalid_message"))
              .build();
          return null;
        }
      });

  Assert.assertFalse("Should not create a file when schema is rejected",
      file.exists());
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:22,代码来源:TestParquetWriter.java


示例14: ElementConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
public ElementConverter(String listName, List<TProtocol> listEvents,
                        GroupType repeatedType, ThriftField thriftElement) {
  this.listEvents = listEvents;
  this.elementEvents = new ArrayList<TProtocol>();
  Type elementType = repeatedType.getType(0);
  if (elementType.isRepetition(Type.Repetition.OPTIONAL)) {
    if (ignoreNullElements) {
      LOG.warn("List " + listName +
          " has optional elements: null elements are ignored.");
    } else {
      throw new ParquetDecodingException("Cannot read list " + listName +
          " with optional elements: set " + IGNORE_NULL_LIST_ELEMENTS +
          " to ignore nulls.");
    }
  }
  elementConverter = newConverter(elementEvents, elementType, thriftElement);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:18,代码来源:ThriftRecordConverter.java


示例15: hasMissingRequiredFieldInGroupType

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private boolean hasMissingRequiredFieldInGroupType(GroupType requested, GroupType fullSchema) {
  for (Type field : fullSchema.getFields()) {

    if (requested.containsField(field.getName())) {
      Type requestedType = requested.getType(field.getName());
      // if a field is in requested schema and the type of it is a group type, then do recursive check
      if (!field.isPrimitive()) {
        if (hasMissingRequiredFieldInGroupType(requestedType.asGroupType(), field.asGroupType())) {
          return true;
        } else {
          continue;// check next field
        }
      }
    } else {
      if (field.getRepetition() == Type.Repetition.REQUIRED) {
        return true; // if a field is missing in requested schema and it's required
      } else {
        continue; // the missing field is not required, then continue checking next field
      }
    }
  }

  return false;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:25,代码来源:ThriftRecordConverter.java


示例16: DataWritableGroupConverter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
public DataWritableGroupConverter(final GroupType selectedGroupType,
    final HiveGroupConverter parent, final int index, final GroupType containingGroupType) {
  this.parent = parent;
  this.index = index;
  final int totalFieldCount = containingGroupType.getFieldCount();
  final int selectedFieldCount = selectedGroupType.getFieldCount();

  currentArr = new Object[totalFieldCount];
  converters = new Converter[selectedFieldCount];

  List<Type> selectedFields = selectedGroupType.getFields();
  for (int i = 0; i < selectedFieldCount; i++) {
    Type subtype = selectedFields.get(i);
    if (containingGroupType.getFields().contains(subtype)) {
      converters[i] = getConverterFromDescription(subtype,
          containingGroupType.getFieldIndex(subtype.getName()), this);
    } else {
      throw new IllegalStateException("Group type [" + containingGroupType +
          "] does not contain requested field: " + subtype);
    }
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:23,代码来源:DataWritableGroupConverter.java


示例17: MessageWriter

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
MessageWriter(Descriptors.Descriptor descriptor, GroupType schema) {
  List<Descriptors.FieldDescriptor> fields = descriptor.getFields();
  fieldWriters = (FieldWriter[]) Array.newInstance(FieldWriter.class, fields.size());

  for (Descriptors.FieldDescriptor fieldDescriptor: fields) {
    String name = fieldDescriptor.getName();
    Type type = schema.getType(name);
    FieldWriter writer = createWriter(fieldDescriptor, type);

    if(fieldDescriptor.isRepeated()) {
     writer = new ArrayWriter(writer);
    }

    writer.setFieldName(name);
    writer.setIndex(schema.getFieldIndex(name));

    fieldWriters[fieldDescriptor.getIndex()] = writer;
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:21,代码来源:ProtoWriteSupport.java


示例18: convertMap

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
/**
 *
 * @param alias
 * @param fieldSchema
 * @return an optional group containing one repeated group field (key, value)
 * @throws FrontendException
 */
private GroupType convertMap(String alias, FieldSchema fieldSchema) {
  Schema innerSchema = fieldSchema.schema;
  if (innerSchema == null || innerSchema.size() != 1) {
    throw new SchemaConversionException("Invalid map Schema, schema should contain exactly one field: " + fieldSchema);
  }
  FieldSchema innerField = null;
  try {
    innerField = innerSchema.getField(0);
  } catch (FrontendException fe) {
    throw new SchemaConversionException("Invalid map schema, cannot infer innerschema: ", fe);
  }
  Type convertedValue = convertWithName(innerField, "value");
  return ConversionPatterns.stringKeyMapType(Repetition.OPTIONAL, alias, name(innerField.alias, "map"),
      convertedValue);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:23,代码来源:PigSchemaConverter.java


示例19: testListsOfPrimitive

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
@Test
public void testListsOfPrimitive() throws Exception {
  for (Type.Repetition repetition : Type.Repetition.values()) {
    for (Type.Repetition valueRepetition : Type.Repetition.values()) {
      for (PrimitiveType.PrimitiveTypeName primitiveTypeName : PrimitiveType.PrimitiveTypeName.values()) {
        if (primitiveTypeName != PrimitiveType.PrimitiveTypeName.INT96) { // INT96 is NYI
          Types.PrimitiveBuilder<PrimitiveType> value = Types.primitive(primitiveTypeName, valueRepetition);
          if (primitiveTypeName == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY)
            value.length(1);
          GroupType type = Types.buildGroup(repetition).addField(value.named("b")).as(OriginalType.LIST).named("a");
          pigSchemaConverter.convertField(type); // no exceptions, please
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:17,代码来源:TestPigSchemaConverter.java


示例20: writeRecordFields

import org.apache.parquet.schema.GroupType; //导入依赖的package包/类
private void writeRecordFields(GroupType schema, Schema avroSchema,
                               Object record) {
  List<Type> fields = schema.getFields();
  List<Schema.Field> avroFields = avroSchema.getFields();
  int index = 0; // parquet ignores Avro nulls, so index may differ
  for (int avroIndex = 0; avroIndex < avroFields.size(); avroIndex++) {
    Schema.Field avroField = avroFields.get(avroIndex);
    if (avroField.schema().getType().equals(Schema.Type.NULL)) {
      continue;
    }
    Type fieldType = fields.get(index);
    Object value = model.getField(record, avroField.name(), avroIndex);
    if (value != null) {
      recordConsumer.startField(fieldType.getName(), index);
      writeValue(fieldType, avroField.schema(), value);
      recordConsumer.endField(fieldType.getName(), index);
    } else if (fieldType.isRepetition(Type.Repetition.REQUIRED)) {
      throw new RuntimeException("Null-value for required field: " + avroField.name());
    }
    index++;
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:23,代码来源:AvroWriteSupport.java



注:本文中的org.apache.parquet.schema.GroupType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProtocolSignature类代码示例发布时间:2022-05-22
下一篇:
Java WinProcess类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap