if (val instanceof Map) {
Map map = (Map)val;
prefix = CompoundBytes.make(prefix, HEADER_BYTE_MAPOPEN);
if (true) {
Bytes headerBytes = CompoundBytes.make(prefix, suffix);
buffer.add(new EditRec(docId, headerBytes.flatten(), idDel));
}
for(Object entryObj : map.entrySet()) {
Map.Entry entry = (Map.Entry) entryObj;
String key = (String)entry.getKey();
Bytes sub = new CompoundBytes(prefix, sencodeMapKey(key));
sub = new CompoundBytes(sub, HEADER_BYTE_COLON);
sencodeMulti(sub, suffix, entry.getValue(), buffer, docId, idDel);
}
} else if (val instanceof List) {
List list = (List)val;
prefix = CompoundBytes.make(prefix, HEADER_BYTE_LISTOPEN);
if (true) {
Bytes headerBytes = CompoundBytes.make(prefix, suffix);
buffer.add(new EditRec(docId, headerBytes.flatten(), idDel));
}
for(int index=list.size()-1; index>=0; index--) {
Object subVal = list.get(index);
Bytes newSuffix = CompoundBytes.make(DbServiceUtil.sencodeListIndex(index), suffix);
sencodeMulti(prefix, newSuffix, subVal, buffer, docId, idDel);
}
} else {
Bytes bytes = CompoundBytes.make(CompoundBytes.make(prefix,sencode(val)),suffix);
buffer.add(new EditRec(docId, bytes.flatten(), false));
}
}