@Override public Status delete(String table, String key) { while (true) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); dictionary.remove(key); return Status.OK; } catch (OConcurrentModificationException cme) { continue; } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } } }
@Override public Status insert(String table, String key, Map<String, ByteIterator> values) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODocument document = new ODocument(CLASS); for (Map.Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { document.field(entry.getKey(), entry.getValue()); } document.save(); final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); dictionary.put(key, document); return Status.OK; } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final ODocument document = dictionary.get(key); if (document != null) { for (Map.Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { document.field(entry.getKey(), entry.getValue()); } document.save(); return Status.OK; } } catch (OConcurrentModificationException cme) { continue; } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } } }
@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final ODocument document = dictionary.get(key); if (document != null) { if (fields != null) { for (String field : fields) { result.put(field, new StringByteIterator((String) document.field(field))); } } else { for (String field : document.fieldNames()) { result.put(field, new StringByteIterator((String) document.field(field))); } } return Status.OK; } } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }
final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final OIndexCursor entries = dictionary.getIndex().iterateEntriesMajor(startkey, true, true);
public void rebuildIndexes() { if (metadata.getIndexManager().autoRecreateIndexesAfterCrash()) { metadata.getIndexManager().recreateIndexes(); } }
/** * {@inheritDoc} */ public ODictionary<ORecord> getDictionary() { checkOpenness(); return metadata.getIndexManager().getDictionary(); }
private void deleteNameCaseInsensitiveIndex(final ODatabaseDocumentTx db) { log.info("Deleting old case-insensitive name index on component"); OIndexManager indexManager = db.getMetadata().getIndexManager(); OIndex nameCaseInsensitiveIndex = indexManager.getIndex(I_NAME_CASE_INSENSITIVE); if (nameCaseInsensitiveIndex != null) { indexManager.dropIndex(I_NAME_CASE_INSENSITIVE); } } }
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); } }
private void createCaseInsensitiveNameCaseInsensitiveIndex(final ODatabaseDocumentTx db, final OClass type) { log.info("Creating case-insensitive index on case-insensitive name field on component"); OIndexManager indexManager = db.getMetadata().getIndexManager(); if (indexManager.getIndex(I_CI_NAME_CASE_INSENSITIVE) == null) { new OIndexBuilder(type, I_CI_NAME_CASE_INSENSITIVE, INDEX_TYPE.NOTUNIQUE) .property(P_CI_NAME, OType.STRING) .caseInsensitive() .build(db); } }
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 }); } } } } }
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; } }
private void createNameCaseInsensitiveIndex(final ODatabaseDocumentTx db, final OClass type) { OIndexManager indexManager = db.getMetadata().getIndexManager(); if (indexManager.getIndex(I_NAME_CASE_INSENSITIVE) == null) { new OIndexBuilder(type, I_NAME_CASE_INSENSITIVE, INDEX_TYPE.NOTUNIQUE) .property(P_NAME, OType.STRING) .caseInsensitive() .build(db); } }
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; }
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); } } }