Skip to content

Commit

Permalink
Use label scan store for index population independent of number of af…
Browse files Browse the repository at this point in the history
…fected nodes
  • Loading branch information
burqen committed Jul 25, 2017
1 parent 09a18be commit 194d51e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
Expand Up @@ -124,8 +124,7 @@ private boolean useAllNodeStoreScan( int[] labelIds )
{ {
try try
{ {
return ArrayUtils.isEmpty( labelIds ) || isEmptyLabelScanStore() || return ArrayUtils.isEmpty( labelIds ) || isEmptyLabelScanStore();
isNumberOfLabeledNodesExceedThreshold( labelIds );
} }
catch ( Exception e ) catch ( Exception e )
{ {
Expand All @@ -139,16 +138,6 @@ private boolean isEmptyLabelScanStore() throws Exception
return labelScanStore.isEmpty(); return labelScanStore.isEmpty();
} }


private boolean isNumberOfLabeledNodesExceedThreshold( int[] labelIds )
{
return getNumberOfLabeledNodes( labelIds ) > getVisitAllNodesThreshold();
}

private long getVisitAllNodesThreshold()
{
return (long) ((VISIT_ALL_NODES_THRESHOLD_PERCENTAGE / 100f) * nodeStore.getHighestPossibleIdInUse());
}

private long getNumberOfLabeledNodes( int[] labelIds ) private long getNumberOfLabeledNodes( int[] labelIds )
{ {
return IntStream.of( labelIds ) return IntStream.of( labelIds )
Expand Down
Expand Up @@ -160,7 +160,7 @@ public void shouldPopulateIndexWithOneNode() throws Exception
IndexEntryUpdate update = IndexEntryUpdate.add( nodeId, descriptor, Values.of( value ) ); IndexEntryUpdate update = IndexEntryUpdate.add( nodeId, descriptor, Values.of( value ) );


verify( populator ).create(); verify( populator ).create();
verify( populator ).configureSampling( true ); verify( populator ).configureSampling( false );
verify( populator ).includeSample( update ); verify( populator ).includeSample( update );
verify( populator ).add( any( IndexEntryUpdate.class) ); verify( populator ).add( any( IndexEntryUpdate.class) );
verify( populator ).sampleResult(); verify( populator ).sampleResult();
Expand Down Expand Up @@ -208,7 +208,7 @@ public void shouldPopulateIndexWithASmallDataset() throws Exception
IndexEntryUpdate update2 = add( node4, descriptor, Values.of( value ) ); IndexEntryUpdate update2 = add( node4, descriptor, Values.of( value ) );


verify( populator ).create(); verify( populator ).create();
verify( populator ).configureSampling( true ); verify( populator ).configureSampling( false );
verify( populator ).includeSample( update1 ); verify( populator ).includeSample( update1 );
verify( populator ).includeSample( update2 ); verify( populator ).includeSample( update2 );
verify( populator, times( 2 ) ).add( any( IndexEntryUpdate.class ) ); verify( populator, times( 2 ) ).add( any( IndexEntryUpdate.class ) );
Expand Down
Expand Up @@ -74,28 +74,7 @@ public void setUp()
} }


@Test @Test
public void visitAllNodesWhenThresholdReached() throws Exception public void visitOnlyLabeledNodes() throws Exception
{
when( nodeStore.getHighestPossibleIdInUse() ).thenReturn( 10L );
when( nodeStore.getHighId() ).thenReturn( 10L );

mockLabelNodeCount( countStore, 1 );
mockLabelNodeCount( countStore, 2 );
mockLabelNodeCount( countStore, 3 );

DynamicIndexStoreView storeView = dynamicIndexStoreView();

StoreScan<Exception> storeScan = storeView
.visitNodes( new int[]{1, 2, 3}, propertyKeyIdFilter, propertyUpdateVisitor, labelUpdateVisitor, false );

storeScan.run();

Mockito.verify( nodeStore, times( 10 ) )
.getRecord( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ) );
}

@Test
public void visitOnlyLabeledNodesWhenThresholdNotReached() throws Exception
{ {
LabelScanReader labelScanReader = mock( LabelScanReader.class ); LabelScanReader labelScanReader = mock( LabelScanReader.class );
when( labelScanStore.newReader() ).thenReturn( labelScanReader ); when( labelScanStore.newReader() ).thenReturn( labelScanReader );
Expand Down

0 comments on commit 194d51e

Please sign in to comment.