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
6 changes: 3 additions & 3 deletions java/vector/src/main/codegen/templates/ComplexWriters.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ protected int idx() {

public void write(${minor.class?cap_first}Holder h) {
mutator.addSafe(idx(), h);
vector.getMutator().setValueCount(idx()+1);
vector.setValueCount(idx()+1);
}

public void write(${minor.class?cap_first}Holder h) {
mutator.addSafe(idx(), h);
vector.getMutator().setValueCount(idx()+1);
vector.setValueCount(idx()+1);
}

public void write${minor.class}(<#list fields as field>${field.type} ${field.name}<#if field_has_next>, </#if></#list>) {
mutator.addSafe(idx(), <#list fields as field>${field.name}<#if field_has_next>, </#if></#list>);
vector.getMutator().setValueCount(idx()+1);
vector.setValueCount(idx()+1);
}

public void setPosition(int idx) {
Expand Down
12 changes: 0 additions & 12 deletions java/vector/src/main/codegen/templates/UnionVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,6 @@ public void copyValueSafe(int from, int to) {
}
}

@Override
@Deprecated
public Accessor getAccessor() {
throw new UnsupportedOperationException("Accessor is not supported for reading from UNION");
}

@Override
@Deprecated
public Mutator getMutator() {
throw new UnsupportedOperationException("Mutator is not supported for writing to UNION");
}

@Override
public FieldReader getReader() {
if (reader == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ArrowBuf[] getBuffers(boolean clear) {

@Override
public int getBufferSize() {
if (getAccessor().getValueCount() == 0) {
if (getValueCount() == 0) {
return 0;
}
return data.writerIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,6 @@ public BaseFixedWidthVector(final String name, final BufferAllocator allocator,
* the top class as of now is not a good idea.
*/


@Override
@Deprecated
public Mutator getMutator() {
throw new UnsupportedOperationException("Mutator is not supported for writing to vector");
}

@Override
@Deprecated
public Accessor getAccessor() {
throw new UnsupportedOperationException("Accessor is not supported for reading from vector");
}

/**
* Get the memory address of buffer that manages the validity
* (NULL or NON-NULL nature) of elements in the vector.
Expand Down Expand Up @@ -711,6 +698,7 @@ private void splitAndTransferValidityBuffer(int startIndex, int length,
*
* @return the number of null elements.
*/
@Override
public int getNullCount() {
return BitVectorHelper.getNullCount(validityBuffer, valueCount);
}
Expand All @@ -721,6 +709,7 @@ public int getNullCount() {
*
* @return valueCount for the vector
*/
@Override
public int getValueCount() {
return valueCount;
}
Expand All @@ -730,6 +719,7 @@ public int getValueCount() {
*
* @param valueCount value count to set
*/
@Override
public void setValueCount(int valueCount) {
this.valueCount = valueCount;
final int currentValueCapacity = getValueCapacity();
Expand Down Expand Up @@ -789,6 +779,7 @@ public boolean isSafe(int index) {
* @param index position of element
* @return true if element at given index is null, false otherwise
*/
@Override
public boolean isNull(int index) {
return (isSet(index) == 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,42 +68,6 @@ public TransferPair getTransferPair(BufferAllocator allocator) {
return getTransferPair(name, allocator);
}

public abstract static class BaseAccessor implements ValueVector.Accessor {
protected BaseAccessor() {
}

@Override
public boolean isNull(int index) {
return false;
}

@Override
// override this in case your implementation is faster, see BitVector
public int getNullCount() {
int nullCount = 0;
for (int i = 0; i < getValueCount(); i++) {
if (isNull(i)) {
nullCount++;
}
}
return nullCount;
}
}

public abstract static class BaseMutator implements ValueVector.Mutator {
protected BaseMutator() {
}

@Override
public void generateTestData(int values) {
}

//TODO: consider making mutator stateless(if possible) on another issue.
@Override
public void reset() {
}
}

@Override
public Iterator<ValueVector> iterator() {
return Collections.emptyIterator();
Expand Down Expand Up @@ -136,33 +100,6 @@ protected ArrowBuf releaseBuffer(ArrowBuf buffer) {
return buffer;
}

@Override
public int getValueCount() {
return getAccessor().getValueCount();
}

@Override
public void setValueCount(int valueCount) {
getMutator().setValueCount(valueCount);
}

@Override

public Object getObject(int index) {
return getAccessor().getObject(index);
}

@Override

public int getNullCount() {
return getAccessor().getNullCount();
}

@Override
public boolean isNull(int index) {
return getAccessor().isNull(index);
}

/* number of bytes for the validity buffer for the given valueCount */
protected static int getValidityBufferSizeFromCount(final int valueCount) {
return (int) Math.ceil(valueCount / 8.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ public BaseVariableWidthVector(final String name, final BufferAllocator allocato
* the top class as of now is not a good idea.
*/

@Override
@Deprecated
public VariableWidthMutator getMutator() {
throw new UnsupportedOperationException("Mutator is not supported for writing into vector");
}

@Override
@Deprecated
public VariableWidthAccessor getAccessor() {
throw new UnsupportedOperationException("Accessor is not supported for reading from vector");
}

/**
* Get buffer that manages the validity (NULL or NON-NULL nature) of
* elements in the vector. Consider it as a buffer for internal bit vector
Expand Down
107 changes: 30 additions & 77 deletions java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,6 @@ public interface ValueVector extends Closeable, Iterable<ValueVector> {
*/
TransferPair makeTransferPair(ValueVector target);

/**
* @return an {@link org.apache.arrow.vector.ValueVector.Accessor accessor} that is used to read from this vector
* instance.
*/
Accessor getAccessor();

/**
* @return an {@link org.apache.arrow.vector.ValueVector.Mutator mutator} that is used to write to this vector
* instance.
*/
Mutator getMutator();

/**
* @return a {@link org.apache.arrow.vector.complex.reader.FieldReader field reader} that supports reading values
* from this vector.
Expand All @@ -160,7 +148,7 @@ public interface ValueVector extends Closeable, Iterable<ValueVector> {

/**
* Returns the number of bytes that is used by this vector if it holds the given number
* of values. The result will be the same as if Mutator.setValueCount() were called, followed
* of values. The result will be the same as if setValueCount() were called, followed
* by calling getBufferSize(), but without any of the closing side-effects that setValueCount()
* implies wrt finishing off the population of a vector. Some operations might wish to use
* this to determine how much memory has been used by a vector so far, even though it is
Expand All @@ -182,91 +170,56 @@ public interface ValueVector extends Closeable, Iterable<ValueVector> {
*/
ArrowBuf[] getBuffers(boolean clear);

/**
* An abstraction that is used to read from this vector instance.
*/
interface Accessor {
/**
* Get the Java Object representation of the element at the specified position. Useful for testing.
*
* @param index Index of the value to get
* @return the friendly java type
*/
Object getObject(int index);

/**
* @return the number of values that is stored in this vector.
*/
int getValueCount();

/**
* @param index the index to check for nullity
* @return true if the value at the given index is null, false otherwise.
*/
boolean isNull(int index);

/**
* @return the number of null values
*/
int getNullCount();
}

/**
* An abstraction that is used to write into this vector instance.
*/
interface Mutator {
/**
* Sets the number of values that is stored in this vector to the given value count.
*
* @param valueCount value count to set.
*/
void setValueCount(int valueCount);

/**
* Resets the mutator to pristine state.
*/
void reset();

/**
* @param values the number of values to generate
* @deprecated this has nothing to do with value vector abstraction and should be removed.
*/
@Deprecated
void generateTestData(int values);
}

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

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

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

/* temporarily add these methods here until we remove other vectors
* (non-nullable) which are under ValueVector hierarchy and still
* use the mutator/accessor interfaces.
/**
* Gets the number of values
* @return
*/
public int getValueCount();
int getValueCount();

public void setValueCount(int valueCount);
/**
* Set number of values in the vector
* @return
*/
void setValueCount(int valueCount);

public Object getObject(int index);
/**
* Get friendly type object from the vector
* @param index
* @return
*/
Object getObject(int index);

public int getNullCount();
/**
* Returns number of null elements in the vector
* @return
*/
int getNullCount();

public boolean isNull(int index);
/**
* Check whether an element in the vector is null
* @param index
* @return
*/
boolean isNull(int index);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,5 @@ public interface VariableWidthVector extends ValueVector {
*/
int getByteCapacity();

VariableWidthMutator getMutator();

VariableWidthAccessor getAccessor();

interface VariableWidthAccessor extends Accessor {
int getValueLength(int index);
}

int getCurrentSizeInBytes();

interface VariableWidthMutator extends Mutator {
void setValueLengthSafe(int index, int length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public String contentToTSVString() {
for (int i = 0; i < rowCount; i++) {
row.clear();
for (FieldVector v : fieldVectors) {
row.add(v.getAccessor().getObject(i));
row.add(v.getObject(i));
}
printRow(sb, row);
}
Expand Down
Loading