-
Notifications
You must be signed in to change notification settings - Fork 1k
Add String-based JSON API to avoid unnecessary conversions (#3369) #3394
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
Conversation
- Add String overloads for jsonArrappend, jsonArrindex, jsonArrinsert - Add String overloads for jsonMerge, jsonSet, jsonStrappend - Implement direct String-to-bytes conversion in RedisJsonCommandBuilder - Update Async, Reactive, and Sync interfaces consistently - Eliminate String → JsonValue → String → bytes conversion overhead
- Add unit tests for all String overload methods - Verify direct string encoding optimization - Test both custom JsonPath and ROOT_PATH scenarios - Validate command construction for all String-based JSON operations
- Remove JavaDoc comments from RedisJsonCommandBuilder String methods to match class conventions - Update @author entries to use full names (SeungSu Kim) - Fix @SInCE annotation from 6.5 to 6.9 for new String overload methods - Restore blank lines and fix spacing to maintain consistent formatting - Align documentation style with existing codebase patterns
7f263e2
to
cd1e1ae
Compare
Thank you so much! I'm really happy to contribute to lettuce, which I've been using regularly. Looking forward to @tishun's review to get this wrapped up! |
src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.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.
LGTM, just the @since
annotation needs to be changed imho
… (redis#3394) * Add String-based JSON API to avoid unnecessary conversions redis#3369 - Add String overloads for jsonArrappend, jsonArrindex, jsonArrinsert - Add String overloads for jsonMerge, jsonSet, jsonStrappend - Implement direct String-to-bytes conversion in RedisJsonCommandBuilder - Update Async, Reactive, and Sync interfaces consistently - Eliminate String → JsonValue → String → bytes conversion overhead * Add comprehensive tests for String JSON API redis#3369 - Add unit tests for all String overload methods - Verify direct string encoding optimization - Test both custom JsonPath and ROOT_PATH scenarios - Validate command construction for all String-based JSON operations * Polish JSON API documentation and formatting redis#3369 - Remove JavaDoc comments from RedisJsonCommandBuilder String methods to match class conventions - Update @author entries to use full names (SeungSu Kim) - Fix @SInCE annotation from 6.5 to 6.9 for new String overload methods - Restore blank lines and fix spacing to maintain consistent formatting - Align documentation style with existing codebase patterns * CAE-1404 - finish String extension for JSON API * Fix since annotation on json string API * Rm useless comments in implementations and mark methods as Override * Rm more comments. * Format --------- Co-authored-by: aleksandar.todorov <a_t_todorov@yahoo.com>
…3394) * Add String-based JSON API to avoid unnecessary conversions #3369 - Add String overloads for jsonArrappend, jsonArrindex, jsonArrinsert - Add String overloads for jsonMerge, jsonSet, jsonStrappend - Implement direct String-to-bytes conversion in RedisJsonCommandBuilder - Update Async, Reactive, and Sync interfaces consistently - Eliminate String → JsonValue → String → bytes conversion overhead * Add comprehensive tests for String JSON API #3369 - Add unit tests for all String overload methods - Verify direct string encoding optimization - Test both custom JsonPath and ROOT_PATH scenarios - Validate command construction for all String-based JSON operations * Polish JSON API documentation and formatting #3369 - Remove JavaDoc comments from RedisJsonCommandBuilder String methods to match class conventions - Update @author entries to use full names (SeungSu Kim) - Fix @SInCE annotation from 6.5 to 6.9 for new String overload methods - Restore blank lines and fix spacing to maintain consistent formatting - Align documentation style with existing codebase patterns * CAE-1404 - finish String extension for JSON API * Fix since annotation on json string API * Rm useless comments in implementations and mark methods as Override * Rm more comments. * Format --------- Co-authored-by: aleksandar.todorov <a_t_todorov@yahoo.com>
This PR adds String-based overloads for JSON commands to eliminate unnecessary conversion overhead between String ↔ JsonValue objects, addressing performance concerns raised in the feature request #3369.
Important Note
The existing JSON API assumes users only work with
JsonValue
objects. In certain cases, applications might want to provide a String interface instead, because otherwise they'd have to convert from string toJsonValue
and then the driver would convert back to String and then to a byte array.This approach provides String-based overloads that work directly with String input/output parameters, instead of
JsonValue
objects, eliminating unnecessary conversions while maintaining full backward compatibility.Performance Benefits
String → JsonValue.of() → toString() → getBytes() → ByteBuffer.wrap() → array()
String → getBytes()
(direct conversion)Changes Made
New String Overload Methods Added
jsonArrappend(K key, JsonPath jsonPath, String... jsonStrings)
jsonArrindex(K key, JsonPath jsonPath, String jsonString, JsonRangeArgs range)
jsonArrinsert(K key, JsonPath jsonPath, int index, String... jsonStrings)
jsonMerge(K key, JsonPath jsonPath, String jsonString)
jsonSet(K key, JsonPath jsonPath, String jsonString, JsonSetArgs options)
jsonStrappend(K key, JsonPath jsonPath, String jsonString)
Core Implementation
Testing