use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class LabelScanStoreTest method shouldFindDecentAmountOfNodesForALabel.
@Test
public void shouldFindDecentAmountOfNodesForALabel() throws Exception {
// GIVEN
// 16 is the magic number of the page iterator
// 32 is the number of nodes in each lucene document
final int labelId = 1, nodeCount = 32 * 16 + 10;
start();
write(new PrefetchingIterator<NodeLabelUpdate>() {
private int i = -1;
@Override
protected NodeLabelUpdate fetchNextOrNull() {
return ++i < nodeCount ? labelChanges(i, NO_LABELS, new long[] { labelId }) : null;
}
});
// WHEN
Set<Long> nodeSet = new TreeSet<>();
LabelScanReader reader = store.newReader();
PrimitiveLongIterator nodes = reader.nodesWithLabel(labelId);
while (nodes.hasNext()) {
nodeSet.add(nodes.next());
}
reader.close();
// THEN
assertEquals("Found gaps in node id range: " + gaps(nodeSet, nodeCount), nodeCount, nodeSet.size());
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class IndexAccessorCompatibility method metaGet.
private List<Long> metaGet(ReaderInteraction interaction) throws Exception {
try (IndexReader reader = accessor.newReader()) {
List<Long> list = new LinkedList<>();
for (PrimitiveLongIterator iterator = interaction.results(reader); iterator.hasNext(); ) {
list.add(iterator.next());
}
Collections.sort(list);
return list;
}
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class PropertyAndNodeIndexedCheck method verifyNodeCorrectlyIndexedUniquely.
private void verifyNodeCorrectlyIndexedUniquely(long nodeId, int propertyKeyId, Object propertyValue, CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine, IndexRule indexRule, IndexReader reader) {
PrimitiveLongIterator indexedNodeIds = null;
try {
indexedNodeIds = reader.query(IndexQuery.exact(propertyKeyId, propertyValue));
} catch (IndexNotApplicableKernelException e) {
indexedNodeIds = PrimitiveLongCollections.emptyIterator();
}
// For verifying node indexed uniquely in offline CC, if one match found in the first stage match,
// then there is no need to filter the result. The result is a exact match.
// If multiple matches found, we need to filter the result to get exact matches.
indexedNodeIds = filterIfMultipleValuesFound(indexedNodeIds, propertyKeyId, propertyValue);
boolean found = false;
while (indexedNodeIds.hasNext()) {
long indexedNodeId = indexedNodeIds.next();
if (nodeId == indexedNodeId) {
found = true;
} else {
engine.report().uniqueIndexNotUnique(indexRule, propertyValue, indexedNodeId);
}
}
if (!found) {
engine.report().notIndexed(indexRule, propertyValue);
}
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class TwoPhaseNodeForRelationshipLocking method unlockAllNodes.
private void unlockAllNodes(KernelStatement state) {
PrimitiveLongIterator iterator = nodeIds.iterator();
while (iterator.hasNext()) {
state.locks().optimistic().releaseExclusive(ResourceTypes.NODE, iterator.next());
}
nodeIds.clear();
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class LongDiffSetsTest method shouldContainSourceForEmptyDiffSets.
// TODO empty diffset EMPTY
// TODO null/isEmpty elements
@Test
public void shouldContainSourceForEmptyDiffSets() throws Exception {
// given
DiffSets<Long> diffSets = new DiffSets<>();
Iterator<Long> expected = diffSets.apply(iteratorSource(1L, 2L));
// when
PrimitiveLongIterator actual = diffSets.augment(iterator(1L, 2L));
// then
assertThat(expected, hasSamePrimitiveItems(actual));
}
Aggregations