mirror of https://github.com/apache/lucene.git
woops, revert
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c2421c0929
commit
d01f0838e4
|
@ -468,22 +468,12 @@ def testChangesText(dir, version, project):
|
||||||
checkChangesContent(open(fullPath, encoding='UTF-8').read(), version, fullPath, project, False)
|
checkChangesContent(open(fullPath, encoding='UTF-8').read(), version, fullPath, project, False)
|
||||||
|
|
||||||
reChangesSectionHREF = re.compile('<a id="(.*?)".*?>(.*?)</a>', re.IGNORECASE)
|
reChangesSectionHREF = re.compile('<a id="(.*?)".*?>(.*?)</a>', re.IGNORECASE)
|
||||||
reUnderbarNotDashHTML = re.compile(r'<li>(\s*(LUCENE|SOLR)_\d\d\d\d+)')
|
|
||||||
reUnderbarNotDashTXT = re.compile(r'\s+((LUCENE|SOLR)_\d\d\d\d+)', re.MULTILINE)
|
|
||||||
def checkChangesContent(s, version, name, project, isHTML):
|
def checkChangesContent(s, version, name, project, isHTML):
|
||||||
|
|
||||||
if isHTML and s.find('Release %s' % version) == -1:
|
if isHTML and s.find('Release %s' % version) == -1:
|
||||||
raise RuntimeError('did not see "Release %s" in %s' % (version, name))
|
raise RuntimeError('did not see "Release %s" in %s' % (version, name))
|
||||||
|
|
||||||
if isHTML:
|
|
||||||
r = reUnderbarNotDashHTML
|
|
||||||
else:
|
|
||||||
r = reUnderbarNotDashTXT
|
|
||||||
|
|
||||||
m = r.search(s)
|
|
||||||
if m is not None:
|
|
||||||
raise RuntimeError('incorrect issue (_ instead of -) in %s: %s' % (name, m.group(1)))
|
|
||||||
|
|
||||||
if s.lower().find('not yet released') != -1:
|
if s.lower().find('not yet released') != -1:
|
||||||
raise RuntimeError('saw "not yet released" in %s' % name)
|
raise RuntimeError('saw "not yet released" in %s' % name)
|
||||||
|
|
||||||
|
|
|
@ -148,9 +148,7 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
// remember which readers are shared between the old and the re-opened
|
// remember which readers are shared between the old and the re-opened
|
||||||
// DirectoryReader - we have to incRef those readers
|
// DirectoryReader - we have to incRef those readers
|
||||||
boolean[] readerShared = new boolean[infos.size()];
|
boolean[] readerShared = new boolean[infos.size()];
|
||||||
|
|
||||||
System.out.println("CYCLE infos=" + infos.size());
|
|
||||||
|
|
||||||
for (int i = infos.size() - 1; i>=0; i--) {
|
for (int i = infos.size() - 1; i>=0; i--) {
|
||||||
// find SegmentReader for this segment
|
// find SegmentReader for this segment
|
||||||
Integer oldReaderIndex = segmentReaders.get(infos.info(i).info.name);
|
Integer oldReaderIndex = segmentReaders.get(infos.info(i).info.name);
|
||||||
|
@ -161,7 +159,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
// there is an old reader for this segment - we'll try to reopen it
|
// there is an old reader for this segment - we'll try to reopen it
|
||||||
newReaders[i] = (SegmentReader) oldReaders.get(oldReaderIndex.intValue());
|
newReaders[i] = (SegmentReader) oldReaders.get(oldReaderIndex.intValue());
|
||||||
}
|
}
|
||||||
System.out.println(" i=" + i + " newReaders[i]=" + newReaders[i]);
|
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
Throwable prior = null;
|
Throwable prior = null;
|
||||||
|
@ -174,7 +171,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
readerShared[i] = false;
|
readerShared[i] = false;
|
||||||
newReaders[i] = newReader;
|
newReaders[i] = newReader;
|
||||||
} else {
|
} else {
|
||||||
System.out.println(" now in else");
|
|
||||||
if (newReaders[i].getSegmentInfo().getDelGen() == infos.info(i).getDelGen()
|
if (newReaders[i].getSegmentInfo().getDelGen() == infos.info(i).getDelGen()
|
||||||
&& newReaders[i].getSegmentInfo().getFieldInfosGen() == infos.info(i).getFieldInfosGen()) {
|
&& newReaders[i].getSegmentInfo().getFieldInfosGen() == infos.info(i).getFieldInfosGen()) {
|
||||||
// No change; this reader will be shared between
|
// No change; this reader will be shared between
|
||||||
|
@ -183,7 +179,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
readerShared[i] = true;
|
readerShared[i] = true;
|
||||||
newReaders[i].incRef();
|
newReaders[i].incRef();
|
||||||
} else {
|
} else {
|
||||||
System.out.println(" has changes");
|
|
||||||
// there are changes to the reader, either liveDocs or DV updates
|
// there are changes to the reader, either liveDocs or DV updates
|
||||||
readerShared[i] = false;
|
readerShared[i] = false;
|
||||||
// Steal the ref returned by SegmentReader ctor:
|
// Steal the ref returned by SegmentReader ctor:
|
||||||
|
@ -196,7 +191,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
// both DV and liveDocs have changed
|
// both DV and liveDocs have changed
|
||||||
newReaders[i] = new SegmentReader(infos.info(i), newReaders[i]);
|
newReaders[i] = new SegmentReader(infos.info(i), newReaders[i]);
|
||||||
}
|
}
|
||||||
System.out.println(" done open");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -206,7 +200,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
for (i++; i < infos.size(); i++) {
|
for (i++; i < infos.size(); i++) {
|
||||||
if (newReaders[i] != null) {
|
if (newReaders[i] != null) {
|
||||||
System.out.println(" decRef i=" + i);
|
|
||||||
try {
|
try {
|
||||||
if (!readerShared[i]) {
|
if (!readerShared[i]) {
|
||||||
// this is a new subReader that is not used by the old one,
|
// this is a new subReader that is not used by the old one,
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.codecs.Codec;
|
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.FieldType;
|
import org.apache.lucene.document.FieldType;
|
||||||
|
@ -38,8 +37,6 @@ import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.search.ScoreDoc;
|
import org.apache.lucene.search.ScoreDoc;
|
||||||
import org.apache.lucene.search.TermQuery;
|
import org.apache.lucene.search.TermQuery;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper.FakeIOException;
|
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
|
@ -621,73 +618,4 @@ public class TestDirectoryReaderReopen extends LuceneTestCase {
|
||||||
r2.close();
|
r2.close();
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOverDecRefDuringReopen() throws Exception {
|
|
||||||
MockDirectoryWrapper dir = newMockDirectory();
|
|
||||||
|
|
||||||
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
|
||||||
iwc.setCodec(Codec.forName("Lucene46"));
|
|
||||||
IndexWriter w = new IndexWriter(dir, iwc);
|
|
||||||
Document doc = new Document();
|
|
||||||
doc.add(newStringField("id", "id", Field.Store.NO));
|
|
||||||
w.addDocument(doc);
|
|
||||||
doc = new Document();
|
|
||||||
doc.add(newStringField("id", "id2", Field.Store.NO));
|
|
||||||
w.addDocument(doc);
|
|
||||||
w.commit();
|
|
||||||
|
|
||||||
// Open reader w/ one segment w/ 2 docs:
|
|
||||||
DirectoryReader r = DirectoryReader.open(dir);
|
|
||||||
|
|
||||||
// Delete 1 doc from the segment:
|
|
||||||
System.out.println("TEST: now delete");
|
|
||||||
w.deleteDocuments(new Term("id", "id"));
|
|
||||||
System.out.println("TEST: now commit");
|
|
||||||
w.commit();
|
|
||||||
|
|
||||||
// Fail when reopen tries to open the live docs file:
|
|
||||||
dir.failOn(new MockDirectoryWrapper.Failure() {
|
|
||||||
|
|
||||||
int failCount;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void eval(MockDirectoryWrapper dir) throws IOException {
|
|
||||||
// Need to throw exc three times so the logic in
|
|
||||||
// SegmentInfos.FindSegmentsFile "really believes" us:
|
|
||||||
if (failCount >= 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//System.out.println("failOn: ");
|
|
||||||
//new Throwable().printStackTrace(System.out);
|
|
||||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
|
||||||
for (int i = 0; i < trace.length; i++) {
|
|
||||||
if ("readLiveDocs".equals(trace[i].getMethodName())) {
|
|
||||||
if (VERBOSE) {
|
|
||||||
System.out.println("TEST: now fail; exc:");
|
|
||||||
new Throwable().printStackTrace(System.out);
|
|
||||||
}
|
|
||||||
failCount++;
|
|
||||||
throw new FakeIOException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Now reopen:
|
|
||||||
System.out.println("TEST: now reopen");
|
|
||||||
try {
|
|
||||||
IndexReader r2 = DirectoryReader.openIfChanged(r);
|
|
||||||
System.out.println("got " + r2);
|
|
||||||
fail("didn't hit exception");
|
|
||||||
} catch (FakeIOException fio) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
IndexSearcher s = newSearcher(r);
|
|
||||||
assertEquals(1, s.search(new TermQuery(new Term("id", "id")), 1).totalHits);
|
|
||||||
|
|
||||||
r.close();
|
|
||||||
w.close();
|
|
||||||
dir.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue