Prepare text search during media setup and retain query sessions through promotion
This commit is contained in:
1 parent
af6ce29125
commit
9aae3f8216
15 files changed
+1235
-65
No files matched your search
@@ -82,6 +82,15 @@ impl Store {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn has_compatible_full_generation(&self, expected: &str) -> Result<bool> {
|
||||
let active: Option<String> = self.connection.query_row(
|
||||
"SELECT g.fingerprint FROM semantic_meta m JOIN semantic_generations g ON g.id=m.active_generation WHERE m.singleton=1 AND g.dimensions=?1",
|
||||
[self.dimensions as i64], |row| row.get(0)).optional()?;
|
||||
Ok(active.as_deref().is_some_and(|active| {
|
||||
super::policy_coverage(expected, active) == Some(super::SemanticCoverage::FullMedia)
|
||||
}))
|
||||
}
|
||||
|
||||
pub(crate) fn active_fingerprint(&self) -> Result<Option<String>> {
|
||||
Ok(self.connection.query_row("SELECT g.fingerprint FROM semantic_meta m JOIN semantic_generations g ON g.id=m.active_generation WHERE m.singleton=1",[],|r|r.get(0)).optional()?)
|
||||
}
|
||||
@@ -525,11 +534,16 @@ impl Store {
|
||||
// A consistent read snapshot covers eligibility and materialization.
|
||||
let generation_span = trace.begin("semantic.generation_snapshot", parent);
|
||||
let snapshot = self.connection.unchecked_transaction()?;
|
||||
let active:Option<i64>=snapshot.query_row("SELECT g.id FROM semantic_generations g JOIN semantic_meta m ON m.active_generation=g.id WHERE g.fingerprint=?1 AND g.dimensions=?2",
|
||||
params![fingerprint,self.dimensions as i64],|row|row.get(0)).optional()?;
|
||||
let Some(active) = active else {
|
||||
let active:Option<(i64,String)>=snapshot.query_row("SELECT g.id,g.fingerprint FROM semantic_generations g JOIN semantic_meta m ON m.active_generation=g.id WHERE g.dimensions=?1",
|
||||
[self.dimensions as i64],|row|Ok((row.get(0)?,row.get(1)?))).optional()?;
|
||||
let Some((active, active_fingerprint)) = active else {
|
||||
trace.end(generation_span, Default::default());
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
if !super::compatible_query_policy(fingerprint, &active_fingerprint) {
|
||||
trace.end(generation_span, Default::default());
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
trace.end(generation_span, Default::default());
|
||||
if !self
|
||||
.ann_cache
|
||||
@@ -542,7 +556,8 @@ impl Store {
|
||||
[active],
|
||||
|row| row.get(0),
|
||||
)?;
|
||||
self.prepared_graphs.get(active, fingerprint, &checksum)
|
||||
self.prepared_graphs
|
||||
.get(active, &active_fingerprint, &checksum)
|
||||
})?;
|
||||
if let Some(graph) = prepared {
|
||||
self.ann_cache = Some((active, graph));
|
||||
|
||||
Reference in new issue
Block a user