@Override public void writeField(Object pojo, int outboundIndex) throws IllegalArgumentException, IllegalAccessException { Long o = (Long) field.get(pojo); if (o != null) { vector.setSafe(outboundIndex, o); } } }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final long value = (long) ((LongObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue); ((BigIntVector) outputVV).setSafe(outputIndex, value); } }
@Override public void set(ValueVector v, int index) { if(obj != null){ ((BigIntVector) v).setSafe(index, obj); } }
public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((BigIntVector) vector).setSafe(i, value); } } vector.setValueCount(count); }
@Override protected void readField(long recordsToReadInThisPass) { if (usingDictionary) { for (int i = 0; i < recordsToReadInThisPass; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.dictionaryValueReader.readLong()); } } else { for (int i = 0; i < recordsToReadInThisPass; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.valueReader.readLong()); } } } }
public void write(NullableBigIntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void write(BigIntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeBigInt(long value) { vector.setSafe(idx(), 1, value); vector.setValueCount(idx()+1); }
static Long[] populate8ByteValues(BigIntVector vector, int size){ vector.allocateNew(); Long values[] = new Long[size]; for(int i = 0; i < values.length; i++){ if (RAND.nextBoolean()) { values[i] = RAND.nextLong(); vector.setSafe(i, values[i]); } } vector.setValueCount(values.length); return values; }
static Long[] populate8ByteValuesWithoutNull(BigIntVector vector, int size){ vector.allocateNew(); Long values[] = new Long[size]; for(int i = 0; i < values.length; i++){ values[i] = RAND.nextLong(); vector.setSafe(i, values[i]); } vector.setValueCount(values.length); return values; }
/** * Method is invoked when we have a straight aggregate (no group by expression) and our input is empty. * In this case we construct an outgoing batch with record count as 1. For the nullable vectors we don't set anything * as we want the output to be NULL. For the required vectors (only for count()) we set the value to be zero since * we don't zero out our buffers initially while allocating them. */ private void constructSpecialBatch() { outgoing.allocateNew(); List<NamedExpression> exprs = config.getExprs(); if(outgoing.getNumberOfColumns() != exprs.size()){ throw new IllegalStateException(); } int exprIndex = 0; for (final VectorWrapper<?> vw: outgoing) { final ValueVector vv = vw.getValueVector(); if (!exprs.isEmpty() && isCount(exprs.get(exprIndex))) { ((BigIntVector) vv).setSafe(0, 0); } vv.setValueCount(SPECIAL_BATCH_COUNT); exprIndex++; } outgoing.setRecordCount(SPECIAL_BATCH_COUNT); }
@Override protected void readField(long recordsToReadInThisPass) { recordsReadInThisIteration = Math.min(pageReader.currentPageCount - pageReader.valuesRead, recordsToReadInThisPass - valuesReadInCurrentPass); if (usingDictionary) { for (int i = 0; i < recordsReadInThisIteration; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.dictionaryValueReader.readLong()); } // Set the write Index. The next page that gets read might be a page that does not use dictionary encoding // and we will go into the else condition below. The readField method of the parent class requires the // writer index to be set correctly. readLengthInBits = recordsReadInThisIteration * dataTypeLengthInBits; readLength = (int) Math.ceil(readLengthInBits / 8.0); int writerIndex = valueVec.getDataBuffer().writerIndex(); valueVec.getDataBuffer().setIndex(0, writerIndex + (int)readLength); } else { super.readField(recordsToReadInThisPass); } } }
@Override protected void generateRecord(long globalRecordIndex, int outputIndex) { nationKey.setSafe(outputIndex, globalRecordIndex); byte[] nameVal = nations.getValue((int) globalRecordIndex).getBytes(Charsets.UTF_8); name.setSafe(outputIndex, nameVal, 0, nameVal.length); regionKey.setSafe(outputIndex, nations.getWeight((int) globalRecordIndex)); // comment byte[] commentVal = commentRandom.nextValue().getBytes(Charsets.UTF_8); comment.setSafe(outputIndex, commentVal, 0, commentVal.length); }
@Override protected void generateRecord(long globalRecordIndex, int outputIndex) { regionKey.setSafe(outputIndex, globalRecordIndex); byte[] nameVal = regions.getValue((int) globalRecordIndex).getBytes(Charsets.UTF_8); name.setSafe(outputIndex, nameVal, 0, nameVal.length); // comment byte[] commentVal = commentRandom.nextValue().getBytes(Charsets.UTF_8); comment.setSafe(outputIndex, commentVal, 0, commentVal.length); }
/** * * @param allocator * @param name * @param data * @return */ public static BigIntVector vectorFor(BufferAllocator allocator,String name,long[] data) { BigIntVector float8Vector = new BigIntVector(name,FieldType.nullable(new ArrowType.Int(64,true)),allocator); float8Vector.allocateNew(data.length); for(int i = 0; i < data.length; i++) { float8Vector.setSafe(i,data[i]); } float8Vector.setValueCount(data.length); return float8Vector; }
private static VectorContainer buildLongGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.Int(64, true), null); final VectorContainer input = new VectorContainer(bufferAllocator); final BigIntVector longVector = input.addOrGet(field); longVector.allocateNew(); SortedSet<Long> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToLong(i)); } } if (existingDict != null) { final BigIntVector existingDictValues = existingDict.getValueAccessorById(BigIntVector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Long> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { longVector.setSafe(recordCount++, iter.next()); } longVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
@Override public int next(int records) { if (position == fixKeyValues1.length) { return 0; } records = Math.min(records, fixKeyValues1.length - position); container.allocateNew(); for (int i = 0; i < records; i++) { final int absoluteRecordIndex = position + i; fixkey1.setSafe(i, fixKeyValues1[absoluteRecordIndex]); fixkey2.setSafe(i, fixKeyValues2[absoluteRecordIndex]); byte[] valueBytes = varKeyValues1[absoluteRecordIndex].getBytes(); varkey1.setSafe(i, valueBytes, 0, valueBytes.length); m1.setSafe(i, measure1[absoluteRecordIndex]); m2.setSafe(i, measure2[absoluteRecordIndex]); m3.setSafe(i, measure3[absoluteRecordIndex]); m4.setSafe(i, measure4[absoluteRecordIndex]); } container.setAllCount(records); position += records; return records; }
protected void generateRecord(long globalRecordIndex, int outputIndex){ final long customerKey = globalRecordIndex; final long nationKey = nationKeyRandom.nextValue(); this.customerKey.setSafe(outputIndex, customerKey); this.nationKey.setSafe(outputIndex, nationKey); this.accountBalance.setSafe(outputIndex, accountBalanceRandom.nextValue()); set(outputIndex, customerName, String.format(ENGLISH, "Customer#%09d", customerKey)); set(outputIndex, address, addressRandom.nextValue()); set(outputIndex, phone, phoneRandom.nextValue(nationKey)); set(outputIndex, marketSegment, marketSegmentRandom.nextValue()); set(outputIndex, comment, commentRandom.nextValue()); set(outputIndex, date, LocalDate.of(yearRandom.nextValue(),1,1).toString()); }