Search in sources :

Example 6 with OTransactionIndexChanges

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);
}
Also used : OTransactionIndexChanges(com.orientechnologies.orient.core.tx.OTransactionIndexChanges)

Example 7 with OTransactionIndexChanges

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);
}
Also used : OTransactionIndexChanges(com.orientechnologies.orient.core.tx.OTransactionIndexChanges)

Example 8 with OTransactionIndexChanges

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);
}
Also used : OTransactionIndexChanges(com.orientechnologies.orient.core.tx.OTransactionIndexChanges)

Example 9 with OTransactionIndexChanges

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);
}
Also used : OTransactionIndexChanges(com.orientechnologies.orient.core.tx.OTransactionIndexChanges)

Example 10 with OTransactionIndexChanges

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();
}
Also used : OTransactionIndexChanges(com.orientechnologies.orient.core.tx.OTransactionIndexChanges) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Aggregations

OTransactionIndexChanges (com.orientechnologies.orient.core.tx.OTransactionIndexChanges)14 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 OTransactionIndexEntry (com.orientechnologies.orient.core.tx.OTransactionIndexChangesPerKey.OTransactionIndexEntry)4 OTransactionIndexChangesPerKey (com.orientechnologies.orient.core.tx.OTransactionIndexChangesPerKey)3 ORecordLazyList (com.orientechnologies.orient.core.db.record.ORecordLazyList)1 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)1 ORID (com.orientechnologies.orient.core.id.ORID)1 OCompositeKey (com.orientechnologies.orient.core.index.OCompositeKey)1 OEmptyIterator (com.orientechnologies.orient.core.iterator.OEmptyIterator)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 IOException (java.io.IOException)1