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 /// Pushes a quin.
9 fn push(&mut self, q: NQuin) -> io::Result<()>;
10
11 /// Record a term's `hash → lexical string` so the value can be recovered later
12 /// (literal text, IRIs). Default is a no-op — sinks that do not build a lexicon
13 /// (or callers that do not need recovery) pay nothing. The streaming ingest sink
14 /// implements this to populate the `.q42` front-of-file Q42LEX section.
15 fn push_lex(&mut self, _hash: u64, _term: &str) {}
16}
17
18impl QuinSink for crate::external_sort::ExternalSorter {
19 /// Pushes a quin.
20 fn push(&mut self, q: NQuin) -> io::Result<()> {
21 crate::external_sort::ExternalSorter::push(self, q)
22 }
23
24 fn push_lex(&mut self, hash: u64, term: &str) {
25 crate::external_sort::ExternalSorter::push_lex(self, hash, term)
26 }
27}