Skip to main content

qualia_core_db/sparql_library/
quin_sink.rs

1//! Shared quin sink trait for streaming RDF parsers.
2
3use crate::NQuin;
4use std::io;
5
6/// Accepts quins from format parsers without mandating heap growth.
7pub trait QuinSink {
8    fn push(&mut self, q: NQuin) -> io::Result<()>;
9
10    /// Record a term's `hash → lexical string` so the value can be recovered later
11    /// (literal text, IRIs). Default is a no-op — sinks that do not build a lexicon
12    /// (or callers that do not need recovery) pay nothing. The streaming ingest sink
13    /// implements this to populate the `.q42` front-of-file Q42LEX section.
14    fn push_lex(&mut self, _hash: u64, _term: &str) {}
15}
16
17impl QuinSink for crate::external_sort::ExternalSorter {
18    fn push(&mut self, q: NQuin) -> io::Result<()> {
19        crate::external_sort::ExternalSorter::push(self, q)
20    }
21
22    fn push_lex(&mut self, hash: u64, term: &str) {
23        crate::external_sort::ExternalSorter::push_lex(self, hash, term)
24    }
25}