aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2023-03-22 13:54:06 +0100
committerGitHub <noreply@github.com>2023-03-22 13:54:06 +0100
commit7c21c2ad4180a164ac57431afc983568a36ba8e1 (patch)
tree2f5c216a8b38fb6da097010ca2a04db4022ecba0 /searchlib
parent0b1773a015d8d24b9b119ec680d6ca0a7ffdf14b (diff)
parente70584698be7984a43464a1e11d1b7bb96f529ae (diff)
Merge pull request #26528 from vespa-engine/toregge/provide-extend-interface-for-single-raw-ext-attribute
Provide extend interface for SingleRawExtAttribute.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/extendattributes/extendattribute.cpp18
-rw-r--r--searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.h3
3 files changed, 17 insertions, 10 deletions
diff --git a/searchlib/src/tests/attribute/extendattributes/extendattribute.cpp b/searchlib/src/tests/attribute/extendattributes/extendattribute.cpp
index c2285a99599..8f056323733 100644
--- a/searchlib/src/tests/attribute/extendattributes/extendattribute.cpp
+++ b/searchlib/src/tests/attribute/extendattributes/extendattribute.cpp
@@ -26,8 +26,7 @@ protected:
void testExtendFloat(Attribute & attr);
template <typename Attribute>
void testExtendString(Attribute & attr);
- template <typename Attribute>
- void testExtendRaw(Attribute & attr);
+ void testExtendRaw(AttributeVector& attr);
};
template <typename Attribute>
@@ -145,33 +144,34 @@ void ExtendAttributeTest::testExtendString(Attribute & attr)
}
}
-template <typename Attribute>
-void ExtendAttributeTest::testExtendRaw(Attribute & attr)
+void ExtendAttributeTest::testExtendRaw(AttributeVector& attr)
{
std::vector<char> empty;
std::vector<char> zeros{10, 0, 0, 11};
+ auto* ext_attr = attr.getExtendInterface();
+ EXPECT_NE(nullptr, ext_attr);
uint32_t docId(0);
EXPECT_EQ(0u, attr.getNumDocs());
attr.addDoc(docId);
EXPECT_EQ(0u, docId);
EXPECT_EQ(1u, attr.getNumDocs());
- attr.add(as_vector("1.7"));
+ ext_attr->add(as_vector("1.7"));
auto buf = attr.get_raw(0);
EXPECT_EQ(as_vector("1.7"), as_vector(buf));
- attr.add(vespalib::ConstArrayRef<char>(as_vector("2.3")));
+ ext_attr->add(vespalib::ConstArrayRef<char>(as_vector("2.3")));
buf = attr.get_raw(0);
EXPECT_EQ(as_vector("2.3"), as_vector(buf));
attr.addDoc(docId);
EXPECT_EQ(1u, docId);
EXPECT_EQ(attr.getNumDocs(), 2u);
- attr.add(as_vector("3.6"));
+ ext_attr->add(as_vector("3.6"));
buf = attr.get_raw(1);
EXPECT_EQ(as_vector("3.6"), as_vector(buf));
buf = attr.get_raw(0);
EXPECT_EQ(as_vector("2.3"), as_vector(buf));
attr.addDoc(docId);
EXPECT_EQ(2u, docId);
- attr.add(zeros);
+ ext_attr->add(zeros);
buf = attr.get_raw(2);
EXPECT_EQ(zeros, as_vector(buf));
attr.addDoc(docId);
@@ -180,7 +180,7 @@ void ExtendAttributeTest::testExtendRaw(Attribute & attr)
EXPECT_EQ(empty, as_vector(buf));
attr.addDoc(docId);
EXPECT_EQ(4u, docId);
- attr.add(empty);
+ ext_attr->add(empty);
buf = attr.get_raw(4);
EXPECT_EQ(empty, as_vector(buf));
}
diff --git a/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.cpp
index 46b275d2ac5..1b617b4e6de 100644
--- a/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.cpp
@@ -64,4 +64,10 @@ SingleRawExtAttribute::get_raw(DocId docid) const
return {_buffer.data() + offset, size};
}
+IExtendAttribute*
+SingleRawExtAttribute::getExtendInterface()
+{
+ return this;
+}
+
}
diff --git a/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.h b/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.h
index a8f20d2bb39..82572df4bd2 100644
--- a/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/single_raw_ext_attribute.h
@@ -21,8 +21,9 @@ public:
void onCommit() override;
void onUpdateStat() override;
bool addDoc(DocId& docId) override;
- bool add(vespalib::ConstArrayRef<char> v, int32_t = 1) override;
+ bool add(vespalib::ConstArrayRef<char> v, int32_t) override;
vespalib::ConstArrayRef<char> get_raw(DocId docid) const override;
+ IExtendAttribute* getExtendInterface() override;
};
}