Search in sources :

Example 21 with OIndexException

use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.

the class OLocalHashTable method create.

@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
@Override
public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valueSerializer, OType[] keyTypes, boolean nullKeyIsSupported) {
    startOperation();
    try {
        final OAtomicOperation atomicOperation;
        try {
            atomicOperation = startAtomicOperation(false);
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during hash table creation"), e);
        }
        acquireExclusiveLock();
        try {
            try {
                if (keyTypes != null)
                    this.keyTypes = Arrays.copyOf(keyTypes, keyTypes.length);
                else
                    this.keyTypes = null;
                this.nullKeyIsSupported = nullKeyIsSupported;
                this.directory = new OHashTableDirectory(treeStateFileExtension, getName(), getFullName(), durableInNonTxMode, storage);
                fileStateId = addFile(atomicOperation, getName() + metadataConfigurationFileExtension);
                directory.create();
                final OCacheEntry hashStateEntry = addPage(atomicOperation, fileStateId);
                pinPage(atomicOperation, hashStateEntry);
                hashStateEntry.acquireExclusiveLock();
                try {
                    OHashIndexFileLevelMetadataPage page = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), true);
                    hashStateEntryIndex = hashStateEntry.getPageIndex();
                } finally {
                    hashStateEntry.releaseExclusiveLock();
                    releasePage(atomicOperation, hashStateEntry);
                }
                final String fileName = getFullName();
                fileId = addFile(atomicOperation, fileName);
                setKeySerializer(keySerializer);
                setValueSerializer(valueSerializer);
                initHashTreeState(atomicOperation);
                if (nullKeyIsSupported)
                    nullBucketFileId = addFile(atomicOperation, getName() + nullBucketFileExtension);
                endAtomicOperation(false, null);
            } catch (IOException e) {
                endAtomicOperation(true, e);
                throw e;
            } catch (Exception e) {
                endAtomicOperation(true, e);
                throw OException.wrapException(new OStorageException("Error during local hash table creation"), e);
            }
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during local hash table creation"), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
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) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OLocalHashTableException(com.orientechnologies.orient.core.exception.OLocalHashTableException) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 22 with OIndexException

use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.

the class OLocalHashTable method setKeySerializer.

@Override
public void setKeySerializer(OBinarySerializer<K> keySerializer) {
    startOperation();
    try {
        final OAtomicOperation atomicOperation;
        try {
            atomicOperation = startAtomicOperation(true);
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during hash set serializer for index keys"), e);
        }
        acquireExclusiveLock();
        try {
            this.keySerializer = keySerializer;
            OCacheEntry hashStateEntry = loadPage(atomicOperation, fileStateId, hashStateEntryIndex, true);
            hashStateEntry.acquireExclusiveLock();
            try {
                OHashIndexFileLevelMetadataPage metadataPage = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), false);
                metadataPage.setKeySerializerId(keySerializer.getId());
            } finally {
                hashStateEntry.releaseExclusiveLock();
                releasePage(atomicOperation, hashStateEntry);
            }
            endAtomicOperation(false, null);
        } catch (IOException e) {
            rollback(e);
            throw OException.wrapException(new OIndexException("Cannot set serializer for index keys"), e);
        } catch (Exception e) {
            rollback(e);
            throw OException.wrapException(new OStorageException("Cannot set serializer for index keys"), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
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) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OLocalHashTableException(com.orientechnologies.orient.core.exception.OLocalHashTableException) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 23 with OIndexException

use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.

the class OLocalHashTable method put.

private boolean put(K key, V value, OIndexEngine.Validator<K, V> validator) {
    final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic();
    startOperation();
    if (statistic != null)
        statistic.startIndexEntryUpdateTimer();
    try {
        final OAtomicOperation atomicOperation;
        try {
            atomicOperation = startAtomicOperation(true);
        } catch (IOException e) {
            throw OException.wrapException(new OIndexException("Error during hash table entry put"), e);
        }
        acquireExclusiveLock();
        try {
            checkNullSupport(key);
            if (key != null) {
                final int keySize = keySerializer.getObjectSize(key, (Object[]) keyTypes);
                if (keySize > MAX_KEY_SIZE)
                    throw new OTooBigIndexKeyException("Key size is more than allowed, operation was canceled. Current key size " + keySize + ", allowed  " + MAX_KEY_SIZE, getName());
            }
            key = keySerializer.preprocess(key, (Object[]) keyTypes);
            final boolean putResult = doPut(key, value, validator, atomicOperation);
            endAtomicOperation(false, null);
            return putResult;
        } catch (IOException e) {
            rollback(e);
            throw OException.wrapException(new OIndexException("Error during index update"), e);
        } catch (Exception e) {
            rollback(e);
            throw OException.wrapException(new OStorageException("Error during index update"), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        if (statistic != null)
            statistic.stopIndexEntryUpdateTimer();
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) IOException(java.io.IOException) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OIndexException(com.orientechnologies.orient.core.index.OIndexException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) OLocalHashTableException(com.orientechnologies.orient.core.exception.OLocalHashTableException) OTooBigIndexKeyException(com.orientechnologies.orient.core.exception.OTooBigIndexKeyException) OStorageException(com.orientechnologies.orient.core.exception.OStorageException)

Example 24 with OIndexException

use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.

the class OLocalHashTable20 method setValueSerializer.

@Override
public void setValueSerializer(OBinarySerializer<V> valueSerializer) {
    final OAtomicOperation atomicOperation;
    try {
        atomicOperation = startAtomicOperation(true);
    } catch (IOException e) {
        throw OException.wrapException(new OIndexException("Error during hash table set serializer for index values"), e);
    }
    acquireExclusiveLock();
    try {
        this.valueSerializer = valueSerializer;
        final OCacheEntry hashStateEntry = loadPage(atomicOperation, fileStateId, hashStateEntryIndex, true);
        hashStateEntry.acquireExclusiveLock();
        try {
            OHashIndexFileLevelMetadataPage metadataPage = new OHashIndexFileLevelMetadataPage(hashStateEntry, getChanges(atomicOperation, hashStateEntry), false);
            metadataPage.setValueSerializerId(valueSerializer.getId());
        } finally {
            hashStateEntry.releaseExclusiveLock();
            releasePage(atomicOperation, hashStateEntry);
        }
        endAtomicOperation(false, null);
    } catch (IOException e) {
        rollback();
        throw OException.wrapException(new OIndexException("Cannot set serializer for index values"), e);
    } catch (Exception e) {
        rollback();
        throw OException.wrapException(new OStorageException("Cannot set serializer for index values"), 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) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) 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)

Example 25 with OIndexException

use of com.orientechnologies.orient.core.index.OIndexException 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

OIndexException (com.orientechnologies.orient.core.index.OIndexException)31 IOException (java.io.IOException)27 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)26 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)23 OException (com.orientechnologies.common.exception.OException)16 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)14 OIndexEngineException (com.orientechnologies.orient.core.index.OIndexEngineException)8 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)6 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)6 OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)3 Constructor (java.lang.reflect.Constructor)2 Analyzer (org.apache.lucene.analysis.Analyzer)2 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)2 OIOException (com.orientechnologies.common.io.OIOException)1 OLuceneQueryContext (com.orientechnologies.lucene.query.OLuceneQueryContext)1 OIndexEngine (com.orientechnologies.orient.core.index.OIndexEngine)1 OHashTableIndexEngine (com.orientechnologies.orient.core.index.engine.OHashTableIndexEngine)1 ORemoteIndexEngine (com.orientechnologies.orient.core.index.engine.ORemoteIndexEngine)1 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1