use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportRelationshipTypeIndexInconsistencies1.
@Test
void shouldReportRelationshipTypeIndexInconsistencies1() throws Exception {
// given
// relationship present in type index but not in store
GraphStoreFixture.IdGenerator idGenerator = fixture.idGenerator();
long relationshipId = idGenerator.relationship();
long relationshipTypeId = idGenerator.relationshipType() - 1;
IndexDescriptor rtiDescriptor = findTokenIndex(fixture, EntityType.RELATIONSHIP);
IndexAccessor accessor = fixture.indexAccessorLookup().apply(rtiDescriptor);
try (IndexUpdater indexUpdater = accessor.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
indexUpdater.process(IndexEntryUpdate.change(relationshipId, rtiDescriptor, new long[] {}, new long[] { relationshipTypeId }));
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.RELATIONSHIP_TYPE_SCAN_DOCUMENT, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class SpecialisedIndexFullCheckTest method shouldReportNodesThatAreIndexedWhenTheyShouldNotBe.
@ParameterizedTest
@EnumSource(IndexSize.class)
void shouldReportNodesThatAreIndexedWhenTheyShouldNotBe(IndexSize indexSize) throws Exception {
indexSize.createAdditionalData(fixture);
// given
long newNode = createOneNode();
Iterator<IndexDescriptor> indexDescriptorIterator = getValueIndexDescriptors();
while (indexDescriptorIterator.hasNext()) {
IndexDescriptor indexDescriptor = indexDescriptorIterator.next();
IndexAccessor accessor = fixture.indexAccessorLookup().apply(indexDescriptor);
try (IndexUpdater updater = accessor.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
updater.process(IndexEntryUpdate.add(newNode, indexDescriptor, values(indexDescriptor)));
}
}
// when
ConsistencySummaryStatistics stats = check();
assertFalse(stats.isConsistent());
RecordType recordType = indexSize == IndexSize.SMALL_INDEX ? RecordType.INDEX : RecordType.NODE;
assertThat(stats.getInconsistencyCountForRecordType(recordType)).isEqualTo(2);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class ReadEntityIdsStepUsingTokenIndexTest method populateTokenIndex.
private void populateTokenIndex(TokenIndexAccessor indexAccessor, BitSet entityIds, long count) throws Exception {
try (IndexUpdater updater = indexAccessor.newUpdater(ONLINE, CursorContext.NULL)) {
long id = 0;
for (int i = 0; i < count; i++) {
updater.process(IndexEntryUpdate.change(id, INDEX_DESCRIPTOR, EMPTY_LONG_ARRAY, new long[] { TOKEN_ID }));
entityIds.set((int) id);
id += random.nextInt(1, 5);
}
}
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NodeCheckerTest method shouldReportNodeLabelNotInIndexMiddleNode.
@Test
void shouldReportNodeLabelNotInIndexMiddleNode() throws Exception {
// given
try (AutoCloseable ignored = tx()) {
try (IndexUpdater writer = labelIndexWriter()) {
for (int i = 0; i < 20; i++) {
long nodeId = node(nodeStore.nextId(CursorContext.NULL), NULL, NULL, label1, label2);
// node 10 missing label2 in index
writer.process(IndexEntryUpdate.change(nodeId, IndexDescriptor.NO_INDEX, EMPTY_LONG_ARRAY, i == 10 ? new long[] { label1 } : new long[] { label1, label2 }));
}
}
}
// when
check();
// then
expect(LabelScanConsistencyReport.class, report -> report.nodeLabelNotInIndex(any(), anyLong()));
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class RelationshipCheckerWithRelationshipTypeIndexTest method storeHasBigGapButIndexDoesNot.
@Test
void storeHasBigGapButIndexDoesNot() throws Exception {
// given
try (Transaction tx = db.beginTx();
IndexUpdater writer = relationshipTypeIndexWriter()) {
for (int i = 0; i < 2 * IDS_PER_CHUNK; i++) {
if (i == 0) {
createCompleteEntry(writer, type);
} else if (i == 10) {
long relationshipId = createStoreEntry(type);
notInUse(relationshipId);
createIndexEntry(writer, relationshipId, type);
} else if (i == IDS_PER_CHUNK - 1) {
createCompleteEntry(writer, type);
} else {
long relationshipId = createStoreEntry(type);
notInUse(relationshipId);
}
}
tx.commit();
}
// when
check();
// then
expect(ConsistencyReport.RelationshipTypeScanConsistencyReport.class, reporter -> reporter.relationshipNotInUse(any()));
}
Aggregations