Skip to content

Commit

Permalink
feat: improve extract hints
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun committed Aug 1, 2024
1 parent 291d9d5 commit 9449f99
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/servers/src/grpc/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,14 @@ fn extract_hints(metadata: &MetadataMap) -> Vec<(String, String)> {
return None;
};
let key = key.as_str();
if !key.starts_with(GREPTIME_DB_HEADER_HINT_PREFIX) {
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;
};
// Safety: we already checked the prefix.
let new_key = key
.strip_prefix(GREPTIME_DB_HEADER_HINT_PREFIX)
.unwrap()
.to_string();
Some((new_key, value.trim().to_string()))
Some((new_key.to_string(), value.trim().to_string()))
})
.collect()
}
Expand Down

0 comments on commit 9449f99

Please sign in to comment.