Search in sources :

Example 1 with OIndexEngineException

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);
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OWriteCache(com.orientechnologies.orient.core.storage.cache.OWriteCache) OReadCache(com.orientechnologies.orient.core.storage.cache.OReadCache) IOException(java.io.IOException) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException)

Example 2 with OIndexEngineException

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);
    }
}
Also used : OLuceneCompositeKey(com.orientechnologies.lucene.collections.OLuceneCompositeKey) Query(org.apache.lucene.search.Query) OCommandContext(com.orientechnologies.orient.core.command.OCommandContext) ParseException(com.orientechnologies.orient.core.sql.parser.ParseException) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException)

Example 3 with OIndexEngineException

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();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OIndexException(com.orientechnologies.orient.core.index.OIndexException) IOException(java.io.IOException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException)

Aggregations

OIndexEngineException (com.orientechnologies.orient.core.index.OIndexEngineException)3 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)2 IOException (java.io.IOException)2 OException (com.orientechnologies.common.exception.OException)1 OLuceneCompositeKey (com.orientechnologies.lucene.collections.OLuceneCompositeKey)1 OCommandContext (com.orientechnologies.orient.core.command.OCommandContext)1 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)1 OIndexException (com.orientechnologies.orient.core.index.OIndexException)1 ParseException (com.orientechnologies.orient.core.sql.parser.ParseException)1 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)1 OReadCache (com.orientechnologies.orient.core.storage.cache.OReadCache)1 OWriteCache (com.orientechnologies.orient.core.storage.cache.OWriteCache)1 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)1 Query (org.apache.lucene.search.Query)1