Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions java/vector/src/main/codegen/templates/FixedValueVectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ public int getBufferSizeFor(final int valueCount) {
return valueCount * ${type.width};
}

@Override
public ArrowBuf getValidityBuffer() {
/* this operation is not supported for non-nullable vectors */
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getDataBuffer() {
/* we are not throwing away getBuffer() of BaseDataValueVector so use it wherever applicable */
return getBuffer();
}

@Override
public ArrowBuf getOffsetBuffer() {
/* this operation is not supported for fixed-width vectors */
throw new UnsupportedOperationException();
}

@Override
public int getValueCapacity(){
return (int) (data.capacity() *1.0 / ${type.width});
Expand Down
33 changes: 30 additions & 3 deletions java/vector/src/main/codegen/templates/NullableValueVectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public int getBufferSizeFor(final int valueCount) {
}

public ArrowBuf getBuffer() {
return values.getBuffer();
return values.getDataBuffer();
}

@Override
Expand Down Expand Up @@ -437,23 +437,50 @@ public void copyFromSafe(int fromIndex, int thisIndex, ${className} from){

@Override
public long getValidityBufferAddress() {
return (bits.getBuffer().memoryAddress());
/* address of the databuffer associated with the bitVector */
return (bits.getDataBuffer().memoryAddress());
}

@Override
public long getDataBufferAddress() {
return (values.getBuffer().memoryAddress());
/* address of the dataBuffer associated with the valueVector */
return (values.getDataBuffer().memoryAddress());
}

@Override
public long getOffsetBufferAddress() {
/* address of the dataBuffer associated with the offsetVector
* this operation is not supported for fixed-width vector types.
*/
<#if type.major != "VarLen">
throw new UnsupportedOperationException();
<#else>
return (values.getOffsetAddr());
</#if>
}

@Override
public ArrowBuf getValidityBuffer() {
/* dataBuffer associated with the bitVector */
return (bits.getDataBuffer());
}

@Override
public ArrowBuf getDataBuffer() {
/* dataBuffer associated with the valueVector */
return (values.getDataBuffer());
}

@Override
public ArrowBuf getOffsetBuffer() {
/* dataBuffer associated with the offsetVector of the valueVector */
<#if type.major != "VarLen">
throw new UnsupportedOperationException();
<#else>
return (values.getOffsetBuffer());
</#if>
}

public final class Accessor extends BaseDataValueVector.BaseAccessor <#if type.major = "VarLen">implements VariableWidthVector.VariableWidthAccessor</#if> {
final BitVector.Accessor bAccessor = bits.getAccessor();
final ${valuesName}.Accessor vAccessor = values.getAccessor();
Expand Down
11 changes: 10 additions & 1 deletion java/vector/src/main/codegen/templates/UnionVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private <T extends FieldVector> T addOrGet(MinorType minorType, Class<T> c) {

@Override
public long getValidityBufferAddress() {
return typeVector.getBuffer().memoryAddress();
return typeVector.getDataBuffer().memoryAddress();
}

@Override
Expand All @@ -147,6 +147,15 @@ public long getOffsetBufferAddress() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getValidityBuffer() { return typeVector.getDataBuffer(); }

@Override
public ArrowBuf getDataBuffer() { throw new UnsupportedOperationException(); }

@Override
public ArrowBuf getOffsetBuffer() { throw new UnsupportedOperationException(); }

public NullableMapVector getMap() {
if (mapVector == null) {
int vectorCount = internalMap.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ public int getBufferSizeFor(final int valueCount) {
return offsetVector.getBufferSizeFor(valueCount + 1) + idx;
}

@Override
public ArrowBuf getValidityBuffer() {
/* this operation is not supported for non-nullable vectors */
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getDataBuffer() {
/* we are not throwing away getBuffer() of BaseDataValueVector so use it wherever applicable */
return getBuffer();
}

@Override
public ArrowBuf getOffsetBuffer() {
/* dataBuffer associated with the underlying offsetVector */
return offsetVector.getDataBuffer();
}

@Override
public int getValueCapacity(){
return Math.max(offsetVector.getValueCapacity() - 1, 0);
Expand Down Expand Up @@ -170,7 +188,7 @@ public ArrowBuf[] getBuffers(boolean clear) {
}

public long getOffsetAddr(){
return offsetVector.getBuffer().memoryAddress();
return offsetVector.getDataBuffer().memoryAddress();
}

public UInt${type.width}Vector getOffsetVector(){
Expand Down
18 changes: 18 additions & 0 deletions java/vector/src/main/java/org/apache/arrow/vector/BitVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ public int getBufferSizeFor(final int valueCount) {
return getSizeFromCount(valueCount);
}

@Override
public ArrowBuf getValidityBuffer() {
/* this operation is not supported for non-nullable vectors */
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getDataBuffer() {
/* we are not throwing away getBuffer() of BaseDataValueVector so use it wherever applicable */
return getBuffer();
}

@Override
public ArrowBuf getOffsetBuffer() {
/* this operation is not supported for fixed-width vectors */
throw new UnsupportedOperationException();
}

int getSizeFromCount(int valueCount) {
return (int) Math.ceil(valueCount / 8.0);
}
Expand Down
21 changes: 21 additions & 0 deletions java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,25 @@ interface Mutator {
@Deprecated
void generateTestData(int values);
}

/**
* Gets the underlying buffer associated with validity vector
*
* @return buffer
*/
public ArrowBuf getValidityBuffer();

/**
* Gets the underlying buffer associated with data vector
*
* @return buffer
*/
public ArrowBuf getDataBuffer();

/**
* Gets the underlying buffer associated with offset vector
*
* @return buffer
*/
public ArrowBuf getOffsetBuffer();
}
15 changes: 15 additions & 0 deletions java/vector/src/main/java/org/apache/arrow/vector/ZeroVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,19 @@ public long getDataBufferAddress() {
public long getOffsetBufferAddress() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getValidityBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getDataBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getOffsetBuffer() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public UnionVector promoteToUnion() {

@Override
public long getValidityBufferAddress() {
return (bits.getBuffer().memoryAddress());
return (bits.getDataBuffer().memoryAddress());
}

@Override
Expand All @@ -308,6 +308,21 @@ public long getOffsetBufferAddress() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getValidityBuffer() {
return (bits.getDataBuffer());
}

@Override
public ArrowBuf getDataBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getOffsetBuffer() {
throw new UnsupportedOperationException();
}

public class Accessor extends BaseValueVector.BaseAccessor {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public TransferPair makeTransferPair(ValueVector target) {

@Override
public long getValidityBufferAddress() {
return (bits.getBuffer().memoryAddress());
return (bits.getDataBuffer().memoryAddress());
}

@Override
Expand All @@ -190,9 +190,20 @@ public long getDataBufferAddress() {

@Override
public long getOffsetBufferAddress() {
return (offsets.getBuffer().memoryAddress());
return (offsets.getDataBuffer().memoryAddress());
}

@Override
public ArrowBuf getValidityBuffer() { return bits.getDataBuffer(); }

@Override
public ArrowBuf getDataBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getOffsetBuffer() { return offsets.getDataBuffer(); }

private class TransferImpl implements TransferPair {

ListVector to;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.google.common.collect.Ordering;
import com.google.common.primitives.Ints;

import io.netty.buffer.ArrowBuf;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.BaseValueVector;
import org.apache.arrow.vector.FieldVector;
Expand Down Expand Up @@ -129,6 +131,21 @@ public int getBufferSizeFor(final int valueCount) {
return (int) bufferSize;
}

@Override
public ArrowBuf getValidityBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getDataBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getOffsetBuffer() {
throw new UnsupportedOperationException();
}

@Override
public TransferPair getTransferPair(BufferAllocator allocator) {
return getTransferPair(name, allocator, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@ public long getOffsetBufferAddress() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getValidityBuffer() {
return bits.getDataBuffer();
}

@Override
public ArrowBuf getDataBuffer() {
throw new UnsupportedOperationException();
}

@Override
public ArrowBuf getOffsetBuffer() {
throw new UnsupportedOperationException();
}

public final class Accessor extends MapVector.Accessor {
final BitVector.Accessor bAccessor = bits.getAccessor();

Expand Down