Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix int overflow issue for progress #186

Merged
merged 2 commits into from Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/hnsw/external_index.c
Expand Up @@ -32,7 +32,7 @@ static uint32 UsearchNodeBytes(usearch_metadata_t *metadata, int vector_bytes, i
}

static char *extract_node(char *data,
int progress,
progress_t progress,
int dim,
usearch_metadata_t *metadata,
/*->>output*/ int *node_size,
Expand Down Expand Up @@ -107,7 +107,7 @@ void StoreExternalIndexBlockMapGroup(Relation index,
HnswIndexHeaderPage *headerp,
ForkNumber forkNum,
char *data,
int *progress,
progress_t *progress,
int dimension,
int first_node_index,
size_t num_added_vectors,
Expand Down Expand Up @@ -275,11 +275,11 @@ void StoreExternalIndex(Relation index,
memcpy(headerp->usearch_header, data, USEARCH_HEADER_SIZE);
((PageHeader)header_page)->pd_lower = ((char *)headerp + sizeof(HnswIndexHeaderPage)) - (char *)header_page;

int progress = USEARCH_HEADER_SIZE; // usearch header size
int blockmap_groupno = 0;
int group_node_first_index = 0;
int num_added_vectors_remaining = (int)num_added_vectors;
int batch_size = HNSW_BLOCKMAP_BLOCKS_PER_PAGE;
progress_t progress = USEARCH_HEADER_SIZE; // usearch header size
int blockmap_groupno = 0;
int group_node_first_index = 0;
int num_added_vectors_remaining = (int)num_added_vectors;
int batch_size = HNSW_BLOCKMAP_BLOCKS_PER_PAGE;
while(num_added_vectors_remaining > 0) {
StoreExternalIndexBlockMapGroup(index,
external_index,
Expand Down
1 change: 1 addition & 0 deletions src/hnsw/external_index.h
Expand Up @@ -33,6 +33,7 @@

#define USEARCH_HEADER_SIZE 80

typedef unsigned long long int progress_t;
typedef struct HnswIndexHeaderPage
{
uint32 magicNumber;
Expand Down