com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx Java Examples

The following examples show how to use com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrientMassiveInsertion.java    From graphdb-benchmarks with Apache License 2.0 6 votes vote down vote up
public OrientMassiveInsertion(final String url)
{
    super(GraphDatabaseType.ORIENT_DB, null /* resultsPath */);
    OGlobalConfiguration.ENVIRONMENT_CONCURRENT.setValue(false);
    OrientGraphNoTx transactionlessGraph = new OrientGraphNoTx(url);
    for (int i = 0; i < NUMBER_OF_ORIENT_CLUSTERS; ++i)
    {
        transactionlessGraph.getVertexBaseType().addCluster("v_" + i);
        transactionlessGraph.getEdgeBaseType().addCluster("e_" + i);
    }
    transactionlessGraph.shutdown();

    graph = new OGraphBatchInsertBasic(url);
    graph.setAverageEdgeNumberPerNode(AVERAGE_NUMBER_OF_EDGES_PER_NODE);
    graph.setEstimatedEntries(ESTIMATED_ENTRIES);
    graph.setIdPropertyName("nodeId");
    graph.begin();
}
 
Example #2
Source File: DataDependencePlugin.java    From bjoern with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute() throws Exception {
	OrientGraphNoTx graph = orientConnector.getNoTxGraphInstance();
	ReachingDefinitionAnalyser analyser = new ReachingDefinitionAnalyser(
			DefinitionProvider::generatedDefinitions,
			DefinitionProvider::killedDefinitions);
	for (Function function : LookupOperations.getFunctions(graph)) {
		Instruction entry = Traversals
				.functionToEntryInstruction(function);
		if (null == entry) {
			continue;
		}
		Map<Vertex, Set<ReachingDefinitionAnalyser.Definition>>
				reachingDefinitions = analyser
				.analyse(entry);
		DataDependenceCreator
				.createFromReachingDefinitions(reachingDefinitions);

	}
}
 
Example #3
Source File: VSAPlugin.java    From bjoern with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute() throws Exception
{
	OrientGraphNoTx graph = orientConnector.getNoTxGraphInstance();
	VSA vsa = new VSA();
	for (Function function : LookupOperations.getFunctions(graph))
	{
		try
		{
			logger.info(function.toString());
			vsa.performIntraProceduralVSA(function);
		} catch (Exception e)
		{
			logger.error("Error for function " + function + ": " + e.getMessage());
		}
	}
	graph.shutdown();
}
 
Example #4
Source File: OrientGraphDatabase.java    From graphdb-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public void delete()
{
    OrientGraphNoTx g = new OrientGraphNoTx("plocal:" + dbStorageDirectory.getAbsolutePath());
    g.drop();

    Utils.deleteRecursively(dbStorageDirectory);
}
 
Example #5
Source File: OctopusGremlinShell.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
private void openDatabaseConnection(String dbName)
{
	// TODO: We should check whether the database exists

	graph = new OrientGraphNoTx(
			"plocal:" + System.getProperty("ORIENTDB_HOME") + "/databases/" + dbName);
	this.shell.setVariable("g", graph);
}
 
Example #6
Source File: AbstractDbRule.java    From light with Apache License 2.0 5 votes vote down vote up
protected String execSchemaCmd(Map<String, Object> data) {
    String result = "";
    String script = (String) data.get("script");
    OrientGraphNoTx graph = ServiceLocator.getInstance().getGraphNoTx();
    try{
        graph.command(new OCommandScript("sql", script)).execute();
    } catch (Exception e) {
        logger.error("Exception:", e);
        result = e.getMessage();
    } finally {
        graph.shutdown();
    }
    return result;
}
 
Example #7
Source File: DoubleLuceneTest.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoubleLucene() {
  OrientGraphNoTx graph = new OrientGraphNoTx("memory:doubleLucene");
  ODatabaseDocumentTx db = graph.getRawGraph();

  db.command(new OCommandSQL("create class Test extends V")).execute();
  db.command(new OCommandSQL("create property Test.attr1 string")).execute();
  db.command(new OCommandSQL("create index Test.attr1 on Test (attr1) fulltext engine lucene")).execute();
  db.command(new OCommandSQL("create property Test.attr2 string")).execute();
  db.command(new OCommandSQL("create index Test.attr2 on Test (attr2) fulltext engine lucene")).execute();
  db.command(new OCommandSQL("insert into Test set attr1='foo', attr2='bar'")).execute();
  db.command(new OCommandSQL("insert into Test set attr1='bar', attr2='foo'")).execute();

  List<ODocument> results = db.command(new OCommandSQL("select from Test where attr1 lucene 'foo*' OR attr2 lucene 'foo*'"))
      .execute();
  Assert.assertEquals(results.size(), 2);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'bar*' OR attr2 lucene 'bar*'")).execute();

  Assert.assertEquals(results.size(), 2);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'foo*' AND attr2 lucene 'bar*'")).execute();

  Assert.assertEquals(results.size(), 1);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'bar*' AND attr2 lucene 'foo*'")).execute();

  Assert.assertEquals(results.size(), 1);

}
 
Example #8
Source File: GraphPool.java    From guice-persist-orient with MIT License 5 votes vote down vote up
@Override
public OrientBaseGraph get() {
    if (transaction.get() == null) {
        final ODatabaseDocumentInternal documentDb = (ODatabaseDocumentInternal) documentPool.get();
        final OrientBaseGraph graph = transactionManager.getActiveTransactionType() == OTransaction.TXTYPE.NOTX
                ? new OrientGraphNoTx(documentDb) : new OrientGraph(documentDb);
        transaction.set(graph);
    }
    final OrientBaseGraph db = transaction.get();
    db.getRawGraph().activateOnCurrentThread();
    return db;
}
 
Example #9
Source File: OrientGraphNoTxProvider.java    From guice-persist-orient with MIT License 5 votes vote down vote up
@Override
public OrientGraphNoTx get() {
    final OrientBaseGraph graph = provider.get();
    Preconditions.checkState(graph instanceof OrientGraphNoTx,
            "You must use OrientGraph within transaction or disable transaction "
                    + "(or use OrientBaseGraph as universal solution for all cases)");
    return (OrientGraphNoTx) graph;
}
 
Example #10
Source File: FunctionExportPlugin.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute() throws Exception
{
	OrientGraphNoTx graph = orientConnector.getNoTxGraphInstance();

	Iterable<Vertex> functions = LookupOperations.getAllFunctions(graph);

	for (Vertex function : functions)
	{
		exportFunction(function);
	}

	graph.shutdown();
}
 
Example #11
Source File: UseDefAnalyserPlugin.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute() throws Exception
{
	OrientGraphNoTx graph = orientConnector.getNoTxGraphInstance();
	UseDefAnalyser analyzer = new UseDefAnalyser();
	for (Function function : LookupOperations.getFunctions(graph))
	{
		List<Aloc> alocs = Traversals.functionToAlocs(function);
		for (BasicBlock block : function.basicBlocks())
		{
			analyzer.analyse(block, alocs);
		}
	}
}
 
Example #12
Source File: LookupOperations.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
public static Iterable<Function> getFunctions(OrientGraphNoTx graph)
{
	boolean parallel = true;
	Iterable<Vertex> functions = graph.command(BjoernConstants.LUCENE_QUERY)
			.execute("nodeType:" + BjoernNodeTypes.FUNCTION);
	return StreamSupport.stream(functions.spliterator(), parallel).map(Function::new)
			.collect(Collectors.toList());
}
 
Example #13
Source File: LookupOperations.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
@Deprecated
public static Iterable<Vertex> getAllFunctions(OrientGraphNoTx graph)
{
	Iterable<Vertex> functions = graph.command(
			BjoernConstants.LUCENE_QUERY).execute("nodeType:" + BjoernNodeTypes.FUNCTION);
	return functions;
}
 
Example #14
Source File: CSVImporter.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
protected void openNoTxForMassiveInsert()
{
	OGlobalConfiguration.USE_WAL.setValue(false);
	OGlobalConfiguration.WAL_SYNC_ON_PAGE_FLUSH.setValue(false);

	noTx = new OrientGraphNoTx(
			"plocal:" + System.getProperty("ORIENTDB_HOME") + "/databases/" + dbName);
	noTx.declareIntent(new OIntentMassiveInsert());
}
 
Example #15
Source File: FunctionAlocCreator.java    From bjoern with GNU General Public License v3.0 4 votes vote down vote up
FunctionAlocCreator(Radare radare, OrientGraphNoTx graph) throws
		IOException {
	this.radare = radare;
	this.graph = graph;
}
 
Example #16
Source File: ParamDetectPlugin.java    From bjoern with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute() throws Exception
{
	OrientGraphNoTx graph = orientConnector.getNoTxGraphInstance();
	orientConnector.disconnect();
}
 
Example #17
Source File: GraphPoolBinder.java    From guice-persist-orient with MIT License 4 votes vote down vote up
public GraphPoolBinder(final OrientModule module, final Method bindPool, final Binder binder) throws Exception {
    binder.bind(OrientGraph.class).toProvider(OrientGraphProvider.class);
    binder.bind(OrientGraphNoTx.class).toProvider(OrientGraphNoTxProvider.class);
    bindPool.invoke(module, OrientBaseGraph.class, GraphPool.class);
}
 
Example #18
Source File: CSVImporter.java    From bjoern with GNU General Public License v3.0 4 votes vote down vote up
public OrientGraphNoTx getNoTx()
{
	return noTx;
}
 
Example #19
Source File: ServiceLocator.java    From light with Apache License 2.0 4 votes vote down vote up
public OrientGraphNoTx getGraphNoTx() {
    return getFactory().getNoTx();
}
 
Example #20
Source File: OrientDBGraphAPILiveTest.java    From tutorials with MIT License 4 votes vote down vote up
public static void setup() {
    String orientDBFolder = System.getenv("ORIENTDB_HOME");
    graph = new OrientGraphNoTx("plocal:" + orientDBFolder + "/databases/BaeldungDB", "admin", "admin");
}
 
Example #21
Source File: OrientDBConnector.java    From bjoern with GNU General Public License v3.0 4 votes vote down vote up
public OrientGraphNoTx getNoTxGraphInstance()
{
	return graphFactory.getNoTx();
}