vibhatha commented on code in PR #41967:
URL: https://github.com/apache/arrow/pull/41967#discussion_r1628995808
##########
java/c/src/main/java/org/apache/arrow/c/BufferImportTypeVisitor.java:
##########
@@ -210,9 +223,48 @@ public List<ArrowBuf> visit(ArrowType.Utf8 type) {
}
}
+ private List<ArrowBuf> visitVariableWidthView(ArrowType type) {
+ try (ArrowBuf view = importView(type)) {
+ List<ArrowBuf> buffers = new ArrayList<>();
+ view.getReferenceManager().retain();
+ ArrowBuf maybeValidityBuffer = maybeImportBitmap(type);
+ buffers.add(maybeValidityBuffer);
+ buffers.add(view);
+ final int elementSize = BaseVariableWidthViewVector.ELEMENT_SIZE;
+ final int lengthWidth = BaseVariableWidthViewVector.LENGTH_WIDTH;
+ final int prefixWidth = BaseVariableWidthViewVector.PREFIX_WIDTH;
+ final int lengthPrefixWidth = lengthWidth + prefixWidth;
+ // Map to store the data buffer index and the total length of data in
that buffer
+ Map<Integer, Long> dataBufferInfo = new HashMap<>();
+ for (int i = 0; i < fieldNode.getLength(); i++) {
+ final int length = view.getInt((long) i * elementSize);
+ if (length > BaseVariableWidthViewVector.INLINE_SIZE) {
+ checkState(maybeValidityBuffer != null,
+ "Validity buffer is required for data of type " + type);
+ if (BitVectorHelper.get(maybeValidityBuffer, i) == 1) {
+ final int bufferIndex =
+ view.getInt(((long) i * elementSize) + lengthPrefixWidth);
+ if (dataBufferInfo.containsKey(bufferIndex)) {
+ dataBufferInfo.compute(bufferIndex, (key, value) -> value !=
null ? value + (long) length : 0);
+ } else {
+ dataBufferInfo.put(bufferIndex, (long) length);
+ }
+ }
+ }
+ }
Review Comment:
should we go for a more efficient approach?
--
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]