@Override public void allocateNew() { try { offsets.allocateNew(); values.allocateNew(); } catch (OutOfMemoryException e) { clear(); throw e; } offsets.zeroVector(); mutator.reset(); }
@Override public void collectLedgers(Set<BufferLedger> ledgers) { offsets.collectLedgers(ledgers); vector.collectLedgers(ledgers); }
@Override public void startNewValue(int index) { while (offsets.getValueCapacity() <= index) { offsets.reAlloc(); } offsets.getMutator().setSafe(index+1, offsets.getAccessor().get(index)); setValueCount(index+1); }
public void copyFromSafe(int fromIndex, int thisIndex, UInt4Vector from) { while(thisIndex >= getValueCapacity()) { reAlloc(); } copyFrom(fromIndex, thisIndex, from); }
/** * Set the value of a required or nullable vector. Grows the vector as needed. * Does not enforce size limits; scalar fixed-width types can never overflow * a vector. * @param index item to write */ public void setSafe(int index, int value) { while(index >= getValueCapacity()) { reAlloc(); } set(index, value); }
protected void add(int index, Float8Holder holder) { final int nextOffset = offsets.getAccessor().get(index+1); values.getMutator().set(nextOffset, holder); offsets.getMutator().set(index+1, nextOffset+1); }
@Override public int getPayloadByteCount(int valueCount) { if (valueCount == 0) { return 0; } // If 1 or more values, then the last value is set to // the offset of the next value, which is the same as // the length of existing values. // In addition to the actual data bytes, we must also // include the "overhead" bytes: the offset vector entries // that accompany each column value. Thus, total payload // size is consumed text bytes + consumed offset vector // bytes. return offsetVector.getAccessor().get(valueCount) + offsetVector.getPayloadByteCount(valueCount); }
@Override public DrillBuf getBuffer() { return values.getBuffer(); }
public static void printOffsets(UInt4Vector vector, int start, int length) { header(vector, start, length); for (int i = start, j = 0; j < length; i++, j++) { if (j > 0) { System.out.print(" "); } System.out.print(vector.getAccessor().get(i)); } System.out.print("], addr = "); System.out.println(vector.getBuffer().addr()); }
@Override public int getValueCapacity() { return vector.getValueCapacity(); }
public void allocateNew(int valueCount, int innerValueCount) { clear(); getOffsetVector().allocateNew(valueCount + 1); getOffsetVector().getMutator().setSafe(0, 0); getMutator().reset(); }
@Override public int getPayloadByteCount(int valueCount) { // For nullable, we include all values, null or not, in computing // the value length. return bits.getPayloadByteCount(valueCount) + values.getPayloadByteCount(valueCount); }
public RepeatedMapVector(MaterializedField field, BufferAllocator allocator, CallBack callBack) { this(field, new UInt4Vector(BaseRepeatedValueVector.OFFSETS_FIELD, allocator), callBack); }
private void expandRepeatedOffsets(){ vector.getOffsetVector().reAlloc(); long diff = repeatedOffset - repeatedOffsetOriginal; loadRepeatedOffsetAddress(); repeatedOffset += diff; }
/** * Allocate a new buffer that supports setting at least the provided number of * values. May actually be sized bigger depending on underlying buffer * rounding size. Must be called prior to using the ValueVector. * * Note that the maximum number of values a vector can allocate is * Integer.MAX_VALUE / value width. * * @param valueCount * @throws OutOfMemoryException * if it can't allocate the new buffer */ @Override public void allocateNew(final int valueCount) { allocateBytes(valueCount * VALUE_WIDTH); }
/** * Add an element to the given record index. This is similar to the set() method in other * value vectors, except that it permits setting multiple values for a single record. * * @param index record of the element to add * @param value value to add to the given row */ public void add(int index, int value) { final int nextOffset = offsets.getAccessor().get(index+1); values.getMutator().set(nextOffset, value); offsets.getMutator().set(index+1, nextOffset+1); }
@Override public int getPayloadByteCount(int valueCount) { if (valueCount == 0) { return 0; } // If 1 or more values, then the last value is set to // the offset of the next value, which is the same as // the length of existing values. // In addition to the actual data bytes, we must also // include the "overhead" bytes: the offset vector entries // that accompany each column value. Thus, total payload // size is consumed text bytes + consumed offset vector // bytes. return offsetVector.getAccessor().get(valueCount) + offsetVector.getPayloadByteCount(valueCount); }
public void setSafe(int index, UInt4Holder holder) { while(index >= getValueCapacity()) { reAlloc(); } set(index, holder); }
public void copyFromSafe(int fromIndex, int thisIndex, UInt4Vector from) { while(thisIndex >= getValueCapacity()) { reAlloc(); } copyFrom(fromIndex, thisIndex, from); }
public long getOffsetAddr(){ return offsetVector.getBuffer().memoryAddress(); }