Search in sources :

Example 1 with OLuceneTxOperations

use of com.orientechnologies.lucene.OLuceneTxOperations in project orientdb by orientechnologies.

the class OLuceneIndexNotUnique method removeFromSnapshot.

@Override
protected void removeFromSnapshot(Object key, OIdentifiable value, Map<Object, Object> snapshot) {
    key = getCollatingValue(key);
    OLuceneTxOperations operations = (OLuceneTxOperations) snapshot.get(key);
    if (operations == null) {
        operations = new OLuceneTxOperations();
        snapshot.put(key, operations);
    }
    operations.removed.add(value.getIdentity());
    snapshot.put(key, operations);
}
Also used : OLuceneTxOperations(com.orientechnologies.lucene.OLuceneTxOperations)

Example 2 with OLuceneTxOperations

use of com.orientechnologies.lucene.OLuceneTxOperations in project orientdb by orientechnologies.

the class OLuceneIndexNotUnique method commitSnapshot.

@Override
protected void commitSnapshot(final Map<Object, Object> snapshot) {
    while (true) try {
        storage.callIndexEngine(false, false, indexId, new OIndexEngineCallback<Object>() {

            @Override
            public Boolean callEngine(OIndexEngine engine) {
                OLuceneIndexEngine indexEngine = (OLuceneIndexEngine) engine;
                for (Map.Entry<Object, Object> snapshotEntry : snapshot.entrySet()) {
                    Object key = snapshotEntry.getKey();
                    OLuceneTxOperations operations = (OLuceneTxOperations) snapshotEntry.getValue();
                    for (OIdentifiable oIdentifiable : operations.removed) {
                        indexEngine.remove(decodeKey(key), oIdentifiable);
                    }
                }
                for (Map.Entry<Object, Object> snapshotEntry : snapshot.entrySet()) {
                    Object key = snapshotEntry.getKey();
                    OLuceneTxOperations operations = (OLuceneTxOperations) snapshotEntry.getValue();
                    indexEngine.put(decodeKey(key), operations.added);
                }
                OTransaction transaction = getDatabase().getTransaction();
                resetTransactionChanges(transaction);
                return null;
            }
        });
        break;
    } catch (OInvalidIndexEngineIdException e) {
        doReloadIndexEngine();
    }
}
Also used : OTransaction(com.orientechnologies.orient.core.tx.OTransaction) OInvalidIndexEngineIdException(com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException) OIndexEngine(com.orientechnologies.orient.core.index.OIndexEngine) OLuceneIndexEngine(com.orientechnologies.lucene.engine.OLuceneIndexEngine) OLuceneTxOperations(com.orientechnologies.lucene.OLuceneTxOperations) OIndexEngineCallback(com.orientechnologies.orient.core.storage.impl.local.OIndexEngineCallback) Map(java.util.Map) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 3 with OLuceneTxOperations

use of com.orientechnologies.lucene.OLuceneTxOperations in project orientdb by orientechnologies.

the class OLuceneIndexNotUnique method putInSnapshot.

@Override
protected void putInSnapshot(Object key, OIdentifiable value, Map<Object, Object> snapshot) {
    key = getCollatingValue(key);
    OLuceneTxOperations operations = (OLuceneTxOperations) snapshot.get(key);
    if (operations == null) {
        operations = new OLuceneTxOperations();
        snapshot.put(key, operations);
    }
    operations.added.add(value.getIdentity());
    snapshot.put(key, operations);
}
Also used : OLuceneTxOperations(com.orientechnologies.lucene.OLuceneTxOperations)

Aggregations

OLuceneTxOperations (com.orientechnologies.lucene.OLuceneTxOperations)3 OLuceneIndexEngine (com.orientechnologies.lucene.engine.OLuceneIndexEngine)1 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1 OInvalidIndexEngineIdException (com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException)1 OIndexEngine (com.orientechnologies.orient.core.index.OIndexEngine)1 OIndexEngineCallback (com.orientechnologies.orient.core.storage.impl.local.OIndexEngineCallback)1 OTransaction (com.orientechnologies.orient.core.tx.OTransaction)1 Map (java.util.Map)1