Search in sources :

Example 91 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class MultipleOpenCursorsTest method multipleIteratorsNotNestedRange.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNotNestedRange(IndexCoordinator indexCoordinator) throws KernelException {
    assumeTrue(indexCoordinator.supportRangeQuery());
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryRange(ktx);
            NodeValueIndexCursor cursor2 = indexCoordinator.queryRange(ktx)) {
            List<Long> actual1 = asList(cursor1);
            List<Long> actual2 = asList(cursor2);
            // then
            indexCoordinator.assertRangeResult(actual1);
            indexCoordinator.assertRangeResult(actual2);
        }
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NodeValueIndexCursor(org.neo4j.internal.kernel.api.NodeValueIndexCursor) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 92 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class MultipleOpenCursorsTest method multipleIteratorsNestedInterleavedExists.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInterleavedExists(IndexCoordinator indexCoordinator) throws Exception {
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExists(ktx)) {
            List<Long> actual1 = new ArrayList<>();
            try (NodeValueIndexCursor cursor2 = indexCoordinator.queryExists(ktx)) {
                List<Long> actual2 = new ArrayList<>();
                // Interleave
                exhaustInterleaved(cursor1, actual1, cursor2, actual2);
                // then
                indexCoordinator.assertExistsResult(actual1);
                indexCoordinator.assertExistsResult(actual2);
            }
        }
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NodeValueIndexCursor(org.neo4j.internal.kernel.api.NodeValueIndexCursor) ArrayList(java.util.ArrayList) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 93 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class FullScanStoreViewTest method getOrCreateIds.

private void getOrCreateIds() throws KernelException {
    try (Transaction tx = graphDb.beginTx()) {
        TokenWrite tokenWrite = ((InternalTransaction) tx).kernelTransaction().tokenWrite();
        labelId = tokenWrite.labelGetOrCreateForName("Person");
        relTypeId = tokenWrite.relationshipTypeGetOrCreateForName("Knows");
        propertyKeyId = tokenWrite.propertyKeyGetOrCreateForName("name");
        relPropertyKeyId = tokenWrite.propertyKeyGetOrCreateForName("duration");
        tx.commit();
    }
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Example 94 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class SchemaStorageIT method initStorage.

@BeforeEach
void initStorage() throws Exception {
    try (Transaction transaction = db.beginTx()) {
        TokenWrite tokenWrite = ((InternalTransaction) transaction).kernelTransaction().tokenWrite();
        tokenWrite.propertyKeyGetOrCreateForName(PROP1);
        tokenWrite.propertyKeyGetOrCreateForName(PROP2);
        tokenWrite.labelGetOrCreateForName(LABEL1);
        tokenWrite.labelGetOrCreateForName(LABEL2);
        tokenWrite.relationshipTypeGetOrCreateForName(TYPE1);
        transaction.commit();
    }
    schemaStore = storageEngine.testAccessNeoStores().getSchemaStore();
    storage = new SchemaStorage(schemaStore, tokenHolders, () -> KernelVersion.LATEST);
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) SchemaStorage(org.neo4j.internal.recordstorage.SchemaStorage) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 95 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class DefaultValueMapperTest method shouldHandleSingleNodePath.

@Test
void shouldHandleSingleNodePath() {
    // Given
    Node node;
    try (Transaction tx = db.beginTx()) {
        node = tx.createNode();
        tx.commit();
    }
    // Then
    try (Transaction tx = db.beginTx()) {
        var mapper = new DefaultValueMapper((InternalTransaction) tx);
        Path mapped = mapper.mapPath(path(asNodeValues(node), asRelationshipsValues()));
        assertThat(mapped.length()).isEqualTo(0);
        assertThat(mapped.startNode()).isEqualTo(node);
        assertThat(mapped.endNode()).isEqualTo(node);
        assertThat(Iterables.asList(mapped.relationships())).hasSize(0);
        assertThat(Iterables.asList(mapped.reverseRelationships())).hasSize(0);
        assertThat(Iterables.asList(mapped.nodes())).isEqualTo(singletonList(node));
        assertThat(Iterables.asList(mapped.reverseNodes())).isEqualTo(singletonList(node));
        assertThat(mapped.lastRelationship()).isNull();
        assertThat(Iterators.asList(mapped.iterator())).isEqualTo(singletonList(node));
    }
}
Also used : Path(org.neo4j.graphdb.Path) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Test(org.junit.jupiter.api.Test)

Aggregations

InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)126 Transaction (org.neo4j.graphdb.Transaction)58 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)53 Test (org.junit.jupiter.api.Test)46 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 MethodSource (org.junit.jupiter.params.provider.MethodSource)18 Node (org.neo4j.graphdb.Node)16 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)15 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 Result (org.neo4j.graphdb.Result)12 TokenRead (org.neo4j.internal.kernel.api.TokenRead)11 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)10 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)8 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)7 Relationship (org.neo4j.graphdb.Relationship)6 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)6 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)6 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)6 ReturnsDeepStubs (org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs)5