use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class CompositeIndexingIT method shouldSeeAllEntitiesAddedBeforeTransaction.
@ParameterizedTest
@MethodSource("params")
void shouldSeeAllEntitiesAddedBeforeTransaction(Params params) throws Exception {
setup(params.prototypeFactory);
var entityControl = params.entityControl;
if (// this test does not make any sense for UNIQUE indexes
!index.isUnique()) {
long entity1 = createEntity(entityControl);
long entity2 = createEntity(entityControl);
long entity3 = createEntity(entityControl);
try (Transaction tx = graphDatabaseAPI.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
assertThat(entityControl.seek(ktx, index)).contains(entity1, entity2, entity3);
}
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class CompositeIndexingIT method shouldNotSeeEntitiesLackingOneProperty.
@ParameterizedTest
@MethodSource("params")
void shouldNotSeeEntitiesLackingOneProperty(Params params) throws Exception {
setup(params.prototypeFactory);
var entityControl = params.entityControl;
long entity = createEntity(entityControl);
try (Transaction tx = graphDatabaseAPI.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
entityControl.createEntity(ktx, index, true);
assertThat(entityControl.seek(ktx, index)).containsExactly(entity);
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class CompositeIndexingIT method createEntity.
private long createEntity(EntityControl entityControl) throws KernelException {
long id;
try (Transaction tx = graphDatabaseAPI.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
id = entityControl.createEntity(ktx, index);
tx.commit();
}
return id;
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class CompositeIndexingIT method setup.
void setup(PrototypeFactory prototypeFactory) throws Exception {
var prototype = prototypeFactory.build(labelId, relTypeId, propIds);
try (Transaction tx = graphDatabaseAPI.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
if (prototype.isUnique()) {
ConstraintDescriptor constraint = ktx.schemaWrite().uniquePropertyConstraintCreate(prototype);
index = ktx.schemaRead().indexGetForName(constraint.getName());
} else {
index = ktx.schemaWrite().indexCreate(prototype.schema(), null);
}
tx.commit();
}
try (Transaction tx = graphDatabaseAPI.beginTx()) {
tx.schema().awaitIndexesOnline(5, MINUTES);
tx.commit();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class TransactionTracingIT method tracePageCacheAccessOnAllNodesAccess.
@Test
void tracePageCacheAccessOnAllNodesAccess() {
try (Transaction transaction = database.beginTx()) {
for (int i = 0; i < ENTITY_COUNT; i++) {
transaction.createNode();
}
transaction.commit();
}
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var cursorContext = transaction.kernelTransaction().cursorContext();
assertZeroCursor(cursorContext);
softly.assertThat(Iterables.count(transaction.getAllNodes())).as("Number of expected nodes").isEqualTo(ENTITY_COUNT);
softly.assertThat(cursorContext.getCursorTracer().pins()).as("Number of cursor pins").isEqualTo(2);
softly.assertThat(cursorContext.getCursorTracer().unpins()).as("Number of cursor unpins").isEqualTo(1);
softly.assertThat(cursorContext.getCursorTracer().hits()).as("Number of cursor hits").isEqualTo(2);
}
}
Aggregations