[java] Is there a way to get the length of the data from bytes at a small system cost?
- 主要语言
- Java
- 星标
- 94
- 派生
- 152
- 平均合并
- 3 天 16 小时
- 30 天内合并 PR
- 11
描述
### 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 fields = Arrays.asList(encodedVector.getField());
List 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
贡献指南
调研方向
从 issue 中链接的 Java IPC 文档开始,检查其中展示的 ArrowStreamWriter、VectorSchemaRoot、MessageSerializer、ReadChannel 和 RecordBatch API。将序列化后的 byte[] 长度与 RecordBatch.length() 进行比较,并确定是否需要现有的低开销 API 或对文档进行澄清;完成的标准是明确记录受支持的方法及其开销。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- data
- Issue 类型
- 文档
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100