pub struct KgStore { /* private fields */ }Expand description
Full-featured Arrow-native knowledge graph store.
Provides:
- Namespace prefix management (expand/compact URIs)
- Pattern-based triple queries
- Keyword search (case-insensitive substring matching)
- Knowledge gap tracking
- Bulk add operations
Implementations§
Source§impl KgStore
impl KgStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new store with standard RDF prefixes and a single “default” namespace.
Sourcepub fn with_config(
namespaces: &[&str],
default_namespace: &str,
layer: Option<u8>,
) -> Self
pub fn with_config( namespaces: &[&str], default_namespace: &str, layer: Option<u8>, ) -> Self
Create with custom namespace partitions and layer.
Sourcepub fn bind_prefix(&mut self, prefix: &str, uri: &str)
pub fn bind_prefix(&mut self, prefix: &str, uri: &str)
Bind a namespace prefix (e.g., "rdf" → "http://www.w3.org/...").
Sourcepub fn expand_uri(&self, value: &str) -> String
pub fn expand_uri(&self, value: &str) -> String
Expand a prefixed URI (e.g., “rdf:type” → full URI). Returns the original string if no prefix matches.
Sourcepub fn compact_uri(&self, uri: &str) -> String
pub fn compact_uri(&self, uri: &str) -> String
Compact a full URI to prefixed form. Matches longest prefix first to avoid ambiguity.
Sourcepub fn add_triple(
&mut self,
subject: &str,
predicate: &str,
object: &str,
source: Option<&str>,
confidence: f64,
) -> Result<String, StoreError>
pub fn add_triple( &mut self, subject: &str, predicate: &str, object: &str, source: Option<&str>, confidence: f64, ) -> Result<String, StoreError>
Add a triple with automatic namespace expansion on URIs.
Sourcepub fn add_triples(
&mut self,
triples: &[(&str, &str, &str, f64)],
source: Option<&str>,
) -> Result<Vec<String>, StoreError>
pub fn add_triples( &mut self, triples: &[(&str, &str, &str, f64)], source: Option<&str>, ) -> Result<Vec<String>, StoreError>
Add multiple triples in batch.
Sourcepub fn query(
&self,
subject: Option<&str>,
predicate: Option<&str>,
object: Option<&str>,
) -> Result<Vec<StoredTriple>, StoreError>
pub fn query( &self, subject: Option<&str>, predicate: Option<&str>, object: Option<&str>, ) -> Result<Vec<StoredTriple>, StoreError>
Query by (s, p, o) pattern. None means wildcard. URIs are expanded.
Sourcepub fn search_by_keywords(
&self,
keywords: &[&str],
) -> Vec<(StoredTriple, String)>
pub fn search_by_keywords( &self, keywords: &[&str], ) -> Vec<(StoredTriple, String)>
Search by keywords (case-insensitive substring match on s/p/o).
Sourcepub fn record_knowledge_gap(
&mut self,
question: &str,
keywords: &[&str],
confidence: f64,
missing_concepts: &[&str],
) -> usize
pub fn record_knowledge_gap( &mut self, question: &str, keywords: &[&str], confidence: f64, missing_concepts: &[&str], ) -> usize
Record a knowledge gap.
Sourcepub fn unresolved_gaps(&self) -> Vec<&KnowledgeGap>
pub fn unresolved_gaps(&self) -> Vec<&KnowledgeGap>
Get unresolved knowledge gaps.
Sourcepub fn resolve_gap(&mut self, index: usize) -> bool
pub fn resolve_gap(&mut self, index: usize) -> bool
Resolve a knowledge gap by index.
Sourcepub fn statistics(&self) -> KgStats
pub fn statistics(&self) -> KgStats
Get store statistics.
Sourcepub fn inner(&self) -> &ArrowGraphStore
pub fn inner(&self) -> &ArrowGraphStore
Get reference to underlying ArrowGraphStore.
Sourcepub fn inner_mut(&mut self) -> &mut ArrowGraphStore
pub fn inner_mut(&mut self) -> &mut ArrowGraphStore
Get mutable reference to underlying ArrowGraphStore.