Search in sources :

Example 1 with KernelAPI

use of org.neo4j.kernel.api.KernelAPI in project neo4j by neo4j.

the class CommunityCypherEngineProvider method createEngine.

@Override
protected QueryExecutionEngine createEngine(Dependencies deps, GraphDatabaseAPI graphAPI) {
    GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graphAPI);
    deps.satisfyDependency(queryService);
    DependencyResolver resolver = graphAPI.getDependencyResolver();
    LogService logService = resolver.resolveDependency(LogService.class);
    KernelAPI kernelAPI = resolver.resolveDependency(KernelAPI.class);
    Monitors monitors = resolver.resolveDependency(Monitors.class);
    LogProvider logProvider = logService.getInternalLogProvider();
    CommunityCompatibilityFactory compatibilityFactory = new CommunityCompatibilityFactory(queryService, kernelAPI, monitors, logProvider);
    deps.satisfyDependencies(compatibilityFactory);
    return new ExecutionEngine(queryService, logProvider, compatibilityFactory);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) Monitors(org.neo4j.kernel.monitoring.Monitors) CommunityCompatibilityFactory(org.neo4j.cypher.internal.CommunityCompatibilityFactory) GraphDatabaseCypherService(org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService) KernelAPI(org.neo4j.kernel.api.KernelAPI) LogService(org.neo4j.kernel.impl.logging.LogService) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 2 with KernelAPI

use of org.neo4j.kernel.api.KernelAPI in project neo4j by neo4j.

the class ExecutionEngineTests method shouldConvertListsAndMapsWhenPassingFromScalaToJava.

@Test
public void shouldConvertListsAndMapsWhenPassingFromScalaToJava() throws Exception {
    GraphDatabaseQueryService graph = new GraphDatabaseCypherService(this.database.getGraphDatabaseAPI());
    KernelAPI kernelAPI = graph.getDependencyResolver().resolveDependency(KernelAPI.class);
    Monitors monitors = graph.getDependencyResolver().resolveDependency(Monitors.class);
    NullLogProvider nullLogProvider = NullLogProvider.getInstance();
    CommunityCompatibilityFactory compatibilityFactory = new CommunityCompatibilityFactory(graph, kernelAPI, monitors, nullLogProvider);
    ExecutionEngine executionEngine = new ExecutionEngine(graph, nullLogProvider, compatibilityFactory);
    Result result;
    try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.implicit, SecurityContext.AUTH_DISABLED)) {
        String query = "RETURN { key : 'Value' , collectionKey: [{ inner: 'Map1' }, { inner: 'Map2' }]}";
        TransactionalContext tc = createTransactionContext(graph, tx, query);
        result = executionEngine.executeQuery(query, NO_PARAMS, tc);
        tx.success();
    }
    Map firstRowValue = (Map) result.next().values().iterator().next();
    assertThat(firstRowValue.get("key"), is("Value"));
    List theList = (List) firstRowValue.get("collectionKey");
    assertThat(((Map) theList.get(0)).get("inner"), is("Map1"));
    assertThat(((Map) theList.get(1)).get("inner"), is("Map2"));
}
Also used : GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) GraphDatabaseCypherService(org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Result(org.neo4j.graphdb.Result) Monitors(org.neo4j.kernel.monitoring.Monitors) NullLogProvider(org.neo4j.logging.NullLogProvider) CommunityCompatibilityFactory(org.neo4j.cypher.internal.CommunityCompatibilityFactory) List(java.util.List) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) KernelAPI(org.neo4j.kernel.api.KernelAPI) Map(java.util.Map) Test(org.junit.Test)

Example 3 with KernelAPI

use of org.neo4j.kernel.api.KernelAPI in project neo4j by neo4j.

the class NeoStoreDataSource method buildKernel.

private NeoStoreKernelModule buildKernel(TransactionAppender appender, IndexingService indexingService, StoreReadLayer storeLayer, UpdateableSchemaState updateableSchemaState, LabelScanStore labelScanStore, StorageEngine storageEngine, IndexConfigStore indexConfigStore, TransactionIdStore transactionIdStore, AvailabilityGuard availabilityGuard, Clock clock, PropertyAccessor propertyAccessor) throws KernelException, IOException {
    TransactionCommitProcess transactionCommitProcess = commitProcessFactory.create(appender, storageEngine, config);
    /*
         * This is used by legacy indexes and constraint indexes whenever a transaction is to be spawned
         * from within an existing transaction. It smells, and we should look over alternatives when time permits.
         */
    Supplier<KernelAPI> kernelProvider = () -> kernelModule.kernelAPI();
    boolean releaseSchemaLockWhenBuildingConstratinIndexes = config.get(GraphDatabaseSettings.release_schema_lock_while_building_constraint);
    ConstraintIndexCreator constraintIndexCreator = new ConstraintIndexCreator(kernelProvider, indexingService, propertyAccessor, releaseSchemaLockWhenBuildingConstratinIndexes);
    LegacyIndexStore legacyIndexStore = new LegacyIndexStore(config, indexConfigStore, kernelProvider, legacyIndexProviderLookup);
    StatementOperationContainer statementOperationContainer = dependencies.satisfyDependency(buildStatementOperations(storeLayer, autoIndexing, constraintIndexCreator, updateableSchemaState, guard, legacyIndexStore));
    TransactionHooks hooks = new TransactionHooks();
    KernelTransactions kernelTransactions = life.add(new KernelTransactions(statementLocksFactory, constraintIndexCreator, statementOperationContainer, schemaWriteGuard, transactionHeaderInformationFactory, transactionCommitProcess, indexConfigStore, legacyIndexProviderLookup, hooks, transactionMonitor, availabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, accessCapability));
    final Kernel kernel = new Kernel(kernelTransactions, hooks, databaseHealth, transactionMonitor, procedures, config);
    kernel.registerTransactionHook(transactionEventHandlers);
    final NeoStoreFileListing fileListing = new NeoStoreFileListing(storeDir, labelScanStore, indexingService, legacyIndexProviderLookup, storageEngine);
    return new NeoStoreKernelModule(transactionCommitProcess, kernel, kernelTransactions, fileListing);
}
Also used : NeoStoreFileListing(org.neo4j.kernel.impl.transaction.state.NeoStoreFileListing) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) LegacyIndexStore(org.neo4j.kernel.impl.index.LegacyIndexStore) TransactionCommitProcess(org.neo4j.kernel.impl.api.TransactionCommitProcess) TransactionHooks(org.neo4j.kernel.impl.api.TransactionHooks) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) KernelAPI(org.neo4j.kernel.api.KernelAPI) Kernel(org.neo4j.kernel.impl.api.Kernel)

Example 4 with KernelAPI

use of org.neo4j.kernel.api.KernelAPI in project neo4j by neo4j.

the class IsolatedTransactionTokenCreator method getOrCreate.

@Override
public synchronized int getOrCreate(String name) throws org.neo4j.kernel.api.exceptions.KernelException {
    KernelAPI kernel = kernelSupplier.get();
    try (KernelTransaction transaction = kernel.newTransaction(Type.implicit, AUTH_DISABLED)) {
        try (Statement statement = transaction.acquireStatement()) {
            int id = createKey(statement, name);
            transaction.success();
            return id;
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Statement(org.neo4j.kernel.api.Statement) KernelAPI(org.neo4j.kernel.api.KernelAPI)

Example 5 with KernelAPI

use of org.neo4j.kernel.api.KernelAPI in project neo4j by neo4j.

the class IndexPopulationFlipRaceIT method verifyThatThereAreExactlyOneIndexEntryPerNodeInTheIndexes.

private void verifyThatThereAreExactlyOneIndexEntryPerNodeInTheIndexes(int i, Pair<long[], long[]> data) throws Exception {
    KernelAPI kernelAPI = db.getDependencyResolver().resolveDependency(KernelAPI.class);
    try (KernelTransaction tx = kernelAPI.newTransaction(KernelTransaction.Type.implicit, AnonymousContext.read());
        Statement statement = tx.acquireStatement()) {
        int labelAId = statement.readOperations().labelGetForName(labelA(i).name());
        int keyAId = statement.readOperations().propertyKeyGetForName(keyA(i));
        int labelBId = statement.readOperations().labelGetForName(labelB(i).name());
        int keyBId = statement.readOperations().propertyKeyGetForName(keyB(i));
        NewIndexDescriptor indexA = NewIndexDescriptorFactory.forLabel(labelAId, keyAId);
        NewIndexDescriptor indexB = NewIndexDescriptorFactory.forLabel(labelBId, keyBId);
        for (int j = 0; j < NODES_PER_INDEX; j++) {
            long nodeAId = data.first()[j];
            assertEquals(1, statement.readOperations().nodesCountIndexed(indexA, nodeAId, nodeAId));
            long nodeBId = data.other()[j];
            assertEquals(1, statement.readOperations().nodesCountIndexed(indexB, nodeBId, nodeBId));
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) KernelAPI(org.neo4j.kernel.api.KernelAPI)

Aggregations

KernelAPI (org.neo4j.kernel.api.KernelAPI)12 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)8 Statement (org.neo4j.kernel.api.Statement)8 CommunityCompatibilityFactory (org.neo4j.cypher.internal.CommunityCompatibilityFactory)3 GraphDatabaseCypherService (org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService)3 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 Monitors (org.neo4j.kernel.monitoring.Monitors)3 List (java.util.List)2 Test (org.junit.Test)2 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)2 LogProvider (org.neo4j.logging.LogProvider)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1 EnterpriseCompatibilityFactory (org.neo4j.cypher.internal.EnterpriseCompatibilityFactory)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1