public OCommandRequest command(OCommandRequest iCommand) { return graph.command(iCommand); }
@Override public OCommandRequest wrapCommand(final OCommandRequest command) { return provider.get().command(command); }
@SuppressWarnings("unchecked") public Object command(final String language, final String iText, final Object[] iArgs) { Object result; if (language.equalsIgnoreCase("sql")) result = graph.command(new OCommandSQL(iText)).execute(iArgs); else if (language.equalsIgnoreCase("gremlin")) result = graph.command(new OCommandGremlin(iText)).execute(iArgs); else result = graph.command(new OCommandScript(language, iText)).execute(iArgs); if (result instanceof Iterable<?>) { // FOR SAKE OF SIMPLICITY TRANSFORM ANY ITERABLE IN ARRAY final List<Object> list = new ArrayList<Object>(); for (Object o : (Iterable<Object>) result) { list.add(o); } result = list.toArray(); } return result; }
@Override public Void call(final OBaseWorkLoadContext context) { final OWorkLoadContext graphContext = ((OWorkLoadContext) context); final OrientBaseGraph graph = graphContext.graph; for (int i = 0; i < startingVertices.size(); ++i) { final Iterable<OrientVertex> commandResult = graph.command(new OCommandSQL("select shortestPath(?,?, 'both')")) .execute(startingVertices.get(context.currentIdx), startingVertices.get(i)); for (OrientVertex v : commandResult) { Collection depth = v.getRecord().field("shortestPath"); if (depth != null && !depth.isEmpty()) { totalDepth.addAndGet(depth.size()); long max = maxDepth.get(); while (depth.size() > max) { if (maxDepth.compareAndSet(max, depth.size())) break; max = maxDepth.get(); } } else notConnected.incrementAndGet(); } } result.current.incrementAndGet(); return null; } });
vertices = graph.command(new OSQLSynchQuery<OrientVertex>(text, limit).setFetchPlan(fetchPlan)).execute(); else if (language.equals("gremlin")) { List<Object> result = new ArrayList<Object>();
public void runImport(String inputFile, String dbURL) throws IOException, FileNotFoundException { if (inputFile == null) throw new OSystemException("needed an input file as first argument"); if (dbURL == null) throw new OSystemException("needed an database location as second argument"); ODatabaseDocumentInternal db = new ODatabaseDocumentTx(dbURL); ODatabaseHelper.deleteDatabase(db, db.getType()); OrientBaseGraph g = OrientGraphFactory.getNoTxGraphImplFactory().getGraph(dbURL); System.out.println("Importing graph from file '" + inputFile + "' into database: " + g + "..."); final long startTime = System.currentTimeMillis(); OConsoleDatabaseApp console = new OGremlinConsole(new String[] { "import database " + inputFile }) .setCurrentDatabase(g.getRawGraph()); console.run(); System.out.println("Imported in " + (System.currentTimeMillis() - startTime) + "ms. Vertexes: " + g.countVertices()); g.command(new OCommandSQL("alter database TIMEZONE 'GMT'")).execute(); g.command(new OCommandSQL("alter database LOCALECOUNTRY 'UK'")).execute(); g.command(new OCommandSQL("alter database LOCALELANGUAGE 'EN'")).execute(); g.shutdown(); } }
OrientBaseGraph g = new OrientGraph(ServiceLocator.getInstance().getDbUrl()); g.command(new OCommandSQL("alter database custom useLightweightEdges=true")).execute(); g.command(new OCommandSQL("alter database DATETIMEFORMAT yyyy-MM-dd'T'HH:mm:ss.SSS")).execute(); g.command(new OCommandSQL("alter database TIMEZONE UTC")).execute(); OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1); } finally {