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();
}
}
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();
}
}
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();
}
}
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);
}
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));
}
}
Aggregations