Skip to main content

KgStore

Struct KgStore 

Source
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

Source

pub fn new() -> Self

Create a new store with standard RDF prefixes and a single “default” namespace.

Source

pub fn with_config( namespaces: &[&str], default_namespace: &str, layer: Option<u8>, ) -> Self

Create with custom namespace partitions and layer.

Source

pub fn bind_prefix(&mut self, prefix: &str, uri: &str)

Bind a namespace prefix (e.g., "rdf""http://www.w3.org/...").

Source

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.

Source

pub fn compact_uri(&self, uri: &str) -> String

Compact a full URI to prefixed form. Matches longest prefix first to avoid ambiguity.

Source

pub fn prefixes(&self) -> &HashMap<String, String>

Get all bound prefixes.

Source

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.

Source

pub fn add_triples( &mut self, triples: &[(&str, &str, &str, f64)], source: Option<&str>, ) -> Result<Vec<String>, StoreError>

Add multiple triples in batch.

Source

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.

Source

pub fn search_by_keywords( &self, keywords: &[&str], ) -> Vec<(StoredTriple, String)>

Search by keywords (case-insensitive substring match on s/p/o).

Source

pub fn clear(&mut self)

Clear all triples.

Source

pub fn record_knowledge_gap( &mut self, question: &str, keywords: &[&str], confidence: f64, missing_concepts: &[&str], ) -> usize

Record a knowledge gap.

Source

pub fn unresolved_gaps(&self) -> Vec<&KnowledgeGap>

Get unresolved knowledge gaps.

Source

pub fn resolve_gap(&mut self, index: usize) -> bool

Resolve a knowledge gap by index.

Source

pub fn statistics(&self) -> KgStats

Get store statistics.

Source

pub fn len(&self) -> usize

Total triple count.

Source

pub fn is_empty(&self) -> bool

Whether empty.

Source

pub fn inner(&self) -> &ArrowGraphStore

Get reference to underlying ArrowGraphStore.

Source

pub fn inner_mut(&mut self) -> &mut ArrowGraphStore

Get mutable reference to underlying ArrowGraphStore.

Trait Implementations§

Source§

impl Default for KgStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.