Skip to content

Commit

Permalink
Merge pull request #58 from ava57r/clustering-1
Browse files Browse the repository at this point in the history
improve Clustering impl
  • Loading branch information
Enet4 authored Oct 19, 2022
2 parents e2e012c + efbd31a commit 05031d0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ impl ClusteringParameters {
self.inner.spherical != 0
}

/// Getter for the `int_centroids` property.
/// Round centroids coordinates to integer
pub fn int_centroids(&self) -> bool {
self.inner.int_centroids != 0
}

pub fn update_index(&self) -> bool {
self.inner.update_index != 0
}
Expand All @@ -64,6 +70,12 @@ impl ClusteringParameters {
self.inner.seed as u32
}

/// Getter for the `decode_block_size` property.
/// How many vectors at a time to decode
pub fn decode_block_size(&self) -> usize {
self.inner.decode_block_size
}

pub fn set_niter(&mut self, niter: u32) {
self.inner.niter = (niter & 0x7FFF_FFFF) as i32;
}
Expand Down Expand Up @@ -92,13 +104,25 @@ impl ClusteringParameters {
self.inner.spherical = if spherical { 1 } else { 0 };
}

/// Setter for the `int_centroids` property.
/// Round centroids coordinates to integer
pub fn set_int_centroids(&mut self, int_centroids: bool) {
self.inner.int_centroids = if int_centroids { 1 } else { 0 }
}

pub fn set_verbose(&mut self, verbose: bool) {
self.inner.verbose = if verbose { 1 } else { 0 };
}

pub fn set_seed(&mut self, seed: u32) {
self.inner.seed = seed as i32;
}

/// Setter for the `decode_block_size` property.
/// How many vectors at a time to decode
pub fn set_decode_block_size(&mut self, decode_block_size: usize) {
self.inner.decode_block_size = decode_block_size;
}
}

#[repr(C)]
Expand Down Expand Up @@ -305,6 +329,12 @@ impl Clustering {
unsafe { faiss_Clustering_spherical(self.inner) != 0 }
}

/// Getter for the `int_centroids` property of `Clustering`.
/// Round centroids coordinates to integer
pub fn int_centroids(&self) -> bool {
unsafe { faiss_Clustering_int_centroids(self.inner) != 0 }
}

/** Getter for the `update_index` property of `Clustering`. */
pub fn update_index(&self) -> bool {
unsafe { faiss_Clustering_update_index(self.inner) != 0 }
Expand All @@ -320,6 +350,12 @@ impl Clustering {
unsafe { faiss_Clustering_seed(self.inner) as u32 }
}

/// Getter for the `decode_block_size` property of `Clustering`.
/// How many vectors at a time to decode
pub fn decode_block_size(&self) -> usize {
unsafe { faiss_Clustering_decode_block_size(self.inner) }
}

/** Getter for the minimum number of points per centroid. */
pub fn min_points_per_centroid(&self) -> u32 {
unsafe { faiss_Clustering_min_points_per_centroid(self.inner) as u32 }
Expand Down

0 comments on commit 05031d0

Please sign in to comment.