-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: LazyResultSet implemenation, allowing one-by-one parsing (#14)
* no lock * Works now * Works, added example, fixed docs * Move to use try_fold * Remove time testing
- Loading branch information
Showing
12 changed files
with
210 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright FalkorDB Ltd. 2023 - present | ||
* Licensed under the Server Side Public License v1 (SSPLv1). | ||
*/ | ||
|
||
use falkordb::{FalkorClientBuilder, FalkorResult}; | ||
|
||
fn main() -> FalkorResult<()> { | ||
let client = FalkorClientBuilder::new() | ||
.with_connection_info("falkor://127.0.0.1:6379".try_into()?) | ||
.build()?; | ||
|
||
// Dataset is available in the 'resources' directory | ||
let mut graph = client.select_graph("imdb"); | ||
|
||
let mut cloned_graph = client.copy_graph("imdb", "imdb_clone")?; | ||
|
||
let mut res = graph.query("MATCH (a:actor) return a").execute()?; | ||
let mut clone_graph_res = cloned_graph.query("MATCH (a:actor) return a").execute()?; | ||
|
||
// Parses them one by one, to avoid unneeded performance hits | ||
assert_eq!(res.data.len(), 1317); | ||
assert_eq!(clone_graph_res.data.len(), 1317); | ||
if let (Some(orig), Some(cloned)) = (res.data.next(), clone_graph_res.data.next()) { | ||
println!("Original one: {orig:?}, Cloned one: {cloned:?}"); | ||
assert_eq!(orig, cloned); | ||
} | ||
|
||
// We have already parsed one result | ||
assert_eq!(res.data.len(), 1316); | ||
assert_eq!(clone_graph_res.data.len(), 1316); | ||
|
||
// more iterator usage: | ||
for (orig, cloned) in res.data.zip(clone_graph_res.data) { | ||
println!("Original one: {orig:?}, Cloned one: {cloned:?}"); | ||
assert_eq!(orig, cloned); | ||
} | ||
|
||
cloned_graph.delete()?; | ||
|
||
let res_again = graph.query("MATCH (a:actor) return a").execute()?; | ||
let as_vec = res_again.data.collect::<Vec<_>>(); | ||
assert_eq!(as_vec.len(), 1317); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.