本文整理汇总了Java中org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.PrimitiveTypeName方法的具体用法?Java PrimitiveType.PrimitiveTypeName怎么用?Java PrimitiveType.PrimitiveTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.parquet.schema.PrimitiveType
的用法示例。
在下文中一共展示了PrimitiveType.PrimitiveTypeName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testListsOfPrimitive
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的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
}
}
}
}
}
示例2: getTypeLengthInBits
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
/**
* @param type a fixed length type from the parquet library enum
* @return the length in pageDataByteArray of the type
*/
public static int getTypeLengthInBits(PrimitiveType.PrimitiveTypeName type) {
switch (type) {
case INT64: return 64;
case INT32: return 32;
case BOOLEAN: return 1;
case FLOAT: return 32;
case DOUBLE: return 64;
case INT96: return 96;
// binary and fixed length byte array
default:
throw new IllegalStateException("Length cannot be determined for type " + type);
}
}
示例3: toMajorType
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length,
TypeProtos.DataMode mode, SchemaElement schemaElement,
OptionManager options, Field arrowField, final boolean readInt96AsTimeStamp) {
MinorType minorType = getMinorType(primitiveTypeName, length, schemaElement, options, arrowField, readInt96AsTimeStamp);
TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode);
if (CoreDecimalUtility.isDecimalType(minorType)) {
typeBuilder.setPrecision(schemaElement.getPrecision()).setScale(schemaElement.getScale());
}
return typeBuilder.build();
}
示例4: toMajorType
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length,
TypeProtos.DataMode mode, ConvertedType convertedType, int precision, int scale,
OptionManager options) {
MinorType minorType = getMinorType(primitiveTypeName, length, convertedType, precision, scale, options);
TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode);
if (CoreDecimalUtility.isDecimalType(minorType)) {
typeBuilder.setPrecision(precision).setScale(scale);
}
return typeBuilder.build();
}
示例5: printColumnChunk
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
private void printColumnChunk(Logger console, int width, ColumnChunkMetaData column, MessageType schema) {
String[] path = column.getPath().toArray();
PrimitiveType type = primitive(schema, path);
Preconditions.checkNotNull(type);
ColumnDescriptor desc = schema.getColumnDescription(path);
long size = column.getTotalSize();
long count = column.getValueCount();
float perValue = ((float) size) / count;
CompressionCodecName codec = column.getCodec();
Set<Encoding> encodings = column.getEncodings();
EncodingStats encodingStats = column.getEncodingStats();
String encodingSummary = encodingStats == null ?
encodingsAsString(encodings, desc) :
encodingStatsAsString(encodingStats);
Statistics stats = column.getStatistics();
String name = column.getPath().toDotString();
PrimitiveType.PrimitiveTypeName typeName = type.getPrimitiveTypeName();
if (typeName == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {
console.info(String.format("%-" + width + "s FIXED[%d] %s %-7s %-9d %-8s %-7s %s",
name, type.getTypeLength(), shortCodec(codec), encodingSummary, count,
humanReadable(perValue), stats == null ? "" : String.valueOf(stats.getNumNulls()),
minMaxAsString(stats, type.getOriginalType())));
} else {
console.info(String.format("%-" + width + "s %-9s %s %-7s %-9d %-10s %-7s %s",
name, typeName, shortCodec(codec), encodingSummary, count, humanReadable(perValue),
stats == null ? "" : String.valueOf(stats.getNumNulls()),
minMaxAsString(stats, type.getOriginalType())));
}
}
示例6: getType
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
public PrimitiveType.PrimitiveTypeName getType() {
return this.type;
}
示例7: setType
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
public void setType(PrimitiveType.PrimitiveTypeName type) {
this.type = type;
}
示例8: getStat
import org.apache.parquet.schema.PrimitiveType; //导入方法依赖的package包/类
/**
* Builds column statistics using given primitiveType, originalType, repetitionLevel, scale,
* precision, numNull, min and max values.
*
* @param min min value for statistics
* @param max max value for statistics
* @param numNull num_nulls for statistics
* @param primitiveType type that determines statistics class
* @param originalType type that determines statistics class
* @param repetitionLevel field repetition level
* @param scale scale value (used for DECIMAL type)
* @param precision precision value (used for DECIMAL type)
* @return column statistics
*/
private ColumnStatistics getStat(Object min, Object max, Long numNull,
PrimitiveType.PrimitiveTypeName primitiveType, OriginalType originalType,
Integer repetitionLevel, int scale, int precision) {
Statistics stat = Statistics.getStatsBasedOnType(primitiveType);
Statistics convertedStat = stat;
TypeProtos.MajorType type = ParquetGroupScan.getType(primitiveType, originalType, scale, precision);
// Change to repeated if repetitionLevel > 0
if (repetitionLevel != null && repetitionLevel > 0) {
type = Types.withScaleAndPrecision(type.getMinorType(), TypeProtos.DataMode.REPEATED, scale, precision);
}
if (numNull != null) {
stat.setNumNulls(numNull);
}
if (min != null && max != null ) {
switch (type.getMinorType()) {
case INT :
case TIME:
((IntStatistics) stat).setMinMax(Integer.parseInt(min.toString()), Integer.parseInt(max.toString()));
break;
case BIGINT:
case TIMESTAMP:
((LongStatistics) stat).setMinMax(Long.parseLong(min.toString()), Long.parseLong(max.toString()));
break;
case FLOAT4:
((FloatStatistics) stat).setMinMax(Float.parseFloat(min.toString()), Float.parseFloat(max.toString()));
break;
case FLOAT8:
((DoubleStatistics) stat).setMinMax(Double.parseDouble(min.toString()), Double.parseDouble(max.toString()));
break;
case DATE:
convertedStat = new LongStatistics();
convertedStat.setNumNulls(stat.getNumNulls());
final long minMS = convertToDrillDateValue(Integer.parseInt(min.toString()));
final long maxMS = convertToDrillDateValue(Integer.parseInt(max.toString()));
((LongStatistics) convertedStat ).setMinMax(minMS, maxMS);
break;
default:
}
}
return new ColumnStatistics(convertedStat, type);
}