apache / apache/arrow-java

[java] Is there a way to get the length of the data from bytes at a small system cost?

Ouverte
#138 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
94
Forks
152
Merge moyen
3 j 16 h
PR mergées (30 j)
11

Description

### 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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la documentation Java IPC liée dans l’issue et examinez les API ArrowStreamWriter, VectorSchemaRoot, MessageSerializer, ReadChannel et RecordBatch qui y sont présentées. Comparez la longueur du byte[] sérialisé avec RecordBatch.length() et déterminez si une API existante à faible overhead ou une clarification de la documentation est nécessaire ; le travail est considéré comme terminé lorsque l’approche prise en charge et son coût sont clairement documentés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
data
Type d'issue
Documentation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.