use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.
the class OHashIndexFactory method createIndexEngine.
@Override
public OIndexEngine createIndexEngine(final String algoritm, final String name, final Boolean durableInNonTxMode, final OStorage storage, final int version, final Map<String, String> engineProperties) {
OIndexEngine indexEngine;
final String storageType = storage.getType();
if (storageType.equals("memory") || storageType.equals("plocal"))
indexEngine = new OHashTableIndexEngine(name, durableInNonTxMode, (OAbstractPaginatedStorage) storage, version);
else if (storageType.equals("distributed"))
// DISTRIBUTED CASE: HANDLE IT AS FOR LOCAL
indexEngine = new OHashTableIndexEngine(name, durableInNonTxMode, (OAbstractPaginatedStorage) storage.getUnderlying(), version);
else if (storageType.equals("remote"))
indexEngine = new ORemoteIndexEngine(name);
else
throw new OIndexException("Unsupported storage type: " + storageType);
return indexEngine;
}
use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.
the class OLuceneAnalyzerFactory method buildAnalyzer.
private Analyzer buildAnalyzer(String analyzerFQN, Collection<String> stopwords) {
try {
final Class classAnalyzer = Class.forName(analyzerFQN);
final Constructor constructor = classAnalyzer.getDeclaredConstructor(CharArraySet.class);
return (Analyzer) constructor.newInstance(new CharArraySet(stopwords, true));
} catch (ClassNotFoundException e) {
throw OException.wrapException(new OIndexException("Analyzer: " + analyzerFQN + " not found"), e);
} catch (NoSuchMethodException e) {
throw OException.wrapException(new OIndexException("Couldn't instantiate analyzer: public constructor not found"), e);
} catch (Exception e) {
OLogManager.instance().error(this, "Error on getting analyzer for Lucene index", e);
}
return new StandardAnalyzer();
}
use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.
the class OLuceneFullTextIndexEngine method getResults.
private Set<OIdentifiable> getResults(Query query, OCommandContext context, Object key, OLuceneTxChanges changes) {
try {
IndexSearcher searcher = searcher();
OLuceneQueryContext queryContext = new OLuceneQueryContext(context, searcher, query).setChanges(changes);
if (facetManager.supportsFacets()) {
facetManager.addFacetContext(queryContext, key);
}
return OLuceneResultSetFactory.INSTANCE.create(this, queryContext);
} catch (IOException e) {
throw OIOException.wrapException(new OIndexException("Error reading from Lucene index"), e);
}
}
use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.
the class OLocalHashTable method setValueSerializer.
@Override
public void setValueSerializer(OBinarySerializer<V> valueSerializer) {
startOperation();
try {
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(e);
throw OException.wrapException(new OIndexException("Cannot set serializer for index values"), e);
} catch (Exception e) {
rollback(e);
throw OException.wrapException(new OStorageException("Cannot set serializer for index values"), e);
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.index.OIndexException in project orientdb by orientechnologies.
the class OLocalHashTable method get.
public V get(K key) {
final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic();
startOperation();
if (statistic != null)
statistic.startIndexEntryReadTimer();
try {
atomicOperationsManager.acquireReadLock(this);
try {
acquireSharedLock();
try {
final OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
checkNullSupport(key);
if (key == null) {
if (getFilledUpTo(atomicOperation, nullBucketFileId) == 0)
return null;
V result = null;
OCacheEntry cacheEntry = loadPage(atomicOperation, nullBucketFileId, 0, false);
cacheEntry.acquireSharedLock();
try {
ONullBucket<V> nullBucket = new ONullBucket<V>(cacheEntry, getChanges(atomicOperation, cacheEntry), valueSerializer, false);
result = nullBucket.getValue();
} finally {
cacheEntry.releaseSharedLock();
releasePage(atomicOperation, cacheEntry);
}
return result;
} else {
key = keySerializer.preprocess(key, (Object[]) keyTypes);
final long hashCode = keyHashFunction.hashCode(key);
OHashTable.BucketPath bucketPath = getBucket(hashCode);
final long bucketPointer = directory.getNodePointer(bucketPath.nodeIndex, bucketPath.itemIndex + bucketPath.hashMapOffset);
if (bucketPointer == 0)
return null;
final long pageIndex = getPageIndex(bucketPointer);
OCacheEntry cacheEntry = loadPage(atomicOperation, fileId, pageIndex, false);
cacheEntry.acquireSharedLock();
try {
final OHashIndexBucket<K, V> bucket = new OHashIndexBucket<K, V>(cacheEntry, keySerializer, valueSerializer, keyTypes, getChanges(atomicOperation, cacheEntry));
OHashIndexBucket.Entry<K, V> entry = bucket.find(key, hashCode);
if (entry == null)
return null;
return entry.value;
} finally {
cacheEntry.releaseSharedLock();
releasePage(atomicOperation, cacheEntry);
}
}
} finally {
releaseSharedLock();
}
} catch (IOException e) {
throw OException.wrapException(new OIndexException("Exception during index value retrieval"), e);
} finally {
atomicOperationsManager.releaseReadLock(this);
}
} finally {
if (statistic != null)
statistic.stopIndexEntryReadTimer();
completeOperation();
}
}
Aggregations