use of com.facebook.presto.spi.type.TypeSignatureParameter in project presto by prestodb.
the class ParquetReader method readStruct.
private Block readStruct(Type type, List<String> path, IntList elementOffsets) throws IOException {
List<TypeSignatureParameter> parameters = type.getTypeSignature().getParameters();
Block[] blocks = new Block[parameters.size()];
for (int i = 0; i < parameters.size(); i++) {
NamedTypeSignature namedTypeSignature = parameters.get(i).getNamedTypeSignature();
Type fieldType = typeManager.getType(namedTypeSignature.getTypeSignature());
String name = namedTypeSignature.getName();
blocks[i] = readBlock(name, fieldType, path, new IntArrayList());
}
InterleavedBlock interleavedBlock = new InterleavedBlock(blocks);
int blockSize = blocks[0].getPositionCount();
int[] offsets = new int[blockSize + 1];
for (int i = 1; i < offsets.length; i++) {
elementOffsets.add(parameters.size());
offsets[i] = i * parameters.size();
}
return new ArrayBlock(blockSize, new boolean[blockSize], offsets, interleavedBlock);
}
use of com.facebook.presto.spi.type.TypeSignatureParameter in project presto by prestodb.
the class TypeRegistry method instantiateParametricType.
private Type instantiateParametricType(TypeSignature signature) {
List<TypeParameter> parameters = new ArrayList<>();
for (TypeSignatureParameter parameter : signature.getParameters()) {
TypeParameter typeParameter = TypeParameter.of(parameter, this);
if (typeParameter == null) {
return null;
}
parameters.add(typeParameter);
}
ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
if (parametricType == null) {
return null;
}
try {
Type instantiatedType = parametricType.createType(parameters);
//checkState(instantiatedType.equalsSignature(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
return instantiatedType;
} catch (IllegalArgumentException e) {
// TODO: check whether a type constructor actually exists rather than failing when it doesn't. This will be possible in the next version of the type system
return null;
}
}
Aggregations