blob: 50b63e2d5d7b86a058d1a97acd8b476c0803d5ca (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.expression;
import com.yahoo.vespa.objects.Deserializer;
import com.yahoo.vespa.objects.ObjectVisitor;
import com.yahoo.vespa.objects.Serializer;
/**
* @author baldersheim
*/
public class RawBucketResultNode extends BucketResultNode {
// The global class identifier shared with C++.
public static final int classId = registerClass(0x4000 + 125, RawBucketResultNode.class);
// bucket start, inclusive
private ResultNode from = RawResultNode.getNegativeInfinity();
// bucket end, exclusive
private ResultNode to = RawResultNode.getNegativeInfinity();
@Override
public boolean empty() {
return to.equals(from);
}
/**
* Constructs an empty result node.
*/
public RawBucketResultNode() {
// empty
}
/**
* Create a bucket with the given limits
*
* @param from bucket start
* @param to bucket end
*/
public RawBucketResultNode(ResultNode from, ResultNode to) {
this.from = from;
this.to = to;
}
/**
* Obtain the bucket start
*
* @return bucket start
*/
public byte[] getFrom() {
return from.getRaw();
}
/**
* Obtain the bucket end
*
* @return bucket end
*/
public byte[] getTo() {
return to.getRaw();
}
@Override
protected int onGetClassId() {
return classId;
}
@Override
protected void onSerialize(Serializer buf) {
serializeOptional(buf, from);
serializeOptional(buf, to);
}
@Override
protected void onDeserialize(Deserializer buf) {
from = (ResultNode)deserializeOptional(buf);
to = (ResultNode)deserializeOptional(buf);
}
@Override
protected int onCmp(ResultNode rhs) {
if (classId != rhs.getClassId()) {
return (classId - rhs.getClassId());
}
RawBucketResultNode b = (RawBucketResultNode)rhs;
int diff = from.compareTo(b.from);
return (diff == 0) ? to.compareTo(b.to) : diff;
}
@Override
public int hashCode() {
return super.hashCode() + from.hashCode() + to.hashCode();
}
@Override
public void visitMembers(ObjectVisitor visitor) {
super.visitMembers(visitor);
visitor.visit("from", from);
visitor.visit("to", to);
}
}
|