Skip to content

Commit 756766a

Browse files
committed
remove repr(packed) because bincode already packs structs
1 parent 9f25ffd commit 756766a

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎crates/api/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ mod tests {
233233
let temp_dir = tempdir().unwrap();
234234
let config = DbConfig {
235235
storage_type: StorageType::RocksDb,
236-
index_type: IndexType::HNSW,
236+
index_type: IndexType::Flat,
237237
data_path: temp_dir.path().to_path_buf(),
238238
dimension: 3,
239239
similarity: Similarity::Cosine,
@@ -359,7 +359,7 @@ mod tests {
359359

360360
// Search with limit 3
361361
let query = vec![0.0, 0.0, 0.0];
362-
let results = db.search(query, Similarity::Cosine, 3).unwrap();
362+
let results = db.search(query, Similarity::Euclidean, 3).unwrap();
363363

364364
assert_eq!(results.len(), 3);
365365
}

‎crates/index/src/hnsw/serialize.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::{
1212
},
1313
};
1414

15-
#[repr(packed)]
1615
#[derive(Serialize, Deserialize)]
1716
pub struct HnswMetadataPack {
1817
pub ef_construction: usize,
@@ -51,7 +50,7 @@ impl SerializableIndex for HnswIndex {
5150
.map_err(|e| DbError::SerializationError(e.to_string()))?;
5251
buffer.extend(index_bytes);
5352

54-
return Ok(buffer);
53+
Ok(buffer)
5554
}
5655

5756
fn serialize_metadata(&self) -> Result<Vec<u8>, DbError> {
@@ -66,7 +65,7 @@ impl SerializableIndex for HnswIndex {
6665
let metadata_bytes = bincode::serialize(&index_pack)
6766
.map_err(|e| DbError::SerializationError(e.to_string()))?;
6867
buffer.extend(metadata_bytes);
69-
return Ok(buffer);
68+
Ok(buffer)
7069
}
7170

7271
fn snapshot(&self) -> Result<IndexSnapshot, DbError> {

‎crates/snapshot/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ impl Snapshot {
283283
IndexType::Flat => Arc::new(RwLock::new(FlatIndex::deserialize(&index_snapshot)?)),
284284
IndexType::KDTree => Arc::new(RwLock::new(KDTree::deserialize(&index_snapshot)?)),
285285
IndexType::HNSW => Arc::new(RwLock::new(HnswIndex::deserialize(&index_snapshot)?)),
286-
_ => return Err(DbError::SnapshotError("Unsupported index type".to_string())),
287286
};
288287

289288
vector_index

0 commit comments

Comments
 (0)