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
{
return ArrayUtils.isEmpty( labelIds ) || isEmptyLabelScanStore() ||
isNumberOfLabeledNodesExceedThreshold( labelIds );
return ArrayUtils.isEmpty( labelIds ) || isEmptyLabelScanStore();
}
catch ( Exception e )
{
Expand All @@ -139,16 +138,6 @@ private boolean isEmptyLabelScanStore() throws Exception
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 )
{
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 ) );

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

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

@Test
public void visitAllNodesWhenThresholdReached() 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
public void visitOnlyLabeledNodes() throws Exception
{
LabelScanReader labelScanReader = mock( LabelScanReader.class );
when( labelScanStore.newReader() ).thenReturn( labelScanReader );
Expand Down

0 comments on commit 194d51e

Please sign in to comment.