blob: 0576f507ffc8a69c546bcc468305aa23edbe5286 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.fs4;
import com.yahoo.document.GlobalId;
import java.nio.ByteBuffer;
/**
* Meta attributes on documents (not the document summaries themselves).
* Used in query results and get docusum packages
*
* @author bratseth
*/
public class DocumentInfo implements Cloneable {
private final GlobalId globalId;
private final double metric;
private final int partId;
private final int distributionKey;
DocumentInfo(ByteBuffer buffer, QueryResultPacket owner) {
byte[] rawGid = new byte[GlobalId.LENGTH];
buffer.get(rawGid);
globalId = new GlobalId(rawGid);
metric = decodeMetric(buffer);
partId = owner.getMldFeature() ? buffer.getInt() : 0;
distributionKey = owner.getMldFeature() ? buffer.getInt() : 0;
}
public DocumentInfo(GlobalId globalId, int metric, int partId, int distributionKey) {
this.globalId=globalId;
this.metric=metric;
this.partId=partId;
this.distributionKey = distributionKey;
}
private double decodeMetric(ByteBuffer buffer) {
return buffer.getDouble();
}
public GlobalId getGlobalId() { return globalId; }
/** Raw rank score */
public double getMetric() { return metric; }
/** Partition this document resides on */
public int getPartId() { return partId; }
/** Unique key for the node this document resides on */
public int getDistributionKey() { return distributionKey; }
public String toString() {
return "document info [globalId=" + globalId + ", metric=" + metric + "]";
}
/**
* Implements the Cloneable interface
*/
public Object clone() {
try {
DocumentInfo docInfo=(DocumentInfo) super.clone();
return docInfo;
}
catch (CloneNotSupportedException e) {
throw new RuntimeException("Someone inserted a nonclonable superclass");
}
}
}
|