use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexMultiValues method remove.
@Override
public boolean remove(Object key, final OIdentifiable value) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values = null;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null) {
return false;
}
final OModifiableBoolean removed = new OModifiableBoolean(false);
final Callable<Object> creator = new EntityRemover(value, removed, values);
while (true) try {
storage.updateIndexEntry(indexId, key, creator);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
return removed.getValue();
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexMultiValues method get.
public Set<OIdentifiable> get(Object key) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireSharedLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null)
return Collections.emptySet();
return Collections.unmodifiableSet(values);
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseSharedLock(key);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexDictionary method put.
public OIndexOneValue put(Object key, final OIdentifiable value) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive) {
keyLockManager.acquireExclusiveLock(key);
}
try {
acquireSharedLock();
try {
while (true) {
try {
storage.putIndexValue(indexId, key, value);
return this;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexFullText method remove.
/**
* Splits passed in key on several words and remove records with keys equals to any item of split result and values equals to
* passed in value.
*
* @param key Key to remove.
* @param value Value to remove.
*
* @return <code>true</code> if at least one record is removed.
*/
@Override
public boolean remove(Object key, final OIdentifiable value) {
if (key == null)
return false;
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
final Set<String> words = splitIntoWords(key.toString());
final OModifiableBoolean removed = new OModifiableBoolean(false);
for (final String word : words) {
acquireSharedLock();
try {
Set<OIdentifiable> recs;
while (true) {
try {
recs = (Set<OIdentifiable>) storage.getIndexValue(indexId, word);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (recs != null && !recs.isEmpty()) {
while (true) {
try {
storage.updateIndexEntry(indexId, word, new EntityRemover(recs, value, removed));
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
}
} finally {
releaseSharedLock();
}
}
return removed.getValue();
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexFullText method put.
/**
* Indexes a value and save the index. Splits the value in single words and index each one. Save of the index is responsibility of
* the caller.
*/
@Override
public OIndexFullText put(Object key, final OIdentifiable singleValue) {
if (key == null)
return this;
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
final Set<String> words = splitIntoWords(key.toString());
// FOREACH WORD CREATE THE LINK TO THE CURRENT DOCUMENT
for (final String word : words) {
acquireSharedLock();
try {
Set<OIdentifiable> refs;
while (true) {
try {
refs = (Set<OIdentifiable>) storage.getIndexValue(indexId, word);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
final boolean durable;
if (metadata != null && Boolean.TRUE.equals(metadata.field("durableInNonTxMode")))
durable = true;
else
durable = false;
final Set<OIdentifiable> refsc = refs;
// SAVE THE INDEX ENTRY
while (true) {
try {
storage.updateIndexEntry(indexId, word, new Callable<Object>() {
@Override
public Object call() throws Exception {
Set<OIdentifiable> result = null;
if (refsc == null) {
// WORD NOT EXISTS: CREATE THE KEYWORD CONTAINER THE FIRST TIME THE WORD IS FOUND
if (ODefaultIndexFactory.SBTREEBONSAI_VALUE_CONTAINER.equals(valueContainerAlgorithm)) {
result = new OIndexRIDContainer(getName(), durable);
} else {
throw new IllegalStateException("MBRBTreeContainer is not supported any more");
}
} else {
result = refsc;
}
// ADD THE CURRENT DOCUMENT AS REF FOR THAT WORD
result.add(singleValue);
return result;
}
});
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
} finally {
releaseSharedLock();
}
}
return this;
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
Aggregations