-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Cluster SCAN request #1737
Java: Cluster SCAN request #1737
Conversation
java/client/src/main/java/glide/api/models/commands/scan/ScanOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/scan/ClusterScanCursor.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/scan/ClusterScanCursor.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/scan/ScanOptions.java
Show resolved
Hide resolved
b695e4a
to
dbaabe3
Compare
Signed-off-by: Andrew Carbonetto <[email protected]>
Notes: - ClusterScanCursor is an interface end users should work with. It is in a package exposed in the module. - NativeClusterScanCursor is an implementation of the above that is in an internal package. It wraps Rust cursor strings. - RedisClusterClient intercepts the result from Rust to wrap the cursor string in a NativeClusterScanCursor - The caller is responsible for closing ClusterScanCursor. If they don't, it'll get cleaned up at GC-time, but this is non-deterministic.
Look for the "finished" string
The same hash could potentially be reused.
* Validate that either the initial cursor is used, or an unfinished cursor. * Test-by-reference for the initial cursor instead of evaluating its string. * Clean-up unfinished cursors if they get re-used in scan. * Throw errors if a finished cursor is passed to scan.
- The cursor object manages updating cursor handles and internal state - It auto-cleans at the end of the data - The user can also dispose of the cursor early
When using the ScanOptions type, pass native names through to the rust layer when using cluster scans, and enum names when using standalone scans.
Also flushall before each test to avoid flakiness from leftover state
For consistency with Python
Move access to this to an internal detail interface. The user shouldn't need this string themselves.
resolve conflicts
998042d
to
7948b57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing off on the Rust portion.
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/GenericClusterCommands.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I didn't review tests yet, but I trust you.
*/ | ||
public static void log( | ||
@NonNull Level level, @NonNull String logIdentifier, @NonNull Throwable throwable) { | ||
// TODO: Add the corresponding API to Python and Node.js. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to post such TODO as a GH task
@@ -35,7 +37,11 @@ public <T> Script(T code, Boolean binarySafeOutput) { | |||
/** Drop the linked script from glide-rs <code>code</code>. */ | |||
@Override | |||
public void close() throws Exception { | |||
dropScript(hash); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to synchronise this?
java/client/src/main/java/glide/api/models/commands/scan/ClusterScanCursor.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/scan/ClusterScanCursor.java
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/scan/ScanOptions.java
Show resolved
Hide resolved
Signed-off-by: Andrew Carbonetto <[email protected]>
|
||
@Override | ||
public void releaseCursorHandle() { | ||
// Ignore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It overrides the interface and doesn't destroy the instance object.
That way James has smartly prevented anyone from destroying the statically created INITIAL_CURSOR_INSTANCE.
* Added Scan logic to Glide-core * added scan to python * added changes to changelog * fixed comments * changed from hash to nanoid * fixed typing * fixed comments * Stubbing for cluster scan * Update ScanOptions Signed-off-by: Andrew Carbonetto <[email protected]> * ClusterScan implementation Notes: - ClusterScanCursor is an interface end users should work with. It is in a package exposed in the module. - NativeClusterScanCursor is an implementation of the above that is in an internal package. It wraps Rust cursor strings. - RedisClusterClient intercepts the result from Rust to wrap the cursor string in a NativeClusterScanCursor - The caller is responsible for closing ClusterScanCursor. If they don't, it'll get cleaned up at GC-time, but this is non-deterministic. * Make cursor termination behave as Python does Look for the "finished" string * Unrelated: avoid double-dropping of scripts The same hash could potentially be reused. * Better state management of cursors * Validate that either the initial cursor is used, or an unfinished cursor. * Test-by-reference for the initial cursor instead of evaluating its string. * Clean-up unfinished cursors if they get re-used in scan. * Throw errors if a finished cursor is passed to scan. * Update design for an iterative cursor - The cursor object manages updating cursor handles and internal state - It auto-cleans at the end of the data - The user can also dispose of the cursor early * Change the API to match Python * Unit tests * Fix integration tests When using the ScanOptions type, pass native names through to the rust layer when using cluster scans, and enum names when using standalone scans. * Integration test for cluster scan options * Spotless * Add more integration tests Also flushall before each test to avoid flakiness from leftover state * Move population of the ScanOptions protobuf to CommandManager * Rename clusterScan() method to scan() For consistency with Python * Add javadoc comments * Spotless * Abstract the cursor string from the public API Move access to this to an internal detail interface. The user shouldn't need this string themselves. * Spotless * Revert accidental changes resolve conflicts * Address review comments * Get protocol string constants from Rust instead of hard-coding them * Add integration testing for the Stream type filter * Spotless * Update scan documentation Signed-off-by: Andrew Carbonetto <[email protected]> --------- Signed-off-by: Andrew Carbonetto <[email protected]> Co-authored-by: avifenesh <[email protected]> Co-authored-by: Andrew Carbonetto <[email protected]>
Issue #, if available:
N/A
Description of changes:
Support cluster SCAN commands.
This is a port of the Python part of #1623 for Java.
API and implementation notes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.