QueryNode q = index.getTerm(new CompoundBytes(ID_BYTES, new ArrayBytes(Util.decodeString(key))), revNum);
if (q == null) throw new RuntimeException("Object not found; id=\""+key+"\"");
clauses.add(q);
}
if (clauses.size() > 0) {
QueryNode idQuery = new OrderedOrQueryNode(clauses, null, null, null, false, false);
do {
long docId = idQuery.doc();
data.skipTo(docId);
do {
edits.add(new EditRec(docId, data.term(), true));
} while(data.nextTerm() == NextStatus.NEXT_TERM);
} while(idQuery.next());
}
long insId = -1;
for(Map.Entry<String,Object> entry : value.getEntries().entrySet()) {
String key = entry.getKey();
QueryNode q = index.getTerm(new CompoundBytes(ID_BYTES, new ArrayBytes(Util.decodeString(key))), revNum);
if (q != null) {
clauses.add(q);
} else {
long docId = insId--;
DbServiceUtil.sencodeMulti(ArrayBytes.EMPTY_BYTES, entry.getValue(), edits, docId, false);
}
}
if (clauses.size() > 0) {
QueryNode idQuery = new OrderedOrQueryNode(clauses, null, null, null, false, false);
Map<String, Object> entries = value.getEntries();
do {
long docId = idQuery.doc();
Bytes idTerm = idQuery.term();
byte[] idBytes = idTerm.subBytes(NUM_ID_BYTES, idTerm.getLength()-NUM_ID_BYTES).getBytes();
Object val = entries.get(Util.encodeBytes(idBytes));
DbServiceUtil.sencodeMulti(ArrayBytes.EMPTY_BYTES, val, edits, docId, false);
} while(idQuery.next());
}
return edits;
}