use of io.prestosql.spi.block.RowBlock in project carbondata by apache.
the class ComplexTypeStreamReader method putComplexObject.
public void putComplexObject(List<Integer> offsetVector) {
if (type instanceof ArrayType) {
// build child block
Block childBlock = buildChildBlock(getChildrenVector().get(0));
// prepare an offset vector with 0 as initial offset
int[] offsetVectorArray = new int[offsetVector.size() + 1];
for (int i = 1; i <= offsetVector.size(); i++) {
offsetVectorArray[i] = offsetVectorArray[i - 1] + offsetVector.get(i - 1);
}
// prepare Array block
Block arrayBlock = ArrayBlock.fromElementBlock(offsetVector.size(), Optional.empty(), offsetVectorArray, childBlock);
for (int position = 0; position < offsetVector.size(); position++) {
type.writeObject(builder, arrayBlock.getObject(position, Block.class));
}
getChildrenVector().get(0).getColumnVector().reset();
} else {
// build child blocks
List<Block> childBlocks = new ArrayList<>(getChildrenVector().size());
for (CarbonColumnVector child : getChildrenVector()) {
childBlocks.add(buildChildBlock(child));
}
// prepare ROW block
Block rowBlock = RowBlock.fromFieldBlocks(offsetVector.size(), Optional.empty(), childBlocks.toArray(new Block[0]));
for (int position = 0; position < offsetVector.size(); position++) {
type.writeObject(builder, rowBlock.getObject(position, Block.class));
}
for (CarbonColumnVector child : getChildrenVector()) {
child.getColumnVector().reset();
}
}
}
Aggregations