// LOCK INVOLVED INDEXES
List<OIndexMVRBTreeAbstract> lockedIndexes = null;
try {
if (involvedIndexes != null)
for (String indexName : involvedIndexes) {
final OIndexMVRBTreeAbstract index = (OIndexMVRBTreeAbstract) getMetadata().getIndexManager().getIndexInternal(indexName);
if (lockedIndexes == null)
lockedIndexes = new ArrayList<OIndexMVRBTreeAbstract>();
index.acquireExclusiveLock();
lockedIndexes.add(index);
}
getStorage().commit(currentTx);
// COMMIT INDEX CHANGES
final ODocument indexEntries = currentTx.getIndexChanges();
if (indexEntries != null) {
for (Entry<String, Object> indexEntry : indexEntries) {
final OIndex index = getMetadata().getIndexManager().getIndexInternal(indexEntry.getKey());
index.commit((ODocument) indexEntry.getValue());
}
}
} finally {
// RELEASE INDEX LOCKS IF ANY
if (lockedIndexes != null)
for (OIndexMVRBTreeAbstract index : lockedIndexes) {
index.releaseExclusiveLock();
}
}
}