summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-10-28 16:14:04 +0200
committerTor Egge <Tor.Egge@online.no>2022-10-28 16:14:04 +0200
commit034db9700fc8149f617b21a72baa368a57325dcb (patch)
treeb2794a025da8e48bece4af89905ecdff566de2fd /searchlib
parent44595d372748d960535e72ab5086fc1412db867c (diff)
Move tensor attribute constants to separate header file.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h22
4 files changed, 25 insertions, 12 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
index 56b9473b6e6..e2b516154fd 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
@@ -5,6 +5,7 @@
#include "nearest_neighbor_index.h"
#include "nearest_neighbor_index_loader.h"
#include "nearest_neighbor_index_saver.h"
+#include "tensor_attribute_constants.h"
#include <vespa/eval/eval/value.h>
#include <vespa/fastlib/io/bufferedfile.h>
#include <vespa/searchcommon/attribute/config.h>
@@ -31,15 +32,12 @@ namespace search::tensor {
namespace {
-constexpr uint32_t DENSE_TENSOR_ATTRIBUTE_VERSION = 1;
constexpr uint32_t LOAD_COMMIT_INTERVAL = 256;
const vespalib::string tensorTypeTag("tensortype");
class BlobSequenceReader : public ReaderBase
{
private:
- static constexpr uint8_t tensorIsNotPresent = 0;
- static constexpr uint8_t tensorIsPresent = 1;
bool _use_index_file;
FileWithHeader _index_file;
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp
index 5c98da91034..5a47addd4ab 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp
@@ -3,6 +3,7 @@
#include "dense_tensor_attribute_saver.h"
#include "dense_tensor_store.h"
#include "nearest_neighbor_index_saver.h"
+#include "tensor_attribute_constants.h"
#include <vespa/searchlib/util/bufferwriter.h>
#include <vespa/searchlib/attribute/iattributesavetarget.h>
@@ -10,13 +11,6 @@ using vespalib::GenerationHandler;
namespace search::tensor {
-namespace {
-
-constexpr uint8_t tensorIsNotPresent = 0;
-constexpr uint8_t tensorIsPresent = 1;
-
-}
-
DenseTensorAttributeSaver::
DenseTensorAttributeSaver(GenerationHandler::Guard &&guard,
const attribute::AttributeHeader &header,
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index f29751cdabe..84944ea685e 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -2,6 +2,7 @@
#include "tensor_attribute.h"
#include "blob_sequence_reader.h"
+#include "tensor_attribute_constants.h"
#include "tensor_store_saver.h"
#include <vespa/document/base/exceptions.h>
#include <vespa/document/datatype/tensor_data_type.h>
@@ -31,8 +32,6 @@ namespace search::tensor {
namespace {
-constexpr uint32_t TENSOR_ATTRIBUTE_VERSION = 0;
-
Value::UP
createEmptyTensor(const ValueType &type)
{
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h
new file mode 100644
index 00000000000..fe4195d28b8
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h
@@ -0,0 +1,22 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <cstdint>
+
+namespace search::tensor {
+
+/*
+ * Attribute version determines format of saved attributes.
+ */
+inline constexpr uint32_t TENSOR_ATTRIBUTE_VERSION = 0;
+inline constexpr uint32_t DENSE_TENSOR_ATTRIBUTE_VERSION = 1;
+
+/*
+ * Values used to determine if a tensor is present on not for dense tensor attributes
+ * (cf. DENSE_TENSOR_ATTRIBUTE_VERSION) that otherwise has fixed size for a saved tensor.
+ */
+inline constexpr uint8_t tensorIsNotPresent = 0;
+inline constexpr uint8_t tensorIsPresent = 1;
+
+}