public static OIndexFactory getFactory(String indexType, String algorithm) { if (algorithm == null) { algorithm = chooseDefaultIndexAlgorithm(indexType); } algorithm = algorithm.toUpperCase(Locale.ENGLISH); final Iterator<OIndexFactory> ite = getAllFactories(); while (ite.hasNext()) { final OIndexFactory factory = ite.next(); if (factory.getTypes().contains(indexType) && factory.getAlgorithms().contains(algorithm)) { return factory; } } throw new OIndexException("Index with type " + indexType + " and algorithm " + algorithm + " does not exist."); }
private static OIndexDefinition createMultipleFieldIndexDefinition(final OClass oClass, final List<String> fieldsToIndex, final List<OType> types, List<OCollate> collates, String indexKind, String algorithm) { final OIndexFactory factory = OIndexes.getFactory(indexKind, algorithm); final String className = oClass.getName(); final OCompositeIndexDefinition compositeIndex = new OCompositeIndexDefinition(className); for (int i = 0, fieldsToIndexSize = fieldsToIndex.size(); i < fieldsToIndexSize; i++) { OCollate collate = null; if (collates != null) collate = collates.get(i); compositeIndex .addIndex(createSingleFieldIndexDefinition(oClass, fieldsToIndex.get(i), types.get(i), collate, indexKind, algorithm)); } return compositeIndex; }
private static OIndexFactory findFactoryByAlgorithmAndType(String algorithm, String indexType) { for (OIndexFactory factory : getFactories()) { if (indexType == null || indexType.isEmpty() || (factory.getTypes().contains(indexType)) && factory.getAlgorithms() .contains(algorithm)) { return factory; } } throw new OIndexException( "Index type " + indexType + " with engine " + algorithm + " is not supported. Types are " + OCollections .toString(getIndexTypes())); }
if(!OIndexes.getIndexTypes().contains(ID)) try { HighLanderIndexFactory f = new HighLanderIndexFactory(); Set<OIndexFactory> set = new HashSet<OIndexFactory>(); Iterator<OIndexFactory> ite = OIndexes.getAllFactories(); while (ite.hasNext()) { set.add(ite.next());
/** * Iterates on all factories and append all index types. * * @return Set of all index types. */ private static Set<String> getIndexTypes() { final Set<String> types = new HashSet<>(); final Iterator<OIndexFactory> ite = getAllFactories(); while (ite.hasNext()) { types.addAll(ite.next().getTypes()); } return types; }
type = type.toUpperCase(locale); if (algorithm == null) { algorithm = OIndexes.chooseDefaultIndexAlgorithm(type); index = OIndexes.createIndex(getStorage(), iName, type, algorithm, valueContainerAlgorithm, metadata, -1); if (progressListener == null)
.createIndexEngine(engineName, algorithm, indexType, durableInNonTxMode, this, version, apiVersion, multivalue, engineProperties, metadata);
/** * Unregister custom factories */ public static void unregisterFactory(OIndexFactory factory) { DYNAMIC_FACTORIES.remove(factory); scanForPlugins(); }
public static OBaseIndexEngine createIndexEngine(final String name, final String algorithm, final String type, final Boolean durableInNonTxMode, final OStorage storage, final int version, int apiVersion, boolean multivalue, final Map<String, String> indexProperties, ODocument metadata) { final OIndexFactory factory = findFactoryByAlgorithmAndType(algorithm, type); return factory .createIndexEngine(algorithm, name, durableInNonTxMode, storage, version, apiVersion, multivalue, indexProperties); }
private OIndexInternal<?> createIndex(ODocument idx) { final String indexName = idx.field(OIndexInternal.CONFIG_NAME); final String indexType = idx.field(OIndexInternal.CONFIG_TYPE); String algorithm = idx.field(OIndexInternal.ALGORITHM); String valueContainerAlgorithm = idx.field(OIndexInternal.VALUE_CONTAINER_ALGORITHM); ODocument metadata = idx.field(OIndexInternal.METADATA); if (indexType == null) { OLogManager.instance().error(this, "Index type is null, will process other record", null); throw new OIndexException("Index type is null, will process other record. Index configuration: " + idx.toString()); } return OIndexes.createIndex(storage, indexName, indexType, algorithm, valueContainerAlgorithm, metadata, -1); } }
/** * @return Iterator of all index factories */ public static Iterator<OIndexFactory> getAllFactories() { return getFactories().iterator(); }
@Override public void startup() { super.startup(); Orient.instance().addDbLifecycleListener(this); OIndexes.registerFactory(new OLuceneIndexFactory(true)); OSQLEngine.registerOperator(new OLuceneTextOperator()); OSQLEngine.registerOperator(new OLuceneWithinOperator()); OSQLEngine.registerOperator(new OLuceneNearOperator()); OLogManager.instance().info(this, "Lucene index plugin installed and active. Lucene version: %s", OLuceneIndexManagerAbstract.LUCENE_VERSION); }
/** * Iterates on all factories and append all index engines. * * @return Set of all index engines. */ public static Set<String> getIndexEngines() { final Set<String> engines = new HashSet<>(); final Iterator<OIndexFactory> ite = getAllFactories(); while (ite.hasNext()) { engines.addAll(ite.next().getAlgorithms()); } return engines; }
.createIndexEngine(engineName, algorithm, indexType, durableInNonTxMode, this, version, apiVersion, multivalue, engineProperties, null);
/** * Register at runtime custom factories */ public static void registerFactory(OIndexFactory factory) { DYNAMIC_FACTORIES.add(factory); scanForPlugins(); }
/** * @param storage TODO * @param indexType index type * * @return OIndexInternal * * @throws OConfigurationException if index creation failed * @throws OIndexException if index type does not exist */ public static OIndexInternal<?> createIndex(OStorage storage, String name, String indexType, String algorithm, String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException, OIndexException { if (indexType.equalsIgnoreCase(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.name()) || indexType .equalsIgnoreCase(OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX.name()) || indexType .equalsIgnoreCase(OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.name())) { if (!algorithm.equalsIgnoreCase("autosharding")) { algorithm = OHashIndexFactory.HASH_INDEX_ALGORITHM; } } return findFactoryByAlgorithmAndType(algorithm, indexType) .createIndex(name, storage, indexType, algorithm, valueContainerAlgorithm, metadata, version); }
.createIndex(getStorage(), newIndexMetadata.getName(), newIndexMetadata.getType(), newIndexMetadata.getAlgorithm(), newIndexMetadata.getValueContainerAlgorithm(), d.field(OIndexInternal.METADATA), indexVersion);
private OIndex<?> createDictionary() { final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); return createIndex(DICTIONARY_NAME, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.STRING), null, null, null); }
for (Iterator<OIndexFactory> it = OIndexes.getAllFactories(); it.hasNext(); ) { try { final OIndexFactory indexFactory = it.next();
final OStorageConfigurationImpl.IndexEngineData engineData = configuration.getIndexEngine(indexName); final OBaseIndexEngine engine = OIndexes .createIndexEngine(engineData.getName(), engineData.getAlgorithm(), engineData.getIndexType(), engineData.getDurableInNonTxMode(), this, engineData.getVersion(), engineData.getApiVersion(), engineData.isMultivalue(), engineData.getEngineProperties(), null);