Skip to content

Commit b175afa

Browse files
authored
Merge pull request #1309 from zhicwu/main
Fix issue when reading from Lz4InputStream using text-base data format
2 parents 3bbc05d + 9d7b7ac commit b175afa

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

clickhouse-client/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@
3434
</exclusions>
3535
</dependency>
3636

37-
<dependency>
38-
<groupId>com.graphql-java</groupId>
39-
<artifactId>graphql-java</artifactId>
40-
<version>${graphql.version}</version>
41-
<optional>true</optional>
42-
<exclusions>
43-
<exclusion>
44-
<groupId>org.slf4j</groupId>
45-
<artifactId>slf4j-api</artifactId>
46-
</exclusion>
47-
</exclusions>
48-
</dependency>
4937
<dependency>
5038
<groupId>com.google.code.gson</groupId>
5139
<artifactId>gson</artifactId>

clickhouse-data/src/main/java/com/clickhouse/data/stream/Lz4InputStream.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import java.io.InputStream;
55
import java.io.InvalidObjectException;
66
import java.io.StreamCorruptedException;
7+
import java.util.Arrays;
8+
import java.util.LinkedList;
79

810
import com.clickhouse.data.ClickHouseByteUtils;
911
import com.clickhouse.data.ClickHouseByteBuffer;
1012
import com.clickhouse.data.ClickHouseChecker;
1113
import com.clickhouse.data.ClickHouseCityHash;
14+
import com.clickhouse.data.ClickHouseDataUpdater;
1215
import com.clickhouse.data.ClickHouseInputStream;
1316
import com.clickhouse.data.ClickHousePassThruStream;
1417
import com.clickhouse.data.ClickHouseUtils;
@@ -105,6 +108,46 @@ public Lz4InputStream(ClickHousePassThruStream stream, InputStream input, Runnab
105108
this.compressedBlock = ClickHouseByteBuffer.EMPTY_BYTES;
106109
}
107110

111+
@Override
112+
public ClickHouseByteBuffer readCustom(ClickHouseDataUpdater reader) throws IOException {
113+
if (reader == null) {
114+
return byteBuffer.reset();
115+
}
116+
ensureOpen();
117+
118+
LinkedList<byte[]> list = new LinkedList<>();
119+
int length = 0;
120+
boolean more = true;
121+
while (more) {
122+
int remain = limit - position;
123+
if (remain < 1) {
124+
closeQuietly();
125+
more = false;
126+
} else {
127+
int read = reader.update(buffer, position, limit);
128+
if (read == -1) {
129+
list.add(Arrays.copyOfRange(buffer, position, limit));
130+
length += remain;
131+
position = limit;
132+
if (updateBuffer() < 1) {
133+
closeQuietly();
134+
more = false;
135+
}
136+
} else {
137+
if (read > 0) {
138+
byte[] bytes = new byte[read];
139+
System.arraycopy(buffer, position, bytes, 0, read);
140+
list.add(bytes);
141+
length += read;
142+
position += read;
143+
}
144+
more = false;
145+
}
146+
}
147+
}
148+
return byteBuffer.update(list, 0, length);
149+
}
150+
108151
@Override
109152
public void close() throws IOException {
110153
if (!closed) {

pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@
9797
<brotli4j.version>1.11.0</brotli4j.version>
9898
<byte-buddy.version>1.14.0</byte-buddy.version>
9999
<caffeine.version>3.1.4</caffeine.version>
100-
<compress.version>1.22</compress.version>
100+
<compress.version>1.23.0</compress.version>
101101
<dnsjava.version>3.5.2</dnsjava.version>
102102
<fastutil.version>8.5.11</fastutil.version>
103-
<graphql.version>20.0</graphql.version>
104103
<grpc.version>1.53.0</grpc.version>
105104
<gson.version>2.10.1</gson.version>
105+
<janino.version>3.1.9</janino.version>
106106
<jctools.version>4.0.1</jctools.version>
107107
<opencensus.version>0.31.1</opencensus.version>
108108
<protobuf.version>3.22.0</protobuf.version>
@@ -121,18 +121,18 @@
121121
<mysql-driver.version>8.0.32</mysql-driver.version>
122122
<postgresql-driver.version>42.5.4</postgresql-driver.version>
123123

124-
<repackaged.version>1.8.0</repackaged.version>
124+
<repackaged.version>1.9.0</repackaged.version>
125125
<shade.base>${project.groupId}.client.internal</shade.base>
126126

127127
<antrun-plugin.version>3.1.0</antrun-plugin.version>
128128
<assembly-plugin.version>3.5.0</assembly-plugin.version>
129129
<clean-plugin.version>3.2.0</clean-plugin.version>
130130
<compiler-plugin.version>3.11.0</compiler-plugin.version>
131-
<deploy-plugin.version>3.1.0</deploy-plugin.version>
131+
<deploy-plugin.version>3.1.1</deploy-plugin.version>
132132
<enforcer-plugin.version>3.2.1</enforcer-plugin.version>
133133
<exec-plugin.version>3.1.0</exec-plugin.version>
134134
<failsafe-plugin.version>3.0.0-M9</failsafe-plugin.version>
135-
<flatten-plugin.version>1.2.7</flatten-plugin.version>
135+
<flatten-plugin.version>1.4.1</flatten-plugin.version>
136136
<git-plugin.version>4.9.9</git-plugin.version>
137137
<gpg-plugin.version>3.0.1</gpg-plugin.version>
138138
<helper-plugin.version>3.3.0</helper-plugin.version>
@@ -225,11 +225,6 @@
225225
<artifactId>zstd-jni</artifactId>
226226
<version>${zstd-jni.version}</version>
227227
</dependency>
228-
<dependency>
229-
<groupId>com.graphql-java</groupId>
230-
<artifactId>graphql-java</artifactId>
231-
<version>${graphql.version}</version>
232-
</dependency>
233228
<dependency>
234229
<groupId>dnsjava</groupId>
235230
<artifactId>dnsjava</artifactId>
@@ -323,6 +318,11 @@
323318
<artifactId>dec</artifactId>
324319
<version>${brotli.version}</version>
325320
</dependency>
321+
<dependency>
322+
<groupId>org.codehaus.janino</groupId>
323+
<artifactId>janino</artifactId>
324+
<version>${janino.version}</version>
325+
</dependency>
326326
<dependency>
327327
<groupId>org.jctools</groupId>
328328
<artifactId>jctools-core</artifactId>

0 commit comments

Comments
 (0)