@Override final short getShort(int rowId) { return accessor.get(rowId); } }
private static Pair<SmallIntVector, ResultVerifier> testSmallIntVector(final int startIndexInCurrentOutput, final int startIndexInJob) { SmallIntVector colSmallIntV = new SmallIntVector("colSmallInt", allocator); colSmallIntV.allocateNew(5); colSmallIntV.set(0, 20); colSmallIntV.setNull(1); colSmallIntV.set(2, -2000); colSmallIntV.set(3, 32700); colSmallIntV.set(4, 0); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; assertEquals(20, ((Integer)output.extractValue("colSmallInt", 0)).intValue()); assertNull(output.extractValue("colSmallInt", 1)); assertEquals(-2000, ((Integer)output.extractValue("colSmallInt", 2)).intValue()); assertEquals(32700, ((Integer)output.extractValue("colSmallInt", 3)).intValue()); assertEquals(0, ((Integer)output.extractValue("colSmallInt", 4)).intValue()); } }; return Pair.of(colSmallIntV, verifier); }
/** * Same as {@link #set(int, NullableSmallIntHolder)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param holder nullable data holder for value of element */ public void setSafe(int index, NullableSmallIntHolder holder) throws IllegalArgumentException { handleSafe(index); set(index, holder); }
public void loadData(SerializedField metadata, ArrowBuf buffer) { /* clear the current buffers (if any) */ vector.clear(); /* get the metadata children */ final SerializedField bitsField = metadata.getChild(0); final SerializedField valuesField = metadata.getChild(1); final int valuesLength = buffer.capacity(); vector.allocateNew(metadata.getValueCount()); /* set inner validity buffer */ setValidityBuffer(bitsField); /* load inner value buffer */ vector.valueBuffer.close(); loadDataBuffer(valuesField, buffer.slice(0, valuesLength)); }
@Override public FieldVector getNewVector( String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { return new SmallIntVector(name, fieldType, allocator); }
@Override public void allocate() { vector.allocateNew(); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public short get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getShort(index * TYPE_WIDTH); }
public void writeNull() { vector.setNull(idx()); vector.setValueCount(idx()+1); } }
@Override public Field getField() { return vector.getField(); }
@Override public boolean isNull(int index) { return ac.isNull(index); }
public Object readObject(){ return (Object)vector.getObject(idx()); } }
@Override public void clear() { vector.clear(); }
/** * Store the given value at a particular position in the vector. isSet indicates * whether the value is NULL or not. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void set(int index, int isSet, short value) { if (isSet > 0) { set(index, value); } else { BitVectorHelper.setValidityBit(validityBuffer, index, 0); } }
/** * Same as {@link #set(int, int)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param value value of element */ public void setSafe(int index, int value) { handleSafe(index); set(index, value); }
public TransferImpl(String ref, BufferAllocator allocator) { to = new SmallIntVector(ref, field.getFieldType(), allocator); }
/** * Same as {@link #get(int)}. * * @param index position of element * @return element at given index */ public Short getObject(int index) { if (isSet(index) == 0) { return null; } else { return valueBuffer.getShort(index * TYPE_WIDTH); } }
public Field getField(){ return vector.getField(); }
public boolean isSet(){ return !vector.isNull(idx()); }