AMashenkov commented on code in PR #1700:
URL: https://github.com/apache/ignite-3/pull/1700#discussion_r1116688094
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -197,69 +174,203 @@ private void tryEnd() throws Exception {
}
}
- /** Returns mapping of modifications per modification action. */
- private Map<ModifyRow.Operation, Collection<BinaryRowEx>>
getOperationsPerAction(List<ModifyRow> rows) {
- Map<ModifyRow.Operation, Collection<BinaryRowEx>> store = new
EnumMap<>(ModifyRow.Operation.class);
+ private void flushTuples(boolean force) {
+ if (nullOrEmpty(rows) || (!force && rows.size() < MODIFY_BATCH_SIZE)) {
+ return;
+ }
+
+ List<RowT> rows = this.rows;
+ this.rows = new ArrayList<>(MODIFY_BATCH_SIZE);
+
+ switch (modifyOp) {
+ case INSERT:
+ table.insertAll(context(), rows).join();
+
+ break;
+ case UPDATE:
+ inlineUpdates(0, rows);
+
+ table.upsertAll(context(), rows).join();
+
+ break;
+ case MERGE:
+ Pair<List<RowT>, List<RowT>> split = splitMerge(rows);
+
+ List<CompletableFuture<?>> mergeParts = new ArrayList<>(2);
+
+ if (split.getFirst() != null) {
+ mergeParts.add(table.insertAll(context(),
split.getFirst()));
+ }
- for (ModifyRow tuple : rows) {
- store.computeIfAbsent(tuple.getOp(), k -> new
ArrayList<>()).add(tuple.getRow());
+ if (split.getSecond() != null) {
+ mergeParts.add(table.upsertAll(context(),
split.getSecond()));
Review Comment:
Why do we have a separate call if `insertAll`?
'UpsertAll' javadoc says
> inserts a row into the table if does not exist or replaces the existed
one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]