本文整理汇总了Java中com.facebook.presto.spi.type.Type.getTypeParameters方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getTypeParameters方法的具体用法?Java Type.getTypeParameters怎么用?Java Type.getTypeParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.presto.spi.type.Type
的用法示例。
在下文中一共展示了Type.getTypeParameters方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParquetStructConverter
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public ParquetStructConverter(Type prestoType, String columnName, GroupType entryType, int fieldIndex)
{
checkArgument(ROW.equals(prestoType.getTypeSignature().getBase()));
List<Type> prestoTypeParameters = prestoType.getTypeParameters();
List<parquet.schema.Type> fieldTypes = entryType.getFields();
checkArgument(prestoTypeParameters.size() == fieldTypes.size());
this.rowType = prestoType;
this.fieldIndex = fieldIndex;
ImmutableList.Builder<BlockConverter> converters = ImmutableList.builder();
for (int i = 0; i < prestoTypeParameters.size(); i++) {
parquet.schema.Type fieldType = fieldTypes.get(i);
converters.add(createConverter(prestoTypeParameters.get(i), columnName + "." + fieldType.getName(), fieldType, i));
}
this.converters = converters.build();
}
示例2: serializeList
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeList(Type type, BlockBuilder builder, Object object) {
List<?> list = (List) object;
if (list == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
checkArgument(typeParameters.size() == 1, "list must have exactly 1 type parameter");
Type elementType = typeParameters.get(0);
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
} else {
currentBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), list.size());
}
for (Object element : list) {
serializeObject(elementType, currentBuilder, element);
}
if (builder != null) {
builder.closeEntry();
return null;
} else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例3: serializeMap
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeMap(Type type, BlockBuilder builder, Object object) {
Map<?, ?> map = (Map) object;
if (map == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
checkArgument(typeParameters.size() == 2, "map must have exactly 2 type parameter");
Type keyType = typeParameters.get(0);
Type valueType = typeParameters.get(1);
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
} else {
currentBuilder = new InterleavedBlockBuilder(typeParameters, new BlockBuilderStatus(), map.size());
}
for (Map.Entry<?, ?> entry : map.entrySet()) {
// Hive skips map entries with null keys
if (entry.getKey() != null) {
serializeObject(keyType, currentBuilder, entry.getKey());
serializeObject(valueType, currentBuilder, entry.getValue());
}
}
if (builder != null) {
builder.closeEntry();
return null;
} else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例4: serializeList
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeList(Type type, BlockBuilder builder, Object object, ListObjectInspector inspector)
{
List<?> list = inspector.getList(object);
if (list == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
checkArgument(typeParameters.size() == 1, "list must have exactly 1 type parameter");
Type elementType = typeParameters.get(0);
ObjectInspector elementInspector = inspector.getListElementObjectInspector();
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
}
else {
currentBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), list.size());
}
for (Object element : list) {
serializeObject(elementType, currentBuilder, element, elementInspector);
}
if (builder != null) {
builder.closeEntry();
return null;
}
else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例5: serializeMap
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeMap(Type type, BlockBuilder builder, Object object, MapObjectInspector inspector)
{
Map<?, ?> map = inspector.getMap(object);
if (map == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
checkArgument(typeParameters.size() == 2, "map must have exactly 2 type parameter");
Type keyType = typeParameters.get(0);
Type valueType = typeParameters.get(1);
ObjectInspector keyInspector = inspector.getMapKeyObjectInspector();
ObjectInspector valueInspector = inspector.getMapValueObjectInspector();
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
}
else {
currentBuilder = new InterleavedBlockBuilder(typeParameters, new BlockBuilderStatus(), map.size());
}
for (Map.Entry<?, ?> entry : map.entrySet()) {
// Hive skips map entries with null keys
if (entry.getKey() != null) {
serializeObject(keyType, currentBuilder, entry.getKey(), keyInspector);
serializeObject(valueType, currentBuilder, entry.getValue(), valueInspector);
}
}
if (builder != null) {
builder.closeEntry();
return null;
}
else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例6: serializeStruct
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeStruct(Type type, BlockBuilder builder, Object object, StructObjectInspector inspector)
{
if (object == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
List<? extends StructField> allStructFieldRefs = inspector.getAllStructFieldRefs();
checkArgument(typeParameters.size() == allStructFieldRefs.size());
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
}
else {
currentBuilder = new InterleavedBlockBuilder(typeParameters, new BlockBuilderStatus(), typeParameters.size());
}
for (int i = 0; i < typeParameters.size(); i++) {
StructField field = allStructFieldRefs.get(i);
serializeObject(typeParameters.get(i), currentBuilder, inspector.getStructFieldData(object, field), field.getFieldObjectInspector());
}
if (builder != null) {
builder.closeEntry();
return null;
}
else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例7: serializeStruct
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block serializeStruct(Type type, BlockBuilder builder, Object object) {
if (object == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
EthBlock.TransactionObject structData = (EthBlock.TransactionObject) object;
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
} else {
currentBuilder = new InterleavedBlockBuilder(typeParameters, new BlockBuilderStatus(), typeParameters.size());
}
ImmutableList.Builder<Supplier> lstBuilder = ImmutableList.builder();
lstBuilder.add(structData::getHash);
lstBuilder.add(structData::getNonce);
lstBuilder.add(structData::getBlockHash);
lstBuilder.add(structData::getBlockNumber);
lstBuilder.add(structData::getTransactionIndex);
lstBuilder.add(structData::getFrom);
lstBuilder.add(structData::getTo);
lstBuilder.add(structData::getValue);
lstBuilder.add(structData::getGas);
lstBuilder.add(structData::getGasPrice);
lstBuilder.add(structData::getInput);
ImmutableList<Supplier> txColumns = lstBuilder.build();
for (int i = 0; i < typeParameters.size(); i++) {
serializeObject(typeParameters.get(i), currentBuilder, txColumns.get(i).get());
}
if (builder != null) {
builder.closeEntry();
return null;
} else {
Block resultBlock = currentBuilder.build();
return resultBlock;
}
}
示例8: decodeObject
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object decodeObject(Type type, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
String base = type.getTypeSignature().getBase();
if (base.equals(ARRAY)) {
Block arrayBlock = (Block) type.getObject(block, position);
Type elementType = type.getTypeParameters().get(0);
List<Object> array = new ArrayList<>();
for (int entry = 0; entry < arrayBlock.getPositionCount(); entry++) {
array.add(decodeObject(elementType, arrayBlock, entry));
}
return array;
}
if (base.equals(ROW)) {
Block rowBlock = (Block) type.getObject(block, position);
List<Type> fieldTypes = type.getTypeParameters();
List<Object> row = new ArrayList<>();
for (int field = 0; field < fieldTypes.size(); field++) {
row.add(decodeObject(fieldTypes.get(field), rowBlock, field));
}
return row;
}
if (base.equals(MAP)) {
Block mapBlock = (Block) type.getObject(block, position);
Type keyType = type.getTypeParameters().get(0);
Type valueType = type.getTypeParameters().get(1);
Map<Object, Object> map = new LinkedHashMap<>();
int entryCount = mapBlock.getPositionCount() / 2;
for (int entry = 0; entry < entryCount; entry++) {
int blockPosition = entry * 2;
Object key = decodeObject(keyType, mapBlock, blockPosition);
// null keys are not allowed
if (key != null) {
Object value = decodeObject(valueType, mapBlock, blockPosition + 1);
map.put(key, value);
}
}
return map;
}
return type.getObjectValue(SESSION, block, position);
}
示例9: createFieldSetter
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static FieldSetter createFieldSetter(SettableStructObjectInspector rowInspector, Object row, StructField field, Type type)
{
if (type.equals(BooleanType.BOOLEAN)) {
return new BooleanFieldSetter(rowInspector, row, field);
}
if (type.equals(BigintType.BIGINT)) {
return new BigintFieldBuilder(rowInspector, row, field);
}
if (type.equals(DoubleType.DOUBLE)) {
return new DoubleFieldSetter(rowInspector, row, field);
}
if (type.equals(VarcharType.VARCHAR)) {
return new VarcharFieldSetter(rowInspector, row, field);
}
if (type.equals(VarbinaryType.VARBINARY)) {
return new BinaryFieldSetter(rowInspector, row, field);
}
if (type.equals(DateType.DATE)) {
return new DateFieldSetter(rowInspector, row, field);
}
if (type.equals(TimestampType.TIMESTAMP)) {
return new TimestampFieldSetter(rowInspector, row, field);
}
if (isArrayType(type)) {
return new ArrayFieldSetter(rowInspector, row, field, type.getTypeParameters().get(0));
}
if (isMapType(type)) {
return new MapFieldSetter(rowInspector, row, field, type.getTypeParameters().get(0), type.getTypeParameters().get(1));
}
if (isRowType(type)) {
return new RowFieldSetter(rowInspector, row, field, type.getTypeParameters());
}
throw new IllegalArgumentException("unsupported type: " + type);
}