From 8d2d414bdac133212bafdaa0b18cda010512a172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Bour?= Date: Mon, 18 Sep 2023 18:08:20 +0200 Subject: [PATCH] Update bindgen (fixes #15) --- ngt-sys/Cargo.toml | 2 +- src/ngt/index.rs | 16 ++++++------ src/ngt/optim.rs | 14 +++++----- src/qbg/index.rs | 18 ++++++------- src/qbg/properties.rs | 60 +++++++++++++++++++++---------------------- src/qg/index.rs | 4 +-- src/qg/properties.rs | 2 +- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/ngt-sys/Cargo.toml b/ngt-sys/Cargo.toml index 1880084..b2a97e5 100644 --- a/ngt-sys/Cargo.toml +++ b/ngt-sys/Cargo.toml @@ -11,7 +11,7 @@ categories = ["science"] license = "Apache-2.0" [build-dependencies] -bindgen = "0.60" +bindgen = "0.68" cmake = "0.1" cpp_build = { version = "0.5", optional = true } diff --git a/src/ngt/index.rs b/src/ngt/index.rs index 744f09b..10c836f 100644 --- a/src/ngt/index.rs +++ b/src/ngt/index.rs @@ -122,7 +122,7 @@ where self.index, vec.as_ptr() as *mut f32, self.prop.dimension, - res_size as u64, + res_size, epsilon, -1.0, results, @@ -136,7 +136,7 @@ where self.index, vec.as_ptr() as *mut u8, self.prop.dimension, - res_size as u64, + res_size, epsilon, -1.0, results, @@ -150,7 +150,7 @@ where self.index, vec.as_ptr() as *mut _, self.prop.dimension, - res_size as u64, + res_size, epsilon, -1.0, results, @@ -445,9 +445,9 @@ impl Drop for NgtIndex { #[derive(Debug, Clone, PartialEq)] pub struct NgtQuery<'a, T> { query: &'a [T], - pub size: u64, + pub size: usize, pub epsilon: f32, - pub edge_size: u64, + pub edge_size: usize, pub radius: f32, } @@ -460,13 +460,13 @@ where query, size: 10, epsilon: crate::EPSILON, - edge_size: u64::MIN, + edge_size: usize::MIN, radius: -1., } } pub fn size(mut self, size: usize) -> Self { - self.size = size as u64; + self.size = size; self } @@ -476,7 +476,7 @@ where } pub fn edge_size(mut self, edge_size: usize) -> Self { - self.edge_size = edge_size as u64; + self.edge_size = edge_size; self } diff --git a/src/ngt/optim.rs b/src/ngt/optim.rs index 4aa1156..486f22d 100644 --- a/src/ngt/optim.rs +++ b/src/ngt/optim.rs @@ -119,13 +119,13 @@ where /// Parameters for [`optimize_anng_edges_number`](optimize_anng_edges_number). #[derive(Debug, Clone, PartialEq)] pub struct AnngEdgeOptimParams { - pub nb_queries: u64, - pub nb_results: u64, - pub nb_threads: u64, + pub nb_queries: usize, + pub nb_results: usize, + pub nb_threads: usize, pub target_accuracy: f32, - pub target_nb_objects: u64, - pub nb_sample_objects: u64, - pub nb_edges_max: u64, + pub target_nb_objects: usize, + pub nb_sample_objects: usize, + pub nb_edges_max: usize, pub log: bool, } @@ -166,7 +166,7 @@ pub struct AnngRefineParams { expected_accuracy: f32, nb_edges: i32, edge_size: i32, - batch_size: u64, + batch_size: usize, } impl Default for AnngRefineParams { diff --git a/src/qbg/index.rs b/src/qbg/index.rs index 8cf1dfb..4fdf64d 100644 --- a/src/qbg/index.rs +++ b/src/qbg/index.rs @@ -327,12 +327,12 @@ impl IndexMode for ModeWrite {} #[derive(Debug, Clone, PartialEq)] pub struct QbgQuery<'a, T> { query: &'a [T], - pub size: u64, + pub size: usize, pub epsilon: f32, pub blob_epsilon: f32, pub result_expansion: f32, - pub number_of_explored_blobs: u64, - pub number_of_edges: u64, + pub number_of_explored_blobs: usize, + pub number_of_edges: usize, pub radius: f32, } @@ -354,7 +354,7 @@ where } pub fn size(mut self, size: usize) -> Self { - self.size = size as u64; + self.size = size; self } @@ -374,12 +374,12 @@ where } pub fn number_of_explored_blobs(mut self, number_of_explored_blobs: usize) -> Self { - self.number_of_explored_blobs = number_of_explored_blobs as u64; + self.number_of_explored_blobs = number_of_explored_blobs; self } pub fn number_of_edges(mut self, number_of_edges: usize) -> Self { - self.number_of_edges = number_of_edges as u64; + self.number_of_edges = number_of_edges; self } @@ -424,7 +424,7 @@ mod tests { // Insert vectors and get their ids let nvecs = 64; let ids = (1..ndims * nvecs) - .step_by(ndims as usize) + .step_by(ndims) .map(|i| i as f32) .map(|i| { repeat(i) @@ -465,7 +465,7 @@ mod tests { // Insert vectors and get their ids let nvecs = 64; let ids = (1..ndims * nvecs) - .step_by(ndims as usize) + .step_by(ndims) .map(|i| f16::from_f32(i as f32)) .map(|i| { repeat(i) @@ -509,7 +509,7 @@ mod tests { // Insert vectors and get their ids let nvecs = 64; let ids = (1..ndims * nvecs) - .step_by(ndims as usize) + .step_by(ndims) .map(|i| i as u8) .map(|i| { repeat(i) diff --git a/src/qbg/properties.rs b/src/qbg/properties.rs index b77968f..27162cd 100644 --- a/src/qbg/properties.rs +++ b/src/qbg/properties.rs @@ -51,10 +51,10 @@ pub enum QbgDistance { #[derive(Debug, Clone, PartialEq)] pub struct QbgConstructParams { - extended_dimension: u64, - dimension: u64, - number_of_subvectors: u64, - number_of_blobs: u64, + extended_dimension: usize, + dimension: usize, + number_of_subvectors: usize, + number_of_blobs: usize, internal_data_type: QbgObject, data_type: QbgObject, distance_type: QbgDistance, @@ -66,7 +66,7 @@ where T: QbgObjectType, { pub fn dimension(dimension: usize) -> Self { - let extended_dimension = next_multiple_of_16(dimension) as u64; + let extended_dimension = next_multiple_of_16(dimension); let number_of_subvectors = 1; let number_of_blobs = 0; let internal_data_type = T::as_obj(); @@ -75,7 +75,7 @@ where Self { extended_dimension, - dimension: dimension as u64, + dimension, number_of_subvectors, number_of_blobs, internal_data_type, @@ -86,8 +86,8 @@ where } pub fn extended_dimension(mut self, extended_dimension: usize) -> Result { - if extended_dimension % 16 == 0 && extended_dimension as u64 >= self.dimension { - self.extended_dimension = extended_dimension as u64; + if extended_dimension % 16 == 0 && extended_dimension >= self.dimension { + self.extended_dimension = extended_dimension; Ok(self) } else { Err(Error(format!( @@ -98,12 +98,12 @@ where } pub fn number_of_subvectors(mut self, number_of_subvectors: usize) -> Self { - self.number_of_subvectors = number_of_subvectors as u64; + self.number_of_subvectors = number_of_subvectors; self } pub fn number_of_blobs(mut self, number_of_blobs: usize) -> Self { - self.number_of_blobs = number_of_blobs as u64; + self.number_of_blobs = number_of_blobs; self } @@ -149,18 +149,18 @@ pub enum QbgClusteringInitMode { pub struct QbgBuildParams { // hierarchical kmeans hierarchical_clustering_init_mode: QbgClusteringInitMode, - number_of_first_objects: u64, - number_of_first_clusters: u64, - number_of_second_objects: u64, - number_of_second_clusters: u64, - number_of_third_clusters: u64, + number_of_first_objects: usize, + number_of_first_clusters: usize, + number_of_second_objects: usize, + number_of_second_clusters: usize, + number_of_third_clusters: usize, // optimization - number_of_objects: u64, - number_of_subvectors: u64, + number_of_objects: usize, + number_of_subvectors: usize, optimization_clustering_init_mode: QbgClusteringInitMode, - rotation_iteration: u64, - subvector_iteration: u64, - number_of_matrices: u64, + rotation_iteration: usize, + subvector_iteration: usize, + number_of_matrices: usize, rotation: bool, repositioning: bool, } @@ -196,36 +196,36 @@ impl QbgBuildParams { } pub fn number_of_first_objects(mut self, number_of_first_objects: usize) -> Self { - self.number_of_first_objects = number_of_first_objects as u64; + self.number_of_first_objects = number_of_first_objects; self } pub fn number_of_first_clusters(mut self, number_of_first_clusters: usize) -> Self { - self.number_of_first_clusters = number_of_first_clusters as u64; + self.number_of_first_clusters = number_of_first_clusters; self } pub fn number_of_second_objects(mut self, number_of_second_objects: usize) -> Self { - self.number_of_second_objects = number_of_second_objects as u64; + self.number_of_second_objects = number_of_second_objects; self } pub fn number_of_second_clusters(mut self, number_of_second_clusters: usize) -> Self { - self.number_of_second_clusters = number_of_second_clusters as u64; + self.number_of_second_clusters = number_of_second_clusters; self } pub fn number_of_third_clusters(mut self, number_of_third_clusters: usize) -> Self { - self.number_of_third_clusters = number_of_third_clusters as u64; + self.number_of_third_clusters = number_of_third_clusters; self } pub fn number_of_objects(mut self, number_of_objects: usize) -> Self { - self.number_of_objects = number_of_objects as u64; + self.number_of_objects = number_of_objects; self } pub fn number_of_subvectors(mut self, number_of_subvectors: usize) -> Self { - self.number_of_subvectors = number_of_subvectors as u64; + self.number_of_subvectors = number_of_subvectors; self } pub fn optimization_clustering_init_mode( @@ -237,17 +237,17 @@ impl QbgBuildParams { } pub fn rotation_iteration(mut self, rotation_iteration: usize) -> Self { - self.rotation_iteration = rotation_iteration as u64; + self.rotation_iteration = rotation_iteration; self } pub fn subvector_iteration(mut self, subvector_iteration: usize) -> Self { - self.subvector_iteration = subvector_iteration as u64; + self.subvector_iteration = subvector_iteration; self } pub fn number_of_matrices(mut self, number_of_matrices: usize) -> Self { - self.number_of_matrices = number_of_matrices as u64; + self.number_of_matrices = number_of_matrices; self } diff --git a/src/qg/index.rs b/src/qg/index.rs index 5be0fed..bc30faf 100644 --- a/src/qg/index.rs +++ b/src/qg/index.rs @@ -215,7 +215,7 @@ impl Drop for QgIndex { #[derive(Debug, Clone, PartialEq)] pub struct QgQuery<'a, T> { query: &'a [T], - pub size: u64, + pub size: usize, pub epsilon: f32, pub result_expansion: f32, pub radius: f32, @@ -236,7 +236,7 @@ where } pub fn size(mut self, size: usize) -> Self { - self.size = size as u64; + self.size = size; self } diff --git a/src/qg/properties.rs b/src/qg/properties.rs index 53abda3..1754c39 100644 --- a/src/qg/properties.rs +++ b/src/qg/properties.rs @@ -337,7 +337,7 @@ where #[derive(Debug, Clone, PartialEq)] pub struct QgQuantizationParams { pub dimension_of_subvector: f32, - pub max_number_of_edges: u64, + pub max_number_of_edges: usize, } impl Default for QgQuantizationParams {