本文整理汇总了Java中parquet.schema.Type.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getName方法的具体用法?Java Type.getName怎么用?Java Type.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parquet.schema.Type
的用法示例。
在下文中一共展示了Type.getName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTuple
import parquet.schema.Type; //导入方法依赖的package包/类
private void writeTuple(Tuple tuple, GroupType type) {
for (int index = 0; index < type.getFieldCount(); index++) {
Type fieldType = type.getType(index);
String fieldName = fieldType.getName();
// empty fields have to be omitted
if (tuple.isNull(index))
continue;
recordConsumer.startField(fieldName, index);
if (fieldType.isPrimitive()) {
tuple.writePrimitiveValue(recordConsumer, index, (PrimitiveType)fieldType);
}
else {
recordConsumer.startGroup();
writeTuple(tuple.getTuple(index), fieldType.asGroupType());
recordConsumer.endGroup();
}
recordConsumer.endField(fieldName, index);
}
}
示例2: initScanFilter
import parquet.schema.Type; //导入方法依赖的package包/类
/**
* init the scan filter with the read schema
* @param scan
*/
public void initScanFilter(Scan scan){
String schema = new String(scan.getAttribute(HConstants.SCAN_TABLE_SCHEMA));
try {
if (scan != null && schema != null && !schema.isEmpty()) {
MessageType readSchema = MessageTypeParser.parseMessageType(schema);
//readSchema.getFields();
List<Type> types = readSchema.getFields();
for(Type type : types){
String columnName = type.getName();
if(columnName.startsWith("cf"))// fetch the real column name
columnName = columnName.substring(3);
filterColumns.add(columnName.getBytes());
}
}
}catch (Exception e){
//TODO: send the exception back to the client
LOG.error("parse the message schema error" + e);
}
}
示例3: groupToCells
import parquet.schema.Type; //导入方法依赖的package包/类
/**
* transform data in group into cells(List<cell> - > {@link org.apache.hadoop.hbase.client.Result}</>)
* @param group
* @return
*/
public static List<Cell> groupToCells(Group group){
List<Cell> cells = new LinkedList<>();
if(group != null){
cells = new LinkedList<>();
GroupType groupType = group.getType();
List<Type> types = groupType.getFields();
byte [] rowKey = group.getBinary(HConstants.ROW_KEY, 0).getBytes();
long timestamp = group.getLong(HConstants.TIME_STAMP, 0);
for(Type t : types){
if(! t.getName().equals(HConstants.ROW_KEY) && ! t.getName().equals(HConstants.TIME_STAMP)){
String name = t.getName();
String [] names = name.split(":");
if(names.length == 2) {
byte[] value = group.getBinary(name, 0).getBytes();
Cell cell = new KeyValue(rowKey, names[0].getBytes(), names[1].getBytes(), timestamp, value);
cells.add(cell);
}
}
}
}
return cells;
}
示例4: toString
import parquet.schema.Type; //导入方法依赖的package包/类
public String toString(String indent) {
StringBuilder result = new StringBuilder();
int i = 0;
for (Type field : this.schema.getFields()) {
String name = field.getName();
List<Object> values = this.data[i];
for (Object value : values) {
result.append(indent).append(name);
if (value == null) {
result.append(": NULL\n");
} else if (value instanceof Group) {
result.append("\n").append(((ParquetGroup) value).toString(indent + " "));
} else {
result.append(": ").append(value.toString()).append("\n");
}
}
i++;
}
return result.toString();
}
示例5: convertField
import parquet.schema.Type; //导入方法依赖的package包/类
private static SchemaDescription.Field convertField( SchemaDescription schema, Type t ) {
boolean allowNull = t.getRepetition() != Repetition.REQUIRED;
switch ( t.asPrimitiveType().getPrimitiveTypeName() ) {
case BINARY:
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_STRING, allowNull );
case BOOLEAN:
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_BOOLEAN, allowNull );
case DOUBLE:
case FLOAT:
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_NUMBER, allowNull );
case INT32:
case INT64:
if ( t.getOriginalType() == OriginalType.DATE || t.getOriginalType() == OriginalType.TIME_MILLIS
|| t.getOriginalType() == OriginalType.TIMESTAMP_MILLIS ) {
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_DATE, allowNull );
} else {
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_INTEGER, allowNull );
}
case INT96:
return schema.new Field( t.getName(), t.getName(), ValueMetaInterface.TYPE_DATE, allowNull );
default:
throw new RuntimeException( "Undefined type: " + t );
}
}
示例6: createConverter
import parquet.schema.Type; //导入方法依赖的package包/类
private Converter createConverter(Type field) {
if (field.isPrimitive()) {
OriginalType otype = field.getOriginalType();
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;
}
}
return new SimplePrimitiveConverter(field.getName());
}
return new SimpleRecordConverter(field.asGroupType(), field.getName(), this);
}
示例7: getType
import 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));
}
}
示例8: add
import parquet.schema.Type; //导入方法依赖的package包/类
public void add(int fieldIndex, Primitive value) {
Type type = this.schema.getType(fieldIndex);
List<Object> list = this.data[fieldIndex];
if (!type.isRepetition(REPEATED) && !list.isEmpty()) {
throw new IllegalStateException(
"field " + fieldIndex + " (" + type.getName() + ") can not have more than one value: " + list);
} else {
list.add(value);
}
}