Skip to content

Commit

Permalink
close index file fd only if index is not build via socket
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed Sep 3, 2024
1 parent 96f2c24 commit d85aeae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.3)
include(CheckSymbolExists)

set(LANTERN_VERSION 0.3.2)
set(LANTERN_VERSION 0.3.3)

project(
LanternDB
Expand Down Expand Up @@ -263,6 +263,7 @@ endif()
set (_update_files
sql/updates/0.3.0--0.3.1.sql
sql/updates/0.3.1--0.3.2.sql
sql/updates/0.3.2--0.3.3.sql
)

# Generate version information for the binary
Expand Down
Empty file added sql/updates/0.3.2--0.3.3.sql
Empty file.
7 changes: 3 additions & 4 deletions src/hnsw/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_

if(buildstate->index_file_path) {
index_file_fd = open(buildstate->index_file_path, O_RDONLY);
assert(index_file_fd > 0);
} else if(buildstate->external) {
external_index_receive_index_file(buildstate->external_socket, &num_added_vectors, &result_buf);
} else {
Expand All @@ -565,10 +566,9 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_
usearch_save(buildstate->usearch_index, tmp_index_file_path, &error);
assert(error == NULL);
index_file_fd = open(tmp_index_file_path, O_RDONLY);
assert(index_file_fd > 0);
}

assert(index_file_fd > 0);

if(!buildstate->external) {
num_added_vectors = usearch_size(buildstate->usearch_index, &error);
}
Expand Down Expand Up @@ -598,10 +598,9 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_
munmap_ret = munmap(result_buf, index_file_stat.st_size);
assert(munmap_ret == 0);
LDB_UNUSED(munmap_ret);
close(index_file_fd);
}

close(index_file_fd);

if(buildstate->external) {
buildstate->external_socket->close(buildstate->external_socket);
}
Expand Down

0 comments on commit d85aeae

Please sign in to comment.