[ 
https://issues.apache.org/jira/browse/ARROW-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16214555#comment-16214555
 ] 

ASF GitHub Bot commented on ARROW-1474:
---------------------------------------

icexelloss commented on a change in pull request #1203: ARROW-1474:[WIP] Java 
Vector Refactor (Implementation Phase 2)
URL: https://github.com/apache/arrow/pull/1203#discussion_r146157276
 
 

 ##########
 File path: 
java/vector/src/main/java/org/apache/arrow/vector/BaseNullableVariableWidthVector.java
 ##########
 @@ -761,4 +741,57 @@ protected final void handleSafe(int index, int 
dataLength) {
          reallocValueBuffer();
       }
    }
+
+
+   /******************************************************************
+    *                                                                *
+    *                helper methods currently                        *
+    *                used by JsonFileReader and                      *
+    *                JsonFileWriter                                  *
+    *                                                                *
+    ******************************************************************/
+
+
+   public static ArrowBuf setSafeJsonHelper(ArrowBuf data, ArrowBuf offset,
+                                            BufferAllocator allocator, int 
index, byte[] value,
+                                            int valueCount) {
+      if (data == null) {
+         data = allocator.buffer(INITIAL_BYTE_COUNT);
+      }
+      final int currentBufferCapacity = data.capacity();
+      final int currentStartOffset = offset.getInt(index * OFFSET_WIDTH);
+      while (currentBufferCapacity < currentStartOffset + value.length) {
+         final ArrowBuf newBuf = allocator.buffer(currentBufferCapacity * 2);
+         newBuf.setBytes(0, data, 0, currentBufferCapacity);
+         data.release();
+         data = newBuf;
+      }
+      data.setBytes(currentStartOffset, value, 0, value.length);
+      if (index == (valueCount - 1)) {
+         data.writerIndex(offset.getInt(valueCount * OFFSET_WIDTH));
+      }
+      return data;
+   }
+
+   public static byte[] get(final ArrowBuf data, final ArrowBuf offset, int 
index) {
 
 Review comment:
   Sorry, I really don't like having these functions as a part of the vector 
API just for the JSON reader. I am not sure what's the best way to do this 
though - Can you please explain why do we need these methods? The original JSON 
reader/writer use these - 
   
https://github.com/apache/arrow/blob/master/java/vector/src/main/java/org/apache/arrow/vector/file/json/JsonFileReader.java#L344
   
   
https://github.com/apache/arrow/blob/master/java/vector/src/main/java/org/apache/arrow/vector/file/json/JsonFileWriter.java#L240

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [JAVA] ValueVector hierarchy (Implementation Phase 2)
> -----------------------------------------------------
>
>                 Key: ARROW-1474
>                 URL: https://issues.apache.org/jira/browse/ARROW-1474
>             Project: Apache Arrow
>          Issue Type: Sub-task
>            Reporter: Jacques Nadeau
>            Assignee: Siddharth Teotia
>              Labels: pull-request-available
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to