blob: 5314e8b8f5e5b7bbb86a5cf60e2f67a02b6896ee (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.predicate;
import com.google.common.annotations.Beta;
/**
* Represents a hit from the predicate search algorithm.
* Each hit is associated with a subquery bitmap,
* indicating which subqueries the hit represents.
*
* @author Magnar Nedland
*/
@Beta
public class Hit implements Comparable<Hit> {
private final int docId;
private final long subquery;
public Hit(int docId) {
this(docId, SubqueryBitmap.DEFAULT_VALUE);
}
public Hit(int docId, long subquery) {
this.docId = docId;
this.subquery = subquery;
}
@Override
public String toString() {
if (subquery == SubqueryBitmap.DEFAULT_VALUE) {
return "" + docId;
} else {
return "[" + docId + ",0x" + Long.toHexString(subquery) + "]";
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Hit hit = (Hit) o;
if (docId != hit.docId) return false;
if (subquery != hit.subquery) return false;
return true;
}
@Override
public int hashCode() {
int result = docId;
result = 31 * result + (int) (subquery ^ (subquery >>> 32));
return result;
}
public int getDocId() {
return docId;
}
public long getSubquery() {
return subquery;
}
@Override
public int compareTo(Hit o) {
return Integer.compare(docId, o.docId);
}
}
|