private void createComponentIndex(final ODatabaseDocumentTx db, final OClass type) { if (db.getMetadata().getIndexManager().getIndex(I_COMPONENT) == null) { type.createIndex(I_COMPONENT, INDEX_TYPE.NOTUNIQUE, AssetEntityAdapter.P_COMPONENT); } }
public OrientSingleInsertion(OrientGraph orientGraph, File resultsPath) { super(GraphDatabaseType.ORIENT_DB, resultsPath); this.orientGraph = orientGraph; this.index = this.orientGraph.getRawGraph().getMetadata().getIndexManager().getIndex("V.nodeId"); }
@Override @Guarded(by = STARTED) public OIndex<?> getIndex(final String indexName) { try (ODatabaseDocumentTx db = databaseInstance.get().acquire()) { return db.getMetadata().getIndexManager().getIndex(indexName); } }
@Override public OIndex<?> convertToObject(String value, Locale locale) throws ConversionException { return OrientDbWebSession.get().getDatabase().getMetadata().getIndexManager().getIndex(value); }
@Override protected OIndex<?> doBackward(String b) { return OrientDbWebSession.get().getDatabase().getMetadata().getIndexManager().getIndex(b); }
private void updateMavenIndexFileAssetKind() { List<String> mavenRepositoryNames; try (ODatabaseDocumentTx db = configDatabaseInstance.get().connect()) { mavenRepositoryNames = db.<List<ODocument>>query(new OSQLSynchQuery<ODocument>(SELECT_MAVEN_REPOSITORIES)).stream() .map(d -> (String)d.field(P_REPOSITORY_NAME)) .collect(Collectors.toList()); } if (!mavenRepositoryNames.isEmpty()) { OCommandSQL updateAssetCommand = new OCommandSQL(UPDATE_ASSET_KIND); try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(I_REPOSITORY_NAME); mavenRepositoryNames.forEach(repositoryName -> { log.info("Scanning maven2 repository {} for maven index file assets", repositoryName); OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName); if (bucket == null) { log.warn("Unable to find bucket for {}", repositoryName); } else { int updates = db.command(updateAssetCommand).execute(bucket.getIdentity()); if (updates > 0) { log.info( "Updated {} maven index file asset(s) in repository {}: " + "set attributes.maven2.asset_kind='REPOSITORY_INDEX'", updates, repositoryName); } } }); } } } }
public Iterable<Vertex> getVertices(final String iKey, Object iValue) { if (iKey.equals("@class")) return getVerticesOfClass(iValue.toString()); final String indexName; final String key; int pos = iKey.indexOf('.'); if (pos > -1) { indexName = iKey; key = iKey.substring(iKey.indexOf('.') + 1); } else { indexName = OrientVertex.CLASS_NAME + "." + iKey; key = iKey; } final OIndex<?> idx = getContext(true).rawGraph.getMetadata() .getIndexManager().getIndex(indexName); if (idx != null) { iValue = convertKey(idx, iValue); Object indexValue = idx.get(iValue); if (indexValue != null && !(indexValue instanceof Iterable<?>)) indexValue = Arrays.asList(indexValue); return new OrientElementIterable<Vertex>(this, (Iterable<?>) indexValue); } // NO INDEX: EXECUTE A QUERY return query().has(key, iValue).vertices(); }
public Iterable<Edge> getEdges(final String iKey, Object iValue) { if (iKey.equals("@class")) return getEdgesOfClass(iValue.toString()); final String indexName; final String key; int pos = iKey.indexOf('.'); if (pos > -1) { indexName = iKey; key = iKey.substring(iKey.indexOf('.') + 1); } else { indexName = OrientEdge.CLASS_NAME + "." + iKey; key = iKey; } final OIndex<?> idx = getContext(true).rawGraph.getMetadata() .getIndexManager().getIndex(indexName); if (idx != null) { iValue = convertKey(idx, iValue); Object indexValue = (Iterable<?>) idx.get(iValue); if (indexValue != null && !(indexValue instanceof Iterable<?>)) indexValue = Arrays.asList(indexValue); return new OrientElementIterable<Edge>(this, (Iterable<?>) indexValue); } // NO INDEX: EXECUTE A QUERY return query().has(key, iValue).edges(); }
private void createBucketNameIndex() { try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { if (db.getMetadata().getIndexManager().getIndex(I_BUCKET_NAME_VERSION) == null) { OSchema schema = db.getMetadata().getSchema(); OClass type = schema.getClass(COMPONENT_CLASS); if (type != null) { type.createIndex(I_BUCKET_NAME_VERSION, INDEX_TYPE.NOTUNIQUE, new String[] { P_BUCKET, P_NAME, P_VERSION }); } } } } }
protected List<String> getTagEntityListDb(String host, String tagId) { List<String> entityList = null; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { OIndex<?> tagHostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("tagHostIdIdx"); OCompositeKey key = new OCompositeKey(host, tagId); OIdentifiable oid = (OIdentifiable) tagHostIdIdx.get(key); if (oid != null) { ODocument doc = (ODocument)oid.getRecord(); entityList = new ArrayList<String>(); ORidBag entities = doc.field("in_HasTag"); Iterator<OIdentifiable> iterator = entities.iterator(); while (iterator.hasNext()) { OIdentifiable identifiable = iterator.next(); entityList.add(identifiable.getIdentity().toString()); } } } catch (Exception e) { logger.error("Exception:", e); } finally { graph.shutdown(); } return entityList; }
private void createAssetNameIdx(final ODatabaseDocumentTx db, final OClass type) { if (db.getMetadata().getIndexManager().getIndex(I_ASSET_NAME) == null) { new OIndexBuilder(type, I_ASSET_NAME, INDEX_TYPE.NOTUNIQUE) .property(P_NAME, OType.STRING) .caseInsensitive() .build(db); } }
protected Vertex getOrCreate(final String value) { final int key = Integer.parseInt(value); Vertex v; if (index == null) { index = orientGraph.getRawGraph().getMetadata().getIndexManager().getIndex("V.nodeId"); } final OIdentifiable rec = (OIdentifiable) index.get(key); if (rec != null) { return orientGraph.getVertex(rec); } v = orientGraph.addVertex(key, "nodeId", key); if (orientGraph instanceof TransactionalGraph) { ((TransactionalGraph) orientGraph).commit(); } return v; } }
protected ODocument getODocumentByHostId(OrientGraph graph, String index, String host, String id) { ODocument doc = null; OIndex<?> hostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex(index); // this is a unique index, so it retrieves a OIdentifiable OCompositeKey key = new OCompositeKey(host, id); OIdentifiable oid = (OIdentifiable) hostIdIdx.get(key); if (oid != null) { doc = (ODocument)oid.getRecord(); } return doc; }
public OrientVertex getConfigByHostId(OrientGraph graph, String host, String configId) { OrientVertex config = null; OIndex<?> hostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("configHostIdIdx"); OCompositeKey key = new OCompositeKey(host, configId); OIdentifiable oid = (OIdentifiable) hostIdIdx.get(key); if (oid != null) { config = graph.getVertex(oid.getRecord()); } return config; }
public OrientVertex getBranchByHostId(OrientGraph graph, String branchType, String host, String categoryId) { OrientVertex branch = null; OIndex<?> hostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex(branchType + "HostIdIdx"); OCompositeKey key = new OCompositeKey(host, categoryId); OIdentifiable oid = (OIdentifiable) hostIdIdx.get(key); if (oid != null) { branch = graph.getVertex(oid.getRecord()); } return branch; }
Vertex tag = null; OIndex<?> tagHostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("tagHostIdIdx"); OCompositeKey tagKey = new OCompositeKey(host, tagId); OIdentifiable tagOid = (OIdentifiable) tagHostIdIdx.get(tagKey);
sqlQuery = new OSQLSynchQuery<ODocument>(lookup); else { index = pipeline.getDocumentDatabase().getMetadata().getIndexManager().getIndex(lookup); if (index == null) { log(OETLProcessor.LOG_LEVELS.DEBUG, "WARNING: index %s not found. Lookups could be really slow", lookup);
private void createComponentGroupNameVersionIdx(final ODatabaseDocumentTx db, final OClass type) { if (db.getMetadata().getIndexManager().getIndex(I_COMPONENT_GROUP_NAME_VERSION) == null) { new OIndexBuilder(type, I_COMPONENT_GROUP_NAME_VERSION, INDEX_TYPE.NOTUNIQUE) .property(P_GROUP, OType.STRING) .property(P_NAME, OType.STRING) .property(P_VERSION, OType.STRING) .caseInsensitive() .build(db); } } }
Vertex tag = null; OIndex<?> tagHostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("tagHostIdIdx"); OCompositeKey tagKey = new OCompositeKey(host, tagId); OIdentifiable tagOid = (OIdentifiable) tagHostIdIdx.get(tagKey);
@Override public void onUpdate(OrienteerWebApplication app, ODatabaseDocument db, int oldVersion, int newVersion) { int toVersion = oldVersion+1; switch (toVersion) { case 2: convertNameProperty(app, db, OCLASS_PERSPECTIVE); convertNameProperty(app, db, OCLASS_ITEM); break; case 3: onInstall(app, db); break; case 4: OIndex<?> index = db.getMetadata().getIndexManager().getIndex(OCLASS_PERSPECTIVE + ".name"); if(index!=null) index.delete(); onInstall(app, db); break; case 5: OSchemaHelper.bind(db) .oClass(OIdentity.CLASS_NAME) .oProperty("perspective", OType.LINK).linkedClass(OCLASS_PERSPECTIVE); break; default: break; } if(toVersion<newVersion) onUpdate(app, db, toVersion, newVersion); }