From 25d902a8d776ff6e67ae15b188cbc96ca57c88e4 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 22 Nov 2022 11:20:36 +0100 Subject: Move shared test code to test library. --- .../tests/tensor/hnsw_index/hnsw_index_test.cpp | 38 +++------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp') diff --git a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp index b86913caa16..13caad8b6d6 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include #include @@ -11,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -36,39 +37,8 @@ using vespalib::eval::ValueType; using vespalib::datastore::CompactionSpec; using vespalib::datastore::CompactionStrategy; using search::queryeval::GlobalFilter; - -class VectorBufferWriter : public BufferWriter { -private: - char tmp[1024]; -public: - std::vector output; - VectorBufferWriter() { - setup(tmp, 1024); - } - ~VectorBufferWriter() {} - void flush() override { - for (size_t i = 0; i < usedLen(); ++i) { - output.push_back(tmp[i]); - } - rewind(); - } -}; - -class VectorBufferReader { -private: - const std::vector& _data; - size_t _pos; - -public: - VectorBufferReader(const std::vector& data) : _data(data), _pos(0) {} - uint32_t readHostOrder() { - uint32_t result = 0; - assert(_pos + sizeof(uint32_t) <= _data.size()); - std::memcpy(&result, _data.data() + _pos, sizeof(uint32_t)); - _pos += sizeof(uint32_t); - return result; - } -}; +using search::test::VectorBufferReader; +using search::test::VectorBufferWriter; template class MyDocVectorAccess : public DocVectorAccess { -- cgit v1.2.3