Skip to content

Commit

Permalink
Reuse transmute_u8_to_slice (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
hicder authored Jan 2, 2025
1 parent 3337dd0 commit 2cc9ffd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rs/index_server/src/index_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use proto::muopdb::{
FlushRequest, FlushResponse, InsertBinaryRequest, InsertBinaryResponse, InsertRequest, InsertResponse, SearchRequest, SearchResponse
};
use tokio::sync::Mutex;
use utils::mem::transmute_u8_to_slice;

use crate::collection_catalog::CollectionCatalog;

Expand Down Expand Up @@ -189,8 +190,8 @@ impl IndexServer for IndexServerImpl {
match collection_opt {
Some(collection) => {
let dimensions = collection.dimensions();
let vectors = unsafe { std::slice::from_raw_parts(vectors_buffer.as_ptr() as *const f32, vectors_buffer.len() / 4) };
let ids = unsafe { std::slice::from_raw_parts(ids_buffer.as_ptr() as *const u64, ids_buffer.len() / 8) };
let vectors = transmute_u8_to_slice(&vectors_buffer);
let ids = transmute_u8_to_slice(&ids_buffer);

if vectors.len() % dimensions != 0 {
return Err(tonic::Status::new(
Expand Down

0 comments on commit 2cc9ffd

Please sign in to comment.