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 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); }
.getFactory(OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.toString(), OHashIndexFactory.HASH_INDEX_ALGORITHM);
OIndexFactory factory = OIndexes.getFactory(type, algorithm); if (Boolean.TRUE.equals(isAutomatic)) { final int pos = indexName.lastIndexOf('.');
private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) { this.indexClass = indexClass; if (iKeyType == null) iKeyType = OType.STRING; final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); this.recordKeyValueIndex = new OIndexTxAwareOneValue(graph.getRawGraph(), (OIndex<OIdentifiable>) graph .getRawGraph() .getMetadata() .getIndexManager() .createIndex("__@recordmap@___" + indexName, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK, OType.STRING), null, null, null)); final String className; if (Vertex.class.isAssignableFrom(indexClass)) className = VERTEX; else if (Edge.class.isAssignableFrom(indexClass)) className = EDGE; else className = indexClass.getName(); final ODocument metadata = new ODocument(); metadata.field(CONFIG_CLASSNAME, className); metadata.field(CONFIG_RECORD_MAP_NAME, recordKeyValueIndex.getName()); final OIndexFactory nuFactory = OIndexes.getFactory(OClass.INDEX_TYPE.NOTUNIQUE.toString(), null); // CREATE THE MAP this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) graph .getRawGraph() .getMetadata() .getIndexManager() .createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(nuFactory.getLastVersion(), iKeyType), null, null, metadata)); }
OIndexFactory factory = OIndexes.getFactory(indexType.toString(), null);
private OIndex<?> buildKeyValueIndex(final ODocument metadata) { final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); final OIndex<?> recordKeyValueIndex = new OIndexTxAwareOneValue(graph.getRawGraph(), (OIndex<OIdentifiable>) graph .getRawGraph() .getMetadata() .getIndexManager() .createIndex("__@recordmap@___" + underlying.getName(), OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK, OType.STRING), null, null, null)); final List<ODocument> entries = graph.getRawGraph().query( new OSQLSynchQuery<Object>("select from index:" + underlying.getName())); for (ODocument entry : entries) { final OIdentifiable rid = entry.field("rid"); if (rid != null) recordKeyValueIndex.put(new OCompositeKey(rid, entry.field("key")), rid); } metadata.field(CONFIG_RECORD_MAP_NAME, recordKeyValueIndex.getName()); return recordKeyValueIndex; }
public synchronized void create(ODatabaseDocumentInternal database) { schema.create(database); indexManager.create(database); security.create(); functionLibrary.create(database); sequenceLibrary.create(database); security.createClassTrigger(); scheduler.create(database); schema.forceSnapshot(database); // CREATE BASE VERTEX AND EDGE CLASSES schema.createClass(database, "V"); schema.createClass(database, "E"); //create geospatial classes try { OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.SPATIAL.toString(), "LUCENE"); if (factory != null && factory instanceof ODatabaseLifecycleListener) { ((ODatabaseLifecycleListener) factory).onCreate(database); } } catch (OIndexException x) { //the index does not exist } loaded = true; }
public void create(ODatabaseDocumentInternal database) { acquireExclusiveLock(); try { try { save(OMetadataDefault.CLUSTER_INTERNAL_NAME); } catch (Exception e) { OLogManager.instance().error(this, "Error during storing of index manager metadata," + " will try to allocate new document to store index manager metadata", e); // RESET RID TO ALLOCATE A NEW ONE if (ORecordId.isPersistent(document.getIdentity().getClusterPosition())) { document.getIdentity().reset(); save(OMetadataDefault.CLUSTER_INTERNAL_NAME); } } database.getStorage().setIndexMgrRecordId(document.getIdentity().toString()); OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); createIndex(DICTIONARY_NAME, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.STRING), null, null, null); } finally { releaseExclusiveLock(); } }
OIndexFactory factory = OIndexes.getFactory(type.getStringValue(), null);