query: rich QueryResult + toolkit cleanup
QueryResult carries a fields map (BTreeMap<String, Value>) so callers don't re-resolve fields after queries run. Neighbors queries inject edge context (strength, rel_type) at construction time. New public API: - run_query(): parse + execute + format in one call - format_value(): format a Value for display - execute_parsed(): internal, avoids double-parse in run_query Removed: output_stages(), format_field() Simplified commands: - cmd_query, cmd_graph, cmd_link, cmd_list_keys all delegate to run_query - cmd_experience_mine uses existing find_current_transcript() Deduplication: - now_epoch() 3 copies → 1 (capnp_store's public fn) - hub_threshold → Graph::hub_threshold() method - eval_node + eval_edge → single eval() with closure for field resolution - compare() collapsed via Ordering (35 → 15 lines) Modernization: - 12 sites of partial_cmp().unwrap_or(Ordering::Equal) → total_cmp()
This commit is contained in:
parent
64d2b441f0
commit
fa7fe8c14b
7 changed files with 187 additions and 264 deletions
|
|
@ -23,19 +23,10 @@ use std::collections::HashMap;
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
fn home() -> PathBuf {
|
||||
PathBuf::from(env::var("HOME").expect("HOME not set"))
|
||||
}
|
||||
|
||||
fn now_epoch() -> f64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs_f64()
|
||||
}
|
||||
|
||||
// Old system data structures (just enough for deserialization)
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
@ -206,7 +197,7 @@ pub fn migrate() -> Result<(), String> {
|
|||
let node = Node {
|
||||
uuid,
|
||||
version: 1,
|
||||
timestamp: now_epoch(),
|
||||
timestamp: capnp_store::now_epoch(),
|
||||
node_type: if key.contains("journal") {
|
||||
NodeType::EpisodicSession
|
||||
} else {
|
||||
|
|
@ -246,7 +237,7 @@ pub fn migrate() -> Result<(), String> {
|
|||
let node = Node {
|
||||
uuid,
|
||||
version: 1,
|
||||
timestamp: now_epoch(),
|
||||
timestamp: capnp_store::now_epoch(),
|
||||
node_type: if key.contains("journal") {
|
||||
NodeType::EpisodicSession
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue