Skip to content

Commit dd0b245

Browse files
tarzanekvladak
authored andcommitted
lucene 9.5.0
1 parent 5218c10 commit dd0b245

File tree

11 files changed

+50
-25
lines changed

11 files changed

+50
-25
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/DirectoryHistoryReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import org.apache.lucene.document.DateTools;
4040
import org.apache.lucene.document.Document;
41+
import org.apache.lucene.index.StoredFields;
4142
import org.apache.lucene.queryparser.classic.ParseException;
4243
import org.apache.lucene.queryparser.classic.QueryParser;
4344
import org.apache.lucene.search.Query;
@@ -113,9 +114,10 @@ public DirectoryHistoryReader(String path) throws IOException {
113114
}
114115
if (hits != null) {
115116
// Get maximum MAX_RESULTS (why ? XXX) files which were changed recently.
117+
StoredFields storedFields = searcher.storedFields();
116118
for (int i = 0; i < MAX_RESULTS && i < hits.length; i++) {
117119
int docId = hits[i].doc;
118-
Document doc = searcher.doc(docId);
120+
Document doc = storedFields.document(docId);
119121
String rpath = doc.get(QueryBuilder.PATH);
120122
if (!rpath.startsWith(path)) {
121123
continue;

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettingsAccessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.lucene.index.IndexReader;
3232
import org.apache.lucene.index.IndexWriter;
3333
import org.apache.lucene.index.IndexableField;
34+
import org.apache.lucene.index.StoredFields;
3435
import org.apache.lucene.index.Term;
3536
import org.apache.lucene.queryparser.classic.ParseException;
3637
import org.apache.lucene.queryparser.classic.QueryParser;
@@ -92,8 +93,9 @@ public IndexAnalysisSettings3[] read(IndexReader reader, int n) throws IOExcepti
9293
IndexAnalysisSettings3[] res = new IndexAnalysisSettings3[nres];
9394

9495
IndexAnalysisSettingsUpgrader upgrader = new IndexAnalysisSettingsUpgrader();
96+
StoredFields storedFields = searcher.storedFields();
9597
for (int i = 0; i < nres; ++i) {
96-
Document doc = searcher.doc(top.scoreDocs[i].doc);
98+
Document doc = storedFields.document(top.scoreDocs[i].doc);
9799
IndexableField objser = doc.getField(QueryBuilder.OBJSER);
98100
int objver = readObjectVersion(doc);
99101
try {

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.apache.lucene.index.IndexableField;
7272
import org.apache.lucene.index.MultiTerms;
7373
import org.apache.lucene.index.PostingsEnum;
74+
import org.apache.lucene.index.StoredFields;
7475
import org.apache.lucene.index.Term;
7576
import org.apache.lucene.index.Terms;
7677
import org.apache.lucene.index.TermsEnum;
@@ -1003,9 +1004,10 @@ private void removeFileDocUid(String path) throws IOException {
10031004
// Determine if a reversal of counts is necessary, and execute if so.
10041005
if (isCountingDeltas) {
10051006
postsIter = uidIter.postings(postsIter);
1007+
StoredFields storedFields = reader.storedFields();
10061008
while (postsIter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
10071009
// Read a limited-fields version of the document.
1008-
Document doc = reader.document(postsIter.docID(), REVERT_COUNTS_FIELDS);
1010+
Document doc = storedFields.document(postsIter.docID(), REVERT_COUNTS_FIELDS);
10091011
if (doc != null) {
10101012
decrementLOCforDoc(path, doc);
10111013
break;
@@ -1926,7 +1928,7 @@ public static Document getDocument(File file) throws ParseException, IOException
19261928
// No hits, no document...
19271929
return null;
19281930
}
1929-
doc = searcher.doc(top.scoreDocs[0].doc);
1931+
doc = searcher.storedFields().document(top.scoreDocs[0].doc);
19301932
String foundPath = doc.get(QueryBuilder.PATH);
19311933

19321934
// Only use the document if we found an exact match.
@@ -2078,10 +2080,11 @@ boolean checkSettings(File file, String path) throws IOException {
20782080

20792081
int n = 0;
20802082
postsIter = uidIter.postings(postsIter);
2083+
StoredFields storedFields = reader.storedFields();
20812084
while (postsIter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
20822085
++n;
20832086
// Read a limited-fields version of the document.
2084-
Document doc = reader.document(postsIter.docID(), CHECK_FIELDS);
2087+
Document doc = storedFields.document(postsIter.docID(), CHECK_FIELDS);
20852088
if (doc == null) {
20862089
LOGGER.log(Level.FINER, "No Document: {0}", path);
20872090
continue;

opengrok-indexer/src/main/java/org/opengrok/indexer/index/NumLinesLOCAccessor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.lucene.document.StringField;
3131
import org.apache.lucene.index.IndexReader;
3232
import org.apache.lucene.index.IndexWriter;
33+
import org.apache.lucene.index.StoredFields;
3334
import org.apache.lucene.index.Term;
3435
import org.apache.lucene.queryparser.classic.ParseException;
3536
import org.apache.lucene.queryparser.classic.QueryParser;
@@ -122,9 +123,10 @@ private void storeBulk(IndexWriter writer, IndexReader reader,
122123
HashMap<String, Integer> byDir = new HashMap<>();
123124
int intMaximum = Integer.MAX_VALUE < searchResult.hits.totalHits.value ?
124125
Integer.MAX_VALUE : (int) searchResult.hits.totalHits.value;
126+
StoredFields storedFields = searchResult.searcher.storedFields();
125127
for (int i = 0; i < intMaximum; ++i) {
126128
int docID = searchResult.hits.scoreDocs[i].doc;
127-
Document doc = searchResult.searcher.doc(docID);
129+
Document doc = storedFields.document(docID);
128130
String dirPath = doc.get(QueryBuilder.D);
129131
byDir.put(dirPath, docID);
130132
}
@@ -168,7 +170,7 @@ private void updateDocumentData(IndexWriter writer, IndexSearcher searcher,
168170
long extantLines = 0;
169171

170172
if (docID != null) {
171-
Document doc = searcher.doc(docID);
173+
Document doc = searcher.storedFields().document(docID);
172174
if (isAggregatingDeltas) {
173175
extantLines = NumberUtils.toLong(doc.get(QueryBuilder.NUML));
174176
extantLOC = NumberUtils.toLong(doc.get(QueryBuilder.LOC));
@@ -191,8 +193,9 @@ private boolean processFileCounts(NumLinesLOCAggregator countsAggregator,
191193
IndexSearcher searcher, TopDocs hits) throws IOException {
192194

193195
boolean hasDefinedNumLines = false;
196+
StoredFields storedFields = searcher.storedFields();
194197
for (ScoreDoc sd : hits.scoreDocs) {
195-
Document d = searcher.doc(sd.doc);
198+
Document d = storedFields.document(sd.doc);
196199
NullableNumLinesLOC counts = NumLinesLOCUtil.read(d);
197200
if (counts.getNumLines() != null && counts.getLOC() != null) {
198201
NumLinesLOC defCounts = new NumLinesLOC(counts.getPath(),

opengrok-indexer/src/main/java/org/opengrok/indexer/search/DirectoryExtraReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.logging.Level;
3030
import java.util.logging.Logger;
3131
import org.apache.lucene.document.Document;
32+
import org.apache.lucene.index.StoredFields;
3233
import org.apache.lucene.queryparser.classic.ParseException;
3334
import org.apache.lucene.search.IndexSearcher;
3435
import org.apache.lucene.search.Query;
@@ -96,8 +97,9 @@ private List<NullableNumLinesLOC> processHits(IndexSearcher searcher, TopDocs hi
9697

9798
List<NullableNumLinesLOC> results = new ArrayList<>();
9899

100+
StoredFields storedFields = searcher.storedFields();
99101
for (ScoreDoc sd : hits.scoreDocs) {
100-
Document d = searcher.doc(sd.doc);
102+
Document d = storedFields.document(sd.doc);
101103
NullableNumLinesLOC extra = NumLinesLOCUtil.read(d);
102104
results.add(extra);
103105
}

opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.apache.lucene.document.Document;
4747
import org.apache.lucene.index.CorruptIndexException;
4848
import org.apache.lucene.index.IndexableField;
49+
import org.apache.lucene.index.StoredFields;
4950
import org.apache.lucene.search.IndexSearcher;
5051
import org.apache.lucene.search.ScoreDoc;
5152
import org.opengrok.indexer.analysis.AbstractAnalyzer;
@@ -91,9 +92,10 @@ private static Map<String, ArrayList<Integer>> createMap(
9192

9293
LinkedHashMap<String, ArrayList<Integer>> dirHash =
9394
new LinkedHashMap<>();
95+
StoredFields storedFields = searcher.storedFields();
9496
for (int i = startIdx; i < stopIdx; i++) {
9597
int docId = hits[i].doc;
96-
Document doc = searcher.doc(docId);
98+
Document doc = storedFields.document(docId);
9799

98100
String rpath = doc.get(QueryBuilder.PATH);
99101
if (rpath == null) {
@@ -202,8 +204,9 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
202204
xrefPrefix, tabSize, morePrefix);
203205

204206
out.write("</td></tr>");
207+
StoredFields storedFields = sh.getSearcher().storedFields();
205208
for (int docId : entry.getValue()) {
206-
Document doc = sh.getSearcher().doc(docId);
209+
Document doc = storedFields.document(docId);
207210
String rpath = doc.get(QueryBuilder.PATH);
208211
String rpathE = Util.uriEncodePath(rpath);
209212
if (evenRow) {

opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.lucene.document.Document;
4444
import org.apache.lucene.index.IndexableField;
4545
import org.apache.lucene.index.MultiReader;
46+
import org.apache.lucene.index.StoredFields;
4647
import org.apache.lucene.queryparser.classic.ParseException;
4748
import org.apache.lucene.search.IndexSearcher;
4849
import org.apache.lucene.search.Query;
@@ -216,9 +217,10 @@ private void searchIndex(IndexSearcher searcher, boolean paging) throws IOExcept
216217
searcher.search(query, collector);
217218
}
218219
hits = collector.topDocs().scoreDocs;
220+
StoredFields storedFields = searcher.storedFields();
219221
for (ScoreDoc hit : hits) {
220222
int docId = hit.doc;
221-
Document d = searcher.doc(docId);
223+
Document d = storedFields.document(docId);
222224
docs.add(d);
223225
}
224226
}
@@ -383,7 +385,7 @@ public Document doc(int docId) throws IOException {
383385
if (searcher == null) {
384386
throw new IllegalStateException("search(...) did not succeed");
385387
}
386-
return searcher.doc(docId);
388+
return searcher.storedFields().document(docId);
387389
}
388390

389391
/**
@@ -419,15 +421,21 @@ public void results(int start, int end, List<Hit> ret) {
419421
}
420422
hits = collector.topDocs().scoreDocs;
421423
Document d = null;
422-
for (int i = start; i < hits.length; i++) {
423-
int docId = hits[i].doc;
424+
StoredFields storedFields = null;
425+
try {
426+
storedFields = searcher.storedFields();
427+
} catch (Exception e) {
428+
LOGGER.log(
429+
Level.WARNING, SEARCH_EXCEPTION_MSG, e);
430+
}
431+
for (ScoreDoc hit : hits) {
424432
try {
425-
d = searcher.doc(docId);
433+
d = storedFields.document(hit.doc);
434+
docs.add(d);
426435
} catch (Exception e) {
427436
LOGGER.log(
428437
Level.SEVERE, SEARCH_EXCEPTION_MSG, e);
429438
}
430-
docs.add(d);
431439
}
432440
allCollected = true;
433441
}

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
140140

141141
Document doc;
142142
try {
143-
doc = searcher.doc(docId);
143+
doc = searcher.storedFields().document(docId);
144144
} catch (IOException e) {
145145
LOGGER.log(Level.WARNING, "ERROR getting searcher doc(int)", e);
146146
return false;

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.lucene.analysis.Analyzer;
3535
import org.apache.lucene.document.DateTools;
3636
import org.apache.lucene.document.Document;
37+
import org.apache.lucene.index.StoredFields;
3738
import org.apache.lucene.search.DocIdSetIterator;
3839
import org.apache.lucene.search.Query;
3940
import org.apache.lucene.search.uhighlight.UHComponents;
@@ -123,7 +124,7 @@ public String highlightFieldsUnion(String[] fields, Query query,
123124
* getIndexAnalyzer() (if it is called due to requiring ANALYSIS) can be
124125
* influenced by fileTypeName.
125126
*/
126-
Document doc = searcher.doc(docId);
127+
Document doc = searcher.storedFields().document(docId);
127128
fileTypeName = doc == null ? null : doc.get(QueryBuilder.TYPE);
128129
try {
129130
return highlightFieldsUnionWork(fields, query, docId, lineLimit);
@@ -207,12 +208,13 @@ protected List<CharSequence[]> loadFieldValues(String[] fields,
207208
cacheCharsThreshold == 0 ? 1 : (int) Math.min(64, docIter.cost()));
208209

209210
int sumChars = 0;
211+
StoredFields storedFields = searcher.storedFields();
210212
do {
211213
int docId = docIter.nextDoc();
212214
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
213215
break;
214216
}
215-
Document doc = searcher.doc(docId);
217+
Document doc = storedFields.document(docId);
216218

217219
String path = doc.get(QueryBuilder.PATH);
218220
String storedU = doc.get(QueryBuilder.U);

opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ private void maybeRedirectToDefinition(int docID, TermQuery termQuery)
509509
// Attempt to create a direct link to the definition if we search for
510510
// one single definition term AND we have exactly one match AND there
511511
// is only one definition of that symbol in the document that matches.
512-
Document doc = searcher.doc(docID);
512+
Document doc = searcher.storedFields().document(docID);
513513
IndexableField tagsField = doc.getField(QueryBuilder.TAGS);
514514
if (tagsField != null) {
515515
byte[] rawTags = tagsField.binaryValue().bytes;
@@ -532,7 +532,7 @@ private void maybeRedirectToMatchOffset(int docID, List<String> contextFields)
532532
* must be subsequently converted to a line number and that is tractable
533533
* only from plain text.
534534
*/
535-
Document doc = searcher.doc(docID);
535+
Document doc = searcher.storedFields().document(docID);
536536
String genre = doc.get(QueryBuilder.T);
537537
if (!AbstractAnalyzer.Genre.PLAIN.typeName().equals(genre)) {
538538
return;
@@ -569,7 +569,7 @@ private void maybeRedirectToMatchOffset(int docID, List<String> contextFields)
569569
}
570570

571571
private void redirectToFile(int docID) throws IOException {
572-
Document doc = searcher.doc(docID);
572+
Document doc = searcher.storedFields().document(docID);
573573
redirect = contextPath + Prefix.XREF_P + Util.uriEncodePath(doc.get(QueryBuilder.PATH));
574574
}
575575

@@ -746,7 +746,7 @@ public int searchSingle(File file) throws IOException,
746746
}
747747

748748
int docID = top.scoreDocs[0].doc;
749-
Document doc = searcher.doc(docID);
749+
Document doc = searcher.storedFields().document(docID);
750750

751751
String foundPath = doc.get(QueryBuilder.PATH);
752752
// Only use the result if PATH matches exactly.

0 commit comments

Comments
 (0)