use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class BadCollectorTest method shouldBeAbleToRetrieveDuplicateNodeIds.
@Test
public void shouldBeAbleToRetrieveDuplicateNodeIds() throws IOException {
// given
int tolerance = 15;
BadCollector badCollector = new BadCollector(badOutputFile(), tolerance, BadCollector.COLLECT_ALL);
// when
for (int i = 0; i < 15; i++) {
badCollector.collectDuplicateNode(i, i, "group", "source" + i, "otherSource" + i);
}
// then
assertEquals(15, PrimitiveLongCollections.count(badCollector.leftOverDuplicateNodesIds()));
PrimitiveLongSet longs = PrimitiveLongCollections.asSet(badCollector.leftOverDuplicateNodesIds());
for (int i = 0; i < 15; i++) {
assertTrue(longs.contains(i));
}
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class NodeRelationshipCacheTest method shouldVisitChangedNodes.
@Test
public void shouldVisitChangedNodes() throws Exception {
// GIVEN
int nodes = 10;
cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 2, 100, base);
cache.setHighNodeId(nodes);
for (long nodeId = 0; nodeId < nodes; nodeId++) {
cache.incrementCount(nodeId);
if (random.nextBoolean()) {
cache.incrementCount(nodeId);
}
}
PrimitiveLongSet keySparseChanged = Primitive.longSet(nodes);
PrimitiveLongSet keyDenseChanged = Primitive.longSet(nodes);
for (int i = 0; i < nodes / 2; i++) {
long nodeId = random.nextLong(nodes);
cache.getAndPutRelationship(nodeId, Direction.OUTGOING, random.nextLong(1_000_000), false);
boolean dense = cache.isDense(nodeId);
(dense ? keyDenseChanged : keySparseChanged).add(nodeId);
}
{
// WHEN (sparse)
NodeChangeVisitor visitor = (nodeId, array) -> {
// THEN (sparse)
assertTrue("Unexpected sparse change reported for " + nodeId, keySparseChanged.remove(nodeId));
};
cache.visitChangedNodes(visitor, false);
assertTrue("There was " + keySparseChanged.size() + " expected sparse changes that weren't reported", keySparseChanged.isEmpty());
}
{
// WHEN (dense)
NodeChangeVisitor visitor = (nodeId, array) -> {
// THEN (dense)
assertTrue("Unexpected dense change reported for " + nodeId, keyDenseChanged.remove(nodeId));
};
cache.visitChangedNodes(visitor, true);
assertTrue("There was " + keyDenseChanged.size() + " expected dense changes that weren reported", keyDenseChanged.isEmpty());
}
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedIndexReaderTest method rangeSeekByPrefixOverPartitions.
@Test
public void rangeSeekByPrefixOverPartitions() throws Exception {
PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
IndexQuery.StringPrefixPredicate query = IndexQuery.stringPrefix(1, "prefix");
when(indexReader1.query(query)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.query(query)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.query(query)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet results = PrimitiveLongCollections.asSet(indexReader.query(query));
verifyResult(results);
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedIndexReaderTest method rangeSeekByNumberOverPartitions.
@Test
public void rangeSeekByNumberOverPartitions() throws Exception {
PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
IndexQuery.NumberRangePredicate query = IndexQuery.range(1, 1, true, 2, true);
when(indexReader1.query(query)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.query(query)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.query(query)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet results = PrimitiveLongCollections.asSet(indexReader.query(query));
verifyResult(results);
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedIndexReaderTest method scanOverPartitions.
@Test
public void scanOverPartitions() throws Exception {
PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
IndexQuery.ExistsPredicate query = IndexQuery.exists(1);
when(indexReader1.query(query)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.query(query)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.query(query)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet results = PrimitiveLongCollections.asSet(indexReader.query(query));
verifyResult(results);
}
Aggregations