use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class IndexingService method getIndexIds.
public LongSet getIndexIds() {
Iterable<IndexProxy> indexProxies = indexMapRef.getAllIndexProxies();
MutableLongSet indexIds = new LongHashSet();
for (IndexProxy indexProxy : indexProxies) {
indexIds.add(indexProxy.getDescriptor().getId());
}
return indexIds;
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class RollbackIdLeakIT method shouldNotLeakHighIdsOnCreateDeleteInSameTx.
private void shouldNotLeakHighIdsOnCreateDeleteInSameTx(Supplier<DbRestarter> restarterSupplier) throws IOException {
// given
MutableLongSet nodeIds = new LongHashSet();
MutableLongSet relationshipIds = new LongHashSet();
try (DbRestarter restarter = restarterSupplier.get()) {
GraphDatabaseService db = restarter.start();
Node node2;
Relationship relationship2;
try (Transaction tx = db.beginTx()) {
Node node1 = tx.createNode();
Relationship relationship1 = node1.createRelationshipTo(node1, TEST);
node2 = tx.createNode();
relationship2 = node2.createRelationshipTo(node2, TEST);
nodeIds.add(node2.getId());
relationshipIds.add(relationship2.getId());
// Delete first node/relationship, but keep second ones
node1.delete();
nodeIds.add(node1.getId());
relationship1.delete();
relationshipIds.add(relationship1.getId());
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.getNodeById(node2.getId()).delete();
tx.getRelationshipById(relationship2.getId()).delete();
tx.commit();
}
assertAllocateIds(restarter.restart(), nodeIds, relationshipIds);
}
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class ParallelNodeCursorTransactionStateTestBase method createNodes.
private MutableLongSet createNodes(int size) throws TransactionFailureException, InvalidTransactionTypeKernelException {
MutableLongSet nodes = LongSets.mutable.empty();
try (KernelTransaction tx = beginTransaction()) {
Write write = tx.dataWrite();
for (int i = 0; i < size; i++) {
nodes.add(write.nodeCreate());
}
tx.commit();
}
return nodes;
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method createTestGraph.
@Override
public void createTestGraph(GraphDatabaseService graphDb) {
MutableLongSet fooNodes = LongSets.mutable.empty();
MutableLongSet barNodes = LongSets.mutable.empty();
try (KernelTransaction tx = beginTransaction()) {
TokenWrite tokenWrite = tx.tokenWrite();
FOO_LABEL = tokenWrite.labelGetOrCreateForName("foo");
BAR_LABEL = tokenWrite.labelGetOrCreateForName("bar");
Write write = tx.dataWrite();
for (int i = 0; i < NUMBER_OF_NODES; i++) {
long node = write.nodeCreate();
if (i % 2 == 0) {
write.nodeAddLabel(node, FOO_LABEL);
fooNodes.add(node);
} else {
write.nodeAddLabel(node, BAR_LABEL);
barNodes.add(node);
}
}
FOO_NODES = fooNodes;
BAR_NODES = barNodes;
tx.commit();
} catch (KernelException e) {
throw new AssertionError(e);
}
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class ParallelNodeLabelScanTransactionStateTestBase method scanShouldSeeAddedNodes.
@Test
void scanShouldSeeAddedNodes() throws Exception {
int size = 64;
int label = label("L");
MutableLongSet existing = LongSets.mutable.withAll(createNodesWithLabel(label, size));
try (KernelTransaction tx = beginTransaction()) {
MutableLongSet added = LongSets.mutable.withAll(createNodesWithLabel(tx.dataWrite(), label, size));
try (NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(tx.cursorContext())) {
Scan<NodeLabelIndexCursor> scan = tx.dataRead().nodeLabelScan(label);
Set<Long> seen = new HashSet<>();
while (scan.reserveBatch(cursor, 64)) {
while (cursor.next()) {
long nodeId = cursor.nodeReference();
assertTrue(seen.add(nodeId), format("%d was seen multiple times", nodeId));
assertTrue(existing.remove(nodeId) || added.remove(nodeId));
}
}
// make sure we have seen all nodes
assertTrue(existing.isEmpty());
assertTrue(added.isEmpty());
}
}
}
Aggregations