protected OrientGraphContext getContext(final boolean create) { OrientGraphContext context = threadContext.get(); if (context == null || !context.rawGraph.getURL().equals(url)) { if (create) context = openOrCreate(); } return context; }
protected void checkOpenness() { if (internal == null) throw new ODatabaseException("Database '" + getURL() + "' is closed"); }
/** * Returns the Graph URL. */ public String toString() { return StringFactory.graphString(this, getRawGraph().getURL()); }
public String toString() { return StringFactory.graphString(this, getRawGraph().getURL()); }
@Override public void massiveModeLoading(File dataPath) { OrientMassiveInsertion orientMassiveInsertion = new OrientMassiveInsertion(this.graph.getRawGraph().getURL()); orientMassiveInsertion.createGraph(dataPath, 0 /* scenarioNumber */); }
public ScriptEngine get(final OrientBaseGraph iGraph) { ScriptEngine engine = super.get(); if (engine != null) { final OrientBaseGraph currGraph = (OrientBaseGraph) engine.getBindings(ScriptContext.ENGINE_SCOPE).get("g"); if (currGraph == iGraph || (currGraph != null && currGraph.getRawGraph().getURL().equals(iGraph.getRawGraph().getURL()))) { // REUSE IT engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", iGraph); return engine; } } // CREATE A NEW ONE engine = new GremlinGroovyScriptEngine(); engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", iGraph); set(engine); return engine; }
/** * Reuses the underlying database avoiding to create and open it every time. * * @param iDatabase * Underlying OGraphDatabase object */ public OrientBaseGraph reuse(final ODatabaseDocumentTx iDatabase) { this.url = iDatabase.getURL(); this.username = iDatabase.getUser() != null ? iDatabase.getUser() .getName() : null; synchronized (this) { OrientGraphContext context = threadContext.get(); if (context == null || !context.rawGraph.getName().equals(iDatabase.getName())) { removeContext(); context = new OrientGraphContext(); context.rawGraph = iDatabase; checkForGraphSchema(iDatabase); threadContext.set(context); } } return this; }
public void repair(final OrientBaseGraph graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Repair of graph '" + graph.getRawGraph().getURL() + "' is started ...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, false); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, false); message(outputListener, "Repair of graph '" + graph.getRawGraph().getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " removedEdges.....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " removedLinks.....: " + stats.removedLinks + "\n"); message(outputListener, " repairedVertices.: " + stats.repairedVertices + "\n"); }
public void check(final OrientBaseGraph graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Check of graph '" + graph.getRawGraph().getURL() + "' is started...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, true); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, true); message(outputListener, "Check of graph '" + graph.getRawGraph().getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " edgesToRemove....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " linksToRemove....: " + stats.removedLinks + "\n"); message(outputListener, " verticesToRepair.: " + stats.repairedVertices + "\n"); }