aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-03-15 14:11:13 +0100
committerTor Egge <Tor.Egge@online.no>2023-03-15 14:11:13 +0100
commit851e8e34a17eeed3eef2fe47f2310ad0f876f0bd (patch)
treea6142e7a59c1e1cb8c3f9627542debacb4d2b714
parente54a7a0bb3470adb1cfb373c348c43da6d79e239 (diff)
Factor out implementation dependent sizeof(std::string).
-rw-r--r--searchlib/src/tests/attribute/attribute_test.cpp18
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp2
2 files changed, 11 insertions, 9 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp
index f336742ca4b..6699ea82f1f 100644
--- a/searchlib/src/tests/attribute/attribute_test.cpp
+++ b/searchlib/src/tests/attribute/attribute_test.cpp
@@ -49,6 +49,8 @@ string tmpDir("tmp");
string clsDir("clstmp");
string asuDir("asutmp");
+constexpr size_t sizeof_large_string_entry = sizeof(vespalib::datastore::UniqueStoreEntry<std::string>);
+
}
namespace search {
@@ -947,8 +949,8 @@ AttributeTest::testSingle()
{
AttributePtr ptr = createAttribute("sv-string", Config(BasicType::STRING, CollectionType::SINGLE));
ptr->updateStat(true);
- EXPECT_EQ(133216u, ptr->getStatus().getAllocated());
- EXPECT_EQ(53280u, ptr->getStatus().getUsed());
+ EXPECT_EQ(133096u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(53240u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testSingle<StringAttribute, string, string>(ptr, values);
}
@@ -957,8 +959,8 @@ AttributeTest::testSingle()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("sv-fs-string", cfg);
ptr->updateStat(true);
- EXPECT_EQ(361584u, ptr->getStatus().getAllocated());
- EXPECT_EQ(105216u, ptr->getStatus().getUsed());
+ EXPECT_EQ(361464u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(105176u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testSingle<StringAttribute, string, string>(ptr, values);
}
@@ -1140,8 +1142,8 @@ AttributeTest::testArray()
{
AttributePtr ptr = createAttribute("a-string", Config(BasicType::STRING, CollectionType::ARRAY));
ptr->updateStat(true);
- EXPECT_EQ(649232u, ptr->getStatus().getAllocated());
- EXPECT_EQ(565856u, ptr->getStatus().getUsed());
+ EXPECT_EQ(649112u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(565816u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<StringAttribute, string>(ptr, values);
}
@@ -1150,8 +1152,8 @@ AttributeTest::testArray()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("afs-string", cfg);
ptr->updateStat(true);
- EXPECT_EQ(899536u, ptr->getStatus().getAllocated());
- EXPECT_EQ(617812u, ptr->getStatus().getUsed());
+ EXPECT_EQ(899416u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(617772u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<StringAttribute, string>(ptr, values);
}
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp
index 3e2adf21619..1d3ba27d6bf 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp
@@ -78,7 +78,7 @@ UniqueStoreSmallStringBufferType::get_memory_allocator() const
}
UniqueStoreExternalStringBufferType::UniqueStoreExternalStringBufferType(uint32_t array_size, uint32_t max_arrays, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator)
- : BufferType<UniqueStoreEntry<std::string>>(array_size, 2u, max_arrays, NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER, ALLOC_GROW_FACTOR),
+ : BufferType<UniqueStoreEntry<std::string>>(array_size, 0u, max_arrays, NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER, ALLOC_GROW_FACTOR),
_memory_allocator(std::move(memory_allocator))
{
}