@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);
if (!db.getMetadata().getSchema().existsClass(CLASS)) { db.getMetadata().getSchema().createClass(CLASS);
public final void updateSchema() { if (db.isClosed()) { db.create(); } OSchema schema = db.getMetadata().getSchema(); for (String docType : DocumentTypes.getDocumentTypes()) { if (!schema.existsClass(docType)) { createDocType(schema, docType); } } if (!schema.existsClass("Signatures")) { createSignatureType(schema); } }
public OrientClassVertexIterator(OrientBaseGraph graph, Iterator<Vertex> iterator, String klass) { this.iterator = iterator; this.graph = graph; this.klass = graph.getRawGraph().getMetadata().getSchema().getClass(klass); }
public OrientSingleInsertion(OrientGraph orientGraph, File resultsPath) { super(GraphDatabaseType.ORIENT_DB, resultsPath); this.orientGraph = orientGraph; this.index = this.orientGraph.getRawGraph().getMetadata().getIndexManager().getIndex("V.nodeId"); }
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); } }
@Override public OrientEdgeType call(final OrientBaseGraph g) { return new OrientEdgeType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, clusters, iSuperClass)); } }, "create edge type '", iClassName, "' as subclass of '", iSuperClass.getName(), "' (clusters=" + clusters + ")");
@Override public OrientEdgeType call(final OrientBaseGraph g) { return new OrientEdgeType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, iSuperClass)); } }, "create edge type '", iClassName, "' as subclass of '", iSuperClass.getName(), "'");
@Override public OrientVertexType call(final OrientBaseGraph g) { return new OrientVertexType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, iSuperClass)); } }, "create vertex type '", iClassName, "' as subclass of '", iSuperClass.getName(), "'");
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); } }
public OClass createVertexType(final String iClassName, final String iSuperClassName) { commitAnyActiveTx("create vertex type '" + iClassName + "' as subclass of '" + iSuperClassName + "'"); return getRawGraph().getMetadata().getSchema() .createClass(iClassName, getVertexType(iSuperClassName)); }
public <T extends Element> void dropKeyIndex(final String key, final Class<T> elementClass) { commitAnyActiveTx("drop key index"); final String className = getClassName(elementClass); getRawGraph().getMetadata().getIndexManager() .dropIndex(className + "." + key); }
/** * Returns the V persistent class as OrientVertexType instance. */ public OrientVertexType getVertexBaseType() { makeActive(); return new OrientVertexType(this, getRawGraph().getMetadata().getSchema().getClass(OrientVertexType.CLASS_NAME)); }
public OClass createVertexType(final String iClassName) { commitAnyActiveTx("create vertex type '" + iClassName + "'"); return getRawGraph().getMetadata().getSchema() .createClass(iClassName, getVertexBaseType()); }
protected double getCustomHeuristicCost(final String functionName, final String[] vertextAxisNames, final OrientVertex start, final OrientVertex goal, final OrientVertex current, final OrientVertex parent, final long depth, double dFactor) { double heuristic = 0.0; OrientGraph ff; OFunction func = OrientGraph.getActiveGraph().getRawGraph().getMetadata().getFunctionLibrary().getFunction(functionName); Object fValue = func.executeInContext(context, vertextAxisNames, start, goal, current, parent, depth, dFactor); if (fValue != null && fValue instanceof Number) { heuristic = doubleOrDefault(fValue, heuristic); } return heuristic; }
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); } }