Skip to content

Commit

Permalink
Removes LabelScanReader#labelsForNode
Browse files Browse the repository at this point in the history
since not all implementations can support this efficiently and it was only
used in consistency checking where it was actually redundant anyway.
  • Loading branch information
tinwelint committed Jan 12, 2017
1 parent 68f5090 commit 6cbd79f
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 295 deletions.
Expand Up @@ -58,9 +58,6 @@ RecordCheck<RelationshipTypeTokenRecord, ConsistencyReport.RelationshipTypeConsi
RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyReport> decorateLabelTokenChecker( RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyReport> decorateLabelTokenChecker(
RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyReport> checker ); RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyReport> checker );


RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> decorateLabelMatchChecker(
RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> checker );

RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker( RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker(
RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker ); RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker );


Expand Down Expand Up @@ -122,13 +119,6 @@ public RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyRepo
return checker; return checker;
} }


@Override
public RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> decorateLabelMatchChecker(
RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> checker )
{
return checker;
}

@Override @Override
public RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker( public RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker(
RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> checker ) RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> checker )
Expand Down Expand Up @@ -233,17 +223,6 @@ public RecordCheck<LabelTokenRecord,ConsistencyReport.LabelTokenConsistencyRepor
return checker; return checker;
} }


@Override
public RecordCheck<NodeRecord,ConsistencyReport.LabelsMatchReport> decorateLabelMatchChecker(
RecordCheck<NodeRecord,ConsistencyReport.LabelsMatchReport> checker )
{
for ( CheckDecorator decorator: decorators)
{
checker = decorator.decorateLabelMatchChecker( checker );
}
return checker;
}

@Override @Override
public RecordCheck<RelationshipGroupRecord,RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker( public RecordCheck<RelationshipGroupRecord,RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker(
RecordCheck<RelationshipGroupRecord,RelationshipGroupConsistencyReport> checker ) RecordCheck<RelationshipGroupRecord,RelationshipGroupConsistencyReport> checker )
Expand Down
Expand Up @@ -46,6 +46,7 @@
import org.neo4j.kernel.impl.store.record.IndexRule; import org.neo4j.kernel.impl.store.record.IndexRule;


import static java.lang.String.format; import static java.lang.String.format;

import static org.neo4j.consistency.checking.full.MultiPassStore.ARRAYS; import static org.neo4j.consistency.checking.full.MultiPassStore.ARRAYS;
import static org.neo4j.consistency.checking.full.MultiPassStore.LABELS; import static org.neo4j.consistency.checking.full.MultiPassStore.LABELS;
import static org.neo4j.consistency.checking.full.MultiPassStore.NODES; import static org.neo4j.consistency.checking.full.MultiPassStore.NODES;
Expand Down Expand Up @@ -171,13 +172,7 @@ public List<ConsistencyCheckerTask> createTasksForFullCheck( boolean checkLabelS
tasks.add( create( "LabelNameStore", nativeStores.getLabelNameStore(), ROUND_ROBIN ) ); tasks.add( create( "LabelNameStore", nativeStores.getLabelNameStore(), ROUND_ROBIN ) );
tasks.add( create( "NodeDynamicLabelStore", nativeStores.getNodeDynamicLabelStore(), ROUND_ROBIN ) ); tasks.add( create( "NodeDynamicLabelStore", nativeStores.getNodeDynamicLabelStore(), ROUND_ROBIN ) );
} }
if ( checkLabelScanStore )
{
tasks.add( recordScanner( "NodeStoreToLabelScanStore",
new IterableStore<>( nativeStores.getNodeStore(), true ),
new NodeToLabelScanRecordProcessor( reporter, labelScanStore ),
CheckStage.Stage9_NS_LabelCounts, ROUND_ROBIN ) );
}
ConsistencyReporter filteredReporter = multiPass.reporter( NODES ); ConsistencyReporter filteredReporter = multiPass.reporter( NODES );
if ( checkLabelScanStore ) if ( checkLabelScanStore )
{ {
Expand Down

This file was deleted.

Expand Up @@ -19,6 +19,7 @@
*/ */
package org.neo4j.consistency.checking.full; package org.neo4j.consistency.checking.full;


import org.neo4j.collection.primitive.PrimitiveLongCollections;
import org.neo4j.consistency.checking.CheckerEngine; import org.neo4j.consistency.checking.CheckerEngine;
import org.neo4j.consistency.checking.ComparativeRecordChecker; import org.neo4j.consistency.checking.ComparativeRecordChecker;
import org.neo4j.consistency.checking.LabelChainWalker; import org.neo4j.consistency.checking.LabelChainWalker;
Expand All @@ -32,7 +33,6 @@
import org.neo4j.kernel.impl.store.record.DynamicRecord; import org.neo4j.kernel.impl.store.record.DynamicRecord;
import org.neo4j.kernel.impl.store.record.NodeRecord; import org.neo4j.kernel.impl.store.record.NodeRecord;


import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort; import static java.util.Arrays.sort;


public class NodeInUseWithCorrectLabelsCheck public class NodeInUseWithCorrectLabelsCheck
Expand All @@ -43,7 +43,13 @@ public class NodeInUseWithCorrectLabelsCheck


public NodeInUseWithCorrectLabelsCheck( long[] expectedLabels ) public NodeInUseWithCorrectLabelsCheck( long[] expectedLabels )
{ {
this.expectedLabels = expectedLabels; this.expectedLabels = sortAndDeduplicate( expectedLabels );
}

private long[] sortAndDeduplicate( long[] labels )
{
sort( labels );
return PrimitiveLongCollections.dedup( labels );
} }


@Override @Override
Expand Down Expand Up @@ -78,14 +84,40 @@ public void checkReference( RECORD record, NodeRecord nodeRecord,


private void validateLabelIds( NodeRecord nodeRecord, long[] actualLabels, REPORT report ) private void validateLabelIds( NodeRecord nodeRecord, long[] actualLabels, REPORT report )
{ {
sort(actualLabels); actualLabels = sortAndDeduplicate( actualLabels );
for ( long expectedLabel : expectedLabels )
int expectedIndex = 0;
int actualIndex = 0;

do
{ {
int labelIndex = binarySearch( actualLabels, expectedLabel ); long expectedLabel = expectedLabels[expectedIndex];
if (labelIndex < 0) long actualLabel = actualLabels[actualIndex];
{ if ( expectedLabel < actualLabel )
report.nodeDoesNotHaveExpectedLabel( nodeRecord, expectedLabel ); { // node store has a label which isn't in label scan store
report.nodeLabelNotInIndex( nodeRecord, expectedLabel );
expectedIndex++;
}
else if ( expectedLabel > actualLabel )
{ // label scan store has a label which isn't in node store
report.nodeDoesNotHaveExpectedLabel( nodeRecord, actualLabel );
actualIndex++;
} }
else
{ // both match
expectedIndex++;
actualIndex++;
}
}
while ( expectedIndex < expectedLabels.length && actualIndex < actualLabels.length );

while ( expectedIndex < expectedLabels.length )
{
report.nodeLabelNotInIndex( nodeRecord, expectedLabels[expectedIndex++] );
}
while ( actualIndex < actualLabels.length )
{
report.nodeDoesNotHaveExpectedLabel( nodeRecord, actualLabels[actualIndex++] );
} }
} }


Expand Down

This file was deleted.

Expand Up @@ -318,14 +318,6 @@ DynamicOwner.NameOwner owner( LabelTokenRecord record )
}; };
} }


@Override
public RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> decorateLabelMatchChecker(
RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> checker )
{
// TODO: Understand what this does.
return checker;
}

RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> decorateDynamicChecker( RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> decorateDynamicChecker(
final RecordType type, final RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> checker ) final RecordType type, final RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> checker )
{ {
Expand Down
Expand Up @@ -86,8 +86,6 @@ void forNodeLabelScan( LabelScanDocument document,
void forIndexEntry( IndexEntry entry, void forIndexEntry( IndexEntry entry,
RecordCheck<IndexEntry, ConsistencyReport.IndexConsistencyReport> checker ); RecordCheck<IndexEntry, ConsistencyReport.IndexConsistencyReport> checker );


void forNodeLabelMatch( NodeRecord nodeRecord, RecordCheck<NodeRecord, LabelsMatchReport> nodeLabelCheck );

void forRelationshipGroup( RelationshipGroupRecord record, void forRelationshipGroup( RelationshipGroupRecord record,
RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker ); RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker );


Expand Down Expand Up @@ -463,6 +461,8 @@ interface NodeInUseWithCorrectLabelsReport extends ConsistencyReport
void nodeNotInUse( NodeRecord referredNodeRecord ); void nodeNotInUse( NodeRecord referredNodeRecord );


void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId ); void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId );

void nodeLabelNotInIndex( NodeRecord referredNodeRecord, long missingLabelId );
} }


interface LabelScanConsistencyReport extends NodeInUseWithCorrectLabelsReport interface LabelScanConsistencyReport extends NodeInUseWithCorrectLabelsReport
Expand All @@ -474,6 +474,10 @@ interface LabelScanConsistencyReport extends NodeInUseWithCorrectLabelsReport
@Override @Override
@Documented( "This label scan document refers to a node that does not have the expected label." ) @Documented( "This label scan document refers to a node that does not have the expected label." )
void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId ); void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId );

@Override
@Documented( "This node record has a label that is not found in the label scan store entry for this node" )
void nodeLabelNotInIndex( NodeRecord referredNodeRecord, long missingLabelId );
} }


interface IndexConsistencyReport extends NodeInUseWithCorrectLabelsReport interface IndexConsistencyReport extends NodeInUseWithCorrectLabelsReport
Expand All @@ -485,11 +489,9 @@ interface IndexConsistencyReport extends NodeInUseWithCorrectLabelsReport
@Override @Override
@Documented( "This index entry refers to a node that does not have the expected label." ) @Documented( "This index entry refers to a node that does not have the expected label." )
void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId ); void nodeDoesNotHaveExpectedLabel( NodeRecord referredNodeRecord, long expectedLabelId );
}


interface LabelsMatchReport extends ConsistencyReport @Override
{ @Documented( "This node record has a label that is not found in the index for this node" )
@Documented( "This node record has a label that is not found in the label scan store entry for this node" )
void nodeLabelNotInIndex( NodeRecord referredNodeRecord, long missingLabelId ); void nodeLabelNotInIndex( NodeRecord referredNodeRecord, long missingLabelId );
} }


Expand Down
Expand Up @@ -60,8 +60,6 @@ public class ConsistencyReporter implements ConsistencyReport.Reporter
ProxyFactory.create( ConsistencyReport.SchemaConsistencyReport.class ); ProxyFactory.create( ConsistencyReport.SchemaConsistencyReport.class );
private static final ProxyFactory<ConsistencyReport.NodeConsistencyReport> NODE_REPORT = private static final ProxyFactory<ConsistencyReport.NodeConsistencyReport> NODE_REPORT =
ProxyFactory.create( ConsistencyReport.NodeConsistencyReport.class ); ProxyFactory.create( ConsistencyReport.NodeConsistencyReport.class );
private static final ProxyFactory<ConsistencyReport.LabelsMatchReport> LABEL_MATCH_REPORT =
ProxyFactory.create( ConsistencyReport.LabelsMatchReport.class );
private static final ProxyFactory<ConsistencyReport.RelationshipConsistencyReport> RELATIONSHIP_REPORT = private static final ProxyFactory<ConsistencyReport.RelationshipConsistencyReport> RELATIONSHIP_REPORT =
ProxyFactory.create( ConsistencyReport.RelationshipConsistencyReport.class ); ProxyFactory.create( ConsistencyReport.RelationshipConsistencyReport.class );
private static final ProxyFactory<ConsistencyReport.PropertyConsistencyReport> PROPERTY_REPORT = private static final ProxyFactory<ConsistencyReport.PropertyConsistencyReport> PROPERTY_REPORT =
Expand Down Expand Up @@ -426,12 +424,6 @@ public void forIndexEntry( IndexEntry entry,
dispatch( RecordType.INDEX, INDEX, entry, checker ); dispatch( RecordType.INDEX, INDEX, entry, checker );
} }


@Override
public void forNodeLabelMatch( NodeRecord nodeRecord, RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> nodeLabelCheck )
{
dispatch( RecordType.NODE, LABEL_MATCH_REPORT, nodeRecord, nodeLabelCheck );
}

@Override @Override
public void forPropertyKey( PropertyKeyTokenRecord key, public void forPropertyKey( PropertyKeyTokenRecord key,
RecordCheck<PropertyKeyTokenRecord, ConsistencyReport.PropertyKeyTokenConsistencyReport> checker ) RecordCheck<PropertyKeyTokenRecord, ConsistencyReport.PropertyKeyTokenConsistencyReport> checker )
Expand Down
Expand Up @@ -280,13 +280,6 @@ public RecordCheck<LabelTokenRecord, ConsistencyReport.LabelTokenConsistencyRepo
return logging( checker ); return logging( checker );
} }


@Override
public RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> decorateLabelMatchChecker(
RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> checker )
{
return logging( checker );
}

@Override @Override
public RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker( public RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> decorateRelationshipGroupChecker(
RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker ) RecordCheck<RelationshipGroupRecord, ConsistencyReport.RelationshipGroupConsistencyReport> checker )
Expand Down
Expand Up @@ -471,7 +471,7 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx,
ConsistencySummaryStatistics stats = check(); ConsistencySummaryStatistics stats = check();


// then // then
on( stats ).verify( RecordType.NODE, 1 ) on( stats ).verify( RecordType.LABEL_SCAN_DOCUMENT, 1 )
.andThatsAllFolks(); .andThatsAllFolks();
} }


Expand Down Expand Up @@ -513,7 +513,7 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx,
ConsistencySummaryStatistics stats = check(); ConsistencySummaryStatistics stats = check();


// then // then
on( stats ).verify( RecordType.NODE, 1 ) on( stats ).verify( RecordType.LABEL_SCAN_DOCUMENT, 1 )
.andThatsAllFolks(); .andThatsAllFolks();
} }


Expand Down
Expand Up @@ -81,7 +81,7 @@ public void shouldReportNodeWithoutExpectedLabelWhenLabelsAreInline() throws Exc
checker(new long[] {labelId1, labelId2}).checkReference( null, node, engineFor( report ), null ); checker(new long[] {labelId1, labelId2}).checkReference( null, node, engineFor( report ), null );


// then // then
verify( report ).nodeDoesNotHaveExpectedLabel( node, labelId2 ); verify( report ).nodeLabelNotInIndex( node, labelId2 );
} }


@Test @Test
Expand All @@ -105,7 +105,7 @@ public void shouldReportNodeWithoutExpectedLabelWhenLabelsAreDynamic() throws Ex
recordAccess.checkDeferred(); recordAccess.checkDeferred();


// then // then
verify( report ).nodeDoesNotHaveExpectedLabel( node, missingLabelId ); verify( report ).nodeLabelNotInIndex( node, missingLabelId );
} }


@Test @Test
Expand Down
Expand Up @@ -98,11 +98,6 @@ public void forIndexEntry( IndexEntry entry, RecordCheck<IndexEntry, Consistency
{ {
} }


@Override
public void forNodeLabelMatch( NodeRecord nodeRecord, RecordCheck<NodeRecord, ConsistencyReport.LabelsMatchReport> nodeLabelCheck )
{
}

@Override @Override
public void forRelationshipGroup( RelationshipGroupRecord record, public void forRelationshipGroup( RelationshipGroupRecord record,
RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> checker ) RecordCheck<RelationshipGroupRecord, RelationshipGroupConsistencyReport> checker )
Expand Down

0 comments on commit 6cbd79f

Please sign in to comment.