use of org.apache.drill.exec.vector.complex.AbstractMapVector in project drill by axbaretto.
the class VectorContainerBuilder method buildMap.
@SuppressWarnings("resource")
private void buildMap(TupleProxy parentTuple, BaseMapColumnState colModel) {
// Creating the map vector will create its contained vectors if we
// give it a materialized field with children. So, instead pass a clone
// without children so we can add them.
ColumnMetadata mapColSchema = colModel.schema().cloneEmpty();
// Don't get the map vector from the vector cache. Map vectors may
// have content that varies from batch to batch. Only the leaf
// vectors can be cached.
AbstractMapVector mapVector;
if (mapColSchema.isArray()) {
// A repeated map shares an offset vector with the internal
// repeated map.
UInt4Vector offsets = (UInt4Vector) colModel.vector();
mapVector = new RepeatedMapVector(mapColSchema.schema(), offsets, null);
} else {
mapVector = new MapVector(mapColSchema.schema(), allocator(), null);
}
// Add the map vector and schema to the parent tuple
parentTuple.add(mapVector);
int index = parentTuple.schema.addColumn(mapColSchema);
assert parentTuple.size() == parentTuple.size();
// Update the tuple, which will add the new columns in the map
updateTuple(colModel.mapState(), parentTuple.mapProxy(index));
}
use of org.apache.drill.exec.vector.complex.AbstractMapVector in project drill by apache.
the class HyperVectorWrapper method getChildWrapper.
@Override
public VectorWrapper<?> getChildWrapper(int[] ids) {
if (ids.length == 1) {
return this;
}
final ValueVector[] vectors = new ValueVector[this.vectors.length];
int index = 0;
for (final ValueVector v : this.vectors) {
ValueVector vector = v;
for (int i = 1; i < ids.length; i++) {
final AbstractMapVector mapLike = AbstractMapVector.class.cast(vector);
if (mapLike == null) {
return null;
}
vector = mapLike.getChildByOrdinal(ids[i]);
}
vectors[index] = vector;
index++;
}
return new HyperVectorWrapper<ValueVector>(vectors[0].getField(), vectors);
}
use of org.apache.drill.exec.vector.complex.AbstractMapVector in project drill by apache.
the class SimpleVectorWrapper method getChildWrapper.
@Override
public VectorWrapper<?> getChildWrapper(int[] ids) {
if (ids.length == 1) {
return this;
}
ValueVector vector = this.vector;
for (int i = 1; i < ids.length; i++) {
final AbstractMapVector mapLike = AbstractMapVector.class.cast(vector);
if (mapLike == null) {
return null;
}
vector = mapLike.getChildByOrdinal(ids[i]);
}
return new SimpleVectorWrapper<>(vector);
}
use of org.apache.drill.exec.vector.complex.AbstractMapVector in project drill by axbaretto.
the class BuildVectorsFromMetadata method buildMap.
/**
* Build a map column including the members of the map given a map
* column schema.
*
* @param schema the schema of the map column
* @return the completed map vector column model
*/
private AbstractMapVector buildMap(ColumnMetadata schema) {
// Creating the map vector will create its contained vectors if we
// give it a materialized field with children. So, instead pass a clone
// without children so we can add them.
MaterializedField mapField = schema.schema();
MaterializedField emptyClone = MaterializedField.create(mapField.getName(), mapField.getType());
// Don't get the map vector from the vector cache. Map vectors may
// have content that varies from batch to batch. Only the leaf
// vectors can be cached.
AbstractMapVector mapVector = (AbstractMapVector) TypeHelper.getNewVector(emptyClone, allocator, null);
// Create the contents building the model as we go.
TupleMetadata mapSchema = schema.mapSchema();
for (int i = 0; i < mapSchema.size(); i++) {
ColumnMetadata childSchema = mapSchema.metadata(i);
mapVector.putChild(childSchema.name(), buildVector(childSchema));
}
return mapVector;
}
use of org.apache.drill.exec.vector.complex.AbstractMapVector in project drill by axbaretto.
the class SimpleVectorWrapper method getChildWrapper.
@SuppressWarnings("resource")
@Override
public VectorWrapper<?> getChildWrapper(int[] ids) {
if (ids.length == 1) {
return this;
}
ValueVector vector = this.vector;
for (int i = 1; i < ids.length; i++) {
final AbstractMapVector mapLike = AbstractMapVector.class.cast(vector);
if (mapLike == null) {
return null;
}
vector = mapLike.getChildByOrdinal(ids[i]);
}
return new SimpleVectorWrapper<>(vector);
}
Aggregations