WIP: work towards wiring up a embeddings_for_digest hashmap that is stored for all indexed files
This commit is contained in:
parent
50cfb067e7
commit
afa59abbcd
2 changed files with 104 additions and 23 deletions
|
@ -9,6 +9,7 @@ use gpui::executor;
|
|||
use project::{search::PathMatcher, Fs};
|
||||
use rpc::proto::Timestamp;
|
||||
use rusqlite::params;
|
||||
use rusqlite::types::Value;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashMap,
|
||||
|
@ -283,6 +284,41 @@ impl VectorDatabase {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn embeddings_for_files(
|
||||
&self,
|
||||
worktree_id_file_paths: Vec<(i64, PathBuf)>,
|
||||
) -> impl Future<Output = Result<HashMap<DocumentDigest, Embedding>>> {
|
||||
todo!();
|
||||
// The remainder of the code is wired up.
|
||||
// I'm having a bit of trouble figuring out the rusqlite syntax for a WHERE (files.worktree_id, files.relative_path) IN (VALUES (?, ?), (?, ?)) query
|
||||
async { Ok(HashMap::new()) }
|
||||
// let mut embeddings_by_digest = HashMap::new();
|
||||
// self.transact(move |db| {
|
||||
|
||||
// let worktree_ids: Rc<Vec<Value>> = Rc::new(
|
||||
// worktree_id_file_paths
|
||||
// .iter()
|
||||
// .map(|(id, _)| Value::from(*id))
|
||||
// .collect(),
|
||||
// );
|
||||
// let file_paths: Rc<Vec<Value>> = Rc::new(worktree_id_file_paths
|
||||
// .iter()
|
||||
// .map(|(_, path)| Value::from(path.to_string_lossy().to_string()))
|
||||
// .collect());
|
||||
|
||||
// let mut query = db.prepare("SELECT digest, embedding FROM documents LEFT JOIN files ON files.id = documents.file_id WHERE (files.worktree_id, files.relative_path) IN (VALUES (rarray = (?1), rarray = (?2))")?;
|
||||
|
||||
// for row in query.query_map(params![worktree_ids, file_paths], |row| {
|
||||
// Ok((row.get::<_, DocumentDigest>(0)?, row.get::<_, Embedding>(1)?))
|
||||
// })? {
|
||||
// if let Ok(row) = row {
|
||||
// embeddings_by_digest.insert(row.0, row.1);
|
||||
// }
|
||||
// }
|
||||
// Ok(embeddings_by_digest)
|
||||
// })
|
||||
}
|
||||
|
||||
pub fn find_or_create_worktree(
|
||||
&self,
|
||||
worktree_root_path: PathBuf,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue