lidavidm commented on code in PR #44241:
URL: https://github.com/apache/arrow/pull/44241#discussion_r1794391973
##########
java/c/src/test/python/integration_tests.py:
##########
@@ -399,6 +399,9 @@ def recreate_batch():
return reader.read_next_batch()
self.round_trip_record_batch(recreate_batch)
+
+ def test_runendencoded_array(self):
+ self.round_trip_array(lambda: pa.RunEndEncodedArray.from_arrays([3, 5,
10, 12, 19], [1, 2, 1, None, 3]), check_metadata=False)
Review Comment:
```suggestion
self.round_trip_array(lambda: pa.RunEndEncodedArray.from_arrays([3,
5, 10, 12, 19], [1, 2, 1, None, 3]), check_metadata=False)
```
##########
java/vector/src/main/java/org/apache/arrow/vector/complex/RunEndEncodedVector.java:
##########
@@ -312,8 +298,68 @@ public TransferPair getTransferPair(Field field,
BufferAllocator allocator, Call
*/
@Override
public TransferPair makeTransferPair(ValueVector target) {
- throw new UnsupportedOperationException(
- "RunEndEncodedVector does not support makeTransferPair(ValueVector)");
+ return new TransferImpl((RunEndEncodedVector) target);
+ }
+
+ private class TransferImpl implements TransferPair {
+
+ RunEndEncodedVector to;
+ TransferPair dataTransferPair;
+ TransferPair reeTransferPair;
+
+ public TransferImpl(String name, BufferAllocator allocator, CallBack
callBack) {
+ this(new RunEndEncodedVector(name, allocator, field.getFieldType(),
callBack));
+ }
+
+ public TransferImpl(Field field, BufferAllocator allocator, CallBack
callBack) {
+ this(new RunEndEncodedVector(field, allocator, callBack));
+ }
+
+ public TransferImpl(RunEndEncodedVector to) {
+ this.to = to;
+ if (to.getRunEndsVector() instanceof ZeroVector) {
+ to.initializeChildrenFromFields(field.getChildren());
+ }
+ reeTransferPair =
getRunEndsVector().makeTransferPair(to.getRunEndsVector());
+ dataTransferPair =
getValuesVector().makeTransferPair(to.getValuesVector());
+ }
+
+ /**
+ * Transfer this vector'data to another vector. The memory associated with
this vector is
+ * transferred to the allocator of target vector for accounting and
management purposes.
+ */
+ @Override
+ public void transfer() {
+ to.clear();
+ dataTransferPair.transfer();
+ reeTransferPair.transfer();
+ if (valueCount > 0) {
+ to.setValueCount(valueCount);
+ }
+ clear();
+ }
+
+ /**
+ * Slice this vector at desired index and length and transfer the
corresponding data to the
+ * target vector.
+ *
+ * @param startIndex start position of the split in source vector.
+ * @param length length of the split.
+ */
+ @Override
+ public void splitAndTransfer(int startIndex, int length) {
+ throw new UnsupportedOperationException();
Review Comment:
Do we have an issue filed for this?
##########
java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java:
##########
@@ -910,7 +910,9 @@ private void readFromJsonIntoVector(Field field,
FieldVector vector) throws IOEx
}
int nullCount = 0;
- if (type instanceof ArrowType.Null) {
+ if (type instanceof ArrowType.RunEndEncoded) {
Review Comment:
We could fold the union check below into this one?
##########
java/c/src/test/python/integration_tests.py:
##########
@@ -399,6 +399,9 @@ def recreate_batch():
return reader.read_next_batch()
self.round_trip_record_batch(recreate_batch)
+
+ def test_runendencoded_array(self):
+ self.round_trip_array(lambda: pa.RunEndEncodedArray.from_arrays([3, 5,
10, 12, 19], [1, 2, 1, None, 3]), check_metadata=False)
Review Comment:
Can we also test empty arrays, and ideally one other type here (strings?)
##########
java/vector/src/main/java/org/apache/arrow/vector/complex/RunEndEncodedVector.java:
##########
@@ -312,8 +298,68 @@ public TransferPair getTransferPair(Field field,
BufferAllocator allocator, Call
*/
@Override
public TransferPair makeTransferPair(ValueVector target) {
- throw new UnsupportedOperationException(
- "RunEndEncodedVector does not support makeTransferPair(ValueVector)");
+ return new TransferImpl((RunEndEncodedVector) target);
+ }
+
+ private class TransferImpl implements TransferPair {
+
+ RunEndEncodedVector to;
+ TransferPair dataTransferPair;
+ TransferPair reeTransferPair;
+
+ public TransferImpl(String name, BufferAllocator allocator, CallBack
callBack) {
+ this(new RunEndEncodedVector(name, allocator, field.getFieldType(),
callBack));
+ }
+
+ public TransferImpl(Field field, BufferAllocator allocator, CallBack
callBack) {
+ this(new RunEndEncodedVector(field, allocator, callBack));
+ }
+
+ public TransferImpl(RunEndEncodedVector to) {
+ this.to = to;
+ if (to.getRunEndsVector() instanceof ZeroVector) {
+ to.initializeChildrenFromFields(field.getChildren());
+ }
+ reeTransferPair =
getRunEndsVector().makeTransferPair(to.getRunEndsVector());
+ dataTransferPair =
getValuesVector().makeTransferPair(to.getValuesVector());
+ }
+
+ /**
+ * Transfer this vector'data to another vector. The memory associated with
this vector is
+ * transferred to the allocator of target vector for accounting and
management purposes.
+ */
+ @Override
+ public void transfer() {
+ to.clear();
+ dataTransferPair.transfer();
+ reeTransferPair.transfer();
+ if (valueCount > 0) {
+ to.setValueCount(valueCount);
+ }
+ clear();
+ }
+
+ /**
+ * Slice this vector at desired index and length and transfer the
corresponding data to the
+ * target vector.
+ *
+ * @param startIndex start position of the split in source vector.
+ * @param length length of the split.
+ */
+ @Override
+ public void splitAndTransfer(int startIndex, int length) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ValueVector getTo() {
+ return to;
+ }
+
+ @Override
+ public void copyValueSafe(int from, int to) {
+ this.to.copyFrom(from, to, RunEndEncodedVector.this);
Review Comment:
It looks like this will just throw because we don't implement copyFrom,
right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]