本文整理汇总了Java中org.apache.drill.exec.vector.NullableIntVector类的典型用法代码示例。如果您正苦于以下问题:Java NullableIntVector类的具体用法?Java NullableIntVector怎么用?Java NullableIntVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NullableIntVector类属于org.apache.drill.exec.vector包,在下文中一共展示了NullableIntVector类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCopier
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
private Copier<?> getCopier(int jdbcType, int offset, ResultSet result, ValueVector v) {
if (v instanceof NullableBigIntVector) {
return new BigIntCopier(offset, result, (NullableBigIntVector.Mutator) v.getMutator());
} else if (v instanceof NullableFloat4Vector) {
return new Float4Copier(offset, result, (NullableFloat4Vector.Mutator) v.getMutator());
} else if (v instanceof NullableFloat8Vector) {
return new Float8Copier(offset, result, (NullableFloat8Vector.Mutator) v.getMutator());
} else if (v instanceof NullableIntVector) {
return new IntCopier(offset, result, (NullableIntVector.Mutator) v.getMutator());
} else if (v instanceof NullableVarCharVector) {
return new VarCharCopier(offset, result, (NullableVarCharVector.Mutator) v.getMutator());
} else if (v instanceof NullableVarBinaryVector) {
return new VarBinaryCopier(offset, result, (NullableVarBinaryVector.Mutator) v.getMutator());
} else if (v instanceof NullableDateVector) {
return new DateCopier(offset, result, (NullableDateVector.Mutator) v.getMutator());
} else if (v instanceof NullableTimeVector) {
return new TimeCopier(offset, result, (NullableTimeVector.Mutator) v.getMutator());
} else if (v instanceof NullableTimeStampVector) {
return new TimeStampCopier(offset, result, (NullableTimeStampVector.Mutator) v.getMutator());
} else if (v instanceof NullableBitVector) {
return new BitCopier(offset, result, (NullableBitVector.Mutator) v.getMutator());
}
throw new IllegalArgumentException("Unknown how to handle vector.");
}
示例2: testNullableFixedVector
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@Test
public void testNullableFixedVector() {
@SuppressWarnings("resource")
NullableIntVector vector = new NullableIntVector(makeField(MinorType.INT, DataMode.OPTIONAL), fixture.allocator() );
vector.allocateNew( );
NullableIntVector.Mutator mutator = vector.getMutator();
for (int i = 0; i < 2 * ValueVector.MAX_ROW_COUNT; i++) {
try {
mutator.setScalar(i, i);
} catch (VectorOverflowException e) {
assertEquals(IntVector.MAX_SCALAR_COUNT, i);
break;
}
}
vector.close();
}
示例3: doTest
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@Override
public void doTest() {
try (NullableIntVector vector = new NullableIntVector(rowSchema.column(0), fixture.allocator());) {
vector.allocateNew(ROW_COUNT);
NullableScalarWriter colWriter = new NullableScalarWriter(
vector, new IntColumnWriter(vector.getValuesVector()));
TestWriterIndex index = new TestWriterIndex();
colWriter.bindIndex(index);
colWriter.startWrite();
timer.start();
while (index.index < ROW_COUNT) {
colWriter.setInt(1234);
}
timer.stop();
colWriter.endWrite();
}
}
示例4: createNonExistentColumns
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
/**
* Create "dummy" fields for columns which are selected in the SELECT clause, but not
* present in the Parquet schema.
* @param output the output container
* @throws SchemaChangeException should not occur
*/
public void createNonExistentColumns(OutputMutator output, List<NullableIntVector> nullFilledVectors) throws SchemaChangeException {
List<SchemaPath> projectedColumns = Lists.newArrayList(selectedCols);
for (int i = 0; i < columnsFound.length; i++) {
SchemaPath col = projectedColumns.get(i);
assert col != null;
if ( ! columnsFound[i] && ! col.equals(Utilities.STAR_COLUMN)) {
nullFilledVectors.add(createMissingColumn(col, output));
}
}
}
示例5: testFixedWidth
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@SuppressWarnings("resource")
@Test
public void testFixedWidth() {
MaterializedField intSchema =
SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.REQUIRED);
IntVector intVector = new IntVector(intSchema, fixture.allocator());
IntVector.Mutator intMutator = intVector.getMutator();
intVector.allocateNew(100);
for (int i = 0; i < 100; i++) {
intMutator.set(i, i * 10);
}
intMutator.setValueCount(100);
MaterializedField nullableIntSchema =
SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.OPTIONAL);
NullableIntVector nullableIntVector = new NullableIntVector(nullableIntSchema, fixture.allocator());
intVector.toNullable(nullableIntVector);
assertEquals(0, intVector.getAccessor().getValueCount());
NullableIntVector.Accessor niAccessor = nullableIntVector.getAccessor();
assertEquals(100, niAccessor.getValueCount());
for (int i = 0; i < 100; i++) {
assertFalse(niAccessor.isNull(i));
assertEquals(i * 10, niAccessor.get(i));
}
nullableIntVector.clear();
// Don't clear the intVector, it should be empty.
// If it is not, the test will fail with a memory leak error.
}
示例6: testNullable
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@SuppressWarnings("resource")
@Test
public void testNullable() {
MaterializedField nullableIntSchema =
SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.OPTIONAL);
NullableIntVector sourceVector = new NullableIntVector(nullableIntSchema, fixture.allocator());
NullableIntVector.Mutator sourceMutator = sourceVector.getMutator();
sourceVector.allocateNew(100);
for (int i = 0; i < 100; i++) {
sourceMutator.set(i, i * 10);
}
sourceMutator.setValueCount(100);
NullableIntVector destVector = new NullableIntVector(nullableIntSchema, fixture.allocator());
sourceVector.toNullable(destVector);
assertEquals(0, sourceVector.getAccessor().getValueCount());
NullableIntVector.Accessor destAccessor = destVector.getAccessor();
assertEquals(100, destAccessor.getValueCount());
for (int i = 0; i < 100; i++) {
assertFalse(destAccessor.isNull(i));
assertEquals(i * 10, destAccessor.get(i));
}
destVector.clear();
// Don't clear the intVector, it should be empty.
// If it is not, the test will fail with a memory leak error.
}
示例7: NullableDictionaryIntReader
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
NullableDictionaryIntReader(ParquetRecordReader parentReader, int allocateSize, ColumnDescriptor descriptor,
ColumnChunkMetaData columnChunkMetaData, boolean fixedLength, NullableIntVector v,
SchemaElement schemaElement) throws ExecutionSetupException {
super(parentReader, allocateSize, descriptor, columnChunkMetaData, fixedLength, v, schemaElement);
}
示例8: getNullableColumnReader
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
public static NullableColumnReader getNullableColumnReader(ParquetRecordReader parentReader, int allocateSize,
ColumnDescriptor columnDescriptor,
ColumnChunkMetaData columnChunkMetaData,
boolean fixedLength,
ValueVector valueVec,
SchemaElement schemaElement) throws ExecutionSetupException {
ConvertedType convertedType = schemaElement.getConverted_type();
if (! columnChunkMetaData.getEncodings().contains(Encoding.PLAIN_DICTIONARY)) {
if (columnDescriptor.getType() == PrimitiveType.PrimitiveTypeName.INT96) {
return new NullableFixedByteAlignedReaders.NullableFixedBinaryReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableVarBinaryVector) valueVec, schemaElement);
}else{
return new NullableFixedByteAlignedReaders.NullableFixedByteAlignedReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, valueVec, schemaElement);
}
} else {
switch (columnDescriptor.getType()) {
case INT32:
if (convertedType == null) {
return new NullableFixedByteAlignedReaders.NullableDictionaryIntReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableIntVector) valueVec, schemaElement);
}
switch (convertedType) {
case DECIMAL:
return new NullableFixedByteAlignedReaders.NullableDictionaryDecimal9Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableDecimal9Vector) valueVec, schemaElement);
case TIME_MILLIS:
return new NullableFixedByteAlignedReaders.NullableDictionaryTimeReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableTimeVector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable converted type " + convertedType + " for primitive type INT32");
}
case INT64:
if (convertedType == null) {
return new NullableFixedByteAlignedReaders.NullableDictionaryBigIntReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableBigIntVector)valueVec, schemaElement);
}
switch (convertedType) {
case DECIMAL:
return new NullableFixedByteAlignedReaders.NullableDictionaryDecimal18Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableDecimal18Vector)valueVec, schemaElement);
case TIMESTAMP_MILLIS:
return new NullableFixedByteAlignedReaders.NullableDictionaryTimeStampReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableTimeStampVector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable converted type " + convertedType + " for primitive type INT64");
}
case INT96:
return new NullableFixedByteAlignedReaders.NullableFixedBinaryReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableVarBinaryVector) valueVec, schemaElement);
case FLOAT:
return new NullableFixedByteAlignedReaders.NullableDictionaryFloat4Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableFloat4Vector)valueVec, schemaElement);
case DOUBLE:
return new NullableFixedByteAlignedReaders.NullableDictionaryFloat8Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableFloat8Vector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable column type " + columnDescriptor.getType().name() );
}
}
}
示例9: IntCopier
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
public IntCopier(int offset, ResultSet set, NullableIntVector.Mutator mutator) {
super(offset, set, mutator);
}
示例10: setSafeValue
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@Override
public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) {
final int value = (int) ((IntObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue);
((NullableIntVector) outputVV).getMutator().setSafe(outputIndex, value);
}
示例11: testUDF
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
@Test
public void testUDF() throws Throwable {
int numRecords = 0;
String planString = Resources.toString(Resources.getResource("functions/hive/UDF.json"), Charsets.UTF_8);
List<QueryDataBatch> results = testPhysicalWithResults(planString);
RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator());
for (QueryDataBatch result : results) {
batchLoader.load(result.getHeader().getDef(), result.getData());
if (batchLoader.getRecordCount() <= 0) {
result.release();
batchLoader.clear();
continue;
}
// Output columns and types
// 1. str1 : Var16Char
// 2. str1Length : Int
// 3. str1Ascii : Int
// 4. flt1 : Float4
// 5. pow : Float8
Var16CharVector str1V = (Var16CharVector) batchLoader.getValueAccessorById(Var16CharVector.class, 0).getValueVector();
NullableIntVector str1LengthV = (NullableIntVector) batchLoader.getValueAccessorById(NullableIntVector.class, 1).getValueVector();
NullableIntVector str1AsciiV = (NullableIntVector) batchLoader.getValueAccessorById(NullableIntVector.class, 2).getValueVector();
Float4Vector flt1V = (Float4Vector) batchLoader.getValueAccessorById(Float4Vector.class, 3).getValueVector();
NullableFloat8Vector powV = (NullableFloat8Vector) batchLoader.getValueAccessorById(NullableFloat8Vector.class, 4).getValueVector();
for (int i=0; i<batchLoader.getRecordCount(); i++) {
String str1 = new String(str1V.getAccessor().get(i), Charsets.UTF_16);
int str1Length = str1LengthV.getAccessor().get(i);
assertTrue(str1.length() == str1Length);
int str1Ascii = str1AsciiV.getAccessor().get(i);
float flt1 = flt1V.getAccessor().get(i);
double pow = 0;
if (!powV.getAccessor().isNull(i)) {
pow = powV.getAccessor().get(i);
assertTrue(Math.pow(flt1, 2.0) == pow);
}
System.out.println(str1 + ", " + str1Length + ", " + str1Ascii + ", " + flt1 + ", " + pow);
numRecords++;
}
result.release();
batchLoader.clear();
}
System.out.println("Processed " + numRecords + " records");
}
示例12: setIntegerColumnValue
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
private void setIntegerColumnValue(final int data, final ProjectedColumnInfo pci, final int count) {
((NullableIntVector.Mutator) pci.vv.getMutator())
.setSafe(count, data);
}
示例13: getNullableColumnReader
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
public static NullableColumnReader<?> getNullableColumnReader(ParquetRecordReader parentReader, int allocateSize,
ColumnDescriptor columnDescriptor,
ColumnChunkMetaData columnChunkMetaData,
boolean fixedLength,
ValueVector valueVec,
SchemaElement schemaElement) throws ExecutionSetupException {
ConvertedType convertedType = schemaElement.getConverted_type();
if (! columnChunkMetaData.getEncodings().contains(Encoding.PLAIN_DICTIONARY)) {
if (columnDescriptor.getType() == PrimitiveType.PrimitiveTypeName.INT96) {
// TODO: check convertedType once parquet support TIMESTAMP_NANOS type annotation.
if (parentReader.getFragmentContext().getOptions().getOption(ExecConstants.PARQUET_READER_INT96_AS_TIMESTAMP).bool_val) {
return new NullableFixedByteAlignedReaders.NullableFixedBinaryAsTimeStampReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableTimeStampVector) valueVec, schemaElement);
} else {
return new NullableFixedByteAlignedReaders.NullableFixedBinaryReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableVarBinaryVector) valueVec, schemaElement);
}
}else{
return new NullableFixedByteAlignedReaders.NullableFixedByteAlignedReader<>(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, valueVec, schemaElement);
}
} else {
switch (columnDescriptor.getType()) {
case INT32:
if (convertedType == null) {
return new NullableFixedByteAlignedReaders.NullableDictionaryIntReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableIntVector) valueVec, schemaElement);
}
switch (convertedType) {
case DECIMAL:
return new NullableFixedByteAlignedReaders.NullableDictionaryDecimal9Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableDecimal9Vector) valueVec, schemaElement);
case TIME_MILLIS:
return new NullableFixedByteAlignedReaders.NullableDictionaryTimeReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableTimeVector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable converted type " + convertedType + " for primitive type INT32");
}
case INT64:
if (convertedType == null) {
return new NullableFixedByteAlignedReaders.NullableDictionaryBigIntReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableBigIntVector)valueVec, schemaElement);
}
switch (convertedType) {
case DECIMAL:
return new NullableFixedByteAlignedReaders.NullableDictionaryDecimal18Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableDecimal18Vector)valueVec, schemaElement);
case TIMESTAMP_MILLIS:
return new NullableFixedByteAlignedReaders.NullableDictionaryTimeStampReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableTimeStampVector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable converted type " + convertedType + " for primitive type INT64");
}
case INT96:
// TODO: check convertedType once parquet support TIMESTAMP_NANOS type annotation.
if (parentReader.getFragmentContext().getOptions().getOption(ExecConstants.PARQUET_READER_INT96_AS_TIMESTAMP).bool_val) {
return new NullableFixedByteAlignedReaders.NullableFixedBinaryAsTimeStampReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableTimeStampVector) valueVec, schemaElement);
} else {
return new NullableFixedByteAlignedReaders.NullableFixedBinaryReader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, true, (NullableVarBinaryVector) valueVec, schemaElement);
}
case FLOAT:
return new NullableFixedByteAlignedReaders.NullableDictionaryFloat4Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableFloat4Vector)valueVec, schemaElement);
case DOUBLE:
return new NullableFixedByteAlignedReaders.NullableDictionaryFloat8Reader(parentReader, allocateSize, columnDescriptor, columnChunkMetaData, fixedLength, (NullableFloat8Vector)valueVec, schemaElement);
default:
throw new ExecutionSetupException("Unsupported nullable column type " + columnDescriptor.getType().name() );
}
}
}
示例14: createMissingColumn
import org.apache.drill.exec.vector.NullableIntVector; //导入依赖的package包/类
/**
* Create a "dummy" column for a missing field. The column is of type optional
* int, but will always be null.
*
* @param col the selected, but non-existent, schema path
* @param output the output container
* @return the value vector for the field
* @throws SchemaChangeException should not occur
*/
private NullableIntVector createMissingColumn(SchemaPath col, OutputMutator output) throws SchemaChangeException {
// col.toExpr() is used here as field name since we don't want to see these fields in the existing maps
MaterializedField field = MaterializedField.create(col.toExpr(),
Types.optional(TypeProtos.MinorType.INT));
return (NullableIntVector) output.addField(field,
TypeHelper.getValueVectorClass(TypeProtos.MinorType.INT, DataMode.OPTIONAL));
}