apply review comment

This commit is contained in:
Tamo 2024-09-19 16:47:06 +02:00
parent 74199f328d
commit f6483cf15d

View File

@ -1648,25 +1648,15 @@ impl Index {
let mut res = BTreeMap::new(); let mut res = BTreeMap::new();
let embedding_configs = self.embedding_configs(rtxn)?; let embedding_configs = self.embedding_configs(rtxn)?;
for config in embedding_configs { for config in embedding_configs {
// TODO: return internal error instead
let embedder_id = self.embedder_category_id.get(rtxn, &config.name)?.unwrap(); let embedder_id = self.embedder_category_id.get(rtxn, &config.name)?.unwrap();
let embedder_id = (embedder_id as u16) << 8; let embeddings = self
.arroy_readers(rtxn, embedder_id, config.config.quantized())
let mut embeddings = Vec::new(); .map_while(|reader| {
'vectors: for i in 0..=u8::MAX { reader
let reader = ArroyWrapper::new( .and_then(|r| r.item_vector(rtxn, docid).map_err(|e| e.into()))
self.vector_arroy, .transpose()
embedder_id | (i as u16), })
config.config.quantized(), .collect::<Result<Vec<_>>>()?;
);
match reader.item_vector(rtxn, docid) {
Err(arroy::Error::MissingMetadata(_)) => break 'vectors,
Err(err) => return Err(err.into()),
Ok(None) => break 'vectors,
Ok(Some(embedding)) => embeddings.push(embedding),
};
}
res.insert(config.name.to_owned(), embeddings); res.insert(config.name.to_owned(), embeddings);
} }
Ok(res) Ok(res)