Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Apr 20, 2016
1 parent 325fad5 commit 529d254
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Expand Up @@ -77,6 +77,11 @@ public void exclude( String value, long decrement )
}

public IndexSample result()
{
return result( -1 );
}

public IndexSample result( int numDocs )
{
if ( !values.isEmpty() )
{
Expand All @@ -86,7 +91,7 @@ public IndexSample result()
long uniqueValues = sampledSteps != 0 ? accumulatedUniqueValues / sampledSteps : 0;
long sampledSize = sampledSteps != 0 ? accumulatedSampledSize / sampledSteps : 0;

return new IndexSample( accumulatedSampledSize, uniqueValues, sampledSize );
return new IndexSample( numDocs < 0 ? accumulatedSampledSize : numDocs, uniqueValues, sampledSize );
}

private void nextStep()
Expand Down
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.kernel.api.impl.schema.sampler;

import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
Expand Down Expand Up @@ -58,7 +59,8 @@ public NonUniqueLuceneIndexSampler( IndexSearcher indexSearcher, TaskControl tas
protected IndexSample performSampling() throws IndexNotFoundKernelException
{
NonUniqueIndexSampler sampler = new NonUniqueIndexSampler( indexSamplingConfig.bufferSize() );
for ( LeafReaderContext readerContext : indexSearcher.getIndexReader().leaves() )
IndexReader indexReader = indexSearcher.getIndexReader();
for ( LeafReaderContext readerContext : indexReader.leaves() )
{
try
{
Expand All @@ -83,8 +85,9 @@ protected IndexSample performSampling() throws IndexNotFoundKernelException
throw new RuntimeException( e );
}
}
Thread.dumpStack();

return sampler.result();
return sampler.result( indexReader.numDocs() );
}

private static Set<String> getFieldNamesToSample( LeafReaderContext readerContext ) throws IOException
Expand Down
Expand Up @@ -206,10 +206,11 @@ private DoubleLongRegister fetchIndexSizeValues( GraphDatabaseService db )
try
{
// Then
db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir().getAbsolutePath() );
db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() );
@SuppressWarnings( "deprecation" )
GraphDatabaseAPI api = (GraphDatabaseAPI) db;
CountsTracker countsTracker = api.getDependencyResolver().resolveDependency( NeoStore.class ).getCounts();
CountsTracker countsTracker = api.getDependencyResolver().resolveDependency( RecordStorageEngine.class )
.testAccessNeoStores().getCounts();
IndexStatisticsKey key = CountsKeyFactory.indexStatisticsKey( 0, 0 ); // cheating a bit...
return countsTracker.get( key, Registers.newDoubleLongRegister() );
}
Expand Down

0 comments on commit 529d254

Please sign in to comment.