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

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

icexelloss commented on a change in pull request #1492: ARROW-633/634: Add 
FixedSizeBinary support in Java and integration tests (Updated)
URL: https://github.com/apache/arrow/pull/1492#discussion_r162480803
 
 

 ##########
 File path: 
java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java
 ##########
 @@ -329,6 +329,36 @@ protected ArrowBuf read(BufferAllocator allocator, int 
count) throws IOException
       }
     };
 
+    BufferReader FIXEDSIZEBINARY = new BufferReader() {
+      @Override
+      protected ArrowBuf read(BufferAllocator allocator, int count) throws 
IOException {
+        ArrayList<byte[]> values = Lists.newArrayList();
+        int byteWidth = 0;
+        for (int i = 0; i < count; i++) {
+          parser.nextToken();
+          final byte[] value = decodeHexSafe(parser.readValueAs(String.class));
+          values.add(value);
+          if (value.length > 0) {
+            if (byteWidth == 0) {
+              byteWidth = value.length;
+            } else if (byteWidth != value.length) {
+              throw new IOException("mismatch byte width (" + value.length + 
") at index " + i + ", expecting " + byteWidth);
+            }
+          }
+        }
+        if (count > 0 && byteWidth == 0) {
+          throw new IOException("could not determine the byte width of the 
vector because all elements are null");
+        }
+
+        ArrowBuf buf = allocator.buffer(byteWidth * count);
+        for (byte[] value : values) {
+          buf.writeBytes(value.length == 0? new byte[byteWidth] : value);
 
 Review comment:
   Why can there be empty values?

----------------------------------------------------------------
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] Add support for FixedSizeBinary type
> -------------------------------------------
>
>                 Key: ARROW-633
>                 URL: https://issues.apache.org/jira/browse/ARROW-633
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: Java - Vectors
>            Reporter: Wes McKinney
>            Assignee: Jingyuan Wang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to