-
Notifications
You must be signed in to change notification settings - Fork 333
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
feat: hint options for gRPC insert #4454
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
8b83aba
to
22db359
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4454 +/- ##
==========================================
- Coverage 84.88% 84.60% -0.29%
==========================================
Files 1081 1081
Lines 192910 193125 +215
==========================================
- Hits 163761 163400 -361
- Misses 29149 29725 +576 |
22db359
to
84c5ca6
Compare
84c5ca6
to
0b88d71
Compare
Good job! A little Java API suggestion: Context.of("x-greptime-hint-merge_mode", "last_non_null")); Adds an API specified for hints:
|
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.
I think we can add a test to ensure the API working well.
https://github.com/GreptimeTeam/greptimedb/blob/main/tests-integration/tests/http.rs
Good point! |
PTAL @killme2008 @WenyXu |
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
PTAL @WenyXu |
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
let key = key.as_str(); | ||
if !key.starts_with(GREPTIME_DB_HEADER_HINT_PREFIX) { | ||
return None; | ||
} | ||
let Ok(value) = value.to_str() else { | ||
// Simply return None for non-string values. | ||
return None; | ||
}; | ||
// Safety: we already checked the prefix. | ||
let new_key = key | ||
.strip_prefix(GREPTIME_DB_HEADER_HINT_PREFIX) | ||
.unwrap() | ||
.to_string(); |
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.
Non-blocking: reduce the overhead of calling starts_with
?
let key = key.as_str(); | |
if !key.starts_with(GREPTIME_DB_HEADER_HINT_PREFIX) { | |
return None; | |
} | |
let Ok(value) = value.to_str() else { | |
// Simply return None for non-string values. | |
return None; | |
}; | |
// Safety: we already checked the prefix. | |
let new_key = key | |
.strip_prefix(GREPTIME_DB_HEADER_HINT_PREFIX) | |
.unwrap() | |
.to_string(); | |
let key = key.as_str(); | |
let Some(new_key) = key.strip_prefix(GREPTIME_DB_HEADER_HINT_PREFIX) else { | |
return None; | |
}; | |
let Ok(value) = value.to_str() else { | |
// Simply return None for non-string values. | |
return None; | |
}; | |
let new_key = new_key.to_string(); |
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.
Looks good, I'll do it in next PR
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
This PR closes #4441
How to use:
For example, if you need to add a hint during the first write to automatically create a table with the option
merge_mode = "last_non_null"
, then we need to add a hint to the gRPC request header:Note, you must use the prefix
x-greptime-hint-
; otherwise, it will not be parsed as a valid hint.Taking the java ingester client as an example, we modify a line of code in this example to:
https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/4fa729a537df3f49278aef58fa919315ad6a7f88/ingester-example/src/main/java/io/greptime/LowLevelApiWriteQuickStart.java#L76
->
Currently, only two hint options are supported, which are append_mode and merge_mode.
Checklist