mirror of https://github.com/apache/lucene.git
LUCENE-2045: fix false FNFE
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@833886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
786eb6ce0d
commit
6ae62295e9
|
@ -184,6 +184,10 @@ Bug fixes
|
||||||
char (U+FFFD) during indexing, to prevent silent index corruption.
|
char (U+FFFD) during indexing, to prevent silent index corruption.
|
||||||
(Peter Keegan, Mike McCandless)
|
(Peter Keegan, Mike McCandless)
|
||||||
|
|
||||||
|
* LUCENE-2045: Fix silly FileNotFoundException hit if you enable
|
||||||
|
infoStream on IndexWriter and then add an empty document and commit
|
||||||
|
(Shai Erera via Mike McCandless)
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
|
|
||||||
* Un-deprecate search(Weight weight, Filter filter, int n) from
|
* Un-deprecate search(Weight weight, Filter filter, int n) from
|
||||||
|
|
|
@ -584,7 +584,8 @@ final class DocumentsWriter {
|
||||||
consumer.flush(threads, flushState);
|
consumer.flush(threads, flushState);
|
||||||
|
|
||||||
if (infoStream != null) {
|
if (infoStream != null) {
|
||||||
final long newSegmentSize = segmentSize(flushState.segmentName);
|
SegmentInfo si = new SegmentInfo(flushState.segmentName, flushState.numDocs, directory);
|
||||||
|
final long newSegmentSize = si.sizeInBytes();
|
||||||
String message = " oldRAMSize=" + numBytesUsed +
|
String message = " oldRAMSize=" + numBytesUsed +
|
||||||
" newFlushedSize=" + newSegmentSize +
|
" newFlushedSize=" + newSegmentSize +
|
||||||
" docs/MB=" + nf.format(numDocsInRAM/(newSegmentSize/1024./1024.)) +
|
" docs/MB=" + nf.format(numDocsInRAM/(newSegmentSize/1024./1024.)) +
|
||||||
|
@ -1138,24 +1139,6 @@ final class DocumentsWriter {
|
||||||
|
|
||||||
NumberFormat nf = NumberFormat.getInstance();
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
|
|
||||||
// TODO FI: this is not flexible -- we can't hardwire
|
|
||||||
// extensions in here:
|
|
||||||
private long segmentSize(String segmentName) throws IOException {
|
|
||||||
// Used only when infoStream != null
|
|
||||||
assert infoStream != null;
|
|
||||||
|
|
||||||
long size = directory.fileLength(segmentName + ".tii") +
|
|
||||||
directory.fileLength(segmentName + ".tis") +
|
|
||||||
directory.fileLength(segmentName + ".frq") +
|
|
||||||
directory.fileLength(segmentName + ".prx");
|
|
||||||
|
|
||||||
final String normFileName = segmentName + ".nrm";
|
|
||||||
if (directory.fileExists(normFileName))
|
|
||||||
size += directory.fileLength(normFileName);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Coarse estimates used to measure RAM usage of buffered deletes
|
// Coarse estimates used to measure RAM usage of buffered deletes
|
||||||
final static int OBJECT_HEADER_BYTES = 8;
|
final static int OBJECT_HEADER_BYTES = 8;
|
||||||
final static int POINTER_NUM_BYTE = Constants.JRE_IS_64BIT ? 8 : 4;
|
final static int POINTER_NUM_BYTE = Constants.JRE_IS_64BIT ? 8 : 4;
|
||||||
|
|
|
@ -4572,4 +4572,17 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
_TestUtil.checkIndex(d);
|
_TestUtil.checkIndex(d);
|
||||||
d.close();
|
d.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNoDocsIndex() throws Throwable {
|
||||||
|
Directory dir = new MockRAMDirectory();
|
||||||
|
IndexWriter writer = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
|
||||||
|
writer.setUseCompoundFile(false);
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
|
||||||
|
writer.setInfoStream(new PrintStream(bos));
|
||||||
|
writer.addDocument(new Document());
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
_TestUtil.checkIndex(dir);
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue