aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2021-09-15 12:53:52 +0000
committerGeir Storli <geirst@verizonmedia.com>2021-09-15 12:53:52 +0000
commit669d65e4c3a3124dc1360231494505546b2d3932 (patch)
tree3119ca499f2cbd036486107f095ea9e6f15236dd /searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
parent83adcb91b4b910d06a20b555ec238df895f92130 (diff)
Change loading of nearest neighbor index to use direct I/O instead of mmapping.
This should reduce memory spike during loading.
Diffstat (limited to 'searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp14
1 files changed, 6 insertions, 8 deletions
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<search::fileutil::LoadedBuffer> _buf;
+ search::FileReader<int> _reader;
public:
- MockIndexLoader(int& index_value,
- std::unique_ptr<search::fileutil::LoadedBuffer> 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<const int*>(_buf->buffer()))[0];
+ _index_value = _reader.readHostOrder();
return false;
}
};
@@ -240,8 +238,8 @@ public:
}
return std::unique_ptr<NearestNeighborIndexSaver>();
}
- std::unique_ptr<NearestNeighborIndexLoader> make_loader(std::unique_ptr<search::fileutil::LoadedBuffer> buf) override {
- return std::make_unique<MockIndexLoader>(_index_value, std::move(buf));
+ std::unique_ptr<NearestNeighborIndexLoader> make_loader(FastOS_FileInterface& file) override {
+ return std::make_unique<MockIndexLoader>(_index_value, file);
}
std::vector<Neighbor> find_top_k(uint32_t k, vespalib::eval::TypedCells vector, uint32_t explore_k,
double distance_threshold) const override