A conversation with someone earlier today got me thinking about cranking
out a patch for SOLR-1559 (in which the goal is to allow for rules do
dermine the iput to optimize(maxNumSegments) instead of requiring a fixed
integer value as input) when i realized that i wasn't certain what
"approved" methods there might be for deterrmining hte current number of
segments from an IndexWriter.
I see IndexWriter.getSegmentCount() but it's package protected (with a
comment that it exists for tests). So my best guess using only public
APIs would be something like...
int numCurrentSegments = -1;
IndexReader r = writer.getReader();
try {
IndexReader[]tmp = r.getSequentialSubReaders();
numCurrentSegments = null==tmp ? 1 : tmp.length;
} finally {
r.close();
}
Is there a better way?
(My main concern about this approach being that my intuition (which seems
supported by the javadocs) is that getReader might be a little
expensive/excesive just to count the segments)
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org