use of org.neo4j.io.pagecache.context.CursorContext.NULL in project neo4j by neo4j.
the class LuceneIndexAccessorTest method indexReportInconsistencyToVisitor.
@Test
void indexReportInconsistencyToVisitor() {
when(schemaIndex.isValid()).thenReturn(false);
MutableBoolean called = new MutableBoolean();
final InvocationHandler handler = (proxy, method, args) -> {
called.setTrue();
return null;
};
assertFalse(accessor.consistencyCheck(new ReporterFactory(handler), NULL), "Expected index to be inconsistent");
assertTrue(called.booleanValue(), "Expected visitor to be called");
}
use of org.neo4j.io.pagecache.context.CursorContext.NULL in project neo4j by neo4j.
the class RecoveryIT method idGeneratorIsDirty.
private boolean idGeneratorIsDirty(Path path, IdType idType) throws IOException {
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), "my db");
try (IdGenerator idGenerator = idGeneratorFactory.open(pageCache, path, idType, () -> 0L, /*will not be used*/
10_000, readOnly(), Config.defaults(), NULL, Sets.immutable.empty())) {
MutableBoolean dirtyOnStartup = new MutableBoolean();
InvocationHandler invocationHandler = (proxy, method, args) -> {
if (method.getName().equals("dirtyOnStartup")) {
dirtyOnStartup.setTrue();
}
return null;
};
ReporterFactory reporterFactory = new ReporterFactory(invocationHandler);
idGenerator.consistencyCheck(reporterFactory, NULL);
return dirtyOnStartup.booleanValue();
}
}
use of org.neo4j.io.pagecache.context.CursorContext.NULL in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldDetectCorrectDuplicateInputIdsWhereManyAccidentalInManyGroups.
@Test
public void shouldDetectCorrectDuplicateInputIdsWhereManyAccidentalInManyGroups() {
// GIVEN
final ControlledEncoder encoder = new ControlledEncoder(new LongEncoder());
final int idsPerGroup = 20;
int groupCount = 5;
for (int i = 0; i < groupCount; i++) {
groups.getOrCreate("Group " + i);
}
IdMapper mapper = mapper(encoder, Radix.LONG, EncodingIdMapper.NO_MONITOR, ParallelSort.DEFAULT, numberOfCollisions -> new LongCollisionValues(NumberArrayFactories.HEAP, numberOfCollisions, INSTANCE));
final AtomicReference<Group> group = new AtomicReference<>();
PropertyValueLookup ids = (nodeId, cursorContext) -> {
int groupId = toIntExact(nodeId / idsPerGroup);
if (groupId == groupCount) {
return null;
}
group.set(groups.get(groupId));
// i.e. all first 10% in each group collides with all other first 10% in each group
if (nodeId % idsPerGroup < 2) {
// Let these colliding values encode into the same eId as well,
// so that they are definitely marked as collisions
encoder.useThisIdToEncodeNoMatterWhatComesIn(1234567L);
return nodeId % idsPerGroup;
}
// The other 90% will be accidental collisions for something else
encoder.useThisIdToEncodeNoMatterWhatComesIn((long) (123456 - group.get().id()));
return nodeId;
};
// WHEN
int count = idsPerGroup * groupCount;
for (long nodeId = 0; nodeId < count; nodeId++) {
mapper.put(ids.lookupProperty(nodeId, NULL), nodeId, group.get());
}
Collector collector = mock(Collector.class);
mapper.prepare(ids, collector, NONE);
// THEN
verifyNoMoreInteractions(collector);
for (long nodeId = 0; nodeId < count; nodeId++) {
assertEquals(nodeId, mapper.get(ids.lookupProperty(nodeId, NULL), group.get()));
}
verifyNoMoreInteractions(collector);
assertFalse(mapper.leftOverDuplicateNodesIds().hasNext());
}
use of org.neo4j.io.pagecache.context.CursorContext.NULL in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldScanAllNodesInBatches.
@Test
void shouldScanAllNodesInBatches() {
// given
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(FOO_LABEL);
MutableLongList ids = LongLists.mutable.empty();
while (scan.reserveBatch(nodes, 3)) {
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
}
// then
assertEquals(FOO_NODES.size(), ids.size());
assertTrue(FOO_NODES.containsAll(ids));
assertTrue(ids.noneSatisfy(f -> BAR_NODES.contains(f)));
}
}
use of org.neo4j.io.pagecache.context.CursorContext.NULL in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldHandleGreatAmountsOfStuff.
@Test
public void shouldHandleGreatAmountsOfStuff() {
// GIVEN
IdMapper idMapper = mapper(new StringEncoder(), Radix.STRING, EncodingIdMapper.NO_MONITOR);
PropertyValueLookup inputIdLookup = (id, cursorContext) -> String.valueOf(id);
int count = 300_000;
// WHEN
for (long nodeId = 0; nodeId < count; nodeId++) {
idMapper.put(inputIdLookup.lookupProperty(nodeId, NULL), nodeId, Group.GLOBAL);
}
idMapper.prepare(inputIdLookup, mock(Collector.class), NONE);
// THEN
for (long nodeId = 0; nodeId < count; nodeId++) {
// the UUIDs here will be generated in the same sequence as above because we reset the random
Object id = inputIdLookup.lookupProperty(nodeId, NULL);
if (idMapper.get(id, Group.GLOBAL) == IdMapper.ID_NOT_FOUND) {
fail("Couldn't find " + id + " even though I added it just previously");
}
}
}
Aggregations