blob: 8ce2b5a65edfba4c68f057ab2b10beb708768526 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "document.h"
#include <cassert>
#include <algorithm>
namespace proton::test {
/**
* Collection of documents contained in the same bucket.
*/
class BucketDocuments
{
private:
DocumentVector _docs;
public:
BucketDocuments()
: _docs()
{
}
document::BucketId getBucket() const {
if (!_docs.empty()) {
return _docs.back().getBucket();
}
return document::BucketId();
}
const DocumentVector &getDocs() const { return _docs; }
DocumentVector getGidOrderDocs() const {
DocumentVector retval = _docs;
std::sort(retval.begin(), retval.end(), DocumentGidOrderCmp());
return retval;
}
void addDoc(const Document &doc) {
if (!_docs.empty()) {
assert(_docs.back().getBucket() == doc.getBucket());
}
_docs.push_back(doc);
}
};
}
|