diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2020-10-02 10:07:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 10:07:50 +0200 |
commit | 1a980f57d890cc67a3eb81aa5da92c42751a5201 (patch) | |
tree | a7a0e834ef674061d18b20032e02274acf9bab5e /searchlib | |
parent | ebe20db2bf63f001e5792812057e7ae8bc76c385 (diff) | |
parent | bbbd46939473092b1adaec45326ed7ce1aa1827f (diff) |
Merge pull request #14656 from vespa-engine/arnej/cleanup-value-api-1
Arnej/cleanup value api 1
Diffstat (limited to 'searchlib')
15 files changed, 49 insertions, 52 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 1a342a92b3d..b4bf571c756 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -181,7 +181,7 @@ public: _adds.emplace_back(docid, DoubleVector(vector.begin(), vector.end())); } std::unique_ptr<PrepareResult> prepare_add_document(uint32_t docid, - vespalib::tensor::TypedCells vector, + vespalib::eval::TypedCells vector, vespalib::GenerationHandler::Guard guard) const override { (void) guard; auto d_vector = vector.typify<double>(); @@ -222,13 +222,13 @@ public: _index_value = (reinterpret_cast<const int*>(buf.buffer()))[0]; return true; } - std::vector<Neighbor> find_top_k(uint32_t k, vespalib::tensor::TypedCells vector, uint32_t explore_k) const override { + std::vector<Neighbor> find_top_k(uint32_t k, vespalib::eval::TypedCells vector, uint32_t explore_k) const override { (void) k; (void) vector; (void) explore_k; return std::vector<Neighbor>(); } - std::vector<Neighbor> find_top_k_with_filter(uint32_t k, vespalib::tensor::TypedCells vector, + std::vector<Neighbor> find_top_k_with_filter(uint32_t k, vespalib::eval::TypedCells vector, const search::BitVector& filter, uint32_t explore_k) const override { (void) k; diff --git a/searchlib/src/tests/tensor/distance_functions/distance_functions_test.cpp b/searchlib/src/tests/tensor/distance_functions/distance_functions_test.cpp index f11a28b8716..a9e24e056f2 100644 --- a/searchlib/src/tests/tensor/distance_functions/distance_functions_test.cpp +++ b/searchlib/src/tests/tensor/distance_functions/distance_functions_test.cpp @@ -1,6 +1,6 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> #include <vespa/searchlib/tensor/distance_functions.h> #include <vespa/searchlib/tensor/distance_function_factory.h> #include <vespa/vespalib/gtest/gtest.h> @@ -10,7 +10,7 @@ LOG_SETUP("distance_function_test"); using namespace search::tensor; -using vespalib::tensor::TypedCells; +using vespalib::eval::TypedCells; using search::attribute::DistanceMetric; TypedCells t(const std::vector<double> &v) { return TypedCells(v); } 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 cd989c03b4e..acc157709c0 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -1,6 +1,5 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/eval/tensor/dense/typed_cells.h> #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/tensor/distance_functions.h> #include <vespa/searchlib/tensor/doc_vector_access.h> @@ -39,9 +38,9 @@ public: _vectors[docid] = vec; return *this; } - vespalib::tensor::TypedCells get_vector(uint32_t docid) const override { + vespalib::eval::TypedCells get_vector(uint32_t docid) const override { ArrayRef ref(_vectors[docid]); - return vespalib::tensor::TypedCells(ref); + return vespalib::eval::TypedCells(ref); } }; diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp index a5e0e1e2b6a..8790df5a140 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -8,7 +8,7 @@ #include <future> #include <vector> -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/tensor/distance_functions.h> #include <vespa/searchlib/tensor/doc_vector_access.h> @@ -109,10 +109,10 @@ public: memcpy(&_vectors[docid], vec.cbegin(), sizeof(MallocPointVector)); return *this; } - vespalib::tensor::TypedCells get_vector(uint32_t docid) const override { + vespalib::eval::TypedCells get_vector(uint32_t docid) const override { assert(docid < NUM_POSSIBLE_DOCS); ConstVectorRef ref(_vectors[docid]); - return vespalib::tensor::TypedCells(ref); + return vespalib::eval::TypedCells(ref); } }; @@ -175,7 +175,7 @@ public: return result_promise.get_future(); } void run() override { - auto v = vespalib::tensor::TypedCells(vec); + auto v = vespalib::eval::TypedCells(vec); auto up = parent.index->prepare_add_document(docid, v, read_guard); result_promise.set_value(std::move(up)); } diff --git a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_iterator.cpp b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_iterator.cpp index a64168469f0..cf4e8ae2f6a 100644 --- a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_iterator.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_iterator.cpp @@ -7,7 +7,7 @@ using search::tensor::DenseTensorAttribute; using vespalib::ConstArrayRef; using vespalib::tensor::DenseTensorView; using vespalib::tensor::MutableDenseTensorView; -using vespalib::tensor::TypedCells; +using vespalib::eval::TypedCells; using CellType = vespalib::eval::ValueType::CellType; diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index d63249b816f..0a34c18bae9 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -287,7 +287,7 @@ DenseTensorAttribute::get_state(const vespalib::slime::Inserter& inserter) const } } -vespalib::tensor::TypedCells +vespalib::eval::TypedCells DenseTensorAttribute::get_vector(uint32_t docid) const { assert(docid < _refVector.size()); diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h index 1de74d4238d..859ea82cee6 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h @@ -48,7 +48,7 @@ public: void get_state(const vespalib::slime::Inserter& inserter) const override; // Implements DocVectorAccess - vespalib::tensor::TypedCells get_vector(uint32_t docid) const override; + vespalib::eval::TypedCells get_vector(uint32_t docid) const override; const NearestNeighborIndex* nearest_neighbor_index() const { return _index.get(); } }; diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp index 99afcd92fa6..7a020d33d5c 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp @@ -137,7 +137,7 @@ DenseTensorStore::getTensor(EntryRef ref) const if (!ref.valid()) { return std::unique_ptr<Tensor>(); } - vespalib::tensor::TypedCells cells_ref(getRawBuffer(ref), _type.cell_type(), getNumCells()); + vespalib::eval::TypedCells cells_ref(getRawBuffer(ref), _type.cell_type(), getNumCells()); return std::make_unique<DenseTensorView>(_type, cells_ref); } @@ -145,21 +145,21 @@ void DenseTensorStore::getTensor(EntryRef ref, MutableDenseTensorView &tensor) const { if (!ref.valid()) { - vespalib::tensor::TypedCells cells_ref(&_emptySpace[0], _type.cell_type(), getNumCells()); + vespalib::eval::TypedCells cells_ref(&_emptySpace[0], _type.cell_type(), getNumCells()); tensor.setCells(cells_ref); } else { - vespalib::tensor::TypedCells cells_ref(getRawBuffer(ref), _type.cell_type(), getNumCells()); + vespalib::eval::TypedCells cells_ref(getRawBuffer(ref), _type.cell_type(), getNumCells()); tensor.setCells(cells_ref); } } -vespalib::tensor::TypedCells +vespalib::eval::TypedCells DenseTensorStore::get_typed_cells(EntryRef ref) const { if (!ref.valid()) { - return vespalib::tensor::TypedCells(&_emptySpace[0], _type.cell_type(), getNumCells()); + return vespalib::eval::TypedCells(&_emptySpace[0], _type.cell_type(), getNumCells()); } - return vespalib::tensor::TypedCells(getRawBuffer(ref), _type.cell_type(), getNumCells()); + return vespalib::eval::TypedCells(getRawBuffer(ref), _type.cell_type(), getNumCells()); } template <class TensorType> diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h index 75b48da0f25..979df1a9a4e 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h @@ -4,7 +4,7 @@ #include "tensor_store.h" #include <vespa/eval/eval/value_type.h> -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> namespace vespalib { namespace tensor { class MutableDenseTensorView; }} @@ -66,7 +66,7 @@ public: EntryRef move(EntryRef ref) override; std::unique_ptr<Tensor> getTensor(EntryRef ref) const; void getTensor(EntryRef ref, vespalib::tensor::MutableDenseTensorView &tensor) const; - vespalib::tensor::TypedCells get_typed_cells(EntryRef ref) const; + vespalib::eval::TypedCells get_typed_cells(EntryRef ref) const; EntryRef setTensor(const Tensor &tensor); // The following method is meant to be used only for unit tests. uint32_t getArraySize() const { return _bufferType.getArraySize(); } diff --git a/searchlib/src/vespa/searchlib/tensor/distance_function.h b/searchlib/src/vespa/searchlib/tensor/distance_function.h index 7665ca09f5a..30ad1876317 100644 --- a/searchlib/src/vespa/searchlib/tensor/distance_function.h +++ b/searchlib/src/vespa/searchlib/tensor/distance_function.h @@ -4,7 +4,7 @@ #include <memory> -namespace vespalib::tensor { struct TypedCells; } +namespace vespalib::eval { struct TypedCells; } namespace search::tensor { @@ -18,10 +18,10 @@ class DistanceFunction { public: using UP = std::unique_ptr<DistanceFunction>; virtual ~DistanceFunction() {} - virtual double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const = 0; + virtual double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const = 0; virtual double to_rawscore(double distance) const = 0; - virtual double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + virtual double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double limit) const = 0; }; diff --git a/searchlib/src/vespa/searchlib/tensor/distance_functions.h b/searchlib/src/vespa/searchlib/tensor/distance_functions.h index 73716395369..8db7b1f48f1 100644 --- a/searchlib/src/vespa/searchlib/tensor/distance_functions.h +++ b/searchlib/src/vespa/searchlib/tensor/distance_functions.h @@ -3,7 +3,7 @@ #pragma once #include "distance_function.h" -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> #include <vespa/vespalib/hwaccelrated/iaccelrated.h> #include <cmath> @@ -19,7 +19,7 @@ public: SquaredEuclideanDistance() : _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) {} - double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const override { + double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { auto lhs_vector = lhs.typify<FloatType>(); auto rhs_vector = rhs.typify<FloatType>(); size_t sz = lhs_vector.size(); @@ -31,8 +31,8 @@ public: double score = 1.0 / (1.0 + d); return score; } - double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double limit) const override { auto lhs_vector = lhs.typify<FloatType>(); @@ -59,7 +59,7 @@ public: AngularDistance() : _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) {} - double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const override { + double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { auto lhs_vector = lhs.typify<FloatType>(); auto rhs_vector = rhs.typify<FloatType>(); size_t sz = lhs_vector.size(); @@ -84,8 +84,8 @@ public: double score = 1.0 / (1.0 + angle_distance); return score; } - double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double /*limit*/) const override { return calc(lhs, rhs); @@ -104,7 +104,7 @@ public: InnerProductDistance() : _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) {} - double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const override { + double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { auto lhs_vector = lhs.typify<FloatType>(); auto rhs_vector = rhs.typify<FloatType>(); size_t sz = lhs_vector.size(); @@ -116,8 +116,8 @@ public: double score = 1.0 / (1.0 + distance); return score; } - double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double /*limit*/) const override { return calc(lhs, rhs); @@ -141,7 +141,7 @@ public: double s = sin(0.5*angle); return s*s; } - double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const override { + double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { auto lhs_vector = lhs.typify<FloatType>(); auto rhs_vector = rhs.typify<FloatType>(); assert(2 == lhs_vector.size()); @@ -169,8 +169,8 @@ public: double d = 2 * asin(hav_diff) * 6371.0088; // Earth mean radius return 1.0 / (1.0 + d); } - double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double /*limit*/) const override { return calc(lhs, rhs); @@ -186,7 +186,7 @@ template <typename FloatType> class HammingDistance : public DistanceFunction { public: HammingDistance() {} - double calc(const vespalib::tensor::TypedCells& lhs, const vespalib::tensor::TypedCells& rhs) const override { + double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { auto lhs_vector = lhs.typify<FloatType>(); auto rhs_vector = rhs.typify<FloatType>(); size_t sz = lhs_vector.size(); @@ -201,8 +201,8 @@ public: double score = 1.0 / (1.0 + distance); return score; } - double calc_with_limit(const vespalib::tensor::TypedCells& lhs, - const vespalib::tensor::TypedCells& rhs, + double calc_with_limit(const vespalib::eval::TypedCells& lhs, + const vespalib::eval::TypedCells& rhs, double limit) const override { auto lhs_vector = lhs.typify<FloatType>(); diff --git a/searchlib/src/vespa/searchlib/tensor/doc_vector_access.h b/searchlib/src/vespa/searchlib/tensor/doc_vector_access.h index e5dfa35a529..8fcebc64b78 100644 --- a/searchlib/src/vespa/searchlib/tensor/doc_vector_access.h +++ b/searchlib/src/vespa/searchlib/tensor/doc_vector_access.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> #include <cstdint> namespace search::tensor { @@ -15,7 +15,7 @@ namespace search::tensor { class DocVectorAccess { public: virtual ~DocVectorAccess() {} - virtual vespalib::tensor::TypedCells get_vector(uint32_t docid) const = 0; + virtual vespalib::eval::TypedCells get_vector(uint32_t docid) const = 0; }; } diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 2a17378f58a..9def5a7b0a8 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -6,7 +6,6 @@ #include "hnsw_index_saver.h" #include "random_level_generator.h" #include <vespa/searchlib/util/state_explorer_utils.h> -#include <vespa/eval/tensor/dense/typed_cells.h> #include <vespa/vespalib/data/slime/cursor.h> #include <vespa/vespalib/data/slime/inserter.h> #include <vespa/vespalib/datastore/array_store.hpp> diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.h b/searchlib/src/vespa/searchlib/tensor/hnsw_index.h index f9adef0b86c..c07a0642b2e 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.h +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.h @@ -9,7 +9,7 @@ #include "nearest_neighbor_index.h" #include "random_level_generator.h" #include "hnsw_graph.h" -#include <vespa/eval/tensor/dense/typed_cells.h> +#include <vespa/eval/eval/typed_cells.h> #include <vespa/searchlib/common/bitvector.h> #include <vespa/vespalib/datastore/array_store.h> #include <vespa/vespalib/datastore/atomic_entry_ref.h> @@ -72,7 +72,7 @@ protected: using LevelArrayRef = HnswGraph::LevelArrayRef; using LevelArray = vespalib::Array<AtomicEntryRef>; - using TypedCells = vespalib::tensor::TypedCells; + using TypedCells = vespalib::eval::TypedCells; HnswGraph _graph; const DocVectorAccess& _vectors; diff --git a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h index b46c19ac88a..74f14cea21b 100644 --- a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h +++ b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h @@ -4,7 +4,6 @@ #include "distance_function.h" #include "prepare_result.h" -#include <vespa/eval/tensor/dense/typed_cells.h> #include <vespa/vespalib/util/generationhandler.h> #include <vespa/vespalib/util/memoryusage.h> #include <cstdint> @@ -47,7 +46,7 @@ public: * The given read guard must be kept in the result. */ virtual std::unique_ptr<PrepareResult> prepare_add_document(uint32_t docid, - vespalib::tensor::TypedCells vector, + vespalib::eval::TypedCells vector, vespalib::GenerationHandler::Guard read_guard) const = 0; /** * Performs the complete step in a two-phase operation to add a document to the index. @@ -73,12 +72,12 @@ public: virtual bool load(const fileutil::LoadedBuffer& buf) = 0; virtual std::vector<Neighbor> find_top_k(uint32_t k, - vespalib::tensor::TypedCells vector, + vespalib::eval::TypedCells vector, uint32_t explore_k) const = 0; // only return neighbors where the corresponding filter bit is set virtual std::vector<Neighbor> find_top_k_with_filter(uint32_t k, - vespalib::tensor::TypedCells vector, + vespalib::eval::TypedCells vector, const BitVector &filter, uint32_t explore_k) const = 0; |