migrate local.rs and memory.rs to use index
- Add Store::all_keys() method for iteration - Convert store.nodes.get() → store.get_node() - Convert store.nodes.contains_key() → store.contains_key() - Convert store.nodes.values() iteration → all_keys + get_node Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
7eb86656d4
commit
fe6450223c
3 changed files with 46 additions and 27 deletions
|
|
@ -26,7 +26,7 @@ impl MemoryNode {
|
|||
|
||||
/// Load from an already-open store.
|
||||
pub fn from_store(store: &Store, key: &str) -> Option<Self> {
|
||||
let node = store.nodes.get(key)?;
|
||||
let node = store.get_node(key).ok()??;
|
||||
|
||||
// If set, tag links to nodes created after this timestamp as (new)
|
||||
let older_than: i64 = std::env::var("POC_MEMORIES_OLDER_THAN")
|
||||
|
|
@ -45,7 +45,9 @@ impl MemoryNode {
|
|||
continue;
|
||||
};
|
||||
|
||||
let is_new = older_than > 0 && store.nodes.get(neighbor_key.as_str())
|
||||
let is_new = older_than > 0 && store.get_node(neighbor_key)
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|n| n.created_at > older_than)
|
||||
.unwrap_or(false);
|
||||
|
||||
|
|
@ -61,7 +63,7 @@ impl MemoryNode {
|
|||
|
||||
Some(MemoryNode {
|
||||
key: key.to_string(),
|
||||
content: node.content.clone(),
|
||||
content: node.content,
|
||||
links,
|
||||
version: node.version,
|
||||
weight: node.weight,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue