use of com.orientechnologies.orient.core.tx.OTransactionIndexChanges in project orientdb by orientechnologies.
the class OIndexTxAwareOneValue method iterateEntriesBetween.
@Override
public OIndexCursor iterateEntriesBetween(Object fromKey, final boolean fromInclusive, Object toKey, final boolean toInclusive, final boolean ascOrder) {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return super.iterateEntriesBetween(fromKey, fromInclusive, toKey, toInclusive, ascOrder);
fromKey = getCollatingValue(fromKey);
toKey = getCollatingValue(toKey);
final OIndexCursor txCursor;
if (ascOrder)
txCursor = new PureTxBetweenIndexForwardCursor(fromKey, fromInclusive, toKey, toInclusive, indexChanges);
else
txCursor = new PureTxBetweenIndexBackwardCursor(fromKey, fromInclusive, toKey, toInclusive, indexChanges);
if (indexChanges.cleared)
return txCursor;
final OIndexCursor backedCursor = super.iterateEntriesBetween(fromKey, fromInclusive, toKey, toInclusive, ascOrder);
return new OIndexTxCursor(txCursor, backedCursor, ascOrder, indexChanges);
}
use of com.orientechnologies.orient.core.tx.OTransactionIndexChanges in project orientdb by orientechnologies.
the class OIndexTxAwareOneValue method iterateEntriesMajor.
@Override
public OIndexCursor iterateEntriesMajor(Object fromKey, boolean fromInclusive, boolean ascOrder) {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return super.iterateEntriesMajor(fromKey, fromInclusive, ascOrder);
fromKey = getCollatingValue(fromKey);
final OIndexCursor txCursor;
final Object lastKey = indexChanges.getLastKey();
if (ascOrder)
txCursor = new PureTxBetweenIndexForwardCursor(fromKey, fromInclusive, lastKey, true, indexChanges);
else
txCursor = new PureTxBetweenIndexBackwardCursor(fromKey, fromInclusive, lastKey, true, indexChanges);
if (indexChanges.cleared)
return txCursor;
final OIndexCursor backedCursor = super.iterateEntriesMajor(fromKey, fromInclusive, ascOrder);
return new OIndexTxCursor(txCursor, backedCursor, ascOrder, indexChanges);
}
use of com.orientechnologies.orient.core.tx.OTransactionIndexChanges in project orientdb by orientechnologies.
the class OIndexTxAwareOneValue method iterateEntriesMinor.
@Override
public OIndexCursor iterateEntriesMinor(Object toKey, boolean toInclusive, boolean ascOrder) {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return super.iterateEntriesMinor(toKey, toInclusive, ascOrder);
toKey = getCollatingValue(toKey);
final OIndexCursor txCursor;
final Object firstKey = indexChanges.getFirstKey();
if (ascOrder)
txCursor = new PureTxBetweenIndexForwardCursor(firstKey, true, toKey, toInclusive, indexChanges);
else
txCursor = new PureTxBetweenIndexBackwardCursor(firstKey, true, toKey, toInclusive, indexChanges);
if (indexChanges.cleared)
return txCursor;
final OIndexCursor backedCursor = super.iterateEntriesMinor(toKey, toInclusive, ascOrder);
return new OIndexTxCursor(txCursor, backedCursor, ascOrder, indexChanges);
}
use of com.orientechnologies.orient.core.tx.OTransactionIndexChanges in project orientdb by orientechnologies.
the class OIndexTxAwareMultiValue method iterateEntriesMajor.
@Override
public OIndexCursor iterateEntriesMajor(Object fromKey, boolean fromInclusive, boolean ascOrder) {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return super.iterateEntriesMajor(fromKey, fromInclusive, ascOrder);
fromKey = getCollatingValue(fromKey);
final OIndexCursor txCursor;
final Object lastKey = indexChanges.getLastKey();
if (ascOrder)
txCursor = new PureTxBetweenIndexForwardCursor(fromKey, fromInclusive, lastKey, true, indexChanges);
else
txCursor = new PureTxBetweenIndexBackwardCursor(fromKey, fromInclusive, lastKey, true, indexChanges);
if (indexChanges.cleared)
return txCursor;
final OIndexCursor backedCursor = super.iterateEntriesMajor(fromKey, fromInclusive, ascOrder);
return new OIndexTxCursor(txCursor, backedCursor, ascOrder, indexChanges);
}
use of com.orientechnologies.orient.core.tx.OTransactionIndexChanges in project orientdb by orientechnologies.
the class OIndexTxAwareOneValue method get.
@Override
public OIdentifiable get(Object key) {
final OTransactionIndexChanges indexChanges = database.getTransaction().getIndexChanges(delegate.getName());
if (indexChanges == null)
return super.get(key);
key = getCollatingValue(key);
OIdentifiable result;
if (!indexChanges.cleared)
// BEGIN FROM THE UNDERLYING RESULT SET
result = super.get(key);
else
// BEGIN FROM EMPTY RESULT SET
result = null;
// FILTER RESULT SET WITH TRANSACTIONAL CHANGES
final Map.Entry<Object, OIdentifiable> entry = calculateTxIndexEntry(key, result, indexChanges);
if (entry == null)
return null;
return entry.getValue();
}
Aggregations