本文整理了Java中org.apache.parquet.schema.Types.primitive()
方法的一些代码示例,展示了Types.primitive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.primitive()
方法的具体详情如下:
包路径:org.apache.parquet.schema.Types
类名称:Types
方法名:primitive
暂无
代码示例来源:origin: apache/hive
if (typeInfo.getCategory().equals(Category.PRIMITIVE)) {
if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
} else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.shortTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition)
.as(OriginalType.INT_16).named(name);
} else if (typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition)
.as(OriginalType.INT_8).named(name);
} else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.binaryTypeInfo)) {
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
} else if (typeInfo.equals(TypeInfoFactory.voidTypeInfo)) {
throw new UnsupportedOperationException("Void type not implemented");
scale(scale).precision(prec).named(name);
} else if (typeInfo.equals(TypeInfoFactory.dateTypeInfo)) {
代码示例来源:origin: org.apache.parquet/parquet-thrift
private ConvertedField visitPrimitiveType(PrimitiveTypeName type, OriginalType orig, State state) {
PrimitiveBuilder<PrimitiveType> b = primitive(type, state.repetition);
if (orig != null) {
b = b.as(orig);
}
if (fieldProjectionFilter.keep(state.path)) {
return new Keep(state.path, b.named(state.name));
} else {
return new Drop(state.path);
}
}
代码示例来源:origin: com.alibaba.blink/flink-table
private static Type convertType(
final String name, final InternalType type, final Type.Repetition repetition) {
if (DataTypes.INT.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition).named(name);
} else if (DataTypes.SHORT.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition)
.as(OriginalType.INT_16)
.named(name);
} else if (DataTypes.BOOLEAN.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.BOOLEAN, repetition).named(name);
} else if (DataTypes.BYTE.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition)
.as(OriginalType.INT_8)
.named(name);
} else if (DataTypes.DOUBLE.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.DOUBLE, repetition).named(name);
} else if (DataTypes.FLOAT.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.FLOAT, repetition).named(name);
} else if (DataTypes.LONG.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT64, repetition).named(name);
} else if (DataTypes.STRING.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
} else if (DataTypes.DATE.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
} else if (DataTypes.TIME.equals(type)) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition)
.as(OriginalType.TIME_MILLIS)
.named(name);
} else if (DataTypes.TIMESTAMP.equals(type)) {
代码示例来源:origin: org.apache.parquet/parquet-avro
Schema.Type type = schema.getType();
if (type.equals(Schema.Type.BOOLEAN)) {
builder = Types.primitive(BOOLEAN, repetition);
} else if (type.equals(Schema.Type.INT)) {
builder = Types.primitive(INT32, repetition);
} else if (type.equals(Schema.Type.LONG)) {
builder = Types.primitive(INT64, repetition);
} else if (type.equals(Schema.Type.FLOAT)) {
builder = Types.primitive(FLOAT, repetition);
} else if (type.equals(Schema.Type.DOUBLE)) {
builder = Types.primitive(DOUBLE, repetition);
} else if (type.equals(Schema.Type.BYTES)) {
builder = Types.primitive(BINARY, repetition);
} else if (type.equals(Schema.Type.STRING)) {
builder = Types.primitive(BINARY, repetition).as(UTF8);
} else if (type.equals(Schema.Type.RECORD)) {
return new GroupType(repetition, fieldName, convertFields(schema.getFields()));
} else if (type.equals(Schema.Type.ENUM)) {
builder = Types.primitive(BINARY, repetition).as(ENUM);
} else if (type.equals(Schema.Type.ARRAY)) {
if (writeOldListStructure) {
builder = Types.primitive(FIXED_LEN_BYTE_ARRAY, repetition)
.length(schema.getFixedSize());
} else if (type.equals(Schema.Type.UNION)) {
代码示例来源:origin: Netflix/iceberg
public Type primitive(PrimitiveType primitive, Type.Repetition repetition, int id, String name) {
switch (primitive.typeId()) {
case BOOLEAN:
return Types.primitive(BOOLEAN, repetition).id(id).named(name);
case INTEGER:
return Types.primitive(INT32, repetition).id(id).named(name);
case LONG:
return Types.primitive(INT64, repetition).id(id).named(name);
case FLOAT:
return Types.primitive(FLOAT, repetition).id(id).named(name);
case DOUBLE:
return Types.primitive(DOUBLE, repetition).id(id).named(name);
case DATE:
return Types.primitive(INT32, repetition).as(DATE).id(id).named(name);
case TIME:
return Types.primitive(INT64, repetition).as(TIME_MICROS).id(id).named(name);
case TIMESTAMP:
return Types.primitive(INT64, repetition).as(TIMESTAMP_MICROS).id(id).named(name);
case STRING:
return Types.primitive(BINARY, repetition).as(UTF8).id(id).named(name);
case BINARY:
return Types.primitive(BINARY, repetition).id(id).named(name);
case FIXED:
FixedType fixed = (FixedType) primitive;
return Types.primitive(FIXED_LEN_BYTE_ARRAY, repetition).length(fixed.length())
.id(id)
.named(name);
return Types.primitive(INT32, repetition)
代码示例来源:origin: io.prestosql/presto-hive
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: prestosql/presto
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: org.lasersonlab.apache.parquet/parquet-column
@Override
protected Type union(Type toMerge, boolean strict) {
if (!toMerge.isPrimitive()) {
reportSchemaMergeError(toMerge);
}
if (strict) {
// Can't merge primitive fields of different type names or different original types
if (!primitive.equals(toMerge.asPrimitiveType().getPrimitiveTypeName()) ||
!Objects.equals(getLogicalTypeAnnotation(), toMerge.getLogicalTypeAnnotation())) {
reportSchemaMergeError(toMerge);
}
// Can't merge FIXED_LEN_BYTE_ARRAY fields of different lengths
int toMergeLength = toMerge.asPrimitiveType().getTypeLength();
if (primitive == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY && length != toMergeLength) {
reportSchemaMergeError(toMerge);
}
// Can't merge primitive fields with different column orders
if (!columnOrder().equals(toMerge.asPrimitiveType().columnOrder())) {
reportSchemaMergeErrorWithColumnOrder(toMerge);
}
}
Types.PrimitiveBuilder<PrimitiveType> builder = Types.primitive(primitive, toMerge.getRepetition());
if (PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY == primitive) {
builder.length(length);
}
return builder.as(getLogicalTypeAnnotation()).named(getName());
}
代码示例来源:origin: prestosql/presto
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: io.prestosql/presto-hive
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: io.prestosql/presto-hive
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: prestosql/presto
return Types.primitive(PrimitiveTypeName.BINARY, repetition).as(OriginalType.UTF8)
.named(name);
typeInfo.equals(TypeInfoFactory.shortTypeInfo) ||
typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
return Types.primitive(PrimitiveTypeName.INT32, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT64, repetition).named(name);
return Types.primitive(PrimitiveTypeName.DOUBLE, repetition).named(name);
return Types.primitive(PrimitiveTypeName.FLOAT, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BOOLEAN, repetition).named(name);
return Types.primitive(PrimitiveTypeName.BINARY, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT96, repetition).named(name);
return Types.primitive(PrimitiveTypeName.INT32, repetition).as(OriginalType.DATE).named(name);
代码示例来源:origin: org.apache.parquet/parquet-column
@Override
protected Type union(Type toMerge, boolean strict) {
if (!toMerge.isPrimitive()) {
reportSchemaMergeError(toMerge);
}
if (strict) {
// Can't merge primitive fields of different type names or different original types
if (!primitive.equals(toMerge.asPrimitiveType().getPrimitiveTypeName()) ||
getOriginalType() != toMerge.getOriginalType()) {
reportSchemaMergeError(toMerge);
}
// Can't merge FIXED_LEN_BYTE_ARRAY fields of different lengths
int toMergeLength = toMerge.asPrimitiveType().getTypeLength();
if (primitive == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY && length != toMergeLength) {
reportSchemaMergeError(toMerge);
}
// Can't merge primitive fields with different column orders
if (!columnOrder().equals(toMerge.asPrimitiveType().columnOrder())) {
reportSchemaMergeErrorWithColumnOrder(toMerge);
}
}
Types.PrimitiveBuilder<PrimitiveType> builder = Types.primitive(primitive, toMerge.getRepetition());
if (PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY == primitive) {
builder.length(length);
}
return builder.as(getOriginalType()).named(getName());
}
内容来源于网络,如有侵权,请联系作者删除!