use of com.orientechnologies.orient.core.storage.impl.local.OIndexEngineCallback 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();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.OIndexEngineCallback in project orientdb by orientechnologies.
the class OLuceneIndexNotUnique method put.
@Override
public OLuceneIndexNotUnique put(final Object key, final OIdentifiable singleValue) {
if (key != null) {
OTransaction transaction = getDatabase().getTransaction();
if (transaction.isActive()) {
OLuceneTxChanges transactionChanges = getTransactionChanges(transaction);
transaction.addIndexEntry(this, super.getName(), OTransactionIndexChanges.OPERATION.PUT, encodeKey(key), singleValue);
Document luceneDoc;
while (true) {
try {
luceneDoc = storage.callIndexEngine(false, false, indexId, new OIndexEngineCallback<Document>() {
@Override
public Document callEngine(OIndexEngine engine) {
OLuceneIndexEngine oIndexEngine = (OLuceneIndexEngine) engine;
return oIndexEngine.buildDocument(key, singleValue);
}
});
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
try {
transactionChanges.put(key, singleValue, luceneDoc);
} catch (IOException e) {
e.printStackTrace();
}
} else {
while (true) {
try {
storage.updateIndexEntry(indexId, key, new Callable<Object>() {
@Override
public Object call() throws Exception {
return Arrays.asList(singleValue);
}
});
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
}
}
return this;
}
use of com.orientechnologies.orient.core.storage.impl.local.OIndexEngineCallback in project orientdb by orientechnologies.
the class OLuceneIndexNotUnique method onIndexEngineChange.
@Override
protected void onIndexEngineChange(int indexId) {
while (true) try {
storage.callIndexEngine(false, false, indexId, new OIndexEngineCallback<Object>() {
@Override
public Object callEngine(OIndexEngine engine) {
OLuceneIndexEngine oIndexEngine = (OLuceneIndexEngine) engine;
oIndexEngine.init(getName(), getType(), getDefinition(), isAutomatic(), getMetadata());
return null;
}
});
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
Aggregations