当前位置: 首页>>代码示例>>Java>>正文


Java Type.getName方法代码示例

本文整理汇总了Java中org.apache.parquet.schema.Type.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getName方法的具体用法?Java Type.getName怎么用?Java Type.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.parquet.schema.Type的用法示例。


在下文中一共展示了Type.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeObject

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private void writeObject(final Type type, final Object object, final int index) throws SerialisationException {
    if (null != object) {
        final String fieldName = type.getName();
        if (type.isPrimitive()) {
            recordConsumer.startField(fieldName, index);
            if (object instanceof Object[]) {
                for (final Object innerObject : (Object[]) object) {
                    writePrimitive(innerObject);
                }
            } else {
                writePrimitive(object);
            }
            recordConsumer.endField(fieldName, index);
        } else {
            final String originalType = type.getOriginalType().name();
            if ("MAP".equals(originalType)) {
                writeMap(fieldName, index, (Map<Object, Object>) object, type);
            } else if ("LIST".equals(originalType)) {
                writeList(fieldName, index, object, type);
            } else {
                throw new SerialisationException("Could not write object " + object.toString() + " with type " + type.toString());
            }
        }
    }
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:26,代码来源:ElementWriter.java

示例2: buildFieldToConverter

import org.apache.parquet.schema.Type; //导入方法依赖的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

示例3: writeGroup

import org.apache.parquet.schema.Type; //导入方法依赖的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

示例4: toString

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
public String toString(String indent) {
  String result = "";
  int i = 0;
  for (Type field : schema.getFields()) {
    String name = field.getName();
    List<Object> values = data[i];
    ++i;
    if (values != null) {
      if (values.size() > 0) {
        for (Object value : values) {
          result += indent + name;
          if (value == null) {
            result += ": NULL\n";
          } else if (value instanceof Group) {
            result += "\n" + ((SimpleGroup)value).toString(indent+"  ");
          } else {
            result += ": " + value.toString() + "\n";
          }
        }
      }
    }
  }
  return result;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:25,代码来源:SimpleGroup.java

示例5: SchemaIntersection

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
public SchemaIntersection(MessageType fileSchema, Fields requestedFields) {
  if(requestedFields == Fields.UNKNOWN)
    requestedFields = Fields.ALL;

  Fields newFields = Fields.NONE;
  List<Type> newSchemaFields = new ArrayList<Type>();
  int schemaSize = fileSchema.getFieldCount();

  for (int i = 0; i < schemaSize; i++) {
    Type type = fileSchema.getType(i);
    Fields name = new Fields(type.getName());

    if(requestedFields.contains(name)) {
      newFields = newFields.append(name);
      newSchemaFields.add(type);
    }
  }

  this.sourceFields = newFields;
  this.requestedSchema = new MessageType(fileSchema.getName(), newSchemaFields);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:22,代码来源:SchemaIntersection.java

示例6: addChildConverter

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
protected void addChildConverter(OutputMutator mutator,
    List<Field> arrowSchema, Iterator<SchemaPath> colIterator, Type type, Function<String, String> childNameResolver) {
  // Match the name of the field in the schema definition to the name of the field in the query.
  String name = null;
  SchemaPath col;
  PathSegment colPath;
  PathSegment colNextChild = null;
  while (colIterator.hasNext()) {
    col = colIterator.next();
    colPath = col.getRootSegment();
    colNextChild = colPath.getChild();

    if (colPath.isNamed() && (!colPath.getNameSegment().getPath().equals("*"))) {
      name = colPath.getNameSegment().getPath();
      // We may have a field that does not exist in the schema
      if (!name.equalsIgnoreCase(type.getName())) {
        continue;
      }
    }
    break;
  }
  if (name == null) {
    name = type.getName();
  }

  final String nameForChild = childNameResolver.apply(name);
  final Converter converter = type.isPrimitive() ?
    getConverterForType(nameForChild, type.asPrimitiveType())
    : groupConverter(mutator, arrowSchema, type.asGroupType(), colNextChild, nameForChild);
  converters.add(converter);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:ParquetGroupConverter.java

示例7: getType

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private static Type getType(String[] pathSegments, int depth, MessageType schema) {
  Type type = schema.getType(Arrays.copyOfRange(pathSegments, 0, depth + 1));
  if (depth + 1 == pathSegments.length) {
    return type;
  } else {
    Preconditions.checkState(!type.isPrimitive());
    return new GroupType(type.getRepetition(), type.getName(), type.getOriginalType(), getType(pathSegments, depth + 1, schema));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:ParquetRowiseReader.java

示例8: getType

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private static Type getType(String[] pathSegments, int depth, MessageType schema) {
  Type type = schema.getType(Arrays.copyOfRange(pathSegments, 0, depth + 1));
  if (depth + 1 == pathSegments.length) {
    return type;
  } else {
    Preconditions.checkState(!type.isPrimitive());
    return new GroupType(type.getRepetition(), type.getName(), getType(pathSegments, depth + 1, schema));
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:10,代码来源:DrillParquetReader.java

示例9: createConverter

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private Converter createConverter(Type field) {
  OriginalType otype = field.getOriginalType();

  if (field.isPrimitive()) {
    if (otype != null) {
      switch (otype) {
        case MAP: break;
        case LIST: break;
        case UTF8: return new StringConverter(field.getName());
        case MAP_KEY_VALUE: break;
        case ENUM: break;
        case DECIMAL:
          int scale = field.asPrimitiveType().getDecimalMetadata().getScale();
          return new DecimalConverter(field.getName(), scale);
      }
    }

    return new SimplePrimitiveConverter(field.getName());
  }

  GroupType groupType = field.asGroupType();
  if (otype != null) {
    switch (otype) {
      case MAP: return new SimpleMapRecordConverter(groupType, field.getName(), this);
      case LIST: return new SimpleListRecordConverter(groupType, field.getName(), this);
    }
  }
  return new SimpleRecordConverter(groupType, field.getName(), this);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:30,代码来源:SimpleRecordConverter.java

示例10: add

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private void add(int fieldIndex, Primitive value) {
  Type type = schema.getType(fieldIndex);
  List<Object> list = data[fieldIndex];
  if (!type.isRepetition(Type.Repetition.REPEATED)
      && !list.isEmpty()) {
    throw new IllegalStateException("field "+fieldIndex+" (" + type.getName() + ") can not have more than one value: " + list);
  }
  list.add(value);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:10,代码来源:SimpleGroup.java

示例11: StructConverter

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private StructConverter(List<TProtocol> events, GroupType parquetSchema, ThriftField field) {
  this.events = events;
  this.name = field.getName();
  this.tStruct = new TStruct(name);
  this.thriftType = (StructType)field.getType();
  this.schemaSize = parquetSchema.getFieldCount();
  this.converters = new Converter[this.schemaSize];
  List<ThriftField> thriftChildren = thriftType.getChildren();
  for (int i = 0; i < schemaSize; i++) {
    Type schemaType = parquetSchema.getType(i);
    String fieldName = schemaType.getName();
    ThriftField matchingThrift = null;
    for (ThriftField childField: thriftChildren) {
      String thriftChildName = childField.getName();
      if (thriftChildName != null && thriftChildName.equalsIgnoreCase(fieldName)) {
        matchingThrift = childField;
        break;
      }
    }
    if (matchingThrift == null) {
    	// this means the file did not contain that field
      // it will never be populated in this instance
      // other files might populate it
    	continue;
    }
    if (schemaType.isPrimitive()) {
    	converters[i] = new PrimitiveFieldHandler(newConverter(events, schemaType, matchingThrift).asPrimitiveConverter(), matchingThrift, events);
    } else {
    	converters[i] = new GroupFieldhandler(newConverter(events, schemaType, matchingThrift).asGroupConverter(), matchingThrift, events);
    }
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:33,代码来源:ThriftRecordConverter.java

示例12: writeData

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private void writeData(final ArrayWritable arr, final GroupType type) {
  if (arr == null) {
    return;
  }
  final int fieldCount = type.getFieldCount();
  Writable[] values = arr.get();
  for (int field = 0; field < fieldCount; ++field) {
    final Type fieldType = type.getType(field);
    final String fieldName = fieldType.getName();
    final Writable value = values[field];
    if (value == null) {
      continue;
    }
    recordConsumer.startField(fieldName, field);

    if (fieldType.isPrimitive()) {
      writePrimitive(value);
    } else {
      recordConsumer.startGroup();
      if (value instanceof ArrayWritable) {
        if (fieldType.asGroupType().getRepetition().equals(Type.Repetition.REPEATED)) {
          writeArray((ArrayWritable) value, fieldType.asGroupType());
        } else {
          writeData((ArrayWritable) value, fieldType.asGroupType());
        }
      } else if (value != null) {
        throw new ParquetEncodingException("This should be an ArrayWritable or MapWritable: " + value);
      }

      recordConsumer.endGroup();
    }

    recordConsumer.endField(fieldName, field);
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:36,代码来源:DataWritableWriter.java

示例13: ProtoMessageConverter

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
ProtoMessageConverter(ParentValueContainer pvc, Message.Builder builder, GroupType parquetSchema) {

    int schemaSize = parquetSchema.getFieldCount();
    converters = new Converter[schemaSize];

    this.parent = pvc;
    int parquetFieldIndex = 1;

    if (pvc == null) {
      throw new IllegalStateException("Missing parent value container");
    }

    myBuilder = builder;

    Descriptors.Descriptor protoDescriptor = builder.getDescriptorForType();

    for (Type parquetField : parquetSchema.getFields()) {
      Descriptors.FieldDescriptor protoField = protoDescriptor.findFieldByName(parquetField.getName());

      if (protoField == null) {
        String description = "Scheme mismatch \n\"" + parquetField + "\"" +
                "\n proto descriptor:\n" + protoDescriptor.toProto();
        throw new IncompatibleSchemaModificationException("Cant find \"" + parquetField.getName() + "\" " + description);
      }

      converters[parquetFieldIndex - 1] = newMessageConverter(myBuilder, protoField, parquetField);

      parquetFieldIndex++;
    }
  }
 
开发者ID:apache,项目名称:parquet-mr,代码行数:31,代码来源:ProtoMessageConverter.java

示例14: getFieldSchema

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private FieldSchema getFieldSchema(Type parquetType) throws FrontendException {
  final String fieldName = parquetType.getName();
  if (parquetType.isPrimitive()) {
    return getSimpleFieldSchema(fieldName, parquetType);
  } else {
    return getComplexFieldSchema(fieldName, parquetType);
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:9,代码来源:PigSchemaConverter.java

示例15: ColumnIO

import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
ColumnIO(Type type, GroupColumnIO parent, int index) {
  this.type = type;
  this.parent = parent;
  this.index = index;
  this.name = type.getName();
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:7,代码来源:ColumnIO.java


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