Search in sources :

Example 16 with InternalTransaction

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

the class MultipleOpenCursorsTest method multipleIteratorsNestedInterleavedRange.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInterleavedRange(IndexCoordinator indexCoordinator) throws Exception {
    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 = new ArrayList<>();
            List<Long> actual2 = new ArrayList<>();
            // Interleave
            exhaustInterleaved(cursor1, actual1, cursor2, actual2);
            // 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) 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 17 with InternalTransaction

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

the class MultipleOpenCursorsTest method multipleIteratorsNestedInnerNewExact.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInnerNewExact(IndexCoordinator indexCoordinator) throws Exception {
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExact(ktx)) {
            List<Long> actual1 = new ArrayList<>();
            while (cursor1.next()) {
                actual1.add(cursor1.nodeReference());
                try (NodeValueIndexCursor cursor2 = indexCoordinator.queryExact(ktx)) {
                    List<Long> actual2 = asList(cursor2);
                    indexCoordinator.assertExactResult(actual2);
                }
            }
            // then
            indexCoordinator.assertExactResult(actual1);
        }
        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 18 with InternalTransaction

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

the class MultipleOpenCursorsTest method multipleIteratorsNestedInnerNewRange.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInnerNewRange(IndexCoordinator indexCoordinator) throws Exception {
    assumeTrue(indexCoordinator.supportRangeQuery());
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryRange(ktx)) {
            List<Long> actual1 = new ArrayList<>();
            while (cursor1.next()) {
                actual1.add(cursor1.nodeReference());
                try (NodeValueIndexCursor cursor2 = indexCoordinator.queryRange(ktx)) {
                    List<Long> actual2 = asList(cursor2);
                    indexCoordinator.assertRangeResult(actual2);
                }
            }
            // then
            indexCoordinator.assertRangeResult(actual1);
        }
        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 19 with InternalTransaction

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

the class MultipleOpenCursorsTest method multipleCursorsNotNestedExists.

@ParameterizedTest
@MethodSource(value = "params")
void multipleCursorsNotNestedExists(IndexCoordinator indexCoordinator) throws Exception {
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        // when
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExists(ktx);
            NodeValueIndexCursor cursor2 = indexCoordinator.queryExists(ktx)) {
            List<Long> actual1 = asList(cursor1);
            List<Long> actual2 = asList(cursor2);
            // 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) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 20 with InternalTransaction

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

the class MultipleOpenCursorsTest method multipleCursorsNotNestedExact.

@ParameterizedTest
@MethodSource(value = "params")
void multipleCursorsNotNestedExact(IndexCoordinator indexCoordinator) throws Exception {
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExact(ktx);
            NodeValueIndexCursor cursor2 = indexCoordinator.queryExact(ktx)) {
            List<Long> actual1 = asList(cursor1);
            List<Long> actual2 = asList(cursor2);
            // then
            indexCoordinator.assertExactResult(actual1);
            indexCoordinator.assertExactResult(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)

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