本文整理汇总了Java中org.apache.parquet.schema.Type.isPrimitive方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isPrimitive方法的具体用法?Java Type.isPrimitive怎么用?Java Type.isPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.parquet.schema.Type
的用法示例。
在下文中一共展示了Type.isPrimitive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertColumnDescriptor
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
/**
* Converts {@link ColumnDescriptor} to {@link SchemaPath} and converts any parquet LOGICAL LIST to something
* the execution engine can understand (removes the extra 'list' and 'element' fields from the name)
*/
private static SchemaPath convertColumnDescriptor(final MessageType schema, final ColumnDescriptor columnDescriptor) {
List<String> path = Lists.newArrayList(columnDescriptor.getPath());
// go through the path and find all logical lists
int index = 0;
Type type = schema;
while (!type.isPrimitive()) { // don't bother checking the last element in the path as it is a primitive type
type = type.asGroupType().getType(path.get(index));
if (type.getOriginalType() == OriginalType.LIST && LogicalListL1Converter.isSupportedSchema(type.asGroupType())) {
// remove 'list'
type = type.asGroupType().getType(path.get(index+1));
path.remove(index+1);
// remove 'element'
type = type.asGroupType().getType(path.get(index+1));
path.remove(index+1);
}
index++;
}
String[] schemaColDesc = new String[path.size()];
path.toArray(schemaColDesc);
return SchemaPath.getCompoundPath(schemaColDesc);
}
示例2: renameChildTypeToElement
import org.apache.parquet.schema.Type; //导入方法依赖的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());
}
}
示例3: newFieldConverter
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
private Converter newFieldConverter(Type parquetType, ParentContainerUpdater updater)
{
if (parquetType.isRepetition(Type.Repetition.REPEATED) && parquetType.getOriginalType() != OriginalType.LIST) {
// A repeated field that is neither contained by a `LIST`- or `MAP`-annotated group nor
// annotated by `LIST` or `MAP` should be interpreted as a required list of required
// elements where the element type is the type of the field.
if (parquetType.isPrimitive()) {
return new RepeatedPrimitiveConverter(parquetType, updater);
}
else {
return new RepeatedGroupConverter(parquetType, updater);
}
}
else {
return newConverter(parquetType, updater);
}
}
示例4: getColTypeInfo
import org.apache.parquet.schema.Type; //导入方法依赖的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);
}
示例5: 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());
}
}
}
}
示例6: 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;
}
示例7: isElementType
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
/**
* Returns whether the given type is the element type of a list or is a
* synthetic group with one field that is the element type. This is
* determined by checking whether the type can be a synthetic group and by
* checking whether a potential synthetic group matches the expected schema.
* <p>
* Unlike {@link AvroSchemaConverter#isElementType(Type, String)}, this
* method never guesses because the expected schema is known.
*
* @param repeatedType a type that may be the element type
* @param elementSchema the expected Schema for list elements
* @return {@code true} if the repeatedType is the element schema
*/
static boolean isElementType(Type repeatedType, Schema elementSchema) {
if (repeatedType.isPrimitive() ||
repeatedType.asGroupType().getFieldCount() > 1 ||
repeatedType.asGroupType().getType(0).isRepetition(REPEATED)) {
// The repeated type must be the element type because it is an invalid
// synthetic wrapper. Must be a group with one optional or required field
return true;
} else if (elementSchema != null &&
elementSchema.getType() == Schema.Type.RECORD) {
Schema schemaFromRepeated = CONVERTER.convert(repeatedType.asGroupType());
if (checkReaderWriterCompatibility(elementSchema, schemaFromRepeated)
.getType() == COMPATIBLE) {
return true;
}
}
return false;
}
示例8: 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);
}
}
}
示例9: SimpleGroupConverter
import org.apache.parquet.schema.Type; //导入方法依赖的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());
}
}
}
示例10: isListElementType
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
/**
* Returns whether the given type is the element type of a list or is a
* synthetic group with one field that is the element type. This is
* determined by checking whether the type can be a synthetic group and by
* checking whether a potential synthetic group matches the expected
* ThriftField.
* <p>
* This method never guesses because the expected ThriftField is known.
*
* @param repeatedType a type that may be the element type
* @param thriftElement the expected Schema for list elements
* @return {@code true} if the repeatedType is the element schema
*/
static boolean isListElementType(Type repeatedType,
ThriftField thriftElement) {
if (repeatedType.isPrimitive() ||
(repeatedType.asGroupType().getFieldCount() != 1) ||
(repeatedType.asGroupType().getType(0).isRepetition(REPEATED))) {
// The repeated type must be the element type because it is an invalid
// synthetic wrapper. Must be a group with one optional or required field
return true;
} else if (thriftElement != null && thriftElement.getType() instanceof StructType) {
Set<String> fieldNames = new HashSet<String>();
for (ThriftField field : ((StructType) thriftElement.getType()).getChildren()) {
fieldNames.add(field.getName());
}
// If the repeated type is a subset of the structure of the ThriftField,
// then it must be the element type.
return fieldNames.contains(repeatedType.asGroupType().getFieldName(0));
}
return false;
}
示例11: hasMissingRequiredFieldInGroupType
import org.apache.parquet.schema.Type; //导入方法依赖的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;
}
示例12: write
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
@Override
public void write(TupleEntry record) {
recordConsumer.startMessage();
final List<Type> fields = rootSchema.getFields();
for (int i = 0; i < fields.size(); i++) {
Type field = fields.get(i);
if (record == null || record.getObject(field.getName()) == null) {
continue;
}
recordConsumer.startField(field.getName(), i);
if (field.isPrimitive()) {
writePrimitive(record, field.asPrimitiveType());
} else {
throw new UnsupportedOperationException("Complex type not implemented");
}
recordConsumer.endField(field.getName(), i);
}
recordConsumer.endMessage();
}
示例13: getConverterFromDescription
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
protected static Converter getConverterFromDescription(final Type type, final int index,
final HiveGroupConverter parent) {
if (type == null) {
return null;
}
if (type.isPrimitive()) {
return ETypeConverter.getNewConverter(type.asPrimitiveType().getPrimitiveTypeName().javaType,
index, parent);
} else {
if (type.asGroupType().getRepetition() == Repetition.REPEATED) {
return new ArrayWritableGroupConverter(type.asGroupType(), parent, index);
} else {
return new DataWritableGroupConverter(type.asGroupType(), parent, index);
}
}
}
示例14: 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);
}
示例15: addChildConverter
import org.apache.parquet.schema.Type; //导入方法依赖的package包/类
@Override
protected void addChildConverter(OutputMutator mutator, List<Field> arrowSchema, Iterator<SchemaPath> colIterator, Type type, Function<String, String> childNameResolver) {
final String nameForChild = "inner";
if (type.isPrimitive()) {
converters.add( getConverterForType(nameForChild, type.asPrimitiveType()));
} else {
final GroupType groupType = type.asGroupType();
Collection<SchemaPath> c = Lists.newArrayList(colIterator);
if (arrowSchema != null) {
converters.add( groupConverterFromArrowSchema(nameForChild, "$data$", groupType, c));
} else {
converters.add( defaultGroupConverter(mutator, groupType, nameForChild, c, null));
}
}
}