aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/external/visitororder.h
blob: 90d6b2eaf078809ccc4cfbf5870b3e0584c980b3 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <climits>
#include <vespa/document/bucket/bucketid.h>

namespace storage::distributor {

struct VisitorOrder {

    VisitorOrder() = default;

    bool operator()(const document::BucketId& a, const document::BucketId& b) noexcept {
        if (a == document::BucketId(INT_MAX) ||
            b == document::BucketId(0, 0)) {
            return false; // All before max, non before null
        }
        if (a == document::BucketId(0, 0) ||
            b == document::BucketId(INT_MAX)) {
            return true; // All after null, non after max
        }
        return (a.toKey() < b.toKey()); // Reversed bucket id order
    }
};

}