apache / apache/arrow-java

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

Aperta
#138 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
94
Fork
152
Merge medio
3g 16h
PR unite (30g)
11

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la documentazione Java IPC collegata nell’issue e ispeziona le API ArrowStreamWriter, VectorSchemaRoot, MessageSerializer, ReadChannel e RecordBatch mostrate. Confronta la lunghezza del byte[] serializzato con RecordBatch.length() e determina se è necessaria un’API esistente a basso overhead o un chiarimento nella documentazione; il lavoro è completo quando l’approccio supportato e il relativo costo sono documentati chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
data
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.