Skip to content

IGNITE-28773 CacheOperationContext refactoring#13242

Open
zstan wants to merge 2 commits into
apache:masterfrom
zstan:ignite-28773
Open

IGNITE-28773 CacheOperationContext refactoring#13242
zstan wants to merge 2 commits into
apache:masterfrom
zstan:ignite-28773

Conversation

@zstan

@zstan zstan commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors CacheOperationContext construction and usage across internal cache projections to reduce constructor/“setter” sprawl and align flag-setting APIs around withX() methods.

Changes:

  • Replaces direct new CacheOperationContext(...) / mutator-style methods with a CacheOperationContext.builder() + withX() API.
  • Renames skip-store projection from setSkipStore(boolean) to withSkipStore() and updates REST handler code paths accordingly.
  • Adds a new withHandleBinaryInInterceptor() projection API and propagates it through cache proxies.

Reviewed changes

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

Show a summary per file
File Description
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java Switches keep-binary context creation to the new builder/with-style API.
modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java Simplifies the local cache proxy used in REST handler tests after projection API changes.
modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java Updates REST cache-flag application to use withSkipStore() (conditional) and keep-binary projection.
modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java Refactors keep-binary context setup to builder/with-style methods.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java Updates projection API surface (withSkipStore) and introduces withHandleBinaryInInterceptor().
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java Reuses a shared default CacheOperationContext instance instead of allocating new defaults.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java Reworks projection methods to build new immutable contexts via builder/with-style calls; adds interceptor-binary projection plumbing.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java Updates adapter-level projection creation to use builder/with-style contexts and adds new projection API.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java Migrates to new CacheOperationContext “with” methods and extends keep-binary to also set the interceptor-binary flag.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java Replaces hasDataCenterId() checks with dataCenterId() != null.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java Uses builder-based context creation for application attributes.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java Uses builder-based context creation for application attributes and updates data center ID checks.
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java Introduces immutable builder-based CacheOperationContext, shared default instance, and new interceptor-binary flag.
Comments suppressed due to low confidence (1)

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java:24

  • Unused imports java.util.Collections and java.util.HashMap will fail the repository's Checkstyle UnusedImports rule; they are no longer referenced after the refactor and should be removed.
import java.io.Serial;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

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

Comment on lines +259 to +267
@GridToStringInclude
private boolean skipStore;

/** Skip read through. */
@GridToStringInclude
private boolean skipReadThrough;

/** No retries flag. */
@GridToStringInclude

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why only these three fields marked as GridToStringInclude? AFAIK like this annotation is redundant for booleans and we can remove it (and from CacheOperationContext too). Let's check it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you are right, remove it

appAttrs);
/** Context with keepBinary flag. */
public CacheOperationContext withKeepBinary() {
return builder(this).keepBinary(true).build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check for each method:

if (keepBinary)
  return this;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done except expiration for same behavior as in GridCacheAdapter#withExpiryPolicy, really don`t know why equality is not checked there.

Comment on lines 486 to 491
if (opCtx == null)
opCtx = CacheOperationContext.builder().skipReadThrough(true).build();
else {
if (!opCtx.skipReadThrough())
opCtx = opCtx.withSkipReadThrough();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe replace this boilerplate code in cache adapters/cache proxies with something like:

opCtx = CacheOperationContext.of(opCtx).withSkipReadThrough();

?

And implement CacheOperationContext.of like:

return opCtx == null ? INSTANCE : opCtx;

Count of allocated objects will be the same (one builder and one context object). Perhaps builder can be marked as private after such a change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch ! done

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