use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class PrimitiveLongSetTest method intVisitorShouldNotSeeEntriesAfterRequestingBreakOut.
@Test
public void intVisitorShouldNotSeeEntriesAfterRequestingBreakOut() {
// GIVEN
PrimitiveIntSet map = Primitive.intSet();
map.add(1);
map.add(2);
map.add(3);
map.add(4);
final AtomicInteger counter = new AtomicInteger();
// WHEN
map.visitKeys(new PrimitiveIntVisitor<RuntimeException>() {
@Override
public boolean visited(int value) {
return counter.incrementAndGet() > 2;
}
});
// THEN
assertThat(counter.get(), is(3));
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class PrimitiveLongSetTest method intVisitorShouldSeeAllEntriesIfItDoesNotBreakOut.
@SuppressWarnings("unchecked")
@Test
public void intVisitorShouldSeeAllEntriesIfItDoesNotBreakOut() {
// GIVEN
PrimitiveIntSet set = Primitive.intSet();
set.add(1);
set.add(2);
set.add(3);
PrimitiveIntVisitor<RuntimeException> visitor = mock(PrimitiveIntVisitor.class);
// WHEN
set.visitKeys(visitor);
// THEN
verify(visitor).visited(1);
verify(visitor).visited(2);
verify(visitor).visited(3);
verifyNoMoreInteractions(visitor);
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class PrimitiveLongSetTest method longVisitorShouldNotSeeEntriesAfterRequestingBreakOut.
@Test
public void longVisitorShouldNotSeeEntriesAfterRequestingBreakOut() {
// GIVEN
PrimitiveIntSet map = Primitive.intSet();
map.add(1);
map.add(2);
map.add(3);
map.add(4);
final AtomicInteger counter = new AtomicInteger();
// WHEN
map.visitKeys(new PrimitiveIntVisitor<RuntimeException>() {
@Override
public boolean visited(int value) {
return counter.incrementAndGet() > 2;
}
});
// THEN
assertThat(counter.get(), is(3));
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipTypes.
@Override
public PrimitiveIntSet relationshipTypes(KernelStatement statement, NodeItem node) {
if (statement.hasTxStateWithChanges() && statement.txState().nodeIsAddedInThisTx(node.id())) {
return statement.txState().getNodeState(node.id()).relationshipTypes();
}
// Read types in the current transaction
PrimitiveIntSet types = statement.hasTxStateWithChanges() ? statement.txState().getNodeState(node.id()).relationshipTypes() : Primitive.intSet();
// Augment with types stored on disk, minus any types where all rels of that type are deleted
// in current tx.
types.addAll(filter(storeLayer.relationshipTypes(statement.getStoreStatement(), node).iterator(), (current) -> !types.contains(current) && degree(statement, node, Direction.BOTH, current) > 0));
return types;
}
use of org.neo4j.collection.primitive.PrimitiveIntSet in project neo4j by neo4j.
the class StorageLayer method relationshipTypes.
@Override
public PrimitiveIntSet relationshipTypes(StorageStatement statement, NodeItem node) {
PrimitiveIntSet set = intSet();
if (node.isDense()) {
RelationshipGroupRecord groupRecord = relationshipGroupStore.newRecord();
RecordCursor<RelationshipGroupRecord> cursor = statement.recordCursors().relationshipGroup();
for (long id = node.nextGroupId(); id != NO_NEXT_RELATIONSHIP.intValue(); id = groupRecord.getNext()) {
if (cursor.next(id, groupRecord, FORCE)) {
set.add(groupRecord.getType());
}
}
} else {
nodeGetRelationships(statement, node, Direction.BOTH).forAll(relationship -> set.add(relationship.type()));
}
return set;
}
Aggregations