summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/attribute
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-10-08 13:19:51 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-10-08 13:20:51 +0000
commit8a6cd15d44c72c8c36a79939906ecaea0eb266c7 (patch)
treefa2560218cc65563526ade3c8e3716c8a685aa53 /searchcore/src/tests/proton/attribute
parent312694ad6aee3b31f2061b6742b2fb6a8be51a59 (diff)
Use XXH3 over XXH64 as vespalib string hash function
XXH3 is faster than XXH64 across the board, especially for short inputs. Change around some tests that implicitly depended on the old hashing.
Diffstat (limited to 'searchcore/src/tests/proton/attribute')
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_test.cpp27
-rw-r--r--searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp4
-rw-r--r--searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp5
3 files changed, 26 insertions, 10 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp
index 8711a21e5e6..a647085e3d1 100644
--- a/searchcore/src/tests/proton/attribute/attribute_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp
@@ -739,24 +739,31 @@ assertPutDone(AttributeVector &attr, int32_t expVal)
void
putAttributes(AttributeWriterTest &t, std::vector<uint32_t> expExecuteHistory)
{
+ // Since executor distribution depends on the unspecified hash function in vespalib,
+ // decouple attribute names from their usage to allow for picking names that hash
+ // more evenly for a particular implementation.
+ vespalib::string a1_name = "a1";
+ vespalib::string a2_name = "a2x";
+ vespalib::string a3_name = "a3y";
+
Schema s;
- s.addAttributeField(Schema::AttributeField("a1", schema::DataType::INT32, CollectionType::SINGLE));
- s.addAttributeField(Schema::AttributeField("a2", schema::DataType::INT32, CollectionType::SINGLE));
- s.addAttributeField(Schema::AttributeField("a3", schema::DataType::INT32, CollectionType::SINGLE));
+ s.addAttributeField(Schema::AttributeField(a1_name, schema::DataType::INT32, CollectionType::SINGLE));
+ s.addAttributeField(Schema::AttributeField(a2_name, schema::DataType::INT32, CollectionType::SINGLE));
+ s.addAttributeField(Schema::AttributeField(a3_name, schema::DataType::INT32, CollectionType::SINGLE));
DocBuilder idb(s);
- auto a1 = t.addAttribute("a1");
- auto a2 = t.addAttribute("a2");
- auto a3 = t.addAttribute("a3");
+ auto a1 = t.addAttribute(a1_name);
+ auto a2 = t.addAttribute(a2_name);
+ auto a3 = t.addAttribute(a3_name);
EXPECT_EQ(1u, a1->getNumDocs());
EXPECT_EQ(1u, a2->getNumDocs());
EXPECT_EQ(1u, a3->getNumDocs());
t.put(1, *idb.startDocument("id:ns:searchdocument::1").
- startAttributeField("a1").addInt(10).endField().
- startAttributeField("a2").addInt(15).endField().
- startAttributeField("a3").addInt(20).endField().
+ startAttributeField(a1_name).addInt(10).endField().
+ startAttributeField(a2_name).addInt(15).endField().
+ startAttributeField(a3_name).addInt(20).endField().
endDocument(), 1);
assertPutDone(*a1, 10);
assertPutDone(*a2, 15);
@@ -780,7 +787,7 @@ TEST_F(AttributeWriterTest, spreads_write_over_2_write_contexts)
TEST_F(AttributeWriterTest, spreads_write_over_3_write_contexts)
{
setup(8);
- putAttributes(*this, {0, 1, 3});
+ putAttributes(*this, {4, 5, 6});
}
struct MockPrepareResult : public PrepareResult {
diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp
index 2dc51d4577e..494b37297f4 100644
--- a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp
+++ b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp
@@ -120,6 +120,10 @@ TEST_F("require that all attributes can be retrieved", Fixture)
std::vector<const IAttributeVector *> list;
f.ctx->getAttributeList(list);
EXPECT_EQUAL(2u, list.size());
+ // Don't depend on internal (unspecified) ordering
+ std::sort(list.begin(), list.end(), [](auto* lhs, auto* rhs){
+ return lhs->getName() < rhs->getName();
+ });
EXPECT_EQUAL("bar", list[0]->getName());
EXPECT_EQUAL("foo", list[1]->getName());
}
diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp
index d92392ec8df..3155d7930e1 100644
--- a/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp
+++ b/searchcore/src/tests/proton/attribute/imported_attributes_repo/imported_attributes_repo_test.cpp
@@ -9,6 +9,7 @@ LOG_SETUP("imported_attributes_repo_test");
#include <vespa/searchlib/attribute/imported_attribute_vector.h>
#include <vespa/searchlib/attribute/imported_attribute_vector_factory.h>
#include <vespa/searchlib/attribute/reference_attribute.h>
+#include <algorithm>
using proton::ImportedAttributesRepo;
using search::AttributeVector;
@@ -74,6 +75,10 @@ TEST_F("require that all attributes can be retrieved", Fixture)
std::vector<ImportedAttributeVector::SP> list;
f.repo.getAll(list);
EXPECT_EQUAL(2u, list.size());
+ // Don't depend on internal (unspecified) ordering
+ std::sort(list.begin(), list.end(), [](auto& lhs, auto& rhs){
+ return lhs->getName() < rhs->getName();
+ });
EXPECT_EQUAL("bar", list[0]->getName());
EXPECT_EQUAL("foo", list[1]->getName());
}