/
PercolateShardRequest.java
63 lines (51 loc) · 1.67 KB
/
PercolateShardRequest.java
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
package org.elasticsearch.action.percolate;
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
/**
*/
public class PercolateShardRequest extends BroadcastShardOperationRequest {
private String documentType;
private BytesReference source;
private BytesReference fetchedDoc;
public PercolateShardRequest() {
}
public PercolateShardRequest(String index, int shardId, PercolateRequest request) {
super(index, shardId, request);
this.documentType = request.documentType();
this.source = request.source();
this.fetchedDoc = request.fetchedDoc();
}
public String documentType() {
return documentType;
}
public BytesReference source() {
return source;
}
public BytesReference fetchedDoc() {
return fetchedDoc;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
documentType = in.readString();
source = in.readBytesReference();
if (in.readBoolean()) {
fetchedDoc = in.readBytesReference();
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(documentType);
out.writeBytesReference(source);
if (fetchedDoc != null) {
out.writeBoolean(true);
out.writeBytesReference(fetchedDoc);
} else {
out.writeBoolean(false);
}
}
}