public OIndexOneValue put(Object key, final OIdentifiable value) { key = getCollatingValue(key); acquireSharedLock(); try { if (apiVersion == 0) { putV0(key, value); } else if (apiVersion == 1) { putV1(key, value.getIdentity()); } else { throw new IllegalStateException("Invalid API version, " + apiVersion); } return this; } finally { releaseSharedLock(); } }
private void putV0(Object key, OIdentifiable value) { while (true) { try { storage.putIndexValue(indexId, key, value); break; } catch (OInvalidIndexEngineIdException ignore) { doReloadIndexEngine(); } } }
public OIndexOneValue put(final Object iKey, final OIdentifiable iSingleValue) { acquireExclusiveLock(); try { checkForKeyType(iKey); final OIdentifiable value = super.get(iKey); if (value != null){ // DELETE THE PREVIOUS INDEXED RECORD value.getRecord().delete(); } super.put(iKey, iSingleValue); return this; } finally { releaseExclusiveLock(); } } }
private static OIndexInternal<?> createSBTreeIndex(String name, String indexType, String valueContainerAlgorithm, ODocument metadata, OAbstractPaginatedStorage storage, int version, String algorithm) { final int binaryFormatVersion = storage.getConfiguration().getBinaryFormatVersion(); if (OClass.INDEX_TYPE.UNIQUE.toString().equals(indexType)) { return new OIndexUnique(name, indexType, algorithm, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } else if (OClass.INDEX_TYPE.NOTUNIQUE.toString().equals(indexType)) { return new OIndexNotUnique(name, indexType, algorithm, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } else if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) { return new OIndexFullText(name, indexType, algorithm, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } else if (OClass.INDEX_TYPE.DICTIONARY.toString().equals(indexType)) { return new OIndexDictionary(name, indexType, algorithm, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } throw new OConfigurationException("Unsupported type: " + indexType); }
public OIndexInternal<?> createIndex(String name, OStorage storage, String indexType, String algorithm, String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException { if (version < 0) version = getLastVersion(); if (valueContainerAlgorithm == null) valueContainerAlgorithm = ODefaultIndexFactory.NONE_VALUE_CONTAINER; final int binaryFormatVersion = storage.getConfiguration().getBinaryFormatVersion(); if (OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString().equals(indexType)) return new OIndexUnique(name, indexType, algorithm, version, (OAbstractPaginatedStorage) storage.getUnderlying(), valueContainerAlgorithm, metadata, binaryFormatVersion); else if (OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX.toString().equals(indexType)) return new OIndexNotUnique(name, indexType, algorithm, version, (OAbstractPaginatedStorage) storage.getUnderlying(), valueContainerAlgorithm, metadata, binaryFormatVersion); else if (OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX.toString().equals(indexType)) return new OIndexFullText(name, indexType, algorithm, version, (OAbstractPaginatedStorage) storage.getUnderlying(), valueContainerAlgorithm, metadata, binaryFormatVersion); else if (OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.toString().equals(indexType)) return new OIndexDictionary(name, indexType, algorithm, version, (OAbstractPaginatedStorage) storage.getUnderlying(), valueContainerAlgorithm, metadata, binaryFormatVersion); throw new OConfigurationException("Unsupported type: " + indexType); }
private void putV1(Object key, OIdentifiable value) { while (true) { try { storage.putRidIndexEntry(indexId, key, value.getIdentity()); break; } catch (OInvalidIndexEngineIdException ignore) { doReloadIndexEngine(); } } }