Skip to content

IGNITE-28737 Calcite. CacheOperationContext with keepBinary = true need to be used during dml operations#13198

Open
zstan wants to merge 6 commits into
apache:masterfrom
zstan:ignite-28737
Open

IGNITE-28737 Calcite. CacheOperationContext with keepBinary = true need to be used during dml operations#13198
zstan wants to merge 6 commits into
apache:masterfrom
zstan:ignite-28737

Conversation

@zstan
Copy link
Copy Markdown
Contributor

@zstan zstan commented Jun 1, 2026

No description provided.

@zstan
Copy link
Copy Markdown
Contributor Author

zstan commented Jun 1, 2026

No diff are found:

PR:
Benchmark                              (engine)  Mode  Cnt    Score    Error  Units
JmhSqlInsertBenchmark.sqlBatchInsert         H2  avgt   10  318.685 ±  9.853  us/op
JmhSqlInsertBenchmark.sqlBatchInsert    CALCITE  avgt   10  257.238 ± 10.517  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert        H2  avgt   10  155.345 ±  5.747  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert   CALCITE  avgt   10  224.764 ± 14.185  us/op

Benchmark                              (engine)  Mode  Cnt    Score    Error  Units
JmhSqlInsertBenchmark.sqlBatchInsert         H2  avgt   10  328.143 ± 15.095  us/op
JmhSqlInsertBenchmark.sqlBatchInsert    CALCITE  avgt   10  255.619 ± 13.665  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert        H2  avgt   10  155.137 ±  5.734  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert   CALCITE  avgt   10  221.011 ±  9.267  us/op

master:
Benchmark                              (engine)  Mode  Cnt    Score    Error  Units
JmhSqlInsertBenchmark.sqlBatchInsert         H2  avgt   10  320.868 ± 23.729  us/op
JmhSqlInsertBenchmark.sqlBatchInsert    CALCITE  avgt   10  254.849 ±  9.252  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert        H2  avgt   10  155.123 ±  7.118  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert   CALCITE  avgt   10  225.755 ± 11.280  us/op

JmhSqlInsertBenchmark.sqlBatchInsert         H2  avgt   10  313.485 ± 16.779  us/op
JmhSqlInsertBenchmark.sqlBatchInsert    CALCITE  avgt   10  259.445 ± 19.988  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert        H2  avgt   10  156.609 ±  7.658  us/op
JmhSqlInsertBenchmark.sqlSimpleInsert   CALCITE  avgt   10  222.638 ± 11.634  us/op

@zstan zstan force-pushed the ignite-28737 branch 2 times, most recently from 7d05287 to 765fa5d Compare June 1, 2026 15:13
@ignitetcbot
Copy link
Copy Markdown
Contributor

TCBot Test Analysis

Possible Blockers (0)

No blockers found.

New Tests (1)

  • Calcite SQL 3: 1 tests
    • IgniteCalciteTestSuite3: PublicApiIntegrationTest.testSimpleInsert - PASSED

@ignitetcbot
Copy link
Copy Markdown
Contributor

TCBot Test Analysis

Possible Blockers (0)

No blockers found.

New Tests (2)

  • Calcite SQL 3: 2 tests
    • IgniteCalciteTestSuite3: PublicApiIntegrationTest.testTxInsert - PASSED
    • IgniteCalciteTestSuite3: PublicApiIntegrationTest.testSimpleInsert - PASSED

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets Calcite DML execution with keepBinary=true, aiming to avoid unnecessary binary deserialization (especially around entry-processor-based DML) and to add coverage ensuring DML works via the public IgniteCache API in both regular and transactional modes.

Changes:

  • Adjust keepBinary handling for entry-processor/invoke results in several DHT/atomic update code paths.
  • Add a new Calcite integration test (PublicApiIntegrationTest) and include it in the Calcite IntegrationTestSuite.
  • Add Calcite-side utility helpers for forcing/restoring CacheOperationContext keep-binary mode; plus minor build/benchmark updates.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java Tweaks keep-binary behavior when recording entry-processor results during tx prepare.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java Adjusts binary unwrapping behavior for atomic update completion (TRANSFORM path).
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java Changes how keep-binary is applied when adding computed entry-processor results.
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/Commons.java Adds helpers to force/restore keep-binary CacheOperationContext for Calcite operations.
modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java Registers the new public API integration test in the Calcite suite.
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PublicApiIntegrationTest.java New test covering DML via IgniteCache with and without withKeepBinary(), including tx case.
modules/calcite/pom.xml Removes direct checker-qual dependency/property.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlUdfBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlSortBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlSetOpBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlScanBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlDmlBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlCorrelateBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlAggBenchmark.java Adds standard class-level JMH annotations.
modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/sql/JmhSqlInsertBenchmark.java New JMH benchmark comparing SQL insert APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +82 to +103
private void runQuery(int begin, int end, boolean transactional, IgniteCache<?, ?> cache) {
Transaction tx = null;

cache.query(new SqlFieldsQuery("CREATE TABLE IF NOT EXISTS emp(empid INTEGER, deptid INTEGER, name VARCHAR, salary INTEGER, " +
"PRIMARY KEY(empid, deptid)) WITH \"AFFINITY_KEY=deptid" + (transactional ? ", ATOMICITY=transactional" : "") + "\""));

if (transactional) {
//noinspection resource
tx = client.transactions().txStart(PESSIMISTIC, READ_COMMITTED);
}

for (int i = begin; i < end; i++) {
cache.query(new SqlFieldsQuery("INSERT INTO emp (empid, deptid, name, salary) VALUES (?, ?, ?, ?)").setArgs(
i, i % 2, "Employee " + i, i / 10));

cache.query(new SqlFieldsQuery("UPDATE emp SET name = '' WHERE empid = ? AND deptid = ?").setArgs(i, i % 2));
cache.query(new SqlFieldsQuery("DELETE FROM emp WHERE empid = ?").setArgs(i - 1)).getAll();
}

if (transactional)
tx.commit();
}
Comment on lines +581 to +597
public static CacheOperationContext setKeepBinaryContext(GridCacheContext<?, ?> cctx) {
CacheOperationContext opCtx = cctx.operationContextPerCall();

// Force keepBinary for operation context to avoid binary deserialization inside entry processor
CacheOperationContext newOpCtx = null;

if (opCtx == null)
// Mimics behavior of GridCacheAdapter#keepBinary and GridCacheProxyImpl#keepBinary
newOpCtx = new CacheOperationContext(false, false, true, null, false, null, false, null, null);
else if (!opCtx.isKeepBinary())
newOpCtx = opCtx.keepBinary();

if (newOpCtx != null)
cctx.operationContextPerCall(newOpCtx);

return opCtx;
}
Comment on lines 2693 to +2698
retVal.addEntryProcessResult(ctx,
k,
null,
compRes.get1(),
compRes.get2(),
req.keepBinary());
true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants