[client-v2] Reader API that decodes RowBinary values without per-value objects
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- java
- Domaine
- backend, performance
Piste de recherche
Start by tracing RowBinaryWithNamesAndTypesFormatReader, BinaryStreamReader, and the typed getter path described in the issue. Compare the existing reader behavior with the Spark connector workaround in ClickHouse/spark-clickhouse-connector#588, then identify how a buffered stream and row cursor would fit the current API. Done means callers can decode supported RowBinary types without per-value objects while existing getters retain their behavior; the issue does not name tests to run.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
RowBinaryWithNamesAndTypesFormatReader turns every value into a Java object before the caller sees it:
- One stream call per value.
BinaryStreamReaderreads each value from theInputStreamseparately. For example,readIntLEcallsreadNBytes(input, buff, 0, 4)and puts the int together with shifts, so there's at least onereadcall per value, throughCompressedBlockInputStreamand its wrappers. - One object per value.
readRecordstores each value in anObject[](record[i] = val), and the typed getters go through it:getInteger→readNumberValue→readValue(index). That means:- Int32 →
Integer - UInt64 →
BigInteger - Date →
LocalDate - DateTime64 →
ZonedDateTime - String →
String, or withbinary_string_supportaStringValuearound a newbyte[]
- Int32 →
A caller that writes values into its own format, such as Spark's rows, pays for these objects and then converts them back.
Workaround in the Spark connector
ClickHouse/spark-clickhouse-connector#588 reads the RowBinary bytes itself, with its own buffered reader. It only uses client-v2 for the query, the HTTP transport, decompression and parsing the column types. In our benchmark against client-v2 0.9.5 decoding, it used 1.6–5.3× less CPU, depending on the column types. That figure covers buffering and avoiding objects together; we didn't measure them separately.
The cost is that the connector has to copy client-v2's behaviour exactly, and notice when it changes. Moving from 0.9.5 to 0.11.1 changed:
- The name of the decompressing stream class (
ClickHouseLZ4InputStream→CompressedBlockInputStream) - The Date conversion
- The varint length limit
- The wrapper around the response stream
- The text of read errors
Proposal
-
Buffered reads. Read the decompressed stream in large chunks into an internal buffer. Decode fixed-width values from it with a little-endian
ByteBufferview (getInt,getLong), and only call the stream when the buffer is used up. This helps every caller, including the existing object API. -
A cursor over the row, without per-value objects. RowBinary has no offsets, so values are read in column order, each exactly once:
- Primitives: integers and floats as primitives, UInt64 as its raw
longbits. - Dates and times: Date and Date32 as an epoch-day
int, DateTime and DateTime64 as raw seconds or ticks (long), with the scale taken from the column. - Strings: String and FixedString as a buffer, offset and length, valid until the next row.
- Nullable: a null flag before the value, at any depth.
- Array: the length, then each element with the same accessors.
- Map: the entry count, then key, value, key, value.
- Tuple: the fields in order.
JSON, Variant, Dynamic and the interval types could stay on the object API to start with; the connector sends those to client-v2 today too. The existing getters, which allow random access, could be built on the cursor.
- Primitives: integers and floats as primitives, UInt64 as its raw
With this, the connector would drop its own reader and its copies of client-v2's behaviour, and only map values into Spark rows.
- Langage dominant
- Java
- Étoiles
- 1.6k
- Forks
- 657
- Merge moyen
- 2 j 6 h
- PR mergées (30 j)
- 36
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ClickHouse/clickhouse-java
-
api-diagnostics bug jdbc
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
ClickHouse/clickhouse-java#3464 ·
Les mainteneurs répondent en général sous 1 jour
-
tests
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ClickHouse/clickhouse-java#3452 ·
Les mainteneurs répondent en général sous 1 jour
-
bug jdbc performance queries sql-parser
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
ClickHouse/clickhouse-java#3451 ·
Les mainteneurs répondent en général sous 1 jour
-
bug jdbc legacy queries
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
ClickHouse/clickhouse-java#3444 ·
Les mainteneurs répondent en général sous 1 jour
-
api-diagnostics bug client jdbc
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ClickHouse/clickhouse-java#3439 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de ClickHouse/clickhouse-java
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 60/100
quelea-projection/Quelea#749 ·
Les mainteneurs répondent en général sous 1 jour
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 92/100
erkamyaman/rust-anything#963 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 76/100
-
Deferred
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Sanne/incus-spawn#2768 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
morluto/rea#15041 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour