Mercurial > hg > monetdb-java
diff src/main/java/org/monetdb/jdbc/MonetConnection.java @ 521:72007c4f8f8a onclient
Allow MonetUploadHandler to configure the chunk size
(every chunk_size bytes, the client suspends the upload and
asks the server whether to continue)
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Thu, 26 Aug 2021 11:50:11 +0200 (2021-08-26) |
parents | 704a11b93e6b |
children | 6060ca8c5c1a |
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java @@ -3267,6 +3267,7 @@ public class MonetConnection private final MapiSocket server; private PrintStream print = null; private String error = null; + private int customChunkSize = -1; Upload(MapiSocket server) { this.server = server; @@ -3279,13 +3280,17 @@ public class MonetConnection error = errorMessage; } + public void setChunkSize(int chunkSize) { + this.customChunkSize = chunkSize; + } + public PrintStream getStream() throws IOException { if (error != null) { throw new IOException("Cannot send data after an error has been sent"); } if (print == null) { try { - MapiSocket.UploadStream up = server.uploadStream(); + MapiSocket.UploadStream up = customChunkSize >= 0 ? server.uploadStream(customChunkSize) : server.uploadStream(); print = new PrintStream(up, false, "UTF-8"); up.write('\n'); } catch (UnsupportedEncodingException e) {