final String indexName = indexEntry.getKey();
final ODocument indexDoc = (ODocument) indexEntry.getValue();
if (indexDoc == null)
continue;
OTransactionIndexChanges transactionIndexChanges = indexEntries.get(indexEntry.getKey());
if (transactionIndexChanges == null) {
transactionIndexChanges = new OTransactionIndexChanges();
indexEntries.put(indexEntry.getKey(), transactionIndexChanges);
}
final Boolean clearAll = indexDoc.field("clear");
if (clearAll != null && clearAll)
transactionIndexChanges.setCleared();
final Collection<ODocument> entries = indexDoc.field("entries");
if (entries == null)
continue;
for (final ODocument entry : entries) {
final List<ODocument> operations = entry.field("ops");
if (operations == null)
continue;
final Object key;
try {
ODocument keyContainer;
if (protocolVersion <= OChannelBinaryProtocol.PROTOCOL_VERSION_24) {
final String serializedKey = OStringSerializerHelper.decode((String) entry.field("k"));
if (serializedKey.equals("*"))
keyContainer = null;
else {
keyContainer = new ODocument();
keyContainer.setLazyLoad(false);
ORecordSerializerSchemaAware2CSV.INSTANCE.fromString(serializedKey, keyContainer, null);
}
} else {
keyContainer = entry.field("k");
}
if (keyContainer != null) {
final Object storedKey = keyContainer.field("key");
if (storedKey instanceof List)
key = new OCompositeKey((List<? extends Comparable<?>>) storedKey);
else if (Boolean.TRUE.equals(keyContainer.field("binary"))) {
key = OStreamSerializerAnyStreamable.INSTANCE.fromStream((byte[]) storedKey);
} else
key = storedKey;
} else
key = null;
} catch (IOException ioe) {
throw new OTransactionException("Error during index changes deserialization. ", ioe);
}
for (final ODocument op : operations) {
final int operation = (Integer) op.rawField("o");
final OTransactionIndexChanges.OPERATION indexOperation = OTransactionIndexChanges.OPERATION.values()[operation];
final OIdentifiable value = op.field("v");
transactionIndexChanges.getChangesPerKey(key).add(value, indexOperation);
if (value == null)
continue;
final ORID rid = value.getIdentity();