FasterXML / FasterXML/jackson-dataformats-binary

Long strings encoded using streaming form

Aperta
#166 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
cbor
Lingua principale
Java
Stelle
347
Fork
156
Merge medio
3g 8h
PR unite (30g)
23

Descrizione

In `CBORGenerator.java`, there is a limit to the length of the string that can be output before the generator will use the indefinite length encoding. The reason behind this appears to be the complexity of determining the length of the encoded byte stream when it does not fit into an internal buffer, given that the length prefix needs to be output before the data.

For now, we have changed the implementation of `_writeChunkedString(...)` to the following:
```
protected final void writeLongString(char[] text, int offset, int len) throws IOException {
CharBuffer charBuffer = CharBuffer.wrap(text, offset, len);
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(charBuffer);
int byteLen = byteBuffer.remaining();
_writeLengthMarker(PREFIX_TYPE_TEXT, byteLen);
_writeBytes(byteBuffer.array(), byteBuffer.position(), byteLen);
}
```

It should also be possible to use the existing UTF-8 encoder to write the encoding out in pieces with the addition of a `int encodedLength(...)` method to precompute and output the length.

Also, thanks for the awesome library!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in CBORGenerator.java, in _writeChunkedString(...), e confrontalo con l’implementazione proposta di writeLongString e con l’encoder UTF-8 esistente. Determina come anteporre il prefisso di lunghezza alle stringhe lunghe senza fare affidamento sul buffer interno, quindi verifica che la codifica risultante preservi i byte UTF-8 previsti e utilizzi la forma richiesta per le stringhe lunghe.

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

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.