/** * Set the variable length element at the specified index to the data * buffer supplied in the holder. * * @param index position of the element to set * @param holder holder that carries data buffer. */ public void set(int index, VarCharHolder holder) { assert index >= 0; fillHoles(index); BitVectorHelper.setValidityBitToOne(validityBuffer, index); final int dataLength = holder.end - holder.start; final int startOffset = getstartOffset(index); offsetBuffer.setInt((index + 1) * OFFSET_WIDTH, startOffset + dataLength); valueBuffer.setBytes(startOffset, holder.buffer, holder.start, dataLength); lastSet = index; }
/** * Set the variable length element at the specified index to the data * buffer supplied in the holder. * * @param index position of the element to set * @param holder holder that carries data buffer. */ public void set(int index, NullableVarCharHolder holder) { assert index >= 0; fillHoles(index); BitVectorHelper.setValidityBit(validityBuffer, index, holder.isSet); final int dataLength = holder.end - holder.start; final int startOffset = getstartOffset(index); offsetBuffer.setInt((index + 1) * OFFSET_WIDTH, startOffset + dataLength); valueBuffer.setBytes(startOffset, holder.buffer, holder.start, dataLength); lastSet = index; }
/** * 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, VarCharVector from) { final int start = from.offsetBuffer.getInt(fromIndex * OFFSET_WIDTH); final int end = from.offsetBuffer.getInt((fromIndex + 1) * OFFSET_WIDTH); final int length = end - start; fillHoles(thisIndex); BitVectorHelper.setValidityBit(this.validityBuffer, thisIndex, from.isSet(fromIndex)); final int copyStart = offsetBuffer.getInt(thisIndex * OFFSET_WIDTH); from.valueBuffer.getBytes(start, this.valueBuffer, copyStart, length); offsetBuffer.setInt((thisIndex + 1) * OFFSET_WIDTH, copyStart + length); lastSet = thisIndex; }
/** * Same as {@link #copyFrom(int, int, VarCharVector)} except that * it handles the case when the capacity of the vector needs to be expanded * before copy. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFromSafe(int fromIndex, int thisIndex, VarCharVector from) { final int start = from.offsetBuffer.getInt(fromIndex * OFFSET_WIDTH); final int end = from.offsetBuffer.getInt((fromIndex + 1) * OFFSET_WIDTH); final int length = end - start; handleSafe(thisIndex, length); fillHoles(thisIndex); BitVectorHelper.setValidityBit(this.validityBuffer, thisIndex, from.isSet(fromIndex)); final int copyStart = offsetBuffer.getInt(thisIndex * OFFSET_WIDTH); from.valueBuffer.getBytes(start, this.valueBuffer, copyStart, length); offsetBuffer.setInt((thisIndex + 1) * OFFSET_WIDTH, copyStart + length); lastSet = thisIndex; }