use of com.orientechnologies.orient.core.tx.OTransactionIndexChangesPerKey in project orientdb by orientechnologies.
the class OIndexTxAwareOneValue method calculateTxIndexEntry.
private Map.Entry<Object, OIdentifiable> calculateTxIndexEntry(final Object key, final OIdentifiable backendValue, final OTransactionIndexChanges indexChanges) {
final OTransactionIndexChangesPerKey changesPerKey = indexChanges.getChangesPerKey(key);
if (changesPerKey.entries.isEmpty()) {
if (backendValue == null)
return null;
else
return createMapEntry(key, backendValue);
}
OIdentifiable result = backendValue;
for (OTransactionIndexEntry entry : changesPerKey.entries) {
if (entry.operation == OPERATION.REMOVE)
result = null;
else if (entry.operation == OPERATION.PUT)
result = entry.value;
}
if (result == null)
return null;
final OIdentifiable resultValue = result;
return createMapEntry(key, resultValue);
}
use of com.orientechnologies.orient.core.tx.OTransactionIndexChangesPerKey in project orientdb by orientechnologies.
the class OIndexTxAware method getLastKey.
@Override
public Object getLastKey() {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return delegate.getLastKey();
Object indexLastKey;
if (indexChanges.cleared)
indexLastKey = null;
else
indexLastKey = delegate.getLastKey();
Object lastKey = indexChanges.getLastKey();
while (true) {
OTransactionIndexChangesPerKey changesPerKey = indexChanges.getChangesPerKey(lastKey);
for (OTransactionIndexEntry indexEntry : changesPerKey.entries) {
if (indexEntry.operation.equals(OPERATION.REMOVE))
lastKey = null;
else
lastKey = changesPerKey.key;
}
if (changesPerKey.key.equals(indexLastKey))
indexLastKey = lastKey;
if (lastKey != null) {
if (indexLastKey != null && ((Comparable) indexLastKey).compareTo(lastKey) > 0)
return indexLastKey;
return lastKey;
}
lastKey = indexChanges.getLowerKey(changesPerKey.key);
if (lastKey == null)
return indexLastKey;
}
}
Aggregations