private void writeList(ListVector arrowVector, ListColumnVector hiveVector, ListTypeInfo typeInfo, int size, VectorizedRowBatch vectorizedRowBatch, boolean isNative) { final int OFFSET_WIDTH = 4; final TypeInfo elementTypeInfo = typeInfo.getListElementTypeInfo(); final ColumnVector hiveElementVector = hiveVector.child; final FieldVector arrowElementVector = (FieldVector) arrowVector.addOrGetVector(toFieldType(elementTypeInfo)).getVector(); arrowElementVector.setInitialCapacity(hiveVector.childCount); arrowElementVector.allocateNew(); write(arrowElementVector, hiveElementVector, elementTypeInfo, hiveVector.childCount, vectorizedRowBatch, isNative); final ArrowBuf offsetBuffer = arrowVector.getOffsetBuffer(); int nextOffset = 0; for (int rowIndex = 0; rowIndex < size; rowIndex++) { if (hiveVector.isNull[rowIndex]) { offsetBuffer.setInt(rowIndex * OFFSET_WIDTH, nextOffset); } else { offsetBuffer.setInt(rowIndex * OFFSET_WIDTH, nextOffset); nextOffset += (int) hiveVector.lengths[rowIndex]; arrowVector.setNotNull(rowIndex); } } offsetBuffer.setInt(size * OFFSET_WIDTH, nextOffset); }
@Override protected void _setInt(int index, int value) { setInt(index, value); }
public void set(int index, int value) { dataBuffer.setInt(index * TYPE_WIDTH, value); }
private void setParent(int key, int value) { data.setInt(key * NODE_SIZE + OFFSET_PARENT, value); }
/** * Set the element at the given index to the given value. * * @param index position of element * @param days days for the interval * @param milliseconds milliseconds for the interval */ public void set(int index, int days, int milliseconds) { final int offsetIndex = index * TYPE_WIDTH; BitVectorHelper.setValidityBitToOne(validityBuffer, index); valueBuffer.setInt(offsetIndex, days); valueBuffer.setInt((offsetIndex + MILLISECOND_OFFSET), milliseconds); }
private void setLeft(int key, int value) { // System.out.printf("set %d.left %d\n", key, value); data.setInt(key * NODE_SIZE + OFFSET_LEFT, value); if (value != NULL) { setParent(value, key); } }
private void setRight(int key, int value) { data.setInt(key * NODE_SIZE + OFFSET_RIGHT, value); if (value != NULL) { setParent(value, key); } }
/** * End the current value. * * @param index index of the value to end * @param size number of elements in the list that was written */ public void endValue(int index, int size) { final int currentOffset = offsetBuffer.getInt((index + 1) * OFFSET_WIDTH); offsetBuffer.setInt((index + 1) * OFFSET_WIDTH, currentOffset + size); }
public void setSafe(int index, int value) { while(index >= getValueCapacity()) { reAlloc(); } dataBuffer.setInt(index * TYPE_WIDTH, value); }
protected final void setBytes(int index, byte[] value, int start, int length) { /* end offset of current last element in the vector. this will * be the start offset of new element we are trying to store. */ final int startOffset = getstartOffset(index); /* set new end offset */ offsetBuffer.setInt((index + 1) * OFFSET_WIDTH, startOffset + length); /* store the var length data in value buffer */ valueBuffer.setBytes(startOffset, value, start, length); }
public static void setOffsetHelper(final BaseRepeatedValueVector vector, final int indexToGet, final int indexToSet, final BufferAllocator vectorAllocator) { final int valueToSet = vector.offsetBuffer.getInt(indexToGet * BaseRepeatedValueVector.OFFSET_WIDTH); while (indexToSet >= getOffsetBufferValueCapacity(vector)) { reallocOffsetBuffer(vector, vectorAllocator); } vector.offsetBuffer.setInt(indexToSet * BaseRepeatedValueVector.OFFSET_WIDTH, valueToSet); }
public void copyFrom(int fromIndex, int thisIndex, UInt4Vector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, IntervalYearVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, DateDayVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, TimeMilliVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, IntVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, TimeSecVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final int value = from.valueBuffer.getInt(fromIndex * TYPE_WIDTH); valueBuffer.setInt(thisIndex * TYPE_WIDTH, value); }
public int startNewValue(int index) { while (index >= getOffsetBufferValueCapacity()) { reallocOffsetBuffer(); } int offset = offsetBuffer.getInt(index * OFFSET_WIDTH); offsetBuffer.setInt((index + 1) * OFFSET_WIDTH, offset); setValueCount(index + 1); return offset; }
@Override public void endList() { vector.getOffsetBuffer().setInt((idx() + 1) * OFFSET_WIDTH, writer.idx()); setPosition(idx() + 1); }
private RawFragmentBatch newBatch(int index) { ArrowBuf buffer = allocator.buffer(batchAllocateSize); buffer.setInt(0, index); return new RawFragmentBatch(FragmentRecordBatch.getDefaultInstance(), buffer, ackSender); }