summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/document_iterator
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-01-07 06:15:12 +0100
committerGitHub <noreply@github.com>2022-01-07 06:15:12 +0100
commit776a02c236bb78b64d6bb7643f4a5acf2ab0f1e1 (patch)
tree3077f322cc345a30ab801c25da6fbdb845d951b2 /searchcore/src/tests/proton/document_iterator
parent499d884cefeac2a4f5dc071814d1a64ddc249875 (diff)
Revert "Revert "Balder/refactor docentry""
Diffstat (limited to 'searchcore/src/tests/proton/document_iterator')
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index fab46e61494..82eac88a53e 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -48,7 +48,9 @@ using storage::spi::IncludedVersions;
using storage::spi::IterateResult;
using storage::spi::Selection;
using storage::spi::Timestamp;
+using storage::spi::DocumentMetaEnum;
using storage::spi::test::makeSpiBucket;
+using storage::spi::test::equal;
using namespace proton;
@@ -274,18 +276,14 @@ struct PairDR : DocumentRetrieverBaseForTest {
}
};
-size_t getSize() {
- return sizeof(DocEntry);
-}
-
size_t getSize(const document::Document &doc) {
vespalib::nbostream tmp;
doc.serialize(tmp);
- return tmp.size() + getSize();
+ return tmp.size();
}
size_t getSize(const document::DocumentId &id) {
- return id.getSerializedSize() + getSize();
+ return id.getSerializedSize();
}
IDocumentRetriever::SP nil() { return std::make_unique<UnitDR>(); }
@@ -386,19 +384,19 @@ void checkDoc(const IDocumentRetriever &dr, const std::string &id,
EXPECT_TRUE(DocumentId(id) == doc->getId());
}
-void checkEntry(const IterateResult &res, size_t idx, const Timestamp &timestamp, int flags)
+void checkEntry(const IterateResult &res, size_t idx, const Timestamp &timestamp, DocumentMetaEnum flags)
{
ASSERT_LESS(idx, res.getEntries().size());
- DocEntry expect(timestamp, flags);
- EXPECT_EQUAL(expect, *res.getEntries()[idx]);
- EXPECT_EQUAL(getSize(), res.getEntries()[idx]->getSize());
+ auto expect = DocEntry::create(timestamp, flags);
+ EXPECT_TRUE(equal(*expect, *res.getEntries()[idx]));
+ EXPECT_EQUAL(sizeof(DocEntry), res.getEntries()[idx]->getSize());
}
void checkEntry(const IterateResult &res, size_t idx, const DocumentId &id, const Timestamp &timestamp)
{
ASSERT_LESS(idx, res.getEntries().size());
- DocEntry expect(timestamp, storage::spi::REMOVE_ENTRY, id);
- EXPECT_EQUAL(expect, *res.getEntries()[idx]);
+ auto expect = DocEntry::create(timestamp, DocumentMetaEnum::REMOVE_ENTRY, id);
+ EXPECT_TRUE(equal(*expect, *res.getEntries()[idx]));
EXPECT_EQUAL(getSize(id), res.getEntries()[idx]->getSize());
EXPECT_GREATER(getSize(id), 0u);
}
@@ -406,8 +404,8 @@ void checkEntry(const IterateResult &res, size_t idx, const DocumentId &id, cons
void checkEntry(const IterateResult &res, size_t idx, const Document &doc, const Timestamp &timestamp)
{
ASSERT_LESS(idx, res.getEntries().size());
- DocEntry expect(timestamp, storage::spi::NONE, Document::UP(doc.clone()));
- EXPECT_EQUAL(expect, *res.getEntries()[idx]);
+ auto expect = DocEntry::create(timestamp, Document::UP(doc.clone()));
+ EXPECT_TRUE(equal(*expect, *res.getEntries()[idx]));
EXPECT_EQUAL(getSize(doc), res.getEntries()[idx]->getSize());
EXPECT_GREATER(getSize(doc), 0u);
}
@@ -608,9 +606,9 @@ TEST("require that using an empty field set returns meta-data only") {
IterateResult res = itr.iterate(largeNum);
EXPECT_TRUE(res.isCompleted());
EXPECT_EQUAL(3u, res.getEntries().size());
- TEST_DO(checkEntry(res, 0, Timestamp(2), storage::spi::NONE));
- TEST_DO(checkEntry(res, 1, Timestamp(3), storage::spi::NONE));
- TEST_DO(checkEntry(res, 2, Timestamp(4), storage::spi::REMOVE_ENTRY));
+ TEST_DO(checkEntry(res, 0, Timestamp(2), DocumentMetaEnum::NONE));
+ TEST_DO(checkEntry(res, 1, Timestamp(3), DocumentMetaEnum::NONE));
+ TEST_DO(checkEntry(res, 2, Timestamp(4), DocumentMetaEnum::REMOVE_ENTRY));
}
TEST("require that entries in other buckets are skipped") {
@@ -650,15 +648,15 @@ TEST("require that maxBytes splits iteration results for meta-data only iteratio
itr.add(doc("id:ns:document::1", Timestamp(2), bucket(5)));
itr.add(cat(rem("id:ns:document::2", Timestamp(3), bucket(5)),
doc("id:ns:document::3", Timestamp(4), bucket(5))));
- IterateResult res1 = itr.iterate(getSize() + getSize());
+ IterateResult res1 = itr.iterate(2 * sizeof(DocEntry));
EXPECT_TRUE(!res1.isCompleted());
EXPECT_EQUAL(2u, res1.getEntries().size());
- TEST_DO(checkEntry(res1, 0, Timestamp(2), storage::spi::NONE));
- TEST_DO(checkEntry(res1, 1, Timestamp(3), storage::spi::REMOVE_ENTRY));
+ TEST_DO(checkEntry(res1, 0, Timestamp(2), DocumentMetaEnum::NONE));
+ TEST_DO(checkEntry(res1, 1, Timestamp(3), DocumentMetaEnum::REMOVE_ENTRY));
IterateResult res2 = itr.iterate(largeNum);
EXPECT_TRUE(res2.isCompleted());
- TEST_DO(checkEntry(res2, 0, Timestamp(4), storage::spi::NONE));
+ TEST_DO(checkEntry(res2, 0, Timestamp(4), DocumentMetaEnum::NONE));
IterateResult res3 = itr.iterate(largeNum);
EXPECT_TRUE(res3.isCompleted());