Skip to content

Commit

Permalink
Fixes a test assumption about index sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Mar 12, 2018
1 parent 264e096 commit 65447ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -70,8 +70,8 @@ public void close()
@Override
public IndexSampler createSampler()
{
// For an unique index there's an optimization, knowing that all values in it are unique, to simply count
// the number of indexes values and create a sample for that count. The GBPTree doesn't have an O(1)
// For a unique index there's an optimization, knowing that all values in it are unique, to simply count
// the number of indexed values and create a sample for that count. The GBPTree doesn't have an O(1)
// count mechanism, it will have to manually count the indexed values in it to get it.
// For that reason this implementation opts for keeping complexity down by just using the existing
// non-unique sampler which scans the index and counts (potentially duplicates, of which there will
Expand Down
Expand Up @@ -51,7 +51,11 @@
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.TestDirectory;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

public class IndexSamplingIntegrationTest
{
Expand All @@ -60,7 +64,7 @@ public class IndexSamplingIntegrationTest

private final Label label = Label.label( "Person" );
private final String property = "name";
private final int nodes = 1000;
private final long nodes = 1000;
private final String[] names = {"Neo4j", "Neo", "Graph", "Apa"};

@Test
Expand Down Expand Up @@ -121,12 +125,12 @@ public void shouldSampleNotUniqueIndex() throws Throwable

// Then

// sampling will consider also the delete nodes till the next lucene compaction
// lucene will consider also the delete nodes, native won't
DoubleLongRegister register = fetchIndexSamplingValues( db );
assertEquals( names.length, register.readFirst() );
assertEquals( nodes, register.readSecond() );
assertThat( register.readSecond(), allOf( greaterThanOrEqualTo( nodes - deletedNodes ), lessThanOrEqualTo( nodes ) ) );

// but the deleted nodes should not be considered in the index size value
// but regardless, the deleted nodes should not be considered in the index size value
DoubleLongRegister indexSizeRegister = fetchIndexSizeValues( db );
assertEquals( 0, indexSizeRegister.readFirst() );
assertEquals( nodes - deletedNodes, indexSizeRegister.readSecond() );
Expand Down

0 comments on commit 65447ec

Please sign in to comment.