Search in sources :

Example 1 with NullableUInt4Vector

use of org.apache.drill.exec.vector.NullableUInt4Vector in project drill by axbaretto.

the class ParquetGroupScan method populatePruningVector.

public void populatePruningVector(ValueVector v, int index, SchemaPath column, String file) {
    String f = Path.getPathWithoutSchemeAndAuthority(new Path(file)).toString();
    MajorType majorType = getTypeForColumn(column);
    MinorType type = majorType.getMinorType();
    switch(type) {
        case BIT:
            {
                NullableBitVector bitVector = (NullableBitVector) v;
                Boolean value = (Boolean) partitionValueMap.get(f).get(column);
                if (value == null) {
                    bitVector.getMutator().setNull(index);
                } else {
                    bitVector.getMutator().setSafe(index, value ? 1 : 0);
                }
                return;
            }
        case INT:
            {
                NullableIntVector intVector = (NullableIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case SMALLINT:
            {
                NullableSmallIntVector smallIntVector = (NullableSmallIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    smallIntVector.getMutator().setNull(index);
                } else {
                    smallIntVector.getMutator().setSafe(index, value.shortValue());
                }
                return;
            }
        case TINYINT:
            {
                NullableTinyIntVector tinyIntVector = (NullableTinyIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    tinyIntVector.getMutator().setNull(index);
                } else {
                    tinyIntVector.getMutator().setSafe(index, value.byteValue());
                }
                return;
            }
        case UINT1:
            {
                NullableUInt1Vector intVector = (NullableUInt1Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value.byteValue());
                }
                return;
            }
        case UINT2:
            {
                NullableUInt2Vector intVector = (NullableUInt2Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, (char) value.shortValue());
                }
                return;
            }
        case UINT4:
            {
                NullableUInt4Vector intVector = (NullableUInt4Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case BIGINT:
            {
                NullableBigIntVector bigIntVector = (NullableBigIntVector) v;
                Long value = (Long) partitionValueMap.get(f).get(column);
                if (value == null) {
                    bigIntVector.getMutator().setNull(index);
                } else {
                    bigIntVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case FLOAT4:
            {
                NullableFloat4Vector float4Vector = (NullableFloat4Vector) v;
                Float value = (Float) partitionValueMap.get(f).get(column);
                if (value == null) {
                    float4Vector.getMutator().setNull(index);
                } else {
                    float4Vector.getMutator().setSafe(index, value);
                }
                return;
            }
        case FLOAT8:
            {
                NullableFloat8Vector float8Vector = (NullableFloat8Vector) v;
                Double value = (Double) partitionValueMap.get(f).get(column);
                if (value == null) {
                    float8Vector.getMutator().setNull(index);
                } else {
                    float8Vector.getMutator().setSafe(index, value);
                }
                return;
            }
        case VARBINARY:
            {
                NullableVarBinaryVector varBinaryVector = (NullableVarBinaryVector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s == null) {
                    varBinaryVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                varBinaryVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case DECIMAL18:
            {
                NullableDecimal18Vector decimalVector = (NullableDecimal18Vector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s == null) {
                    decimalVector.getMutator().setNull(index);
                    return;
                } else if (s instanceof Integer) {
                    long value = DecimalUtility.getBigDecimalFromPrimitiveTypes((Integer) s, majorType.getScale(), majorType.getPrecision()).longValue();
                    decimalVector.getMutator().setSafe(index, value);
                    return;
                } else if (s instanceof Long) {
                    long value = DecimalUtility.getBigDecimalFromPrimitiveTypes((Long) s, majorType.getScale(), majorType.getPrecision()).longValue();
                    decimalVector.getMutator().setSafe(index, value);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                long value = DecimalUtility.getBigDecimalFromByteArray(bytes, 0, bytes.length, majorType.getScale()).longValue();
                decimalVector.getMutator().setSafe(index, value);
                return;
            }
        case DATE:
            {
                NullableDateVector dateVector = (NullableDateVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    dateVector.getMutator().setNull(index);
                } else {
                    dateVector.getMutator().setSafe(index, value * (long) DateTimeConstants.MILLIS_PER_DAY);
                }
                return;
            }
        case TIME:
            {
                NullableTimeVector timeVector = (NullableTimeVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                if (value == null) {
                    timeVector.getMutator().setNull(index);
                } else {
                    timeVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case TIMESTAMP:
            {
                NullableTimeStampVector timeStampVector = (NullableTimeStampVector) v;
                Long value = (Long) partitionValueMap.get(f).get(column);
                if (value == null) {
                    timeStampVector.getMutator().setNull(index);
                } else {
                    timeStampVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case VARCHAR:
            {
                NullableVarCharVector varCharVector = (NullableVarCharVector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s == null) {
                    varCharVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                varCharVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case INTERVAL:
            {
                NullableIntervalVector intervalVector = (NullableIntervalVector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s == null) {
                    intervalVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                intervalVector.getMutator().setSafe(index, 1, ParquetReaderUtility.getIntFromLEBytes(bytes, 0), ParquetReaderUtility.getIntFromLEBytes(bytes, 4), ParquetReaderUtility.getIntFromLEBytes(bytes, 8));
                return;
            }
        default:
            throw new UnsupportedOperationException("Unsupported type: " + type);
    }
}
Also used : NullableTinyIntVector(org.apache.drill.exec.vector.NullableTinyIntVector) NullableFloat8Vector(org.apache.drill.exec.vector.NullableFloat8Vector) NullableVarBinaryVector(org.apache.drill.exec.vector.NullableVarBinaryVector) NullableUInt1Vector(org.apache.drill.exec.vector.NullableUInt1Vector) NullableIntVector(org.apache.drill.exec.vector.NullableIntVector) NullableBitVector(org.apache.drill.exec.vector.NullableBitVector) NullableFloat4Vector(org.apache.drill.exec.vector.NullableFloat4Vector) NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) NullableDecimal18Vector(org.apache.drill.exec.vector.NullableDecimal18Vector) Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) ReadEntryWithPath(org.apache.drill.exec.store.dfs.ReadEntryWithPath) NullableIntervalVector(org.apache.drill.exec.vector.NullableIntervalVector) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) NullableDateVector(org.apache.drill.exec.vector.NullableDateVector) NullableTimeStampVector(org.apache.drill.exec.vector.NullableTimeStampVector) NullableSmallIntVector(org.apache.drill.exec.vector.NullableSmallIntVector) NullableUInt2Vector(org.apache.drill.exec.vector.NullableUInt2Vector) NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) NullableBigIntVector(org.apache.drill.exec.vector.NullableBigIntVector) NullableTimeVector(org.apache.drill.exec.vector.NullableTimeVector)

Example 2 with NullableUInt4Vector

use of org.apache.drill.exec.vector.NullableUInt4Vector in project drill by axbaretto.

the class TestValueVector method testNullableFixedType.

@Test
public void testNullableFixedType() {
    final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableUInt4Holder.TYPE);
    // Create a new value vector for 1024 integers.
    try (final NullableUInt4Vector vector = new NullableUInt4Vector(field, allocator)) {
        final NullableUInt4Vector.Mutator m = vector.getMutator();
        vector.allocateNew(1024);
        // Put and set a few values
        m.set(0, 100);
        m.set(1, 101);
        m.set(100, 102);
        m.set(1022, 103);
        m.set(1023, 104);
        final NullableUInt4Vector.Accessor accessor = vector.getAccessor();
        assertEquals(100, accessor.get(0));
        assertEquals(101, accessor.get(1));
        assertEquals(102, accessor.get(100));
        assertEquals(103, accessor.get(1022));
        assertEquals(104, accessor.get(1023));
        // Ensure null values throw
        {
            boolean b = false;
            try {
                accessor.get(3);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
        vector.allocateNew(2048);
        {
            boolean b = false;
            try {
                accessor.get(0);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
        m.set(0, 100);
        m.set(1, 101);
        m.set(100, 102);
        m.set(1022, 103);
        m.set(1023, 104);
        assertEquals(100, accessor.get(0));
        assertEquals(101, accessor.get(1));
        assertEquals(102, accessor.get(100));
        assertEquals(103, accessor.get(1022));
        assertEquals(104, accessor.get(1023));
        // Ensure null values throw.
        {
            boolean b = false;
            try {
                vector.getAccessor().get(3);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
    }
}
Also used : NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) MaterializedField(org.apache.drill.exec.record.MaterializedField) VectorTest(org.apache.drill.categories.VectorTest) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 3 with NullableUInt4Vector

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

the class ParquetPartitionDescriptor method populatePruningVector.

private void populatePruningVector(ValueVector v, int index, SchemaPath column, Path file) {
    Path path = Path.getPathWithoutSchemeAndAuthority(file);
    TypeProtos.MajorType majorType = getVectorType(column, null);
    TypeProtos.MinorType type = majorType.getMinorType();
    switch(type) {
        case BIT:
            {
                NullableBitVector bitVector = (NullableBitVector) v;
                Boolean value = groupScan.getPartitionValue(path, column, Boolean.class);
                if (value == null) {
                    bitVector.getMutator().setNull(index);
                } else {
                    bitVector.getMutator().setSafe(index, value ? 1 : 0);
                }
                return;
            }
        case INT:
            {
                NullableIntVector intVector = (NullableIntVector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case SMALLINT:
            {
                NullableSmallIntVector smallIntVector = (NullableSmallIntVector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    smallIntVector.getMutator().setNull(index);
                } else {
                    smallIntVector.getMutator().setSafe(index, value.shortValue());
                }
                return;
            }
        case TINYINT:
            {
                NullableTinyIntVector tinyIntVector = (NullableTinyIntVector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    tinyIntVector.getMutator().setNull(index);
                } else {
                    tinyIntVector.getMutator().setSafe(index, value.byteValue());
                }
                return;
            }
        case UINT1:
            {
                NullableUInt1Vector intVector = (NullableUInt1Vector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value.byteValue());
                }
                return;
            }
        case UINT2:
            {
                NullableUInt2Vector intVector = (NullableUInt2Vector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, (char) value.shortValue());
                }
                return;
            }
        case UINT4:
            {
                NullableUInt4Vector intVector = (NullableUInt4Vector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    intVector.getMutator().setNull(index);
                } else {
                    intVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case BIGINT:
            {
                NullableBigIntVector bigIntVector = (NullableBigIntVector) v;
                Long value = groupScan.getPartitionValue(path, column, Long.class);
                if (value == null) {
                    bigIntVector.getMutator().setNull(index);
                } else {
                    bigIntVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case FLOAT4:
            {
                NullableFloat4Vector float4Vector = (NullableFloat4Vector) v;
                Float value = groupScan.getPartitionValue(path, column, Float.class);
                if (value == null) {
                    float4Vector.getMutator().setNull(index);
                } else {
                    float4Vector.getMutator().setSafe(index, value);
                }
                return;
            }
        case FLOAT8:
            {
                NullableFloat8Vector float8Vector = (NullableFloat8Vector) v;
                Double value = groupScan.getPartitionValue(path, column, Double.class);
                if (value == null) {
                    float8Vector.getMutator().setNull(index);
                } else {
                    float8Vector.getMutator().setSafe(index, value);
                }
                return;
            }
        case VARBINARY:
            {
                NullableVarBinaryVector varBinaryVector = (NullableVarBinaryVector) v;
                Object s = groupScan.getPartitionValue(path, column, Object.class);
                byte[] bytes;
                if (s == null) {
                    varBinaryVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                varBinaryVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case VARDECIMAL:
            {
                NullableVarDecimalVector decimalVector = (NullableVarDecimalVector) v;
                Object s = groupScan.getPartitionValue(path, column, Object.class);
                byte[] bytes;
                if (s == null) {
                    decimalVector.getMutator().setNull(index);
                    return;
                } else if (s instanceof Integer) {
                    bytes = Ints.toByteArray((int) s);
                } else if (s instanceof Long) {
                    bytes = Longs.toByteArray((long) s);
                } else {
                    bytes = getBytes(type, s);
                }
                decimalVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case DATE:
            {
                NullableDateVector dateVector = (NullableDateVector) v;
                Long value = groupScan.getPartitionValue(path, column, Long.class);
                if (value == null) {
                    dateVector.getMutator().setNull(index);
                } else {
                    dateVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case TIME:
            {
                NullableTimeVector timeVector = (NullableTimeVector) v;
                Integer value = groupScan.getPartitionValue(path, column, Integer.class);
                if (value == null) {
                    timeVector.getMutator().setNull(index);
                } else {
                    timeVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case TIMESTAMP:
            {
                NullableTimeStampVector timeStampVector = (NullableTimeStampVector) v;
                Long value = groupScan.getPartitionValue(path, column, Long.class);
                if (value == null) {
                    timeStampVector.getMutator().setNull(index);
                } else {
                    timeStampVector.getMutator().setSafe(index, value);
                }
                return;
            }
        case VARCHAR:
            {
                NullableVarCharVector varCharVector = (NullableVarCharVector) v;
                Object s = groupScan.getPartitionValue(path, column, Object.class);
                byte[] bytes;
                if (s == null) {
                    varCharVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                varCharVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case INTERVAL:
            {
                NullableIntervalVector intervalVector = (NullableIntervalVector) v;
                Object s = groupScan.getPartitionValue(path, column, Object.class);
                byte[] bytes;
                if (s == null) {
                    intervalVector.getMutator().setNull(index);
                    return;
                } else {
                    bytes = getBytes(type, s);
                }
                intervalVector.getMutator().setSafe(index, 1, ParquetReaderUtility.getIntFromLEBytes(bytes, 0), ParquetReaderUtility.getIntFromLEBytes(bytes, 4), ParquetReaderUtility.getIntFromLEBytes(bytes, 8));
                return;
            }
        default:
            throw new UnsupportedOperationException("Unsupported type: " + type);
    }
}
Also used : NullableTinyIntVector(org.apache.drill.exec.vector.NullableTinyIntVector) NullableFloat8Vector(org.apache.drill.exec.vector.NullableFloat8Vector) NullableVarBinaryVector(org.apache.drill.exec.vector.NullableVarBinaryVector) NullableUInt1Vector(org.apache.drill.exec.vector.NullableUInt1Vector) TypeProtos(org.apache.drill.common.types.TypeProtos) NullableVarDecimalVector(org.apache.drill.exec.vector.NullableVarDecimalVector) NullableIntVector(org.apache.drill.exec.vector.NullableIntVector) NullableBitVector(org.apache.drill.exec.vector.NullableBitVector) NullableFloat4Vector(org.apache.drill.exec.vector.NullableFloat4Vector) NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) NullableIntervalVector(org.apache.drill.exec.vector.NullableIntervalVector) NullableDateVector(org.apache.drill.exec.vector.NullableDateVector) NullableTimeStampVector(org.apache.drill.exec.vector.NullableTimeStampVector) NullableSmallIntVector(org.apache.drill.exec.vector.NullableSmallIntVector) NullableUInt2Vector(org.apache.drill.exec.vector.NullableUInt2Vector) NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) NullableBigIntVector(org.apache.drill.exec.vector.NullableBigIntVector) NullableTimeVector(org.apache.drill.exec.vector.NullableTimeVector)

Example 4 with NullableUInt4Vector

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

the class TestValueVector method testNullableFixedType.

@Test
public void testNullableFixedType() {
    final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, NullableUInt4Holder.TYPE);
    // Create a new value vector for 1024 integers.
    try (final NullableUInt4Vector vector = new NullableUInt4Vector(field, allocator)) {
        final NullableUInt4Vector.Mutator m = vector.getMutator();
        vector.allocateNew(1024);
        // Put and set a few values
        m.set(0, 100);
        m.set(1, 101);
        m.set(100, 102);
        m.set(1022, 103);
        m.set(1023, 104);
        final NullableUInt4Vector.Accessor accessor = vector.getAccessor();
        assertEquals(100, accessor.get(0));
        assertEquals(101, accessor.get(1));
        assertEquals(102, accessor.get(100));
        assertEquals(103, accessor.get(1022));
        assertEquals(104, accessor.get(1023));
        // Ensure null values throw
        {
            boolean b = false;
            try {
                accessor.get(3);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
        vector.allocateNew(2048);
        {
            boolean b = false;
            try {
                accessor.get(0);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
        m.set(0, 100);
        m.set(1, 101);
        m.set(100, 102);
        m.set(1022, 103);
        m.set(1023, 104);
        assertEquals(100, accessor.get(0));
        assertEquals(101, accessor.get(1));
        assertEquals(102, accessor.get(100));
        assertEquals(103, accessor.get(1022));
        assertEquals(104, accessor.get(1023));
        // Ensure null values throw.
        {
            boolean b = false;
            try {
                vector.getAccessor().get(3);
            } catch (IllegalStateException e) {
                b = true;
            } finally {
                assertTrue(b);
            }
        }
    }
}
Also used : NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) MaterializedField(org.apache.drill.exec.record.MaterializedField) VectorTest(org.apache.drill.categories.VectorTest) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 5 with NullableUInt4Vector

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

the class ParquetGroupScan method populatePruningVector.

public void populatePruningVector(ValueVector v, int index, SchemaPath column, String file) {
    String f = Path.getPathWithoutSchemeAndAuthority(new Path(file)).toString();
    MinorType type = getTypeForColumn(column).getMinorType();
    switch(type) {
        case INT:
            {
                NullableIntVector intVector = (NullableIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                intVector.getMutator().setSafe(index, value);
                return;
            }
        case SMALLINT:
            {
                NullableSmallIntVector smallIntVector = (NullableSmallIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                smallIntVector.getMutator().setSafe(index, value.shortValue());
                return;
            }
        case TINYINT:
            {
                NullableTinyIntVector tinyIntVector = (NullableTinyIntVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                tinyIntVector.getMutator().setSafe(index, value.byteValue());
                return;
            }
        case UINT1:
            {
                NullableUInt1Vector intVector = (NullableUInt1Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                intVector.getMutator().setSafe(index, value.byteValue());
                return;
            }
        case UINT2:
            {
                NullableUInt2Vector intVector = (NullableUInt2Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                intVector.getMutator().setSafe(index, (char) value.shortValue());
                return;
            }
        case UINT4:
            {
                NullableUInt4Vector intVector = (NullableUInt4Vector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                intVector.getMutator().setSafe(index, value);
                return;
            }
        case BIGINT:
            {
                NullableBigIntVector bigIntVector = (NullableBigIntVector) v;
                Long value = (Long) partitionValueMap.get(f).get(column);
                bigIntVector.getMutator().setSafe(index, value);
                return;
            }
        case FLOAT4:
            {
                NullableFloat4Vector float4Vector = (NullableFloat4Vector) v;
                Float value = (Float) partitionValueMap.get(f).get(column);
                float4Vector.getMutator().setSafe(index, value);
                return;
            }
        case FLOAT8:
            {
                NullableFloat8Vector float8Vector = (NullableFloat8Vector) v;
                Double value = (Double) partitionValueMap.get(f).get(column);
                float8Vector.getMutator().setSafe(index, value);
                return;
            }
        case VARBINARY:
            {
                NullableVarBinaryVector varBinaryVector = (NullableVarBinaryVector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s instanceof Binary) {
                    bytes = ((Binary) s).getBytes();
                } else if (s instanceof String) {
                    bytes = ((String) s).getBytes();
                } else if (s instanceof byte[]) {
                    bytes = (byte[]) s;
                } else {
                    throw new UnsupportedOperationException("Unable to create column data for type: " + type);
                }
                varBinaryVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        case DECIMAL18:
            {
                NullableDecimal18Vector decimalVector = (NullableDecimal18Vector) v;
                Long value = (Long) partitionValueMap.get(f).get(column);
                decimalVector.getMutator().setSafe(index, value);
                return;
            }
        case DATE:
            {
                NullableDateVector dateVector = (NullableDateVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                dateVector.getMutator().setSafe(index, value * (long) DateTimeConstants.MILLIS_PER_DAY);
                return;
            }
        case TIME:
            {
                NullableTimeVector timeVector = (NullableTimeVector) v;
                Integer value = (Integer) partitionValueMap.get(f).get(column);
                timeVector.getMutator().setSafe(index, value);
                return;
            }
        case TIMESTAMP:
            {
                NullableTimeStampVector timeStampVector = (NullableTimeStampVector) v;
                Long value = (Long) partitionValueMap.get(f).get(column);
                timeStampVector.getMutator().setSafe(index, value);
                return;
            }
        case VARCHAR:
            {
                NullableVarCharVector varCharVector = (NullableVarCharVector) v;
                Object s = partitionValueMap.get(f).get(column);
                byte[] bytes;
                if (s instanceof String) {
                    // if the metadata was read from a JSON cache file it maybe a string type
                    bytes = ((String) s).getBytes();
                } else if (s instanceof Binary) {
                    bytes = ((Binary) s).getBytes();
                } else if (s instanceof byte[]) {
                    bytes = (byte[]) s;
                } else {
                    throw new UnsupportedOperationException("Unable to create column data for type: " + type);
                }
                varCharVector.getMutator().setSafe(index, bytes, 0, bytes.length);
                return;
            }
        default:
            throw new UnsupportedOperationException("Unsupported type: " + type);
    }
}
Also used : NullableTinyIntVector(org.apache.drill.exec.vector.NullableTinyIntVector) NullableFloat8Vector(org.apache.drill.exec.vector.NullableFloat8Vector) NullableVarBinaryVector(org.apache.drill.exec.vector.NullableVarBinaryVector) NullableUInt1Vector(org.apache.drill.exec.vector.NullableUInt1Vector) NullableIntVector(org.apache.drill.exec.vector.NullableIntVector) NullableFloat4Vector(org.apache.drill.exec.vector.NullableFloat4Vector) NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) NullableDecimal18Vector(org.apache.drill.exec.vector.NullableDecimal18Vector) Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) ReadEntryWithPath(org.apache.drill.exec.store.dfs.ReadEntryWithPath) NullableDateVector(org.apache.drill.exec.vector.NullableDateVector) NullableTimeStampVector(org.apache.drill.exec.vector.NullableTimeStampVector) NullableSmallIntVector(org.apache.drill.exec.vector.NullableSmallIntVector) NullableUInt2Vector(org.apache.drill.exec.vector.NullableUInt2Vector) NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) NullableBigIntVector(org.apache.drill.exec.vector.NullableBigIntVector) Binary(org.apache.parquet.io.api.Binary) NullableTimeVector(org.apache.drill.exec.vector.NullableTimeVector)

Aggregations

NullableUInt4Vector (org.apache.drill.exec.vector.NullableUInt4Vector)5 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 NullableBigIntVector (org.apache.drill.exec.vector.NullableBigIntVector)3 NullableDateVector (org.apache.drill.exec.vector.NullableDateVector)3 NullableFloat4Vector (org.apache.drill.exec.vector.NullableFloat4Vector)3 NullableFloat8Vector (org.apache.drill.exec.vector.NullableFloat8Vector)3 NullableIntVector (org.apache.drill.exec.vector.NullableIntVector)3 NullableSmallIntVector (org.apache.drill.exec.vector.NullableSmallIntVector)3 NullableTimeStampVector (org.apache.drill.exec.vector.NullableTimeStampVector)3 NullableTimeVector (org.apache.drill.exec.vector.NullableTimeVector)3 NullableTinyIntVector (org.apache.drill.exec.vector.NullableTinyIntVector)3 NullableUInt1Vector (org.apache.drill.exec.vector.NullableUInt1Vector)3 NullableUInt2Vector (org.apache.drill.exec.vector.NullableUInt2Vector)3 NullableVarBinaryVector (org.apache.drill.exec.vector.NullableVarBinaryVector)3 NullableVarCharVector (org.apache.drill.exec.vector.NullableVarCharVector)3 Path (org.apache.hadoop.fs.Path)3 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)2 VectorTest (org.apache.drill.categories.VectorTest)2 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)2 ExecTest (org.apache.drill.exec.ExecTest)2