private void readList(FieldVector arrowVector, ListColumnVector hiveVector, ListTypeInfo typeInfo) { final int size = arrowVector.getValueCount(); final ArrowBuf offsets = arrowVector.getOffsetBuffer(); final int OFFSET_WIDTH = 4; read(arrowVector.getChildrenFromFields().get(0), hiveVector.child, typeInfo.getListElementTypeInfo()); for (int i = 0; i < size; i++) { if (arrowVector.isNull(i)) { VectorizedBatchUtil.setNullColIsNullValue(hiveVector, i); } else { hiveVector.isNull[i] = false; final int offset = offsets.getInt(i * OFFSET_WIDTH); hiveVector.offsets[i] = offset; hiveVector.lengths[i] = offsets.getInt((i + 1) * OFFSET_WIDTH) - offset; } } }
/** * Get the density of this ListVector. * @return density */ public double getDensity() { if (valueCount == 0) { return 0.0D; } final int startOffset = offsetBuffer.getInt(0); final int endOffset = offsetBuffer.getInt(valueCount * OFFSET_WIDTH); final double totalListSize = endOffset - startOffset; return totalListSize / valueCount; }
private void print() { StringBuilder b = new StringBuilder(); b.append("root: " + root + "\n"); for (int i = 0; i < totalCount; i++) { b.append(i + "\t"); b.append(data.getInt(i*NODE_SIZE) + "\t"); b.append(data.getInt(i*NODE_SIZE + OFFSET_PARENT) + "\t"); b.append(data.getInt(i*NODE_SIZE + OFFSET_LEFT) + "\t"); b.append(data.getInt(i*NODE_SIZE + OFFSET_RIGHT) + "\t"); b.append("\n"); } // System.out.println(b); }
private StringBuilder getAsStringBuilderHelper(int index) { int value = valueBuffer.getInt(index * TYPE_WIDTH); final int years = (value / org.apache.arrow.vector.util.DateUtility.yearsToMonths); final int months = (value % org.apache.arrow.vector.util.DateUtility.yearsToMonths); final String yearString = (Math.abs(years) == 1) ? " year " : " years "; final String monthString = (Math.abs(months) == 1) ? " month " : " months "; return (new StringBuilder() .append(years) .append(yearString) .append(months) .append(monthString)); }
/** * 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); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public int get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getInt(index * TYPE_WIDTH); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public int get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getInt(index * TYPE_WIDTH); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public int get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getInt(index * TYPE_WIDTH); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public int get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getInt(index * TYPE_WIDTH); }
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); }
/** * 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); }
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); }
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 startList() { vector.startNewValue(idx()); writer.setPosition(vector.getOffsetBuffer().getInt((idx() + 1) * OFFSET_WIDTH)); }
private void checkBatch(RawFragmentBatch checkBatch, int batchIdx) { assertEquals(batchAllocateSize, checkBatch.getBody().capacity()); assertEquals(batchIdx, checkBatch.getBody().getInt(0)); } }