zzzzming95 opened a new issue, #138:
URL: https://github.com/apache/arrow-java/issues/138

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   [java] Is there a way to get the length of the data from bytes at a small 
system cost?
   
   Like the arrow doc example, 
https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format
   
   We generate the arrow data to bytes[] and transfer it.
   
   ```
     ByteArrayOutputStream out = new ByteArrayOutputStream();
   
     // create VectorSchemaRoot
     List<Field> fields = Arrays.asList(encodedVector.getField());
     List<FieldVector> vectors = Arrays.asList(encodedVector);
     try (VectorSchemaRoot root = new VectorSchemaRoot(fields, vectors)) {
   
         // write data
         ArrowStreamWriter writer = new ArrowStreamWriter(root, provider, 
Channels.newChannel(out));
         writer.start();
         writer.writeBatch();
         writer.end();
     }
   
     // gen arrow data as bytep[]
     out.toByteArray()
   ```
   
   I want to get the data length with a small system load(cpu mem).
   
   Now i using this way to get data lengeh:
   
   ```
               ByteArrayInputStream input = new 
ByteArrayInputStream(out.toByteArray());
               ReadChannel readChannel = new 
ReadChannel(Channels.newChannel(input));
               MessageMetadataResult messageMeta = 
MessageSerializer.readMessage(readChannel);
               RecordBatch recordBatch =
                       (RecordBatch) messageMeta.getMessage().header(new 
RecordBatch());
               input.close();
               readChannel.close();
   
               // get data length
               recordBatch.length()
   ```
   
   
   Is there documentation to guide me on what to do? thanks~
   
   
   
   ### Component(s)
   
   Java


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to