Search in sources :

Example 1 with GraphDatabaseCypherService

use of org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService in project neo4j-documentation by neo4j.

the class DocsExecutionEngineTest method createStuff.

private static DocsSetup createStuff() {
    EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction();
    GraphDatabaseService graph = new TestEnterpriseGraphDatabaseFactory().setFileSystem(fs).newImpermanentDatabase();
    GraphDatabaseCypherService database = new GraphDatabaseCypherService(graph);
    GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graph);
    GraphDatabaseAPI graphAPI = (GraphDatabaseAPI) graph;
    DependencyResolver resolver = graphAPI.getDependencyResolver();
    LogService logService = resolver.resolveDependency(LogService.class);
    Monitors monitors = resolver.resolveDependency(Monitors.class);
    LogProvider logProvider = logService.getInternalLogProvider();
    CommunityCompatibilityFactory inner = new CommunityCompatibilityFactory(queryService, monitors, logProvider);
    EnterpriseCompatibilityFactory compatibilityFactory = new EnterpriseCompatibilityFactory(inner, queryService, monitors, logProvider);
    NullLogProvider logProvider1 = NullLogProvider.getInstance();
    DocsExecutionEngine engine = new DocsExecutionEngine(database, logProvider1, compatibilityFactory);
    PropertyContainerLocker locker = new PropertyContainerLocker();
    TransactionalContextFactory contextFactory = Neo4jTransactionalContextFactory.create(database, locker);
    return new DocsSetup() {

        @Override
        public GraphDatabaseCypherService database() {
            return database;
        }

        @Override
        public DocsExecutionEngine engine() {
            return engine;
        }

        @Override
        public TransactionalContextFactory contextFactory() {
            return contextFactory;
        }
    };
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestEnterpriseGraphDatabaseFactory(org.neo4j.test.TestEnterpriseGraphDatabaseFactory) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) GraphDatabaseCypherService(org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService) EnterpriseCompatibilityFactory(org.neo4j.cypher.internal.EnterpriseCompatibilityFactory) TransactionalContextFactory(org.neo4j.kernel.impl.query.TransactionalContextFactory) Neo4jTransactionalContextFactory(org.neo4j.kernel.impl.query.Neo4jTransactionalContextFactory) DependencyResolver(org.neo4j.graphdb.DependencyResolver) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) PropertyContainerLocker(org.neo4j.kernel.impl.coreapi.PropertyContainerLocker) Monitors(org.neo4j.kernel.monitoring.Monitors) CommunityCompatibilityFactory(org.neo4j.cypher.internal.CommunityCompatibilityFactory) NullLogProvider(org.neo4j.logging.NullLogProvider) DocsExecutionEngine(org.neo4j.cypher.internal.DocsExecutionEngine) LogService(org.neo4j.kernel.impl.logging.LogService)

Example 2 with GraphDatabaseCypherService

use of org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService in project neo4j by neo4j.

the class ManyMergesStressTest method shouldWorkFine.

@Test
void shouldWorkFine() {
    GraphDatabaseQueryService graph = new GraphDatabaseCypherService(db);
    Label person = Label.label("Person");
    try (Transaction tx = db.beginTx()) {
        // THIS USED TO CAUSE OUT OF FILE HANDLES
        // (maybe look at:  http://stackoverflow.com/questions/6210348/too-many-open-files-error-on-lucene)
        tx.schema().indexFor(person).on("id").create();
        // THIS SHOULD ALSO WORK
        tx.schema().constraintFor(person).assertPropertyIsUnique("id").create();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        tx.schema().indexFor(person).on("name").create();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
        tx.commit();
    }
    for (int count = 0; count < TRIES; count++) {
        Pair<String, String> stringPair = getRandomName();
        String ident = stringPair.first();
        String name = stringPair.other();
        String id = Long.toString(Math.abs(random.nextLong()));
        String query = format("MERGE (%s:Person {id: %s}) ON CREATE SET %s.name = \"%s\";", ident, id, ident, name);
        try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.IMPLICIT, LoginContext.AUTH_DISABLED)) {
            Result result = tx.execute(query);
            result.close();
            tx.commit();
        }
    }
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) Label(org.neo4j.graphdb.Label) GraphDatabaseCypherService(org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Result(org.neo4j.graphdb.Result) Test(org.junit.jupiter.api.Test)

Aggregations

GraphDatabaseCypherService (org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService)2 Test (org.junit.jupiter.api.Test)1 CommunityCompatibilityFactory (org.neo4j.cypher.internal.CommunityCompatibilityFactory)1 DocsExecutionEngine (org.neo4j.cypher.internal.DocsExecutionEngine)1 EnterpriseCompatibilityFactory (org.neo4j.cypher.internal.EnterpriseCompatibilityFactory)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Label (org.neo4j.graphdb.Label)1 Result (org.neo4j.graphdb.Result)1 Transaction (org.neo4j.graphdb.Transaction)1 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)1 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1 PropertyContainerLocker (org.neo4j.kernel.impl.coreapi.PropertyContainerLocker)1 LogService (org.neo4j.kernel.impl.logging.LogService)1 Neo4jTransactionalContextFactory (org.neo4j.kernel.impl.query.Neo4jTransactionalContextFactory)1 TransactionalContextFactory (org.neo4j.kernel.impl.query.TransactionalContextFactory)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1 Monitors (org.neo4j.kernel.monitoring.Monitors)1