summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_multi_value_attribute.h32
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_multi_value_read_view.h41
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/iattributevector.h8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h1
7 files changed, 88 insertions, 0 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_attribute.h b/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_attribute.h
new file mode 100644
index 00000000000..5831380eaae
--- /dev/null
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_attribute.h
@@ -0,0 +1,32 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "i_multi_value_read_view.h"
+
+namespace search::attribute {
+
+/**
+ * Interface that provides read views for different multi-value attribute types.
+ *
+ * The type-safe down-cast functions only return a valid pointer when that particular type is supported.
+ * Otherwise a nullptr is returned.
+ */
+class IMultiValueAttribute {
+ virtual ~IMultiValueAttribute() {}
+ virtual const IArrayReadView<int8_t>* as_int8_array() const = 0;
+ virtual const IArrayReadView<int32_t>* as_int32_array() const = 0;
+ virtual const IArrayReadView<int64_t>* as_int64_array() const = 0;
+ virtual const IArrayReadView<float>* as_float_array() const = 0;
+ virtual const IArrayReadView<double>* as_double_array() const = 0;
+
+ virtual const IWeightedSetReadView<int8_t>* as_int8_wset() const = 0;
+ virtual const IWeightedSetReadView<int32_t>* as_int32_wset() const = 0;
+ virtual const IWeightedSetReadView<int64_t>* as_int64_wset() const = 0;
+ virtual const IWeightedSetReadView<float>* as_float_wset() const = 0;
+ virtual const IWeightedSetReadView<double>* as_double_wset() const = 0;
+
+ virtual const IWeightedSetEnumReadView* as_enum_wset() const = 0;
+};
+
+}
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_read_view.h b/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_read_view.h
new file mode 100644
index 00000000000..df69c5cfde8
--- /dev/null
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_multi_value_read_view.h
@@ -0,0 +1,41 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "multivalue.h"
+#include <vespa/vespalib/datastore/atomic_entry_ref.h>
+#include <vespa/vespalib/util/arrayref.h>
+
+namespace search::attribute {
+
+/**
+ * Read view for the raw data stored in a multi-value attribute.
+ * @tparam MultiValueType The multi-value type of the raw data to access.
+ */
+template <typename MultiValueType>
+class IMultiValueReadView {
+public:
+ virtual ~IMultiValueReadView() {}
+ virtual vespalib::ConstArrayRef<MultiValueType> get_raw_values(uint32_t docid) const = 0;
+};
+
+/**
+ * Read view for the raw data stored in an array attribute.
+ * @tparam T The value type of the raw data to access.
+ */
+template <typename T>
+using IArrayReadView = IMultiValueReadView<multivalue::Value<T>>;
+
+/**
+ * Read view for the raw data stored in a weighted set attribute.
+ * @tparam T The value type of the raw data to access.
+ */
+template <typename T>
+using IWeightedSetReadView = IMultiValueReadView<multivalue::WeightedValue<T>>;
+
+/**
+ * Read view for the raw data stored in an enumerated weighted set attribute.
+ */
+using IWeightedSetEnumReadView = IMultiValueReadView<multivalue::WeightedValue<vespalib::datastore::AtomicEntryRef>>;
+
+};
diff --git a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h
index b28855ae4f4..fa91f301b92 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h
@@ -19,6 +19,7 @@ namespace search::tensor {
namespace search::attribute {
+class IMultiValueAttribute;
class ISearchContext;
class SearchContextParams;
@@ -308,6 +309,13 @@ public:
virtual const tensor::ITensorAttribute *asTensorAttribute() const = 0;
/**
+ * Type-safe down-cast to a multi-value attribute.
+ *
+ * @return multi-value attribute or nullptr if not supported.
+ */
+ virtual const IMultiValueAttribute* as_multi_value_attribute() const = 0;
+
+ /**
* Returns the basic type of this attribute vector.
*
* @return basic type
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index ea2379eef58..76494356829 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -567,6 +567,7 @@ attribute::IPostingListAttributeBase *AttributeVector::getIPostingListAttributeB
const attribute::IPostingListAttributeBase *AttributeVector::getIPostingListAttributeBase() const { return nullptr; }
const IDocumentWeightAttribute * AttributeVector::asDocumentWeightAttribute() const { return nullptr; }
const tensor::ITensorAttribute *AttributeVector::asTensorAttribute() const { return nullptr; }
+const attribute::IMultiValueAttribute* AttributeVector::as_multi_value_attribute() const { return nullptr; }
bool AttributeVector::hasPostings() { return getIPostingListAttributeBase() != nullptr; }
uint64_t AttributeVector::getUniqueValueCount() const { return getTotalValueCount(); }
uint64_t AttributeVector::getTotalValueCount() const { return getNumDocs(); }
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index 8f0ce6327a8..ce65664d7d7 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -497,6 +497,7 @@ public:
const IDocumentWeightAttribute *asDocumentWeightAttribute() const override;
const tensor::ITensorAttribute *asTensorAttribute() const override;
+ const attribute::IMultiValueAttribute* as_multi_value_attribute() const override;
/**
- Search for equality
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
index 2a5d57475ca..f1ae5252031 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp
@@ -119,6 +119,10 @@ const tensor::ITensorAttribute *ImportedAttributeVectorReadGuard::asTensorAttrib
return nullptr;
}
+const attribute::IMultiValueAttribute* ImportedAttributeVectorReadGuard::as_multi_value_attribute() const {
+ return nullptr;
+}
+
BasicType::Type ImportedAttributeVectorReadGuard::getBasicType() const {
return _target_attribute.getBasicType();
}
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
index 502215f58cd..f5b896e2da5 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h
@@ -76,6 +76,7 @@ public:
const SearchContextParams &params) const override;
const IDocumentWeightAttribute *asDocumentWeightAttribute() const override;
const tensor::ITensorAttribute *asTensorAttribute() const override;
+ const attribute::IMultiValueAttribute* as_multi_value_attribute() const override;
BasicType::Type getBasicType() const override;
size_t getFixedWidth() const override;
CollectionType::Type getCollectionType() const override;