Search in sources :

Example 1 with AddOrGetResult

use of org.apache.drill.exec.vector.AddOrGetResult in project drill by apache.

the class BaseRepeatedValueVector method addOrGetVector.

@Override
public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(VectorDescriptor descriptor) {
    boolean created = false;
    if (vector == DEFAULT_DATA_VECTOR && descriptor.getType().getMinorType() != TypeProtos.MinorType.LATE) {
        final MaterializedField field = descriptor.withName(DATA_VECTOR_NAME).getField();
        vector = BasicTypeHelper.getNewVector(field, allocator);
        // returned vector must have the same field
        assert field.equals(vector.getField());
        getField().addChild(field);
        created = true;
    }
    final TypeProtos.MajorType actual = vector.getField().getType();
    if (!actual.equals(descriptor.getType())) {
        final String msg = String.format("Inner vector type mismatch. Requested type: [%s], actual type: [%s]", descriptor.getType(), actual);
        throw new SchemaChangeRuntimeException(msg);
    }
    return new AddOrGetResult<>((T) vector, created);
}
Also used : MaterializedField(org.apache.drill.exec.record.MaterializedField) SchemaChangeRuntimeException(org.apache.drill.exec.exception.SchemaChangeRuntimeException) TypeProtos(org.apache.drill.common.types.TypeProtos) AddOrGetResult(org.apache.drill.exec.vector.AddOrGetResult)

Aggregations

TypeProtos (org.apache.drill.common.types.TypeProtos)1 SchemaChangeRuntimeException (org.apache.drill.exec.exception.SchemaChangeRuntimeException)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 AddOrGetResult (org.apache.drill.exec.vector.AddOrGetResult)1