blob: 4ebe0819d9eb1267f6f784a13177b0320cbb4d38 (
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
|
// 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;
/**
* An "extended query result" packet. This is the query result
* packets used today, they allow more flexible sets of parameters
* to be shipped with query results. This packet can be decoded only.
*
* @author <a href="mailto:bratseth@yahoo-inc.com">Jon S Bratseth</a>
*/
public class DocsumPacket extends Packet {
private GlobalId globalId = new GlobalId(new byte[GlobalId.LENGTH]);
private byte[] data;
private DocsumPacket() {
}
/**
* Constructor used by streaming search
*/
public DocsumPacket(byte[] buffer) {
data = buffer.clone();
}
public static DocsumPacket create() {
return new DocsumPacket();
}
public int getCode() { return 205; }
/**
* Fills this packet from a byte buffer positioned at the
* first byte of the packet
*/
public void decodeBody(ByteBuffer buffer) {
byte[] rawGid = new byte[GlobalId.LENGTH];
buffer.get(rawGid);
globalId = new GlobalId(rawGid);
data=new byte[getLength()-12-GlobalId.LENGTH];
buffer.get(data);
}
public GlobalId getGlobalId() { return globalId; }
public byte[] getData() { return data; }
public String toString() {
return "docsum packet [globalId: " + globalId.toString() +
", size: " + (data==null ? "(no data)" : data.length +
" bytes") + " ]";
}
}
|