Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8adfd29
Fixes in config.yml (#409)
rafie Jun 30, 2021
cc6d225
json.get returns a top-level array (as bulk string) (#411)
oshadmi Jul 1, 2021
5d53920
removing docker curl and executing, relying on the contents of github…
chayim Jul 4, 2021
5cf6b36
added generic json path implementation (#336)
Jul 4, 2021
fd5889b
add testGetWithBracketNotation (#416)
oshadmi Jul 5, 2021
f001ee1
avoid path clone when not needed (#398)
gkorland Jul 5, 2021
d3661a3
clippy warnings cleanup (#419)
gkorland Jul 6, 2021
8813a86
change llapi to support multiple jsonpath results (#417)
Jul 6, 2021
e7296cf
optimize set root by caching key value (#418)
Jul 7, 2021
72e8dd6
Optional format (#400)
gkorland Jul 7, 2021
8de09a4
Move to RedisString (trail 2) (#420)
gkorland Jul 7, 2021
9610708
Set vec capcity to 1 by default (#422)
gkorland Jul 8, 2021
f62cf86
change llapi to be declare on the initialize macro so it can be used …
Jul 8, 2021
894770c
move from next_string to next_str (#426)
gkorland Jul 21, 2021
3863551
release drafter and release actions (#427)
chayim Jul 21, 2021
cc69342
avoid json clone (#429)
gkorland Aug 1, 2021
5b9504d
some code cleanup (#436)
gkorland Aug 1, 2021
c636d8f
format code
gkorland Aug 1, 2021
9f1c419
Slice tokenizer json path (#442)
Aug 5, 2021
1ca78bc
[fix] Reduced the total request count on 3 benchmarks with excessive …
filipecosta90 Aug 6, 2021
3d51c06
Support RDB Short Read in RedisJSON (a.k.a diskless-load) (#397)
oshadmi Aug 22, 2021
ca5243a
CircleCI: increase test timeouts (#447)
rafie Aug 23, 2021
3f636ed
Skip test on macos (#448)
oshadmi Aug 24, 2021
f563a0c
Skip test on macos (2) (#449)
oshadmi Aug 24, 2021
b9bfe9c
Skip test on macos (3) (#450)
oshadmi Aug 24, 2021
d780d3a
Updated readies (for getpyrmtools) (#452)
rafie Aug 28, 2021
ebd1601
Issue Template (#432)
chayim Aug 29, 2021
90bc4a0
fix #451 getInt should return long long (#454)
gkorland Aug 30, 2021
28c3f32
Replaces "Redis Labs" with "Redis". (#457)
SuzeShardlow Sep 16, 2021
7cb35db
Docker/debian: moved from Buster to Bullseye (#458)
rafie Sep 20, 2021
8881664
Initial RedisJSON commands.json file (#464)
oshadmi Oct 4, 2021
a8dc0da
Create freebsd.yml (#453)
gkorland Oct 4, 2021
2d9ac84
Return count of cleared results (#467)
gkorland Oct 5, 2021
110038e
Updated module version
rafie Jun 30, 2021
fbe49dc
Updated modules version (2)
rafie Jul 1, 2021
8517ce0
Added integration branch 2.0
rafie Jul 10, 2021
f21b8b3
[2.0] Updated readies
rafie Oct 12, 2021
9fc9550
Merge branch '2.0' into rafi-2.0-sync-with-master-1
rafie Oct 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid path clone when not needed (#398)
Avoid path clone when not needed
  • Loading branch information
gkorland authored Jul 5, 2021
commit f001ee1decfd4ece97204be35e4b30aa436e27be
19 changes: 12 additions & 7 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<'a, V: SelectValue> KeyValue<'a, V> {
let temp_doc = paths.drain(..).fold(HashMap::new(), |mut acc, path| {
let mut selector = Selector::new();
selector.value(self.val);
if let Err(_) = selector.str_path(&path.fixed) {
if let Err(_) = selector.str_path(path.get_path()) {
return acc;
}
let value = match selector.select() {
Expand All @@ -190,20 +190,25 @@ impl<'a, V: SelectValue> KeyValue<'a, V> {
},
Err(_) => None,
};
acc.insert(path.path, value);
acc.insert(path.take_original(), value);
acc
});
Ok(self
.serialize_object(&temp_doc, &indent, &newline, &space)
.into())
} else {
let path = &paths[0];
if path.is_legacy {
if path.is_legacy() {
Ok(self
.serialize_object(self.get_first(&paths[0].fixed)?, &indent, &newline, &space)
.serialize_object(
self.get_first(paths[0].get_path())?,
&indent,
&newline,
&space,
)
.into())
} else {
let values = self.get_values(&path.fixed)?;
let values = self.get_values(path.get_path())?;
Ok(self
.serialize_object(&values, &indent, &newline, &space)
.into())
Expand Down Expand Up @@ -1071,7 +1076,7 @@ pub fn command_json_clear<M: Manager>(manager: M, ctx: &Context, args: Vec<Strin
paths
};

let path = paths.first().unwrap().fixed.as_str();
let path = paths.first().unwrap().get_path();

// FIXME: handle multi paths
let mut redis_key = manager.open_key_write(ctx, &key)?;
Expand All @@ -1080,7 +1085,7 @@ pub fn command_json_clear<M: Manager>(manager: M, ctx: &Context, args: Vec<Strin
.get_value()?
.ok_or_else(RedisError::nonexistent_key)?;

let paths = find_paths(&path, root, |_v| true)?;
let paths = find_paths(path, root, |_v| true)?;
if paths.len() > 0 {
let mut res = None;
for p in paths {
Expand Down
43 changes: 27 additions & 16 deletions src/redisjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,42 @@ impl Format {
/// Backwards compatibility convertor for RedisJSON 1.x clients
///
pub struct Path {
pub path: String,
pub fixed: String,
pub is_legacy: bool,
original_path: String,
fixed_path: Option<String>,
}

impl Path {
pub fn new(path: String) -> Path {
let mut fixed = path.clone();
let mut is_legacy = false;
if !fixed.starts_with('$') {
is_legacy = true;
if fixed == "." {
fixed.replace_range(..1, "$");
} else if fixed.starts_with('.') {
fixed.insert(0, '$');
let fixed_path = if path.starts_with('$') {
None
} else {
let mut cloned = path.clone();
if path == "." {
cloned.replace_range(..1, "$");
} else if path.starts_with('.') {
cloned.insert(0, '$')
} else {
fixed.insert_str(0, "$.");
cloned.insert_str(0, "$.");
}
}
Some(cloned)
};
Path {
path,
fixed,
is_legacy,
original_path: path,
fixed_path,
}
}

pub fn is_legacy(&self) -> bool {
self.fixed_path.is_some()
}

pub fn get_path(&self) -> &String {
self.fixed_path.as_ref().unwrap_or(&self.original_path)
}

pub fn take_original(self) -> String {
self.original_path
}
}

#[derive(Debug)]
Expand Down