blob: 776e428a6ff87b34defa0858483cf7884ec8fb13 (
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 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.predicate.index;
/**
* Represents an entry in a posting list, containing an integer id and integer data reference.
*
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
*/
public class Posting implements Comparable<Posting> {
private final int id;
private final int dataRef;
public Posting(int id, int dataRef) {
this.id = id;
this.dataRef = dataRef;
}
public int getId() {
return id;
}
public int getDataRef() {
return dataRef;
}
@Override
public int compareTo(Posting o) {
return Integer.compareUnsigned(id, o.id);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Posting posting = (Posting) o;
if (id != posting.id) return false;
return dataRef == posting.dataRef;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + dataRef;
return result;
}
}
|