You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrations/language-clients/java/client/client.mdx
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -993,6 +993,52 @@ Table below shows what old options are supported in the new client and their new
993
993
</TabItem>
994
994
</Tabs>
995
995
996
+
997
+
### General Differences
998
+
999
+
- Client V2 uses less proprietary classes to increase portability. For example, V2 works with any implementation of `java.io.InputStream` for
1000
+
writing data to a server.
1001
+
- Client V2 `async` settings is `off` by default. It means no extra threads and more application control over client. This setting should be `off` for majority of use cases. Enabling `async` will create a separate thread for a request. It only make sense when using application controlled
1002
+
executor (see `com.clickhouse.client.api.Client.Builder#setSharedOperationExecutor`)
1003
+
1004
+
### Writing Data
1005
+
1006
+
- use any implementation of `java.io.InputStream`. V1 `com.clickhouse.data.ClickHouseInputStream` is supported but NOT recommended.
1007
+
- once end of input stream is detected it handled accordingly. Previously output stream of a request should be closed.
1008
+
1009
+
```java
1010
+
1011
+
// V2 Insert TSV formatted data.
1012
+
InputStream inData = getInData();
1013
+
InsertSettings settings =newInsertSettings().setInputStreamCopyBufferSize(8198*2); // set copy buffer size
- new low-level API is available `com.clickhouse.client.api.Client#insert(java.lang.String, java.util.List<java.lang.String>, com.clickhouse.client.api.DataStreamWriter, com.clickhouse.data.ClickHouseFormat, com.clickhouse.client.api.insert.InsertSettings)`. `com.clickhouse.client.api.DataStreamWriter` is designed to implement custom data writing logic. For instance, reading data from a
1024
+
queue.
1025
+
1026
+
1027
+
### Reading Data
1028
+
1029
+
- Data is read in `RowBinaryWithNamesAndTypes` format by default. Currently only this format is supported when data binding is required.
1030
+
- Data can be read as a collection of records using `List<GenericRecord> com.clickhouse.client.api.Client#queryAll(java.lang.String)` method. It will read data to a memory and release connection. No need for extra handling. `GenericRecord` gives access to data, implements some conversions.
1031
+
1032
+
```java
1033
+
Collection<GenericRecord> records = client.queryAll("SELECT * FROM table");
0 commit comments