Skip to content

Commit

Permalink
Improve ColumnWriteBuffer recycling
Browse files Browse the repository at this point in the history
Return buffers to the pool after executing prepared INSERT statement, so they can be reused again even if statement is not closed
  • Loading branch information
Andrey Nudko committed Dec 23, 2021
1 parent 830d40e commit bb66e4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public int executeUpdate() throws SQLException {
addParameters();
int result = connection.sendInsertRequest(block);
this.blockInit = false;
this.block.initWriteBuffer();
this.block.cleanup();
return result;
}

Expand All @@ -156,7 +156,7 @@ public int[] executeBatch() throws SQLException {
Arrays.fill(result, 1);
clearBatch();
this.blockInit = false;
this.block.initWriteBuffer();
this.block.cleanup();
return result;
}

Expand All @@ -166,7 +166,6 @@ public void close() throws SQLException {
// Empty insert when close.
this.connection.sendInsertRequest(new Block());
this.blockInit = false;
this.block.initWriteBuffer();
}
// clean up block on close
this.block.cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public int executeUpdate(String query) throws SQLException {
block.initWriteBuffer();
new ValuesNativeInputFormat(matcher.end() - 1, query).fill(block);
updateCount = connection.sendInsertRequest(block);
block.cleanup();
return updateCount;
}
updateCount = -1;
Expand Down

0 comments on commit bb66e4b

Please sign in to comment.