This commit is contained in:
2026-07-22 20:34:15 -04:00
parent 21016af858
commit 0ddf2caf38
6 changed files with 61 additions and 111 deletions
+6 -3
View File
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use iced::futures::TryFutureExt;
use oxigraph::store::Store;
use tracing::debug_span;
use tracing::{debug_span, field};
use crate::rdf::{conversion, materialize};
use crate::rdf::language::LanguageCondition;
@@ -173,7 +173,7 @@ impl Ontology {
.collect::<Dataset>()
}
pub fn index(&self, language: &LanguageCondition, source: Option<Dataset>) -> impl Future<Output = error::Result<HashMap<NamedNode, IndexEntry>>> + 'static {
pub fn query_for_indexable_triples(&self, language: &LanguageCondition, source: Option<Dataset>) -> impl Future<Output = error::Result<HashMap<NamedNode, IndexEntry>>> + 'static {
let language_filter = language.to_filter_expression("fieldValue");
let query = format!(r#"SELECT ?individual ?categoryId ?fieldName ?fieldValue
WHERE {{
@@ -196,7 +196,7 @@ WHERE {{
let store = self.store.clone();
tokio::task::spawn_blocking(move || {
let _span = debug_span!("Index Query").entered();
let span = debug_span!("Indexable Triples Query", solutions = field::Empty).entered();
let query_results = if let Some(source) = &source {
sparql.on_queryable_dataset(source).execute()
} else {
@@ -205,6 +205,7 @@ WHERE {{
let mut results = HashMap::new();
if let QueryResults::Solutions(solutions) = query_results {
let mut counter = 0usize;
for solution in solutions.filter_map(Result::ok) {
let individual = solution.get("individual").and_then(conversion::term_to_named_node);
let catalog_id = solution.get("categoryId").and_then(conversion::term_to_u64);
@@ -219,7 +220,9 @@ WHERE {{
fields: HashMap::from_iter([(field_name.to_owned(), field_value.to_owned())]),
});
}
counter += 1;
}
span.record("solutions", counter);
} else {
unreachable!()
}