Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-41968: [Java] Implement TransferPair functionality for BinaryView #41980

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,12 @@ public void setSafe(int index, NullableViewVarBinaryHolder holder) {
*/
@Override
public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
// TODO: https://github.com/apache/arrow/issues/40932
throw new UnsupportedOperationException("Unsupported operation");
return new TransferImpl(ref, allocator);
}

@Override
public TransferPair getTransferPair(Field field, BufferAllocator allocator) {
// TODO: https://github.com/apache/arrow/issues/40932
throw new UnsupportedOperationException("Unsupported operation");
return new TransferImpl(field, allocator);
}

/**
Expand All @@ -223,7 +221,42 @@ public TransferPair getTransferPair(Field field, BufferAllocator allocator) {
*/
@Override
public TransferPair makeTransferPair(ValueVector to) {
// TODO: https://github.com/apache/arrow/issues/40932
throw new UnsupportedOperationException("Unsupported operation");
return new TransferImpl((ViewVarBinaryVector) to);
}

private class TransferImpl implements TransferPair {
ViewVarBinaryVector to;

public TransferImpl(String ref, BufferAllocator allocator) {
to = new ViewVarBinaryVector(ref, field.getFieldType(), allocator);
}

public TransferImpl(Field field, BufferAllocator allocator) {
to = new ViewVarBinaryVector(field, allocator);
}

public TransferImpl(ViewVarBinaryVector to) {
this.to = to;
}

@Override
public ViewVarBinaryVector getTo() {
return to;
}

@Override
public void transfer() {
transferTo(to);
}

@Override
public void splitAndTransfer(int startIndex, int length) {
splitAndTransferTo(startIndex, length, to);
}

@Override
public void copyValueSafe(int fromIndex, int toIndex) {
to.copyFromSafe(fromIndex, toIndex, ViewVarBinaryVector.this);
}
}
}
Loading
Loading