use of com.orientechnologies.orient.core.index.OIndexEngineException in project orientdb by orientechnologies.
the class OIndexRIDContainer method resolveFileIdByName.
private long resolveFileIdByName(String fileName) {
final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying();
final OAtomicOperation atomicOperation;
try {
atomicOperation = storage.getAtomicOperationsManager().startAtomicOperation(fileName, true);
} catch (IOException e) {
throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
}
try {
final OReadCache readCache = storage.getReadCache();
final OWriteCache writeCache = storage.getWriteCache();
if (atomicOperation == null) {
if (writeCache.exists(fileName))
return writeCache.fileIdByName(fileName);
return readCache.addFile(fileName, writeCache);
} else {
long fileId;
if (atomicOperation.isFileExists(fileName))
fileId = atomicOperation.loadFile(fileName);
else
fileId = atomicOperation.addFile(fileName);
storage.getAtomicOperationsManager().endAtomicOperation(false, null, fileName);
return fileId;
}
} catch (IOException e) {
try {
storage.getAtomicOperationsManager().endAtomicOperation(true, e, fileName);
} catch (IOException ioe) {
throw OException.wrapException(new OIndexEngineException("Error of rollback of atomic operation", fileName), ioe);
}
throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
}
}
use of com.orientechnologies.orient.core.index.OIndexEngineException in project orientdb by orientechnologies.
the class OLuceneFullTextIndexEngine method getInTx.
@Override
public Object getInTx(Object key, OLuceneTxChanges changes) {
try {
Query q = queryBuilder.query(index, key, queryAnalyzer());
OCommandContext context = null;
if (key instanceof OLuceneCompositeKey) {
context = ((OLuceneCompositeKey) key).getContext();
}
return getResults(q, context, key, changes);
} catch (ParseException e) {
throw OException.wrapException(new OIndexEngineException("Error parsing lucene query"), e);
}
}
use of com.orientechnologies.orient.core.index.OIndexEngineException in project orientdb by orientechnologies.
the class OLocalHashTable20 method clear.
@Override
public void clear() {
final OAtomicOperation atomicOperation;
try {
atomicOperation = startAtomicOperation(true);
} catch (IOException e) {
throw OException.wrapException(new OIndexException("Error during hash table clear"), e);
}
acquireExclusiveLock();
try {
final OCacheEntry hashStateEntry = loadPage(atomicOperation, fileStateId, hashStateEntryIndex, true);
hashStateEntry.acquireExclusiveLock();
try {
OHashIndexFileLevelMetadataPage page = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), false);
for (int i = 0; i < HASH_CODE_SIZE; i++) {
if (!page.isRemoved(i)) {
truncateFile(atomicOperation, page.getFileId(i));
page.setBucketsCount(i, 0);
page.setTombstoneIndex(i, -1);
}
}
} finally {
hashStateEntry.releaseExclusiveLock();
releasePage(atomicOperation, hashStateEntry);
}
if (nullKeyIsSupported)
truncateFile(atomicOperation, nullBucketFileId);
initHashTreeState(atomicOperation);
endAtomicOperation(false, null);
} catch (IOException e) {
rollback();
throw OException.wrapException(new OIndexEngineException("Error during hash table clear", getName()), e);
} catch (Exception e) {
rollback();
throw OException.wrapException(new OIndexEngineException("Error during hash table clear", getName()), e);
} finally {
releaseExclusiveLock();
}
}
Aggregations