Skip to content

Commit

Permalink
Update bindgen (fixes #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufflope committed Sep 18, 2023
1 parent 74f92ec commit 8d2d414
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion ngt-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
16 changes: 8 additions & 8 deletions src/ngt/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -445,9 +445,9 @@ impl<T> Drop for NgtIndex<T> {
#[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,
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
14 changes: 7 additions & 7 deletions src/ngt/optim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/qbg/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -354,7 +354,7 @@ where
}

pub fn size(mut self, size: usize) -> Self {
self.size = size as u64;
self.size = size;
self
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
60 changes: 30 additions & 30 deletions src/qbg/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ pub enum QbgDistance {

#[derive(Debug, Clone, PartialEq)]
pub struct QbgConstructParams<T> {
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,
Expand All @@ -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();
Expand All @@ -75,7 +75,7 @@ where

Self {
extended_dimension,
dimension: dimension as u64,
dimension,
number_of_subvectors,
number_of_blobs,
internal_data_type,
Expand All @@ -86,8 +86,8 @@ where
}

pub fn extended_dimension(mut self, extended_dimension: usize) -> Result<Self, Error> {
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!(
Expand All @@ -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
}

Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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(
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/qg/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<T> Drop for QgIndex<T> {
#[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,
Expand All @@ -236,7 +236,7 @@ where
}

pub fn size(mut self, size: usize) -> Self {
self.size = size as u64;
self.size = size;
self
}

Expand Down
2 changes: 1 addition & 1 deletion src/qg/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8d2d414

Please sign in to comment.