aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h
blob: f2eed820c630cfde10feb1bb270f88f1cad0523b (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
43
44
45
46
47
48
49
50
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "bucketresultnode.h"
#include "stringresultnode.h"

namespace search {
namespace expression {

class StringBucketResultNode : public BucketResultNode
{
private:
    ResultNode::CP _from;
    ResultNode::CP _to;
    static StringBucketResultNode _nullResult;
    size_t onGetRawByteSize() const override { return sizeof(_from) + sizeof(_to); }
public:
    struct GetValue {
        BufferRef _tmp;
        ConstBufferRef operator () (const ResultNode & r) { return r.getString(_tmp); }
    };

    DECLARE_EXPRESSIONNODE(StringBucketResultNode);
    DECLARE_NBO_SERIALIZE;
    StringBucketResultNode();
    StringBucketResultNode(const StringBucketResultNode&);
    StringBucketResultNode(StringBucketResultNode&&) noexcept = default;
    StringBucketResultNode(vespalib::stringref from, vespalib::stringref to);
    StringBucketResultNode(ResultNode::UP from, ResultNode::UP to) : _from(from.release()), _to(to.release()) {}
    ~StringBucketResultNode();
    StringBucketResultNode& operator=(const StringBucketResultNode&);
    StringBucketResultNode& operator=(StringBucketResultNode&&);
    size_t hash() const override;
    int onCmp(const Identifiable & b) const override;
    int contains(const StringBucketResultNode & b) const;
    int contains(const ConstBufferRef & v) const { return contains(v.c_str()); }
    int contains(const char * v) const;
    void visitMembers(vespalib::ObjectVisitor &visitor) const override;
    StringBucketResultNode &setRange(vespalib::stringref from, vespalib::stringref to) {
        _from.reset(new StringResultNode(from));
        _to.reset(new StringResultNode(to));
        return *this;
    }
    const StringBucketResultNode& getNullBucket() const override { return getNull(); }
    static const StringBucketResultNode & getNull() { return _nullResult; }
};

}
}