Skip to content

Commit

Permalink
remove unuseful log for ut and ft (#303)
Browse files Browse the repository at this point in the history
Signed-off-by: jinjiabao.jjb <[email protected]>
  • Loading branch information
inabao authored Jan 9, 2025
1 parent f7acef7 commit e87defc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ endif ()

# tests
if (ENABLE_TESTS)
target_compile_definitions(vsag PRIVATE ENABLE_TESTS)
add_subdirectory (tests)
endif ()

Expand Down
4 changes: 4 additions & 0 deletions src/index/diskann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ DiskANN::knn_search(const DatasetPtr& query,
int64_t k,
const std::string& parameters,
const std::function<bool(int64_t)>& filter) const {
#ifndef ENABLE_TESTS
SlowTaskTimer t("diskann knnsearch", 200);
#endif

// cannot perform search on empty index
if (empty_index_) {
Expand Down Expand Up @@ -461,7 +463,9 @@ DiskANN::range_search(const DatasetPtr& query,
const std::string& parameters,
const std::function<bool(int64_t)>& filter,
int64_t limited_size) const {
#ifndef ENABLE_TESTS
SlowTaskTimer t("diskann rangesearch", 200);
#endif

// cannot perform search on empty index
if (empty_index_) {
Expand Down
12 changes: 10 additions & 2 deletions src/index/hnsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ HNSW::build(const DatasetPtr& base) {

tl::expected<std::vector<int64_t>, Error>
HNSW::add(const DatasetPtr& base) {
#ifndef ENABLE_TESTS
SlowTaskTimer t("hnsw add", 20);
#endif
if (use_static_) {
LOG_ERROR_AND_RETURNS(ErrorType::UNSUPPORTED_INDEX_OPERATION,
"static index does not support add");
Expand Down Expand Up @@ -192,8 +194,9 @@ HNSW::knn_search(const DatasetPtr& query,
int64_t k,
const std::string& parameters,
BaseFilterFunctor* filter_ptr) const {
#ifndef ENABLE_TESTS
SlowTaskTimer t_total("hnsw knnsearch", 20);

#endif
try {
// cannot perform search on empty index
if (empty_index_) {
Expand Down Expand Up @@ -315,8 +318,9 @@ HNSW::range_search(const DatasetPtr& query,
const std::string& parameters,
BaseFilterFunctor* filter_ptr,
int64_t limited_size) const {
#ifndef ENABLE_TESTS
SlowTaskTimer t("hnsw rangesearch", 20);

#endif
try {
// cannot perform search on empty index
if (empty_index_) {
Expand Down Expand Up @@ -615,8 +619,10 @@ HNSW::update_id(int64_t old_id, int64_t new_id) {
std::reinterpret_pointer_cast<hnswlib::HierarchicalNSW>(alg_hnsw_)->updateLabel(old_id,
new_id);
} catch (const std::runtime_error& e) {
#ifndef ENABLE_TESTS
logger::warn(
"update error for replace old_id {} to new_id {}: {}", old_id, new_id, e.what());
#endif
return false;
}

Expand All @@ -641,7 +647,9 @@ HNSW::update_vector(int64_t id, const DatasetPtr& new_base, bool need_fine_tune)
std::reinterpret_pointer_cast<hnswlib::HierarchicalNSW>(alg_hnsw_)->updateVector(
id, new_base_vec);
} catch (const std::runtime_error& e) {
#ifndef ENABLE_TESTS
logger::warn("update error for replace vector of id {}: {}", id, e.what());
#endif
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/test_random_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

#include "fixtures/random_allocator.h"
#include "vsag//factory.h"
#include "vsag/options.h"

TEST_CASE("Random Alocator Test", "[ft][hnsw]") {
vsag::Options::Instance().logger()->SetLevel(vsag::Logger::Level::kOFF);
fixtures::RandomAllocator allocator;

auto paramesters = R"(
Expand Down

0 comments on commit e87defc

Please sign in to comment.