blob: fdaec7688bc9218d1cd941ae1735dd6cc55c7bf7 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;
import com.yahoo.document.Document;
import com.yahoo.document.serialization.DocumentDeserializer;
import com.yahoo.vespa.objects.Serializer;
public class DocumentListEntry {
private Document doc;
private long timestamp;
private boolean removeEntry;
public DocumentListEntry(Document doc, long timestamp, boolean removeEntry) {
this.doc = doc;
this.timestamp = timestamp;
this.removeEntry = removeEntry;
}
public void serialize(Serializer buf) {
buf.putLong(null, timestamp);
doc.serialize(buf);
buf.putByte(null, (byte)(removeEntry ? 1 : 0));
}
public static int getApproxSize() {
return 60; // optimzation. approximation is sufficient
}
public DocumentListEntry(DocumentDeserializer buf) {
timestamp = buf.getLong(null);
doc = new Document(buf);
removeEntry = buf.getByte(null) > 0;
}
public Document getDocument() {
return doc;
}
public long getTimestamp() {
return timestamp;
}
public boolean isRemoveEntry() {
return removeEntry;
}
}
|