From 669d65e4c3a3124dc1360231494505546b2d3932 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Wed, 15 Sep 2021 12:53:52 +0000 Subject: Change loading of nearest neighbor index to use direct I/O instead of mmapping. This should reduce memory spike during loading. --- .../attribute/tensorattribute/tensorattribute_test.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp') diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 397347b7651..f694abaae8a 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -94,17 +94,15 @@ public: class MockIndexLoader : public NearestNeighborIndexLoader { private: int& _index_value; - std::unique_ptr _buf; + search::FileReader _reader; public: - MockIndexLoader(int& index_value, - std::unique_ptr buf) + MockIndexLoader(int& index_value, FastOS_FileInterface& file) : _index_value(index_value), - _buf(std::move(buf)) + _reader(file) {} bool load_next() override { - ASSERT_EQUAL(sizeof(int), _buf->size()); - _index_value = (reinterpret_cast(_buf->buffer()))[0]; + _index_value = _reader.readHostOrder(); return false; } }; @@ -240,8 +238,8 @@ public: } return std::unique_ptr(); } - std::unique_ptr make_loader(std::unique_ptr buf) override { - return std::make_unique(_index_value, std::move(buf)); + std::unique_ptr make_loader(FastOS_FileInterface& file) override { + return std::make_unique(_index_value, file); } std::vector find_top_k(uint32_t k, vespalib::eval::TypedCells vector, uint32_t explore_k, double distance_threshold) const override -- cgit v1.2.3