mirror of https://github.com/apache/lucene.git
LUCENE-1257: More generified APIs and implementations. Also makes BooleanQuery implement Iterable for easy extended for loop on clauses. Thanks Kay Kay!
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@826213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58878dd20e
commit
975ce67fb5
|
@ -38,14 +38,14 @@ import org.apache.lucene.util.SortedVIntList;
|
||||||
|
|
||||||
public class BooleanFilter extends Filter
|
public class BooleanFilter extends Filter
|
||||||
{
|
{
|
||||||
ArrayList shouldFilters = null;
|
ArrayList<Filter> shouldFilters = null;
|
||||||
ArrayList notFilters = null;
|
ArrayList<Filter> notFilters = null;
|
||||||
ArrayList mustFilters = null;
|
ArrayList<Filter> mustFilters = null;
|
||||||
|
|
||||||
private DocIdSetIterator getDISI(ArrayList filters, int index, IndexReader reader)
|
private DocIdSetIterator getDISI(ArrayList<Filter> filters, int index, IndexReader reader)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return ((Filter)filters.get(index)).getDocIdSet(reader).iterator();
|
return filters.get(index).getDocIdSet(reader).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ public class BooleanFilter extends Filter
|
||||||
res = new OpenBitSetDISI(getDISI(notFilters, i, reader), reader.maxDoc());
|
res = new OpenBitSetDISI(getDISI(notFilters, i, reader), reader.maxDoc());
|
||||||
res.flip(0, reader.maxDoc()); // NOTE: may set bits on deleted docs
|
res.flip(0, reader.maxDoc()); // NOTE: may set bits on deleted docs
|
||||||
} else {
|
} else {
|
||||||
DocIdSet dis = ((Filter)notFilters.get(i)).getDocIdSet(reader);
|
DocIdSet dis = notFilters.get(i).getDocIdSet(reader);
|
||||||
if(dis instanceof OpenBitSet) {
|
if(dis instanceof OpenBitSet) {
|
||||||
// optimized case for OpenBitSets
|
// optimized case for OpenBitSets
|
||||||
res.andNot((OpenBitSet) dis);
|
res.andNot((OpenBitSet) dis);
|
||||||
|
@ -94,7 +94,7 @@ public class BooleanFilter extends Filter
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res = new OpenBitSetDISI(getDISI(mustFilters, i, reader), reader.maxDoc());
|
res = new OpenBitSetDISI(getDISI(mustFilters, i, reader), reader.maxDoc());
|
||||||
} else {
|
} else {
|
||||||
DocIdSet dis = ((Filter)mustFilters.get(i)).getDocIdSet(reader);
|
DocIdSet dis = mustFilters.get(i).getDocIdSet(reader);
|
||||||
if(dis instanceof OpenBitSet) {
|
if(dis instanceof OpenBitSet) {
|
||||||
// optimized case for OpenBitSets
|
// optimized case for OpenBitSets
|
||||||
res.and((OpenBitSet) dis);
|
res.and((OpenBitSet) dis);
|
||||||
|
@ -132,25 +132,25 @@ public class BooleanFilter extends Filter
|
||||||
{
|
{
|
||||||
if (filterClause.getOccur().equals(Occur.MUST)) {
|
if (filterClause.getOccur().equals(Occur.MUST)) {
|
||||||
if (mustFilters==null) {
|
if (mustFilters==null) {
|
||||||
mustFilters=new ArrayList();
|
mustFilters=new ArrayList<Filter>();
|
||||||
}
|
}
|
||||||
mustFilters.add(filterClause.getFilter());
|
mustFilters.add(filterClause.getFilter());
|
||||||
}
|
}
|
||||||
if (filterClause.getOccur().equals(Occur.SHOULD)) {
|
if (filterClause.getOccur().equals(Occur.SHOULD)) {
|
||||||
if (shouldFilters==null) {
|
if (shouldFilters==null) {
|
||||||
shouldFilters=new ArrayList();
|
shouldFilters=new ArrayList<Filter>();
|
||||||
}
|
}
|
||||||
shouldFilters.add(filterClause.getFilter());
|
shouldFilters.add(filterClause.getFilter());
|
||||||
}
|
}
|
||||||
if (filterClause.getOccur().equals(Occur.MUST_NOT)) {
|
if (filterClause.getOccur().equals(Occur.MUST_NOT)) {
|
||||||
if (notFilters==null) {
|
if (notFilters==null) {
|
||||||
notFilters=new ArrayList();
|
notFilters=new ArrayList<Filter>();
|
||||||
}
|
}
|
||||||
notFilters.add(filterClause.getFilter());
|
notFilters.add(filterClause.getFilter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equalFilters(ArrayList filters1, ArrayList filters2)
|
private boolean equalFilters(ArrayList<Filter> filters1, ArrayList<Filter> filters2)
|
||||||
{
|
{
|
||||||
return (filters1 == filters2) ||
|
return (filters1 == filters2) ||
|
||||||
((filters1 != null) && filters1.equals(filters2));
|
((filters1 != null) && filters1.equals(filters2));
|
||||||
|
@ -191,7 +191,7 @@ public class BooleanFilter extends Filter
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendFilters(ArrayList filters, String occurString, StringBuilder buffer)
|
private void appendFilters(ArrayList<Filter> filters, String occurString, StringBuilder buffer)
|
||||||
{
|
{
|
||||||
if (filters != null) {
|
if (filters != null) {
|
||||||
for (int i = 0; i < filters.size(); i++) {
|
for (int i = 0; i < filters.size(); i++) {
|
||||||
|
|
|
@ -26,8 +26,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class NormalizeCharMap {
|
public class NormalizeCharMap {
|
||||||
|
|
||||||
//Map<Character, NormalizeMap> submap;
|
Map<Character, NormalizeCharMap> submap;
|
||||||
Map submap;
|
|
||||||
String normStr;
|
String normStr;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
|
@ -44,9 +43,9 @@ public class NormalizeCharMap {
|
||||||
for(int i = 0; i < singleMatch.length(); i++) {
|
for(int i = 0; i < singleMatch.length(); i++) {
|
||||||
char c = singleMatch.charAt(i);
|
char c = singleMatch.charAt(i);
|
||||||
if (currMap.submap == null) {
|
if (currMap.submap == null) {
|
||||||
currMap.submap = new HashMap(1);
|
currMap.submap = new HashMap<Character, NormalizeCharMap>(1);
|
||||||
}
|
}
|
||||||
NormalizeCharMap map = (NormalizeCharMap) currMap.submap.get(CharacterCache.valueOf(c));
|
NormalizeCharMap map = currMap.submap.get(CharacterCache.valueOf(c));
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new NormalizeCharMap();
|
map = new NormalizeCharMap();
|
||||||
currMap.submap.put(new Character(c), map);
|
currMap.submap.put(new Character(c), map);
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class WordlistLoader {
|
||||||
* @param wordfile File containing the wordlist
|
* @param wordfile File containing the wordlist
|
||||||
* @return A HashSet with the file's words
|
* @return A HashSet with the file's words
|
||||||
*/
|
*/
|
||||||
public static HashSet getWordSet(File wordfile) throws IOException {
|
public static HashSet<String> getWordSet(File wordfile) throws IOException {
|
||||||
HashSet result = new HashSet();
|
HashSet<String> result = new HashSet<String>();
|
||||||
FileReader reader = null;
|
FileReader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new FileReader(wordfile);
|
reader = new FileReader(wordfile);
|
||||||
|
@ -63,8 +63,8 @@ public class WordlistLoader {
|
||||||
* @param comment The comment string to ignore
|
* @param comment The comment string to ignore
|
||||||
* @return A HashSet with the file's words
|
* @return A HashSet with the file's words
|
||||||
*/
|
*/
|
||||||
public static HashSet getWordSet(File wordfile, String comment) throws IOException {
|
public static HashSet<String> getWordSet(File wordfile, String comment) throws IOException {
|
||||||
HashSet result = new HashSet();
|
HashSet<String> result = new HashSet<String>();
|
||||||
FileReader reader = null;
|
FileReader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new FileReader(wordfile);
|
reader = new FileReader(wordfile);
|
||||||
|
@ -87,8 +87,8 @@ public class WordlistLoader {
|
||||||
* @param reader Reader containing the wordlist
|
* @param reader Reader containing the wordlist
|
||||||
* @return A HashSet with the reader's words
|
* @return A HashSet with the reader's words
|
||||||
*/
|
*/
|
||||||
public static HashSet getWordSet(Reader reader) throws IOException {
|
public static HashSet<String> getWordSet(Reader reader) throws IOException {
|
||||||
HashSet result = new HashSet();
|
HashSet<String> result = new HashSet<String>();
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
try {
|
try {
|
||||||
if (reader instanceof BufferedReader) {
|
if (reader instanceof BufferedReader) {
|
||||||
|
@ -118,8 +118,8 @@ public class WordlistLoader {
|
||||||
* @param comment The string representing a comment.
|
* @param comment The string representing a comment.
|
||||||
* @return A HashSet with the reader's words
|
* @return A HashSet with the reader's words
|
||||||
*/
|
*/
|
||||||
public static HashSet getWordSet(Reader reader, String comment) throws IOException {
|
public static HashSet<String> getWordSet(Reader reader, String comment) throws IOException {
|
||||||
HashSet result = new HashSet();
|
HashSet<String> result = new HashSet<String>();
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
try {
|
try {
|
||||||
if (reader instanceof BufferedReader) {
|
if (reader instanceof BufferedReader) {
|
||||||
|
@ -151,10 +151,10 @@ public class WordlistLoader {
|
||||||
* @return stem dictionary that overrules the stemming algorithm
|
* @return stem dictionary that overrules the stemming algorithm
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static HashMap getStemDict(File wordstemfile) throws IOException {
|
public static HashMap<String, String> getStemDict(File wordstemfile) throws IOException {
|
||||||
if (wordstemfile == null)
|
if (wordstemfile == null)
|
||||||
throw new NullPointerException("wordstemfile may not be null");
|
throw new NullPointerException("wordstemfile may not be null");
|
||||||
HashMap result = new HashMap();
|
HashMap<String, String> result = new HashMap<String, String>();
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
FileReader fr = null;
|
FileReader fr = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -20,9 +20,10 @@ package org.apache.lucene.index;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.lucene.search.Query;
|
||||||
|
|
||||||
/** Holds buffered deletes, by docID, term or query. We
|
/** Holds buffered deletes, by docID, term or query. We
|
||||||
* hold two instances of this class: one for the deletes
|
* hold two instances of this class: one for the deletes
|
||||||
* prior to the last flush, the other for deletes after
|
* prior to the last flush, the other for deletes after
|
||||||
|
@ -32,9 +33,9 @@ import java.util.Map.Entry;
|
||||||
* previously flushed segments. */
|
* previously flushed segments. */
|
||||||
class BufferedDeletes {
|
class BufferedDeletes {
|
||||||
int numTerms;
|
int numTerms;
|
||||||
HashMap terms = new HashMap();
|
HashMap<Term,Num> terms = new HashMap<Term,Num>();
|
||||||
HashMap queries = new HashMap();
|
HashMap<Query,Integer> queries = new HashMap<Query,Integer>();
|
||||||
List docIDs = new ArrayList();
|
List<Integer> docIDs = new ArrayList<Integer>();
|
||||||
long bytesUsed;
|
long bytesUsed;
|
||||||
|
|
||||||
// Number of documents a delete term applies to.
|
// Number of documents a delete term applies to.
|
||||||
|
@ -103,42 +104,38 @@ class BufferedDeletes {
|
||||||
MergePolicy.OneMerge merge,
|
MergePolicy.OneMerge merge,
|
||||||
int mergeDocCount) {
|
int mergeDocCount) {
|
||||||
|
|
||||||
final HashMap newDeleteTerms;
|
final HashMap<Term,Num> newDeleteTerms;
|
||||||
|
|
||||||
// Remap delete-by-term
|
// Remap delete-by-term
|
||||||
if (terms.size() > 0) {
|
if (terms.size() > 0) {
|
||||||
newDeleteTerms = new HashMap();
|
newDeleteTerms = new HashMap<Term, Num>();
|
||||||
Iterator iter = terms.entrySet().iterator();
|
for(Entry<Term,Num> entry : terms.entrySet()) {
|
||||||
while(iter.hasNext()) {
|
Num num = entry.getValue();
|
||||||
Entry entry = (Entry) iter.next();
|
|
||||||
Num num = (Num) entry.getValue();
|
|
||||||
newDeleteTerms.put(entry.getKey(),
|
newDeleteTerms.put(entry.getKey(),
|
||||||
new Num(mapper.remap(num.getNum())));
|
new Num(mapper.remap(num.getNum())));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
newDeleteTerms = null;
|
newDeleteTerms = null;
|
||||||
|
|
||||||
|
|
||||||
// Remap delete-by-docID
|
// Remap delete-by-docID
|
||||||
final List newDeleteDocIDs;
|
final List<Integer> newDeleteDocIDs;
|
||||||
|
|
||||||
if (docIDs.size() > 0) {
|
if (docIDs.size() > 0) {
|
||||||
newDeleteDocIDs = new ArrayList(docIDs.size());
|
newDeleteDocIDs = new ArrayList<Integer>(docIDs.size());
|
||||||
Iterator iter = docIDs.iterator();
|
for (Integer num : docIDs) {
|
||||||
while(iter.hasNext()) {
|
|
||||||
Integer num = (Integer) iter.next();
|
|
||||||
newDeleteDocIDs.add(Integer.valueOf(mapper.remap(num.intValue())));
|
newDeleteDocIDs.add(Integer.valueOf(mapper.remap(num.intValue())));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
newDeleteDocIDs = null;
|
newDeleteDocIDs = null;
|
||||||
|
|
||||||
|
|
||||||
// Remap delete-by-query
|
// Remap delete-by-query
|
||||||
final HashMap newDeleteQueries;
|
final HashMap<Query,Integer> newDeleteQueries;
|
||||||
|
|
||||||
if (queries.size() > 0) {
|
if (queries.size() > 0) {
|
||||||
newDeleteQueries = new HashMap(queries.size());
|
newDeleteQueries = new HashMap<Query, Integer>(queries.size());
|
||||||
Iterator iter = queries.entrySet().iterator();
|
for(Entry<Query,Integer> entry: queries.entrySet()) {
|
||||||
while(iter.hasNext()) {
|
|
||||||
Entry entry = (Entry) iter.next();
|
|
||||||
Integer num = (Integer) entry.getValue();
|
Integer num = (Integer) entry.getValue();
|
||||||
newDeleteQueries.put(entry.getKey(),
|
newDeleteQueries.put(entry.getKey(),
|
||||||
Integer.valueOf(mapper.remap(num.intValue())));
|
Integer.valueOf(mapper.remap(num.intValue())));
|
||||||
|
|
|
@ -83,13 +83,13 @@ public class CheckIndex {
|
||||||
|
|
||||||
/** Empty unless you passed specific segments list to check as optional 3rd argument.
|
/** Empty unless you passed specific segments list to check as optional 3rd argument.
|
||||||
* @see CheckIndex#checkIndex(List) */
|
* @see CheckIndex#checkIndex(List) */
|
||||||
public List/*<String>*/ segmentsChecked = new ArrayList();
|
public List<String> segmentsChecked = new ArrayList<String>();
|
||||||
|
|
||||||
/** True if the index was created with a newer version of Lucene than the CheckIndex tool. */
|
/** True if the index was created with a newer version of Lucene than the CheckIndex tool. */
|
||||||
public boolean toolOutOfDate;
|
public boolean toolOutOfDate;
|
||||||
|
|
||||||
/** List of {@link SegmentInfoStatus} instances, detailing status of each segment. */
|
/** List of {@link SegmentInfoStatus} instances, detailing status of each segment. */
|
||||||
public List/*<SegmentInfoStatus*/ segmentInfos = new ArrayList();
|
public List<SegmentInfoStatus> segmentInfos = new ArrayList<SegmentInfoStatus>();
|
||||||
|
|
||||||
/** Directory index is in. */
|
/** Directory index is in. */
|
||||||
public Directory dir;
|
public Directory dir;
|
||||||
|
@ -544,7 +544,7 @@ public class CheckIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keeper
|
// Keeper
|
||||||
result.newSegments.add(info.clone());
|
result.newSegments.add((SegmentInfo) info.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == result.numBadSegments) {
|
if (0 == result.numBadSegments) {
|
||||||
|
|
|
@ -968,15 +968,13 @@ final class DocumentsWriter {
|
||||||
boolean any = false;
|
boolean any = false;
|
||||||
|
|
||||||
// Delete by term
|
// Delete by term
|
||||||
Iterator iter = deletesFlushed.terms.entrySet().iterator();
|
|
||||||
TermDocs docs = reader.termDocs();
|
TermDocs docs = reader.termDocs();
|
||||||
try {
|
try {
|
||||||
while (iter.hasNext()) {
|
for (Entry<Term, BufferedDeletes.Num> entry: deletesFlushed.terms.entrySet()) {
|
||||||
Entry entry = (Entry) iter.next();
|
Term term = entry.getKey();
|
||||||
Term term = (Term) entry.getKey();
|
|
||||||
|
|
||||||
docs.seek(term);
|
docs.seek(term);
|
||||||
int limit = ((BufferedDeletes.Num) entry.getValue()).getNum();
|
int limit = entry.getValue().getNum();
|
||||||
while (docs.next()) {
|
while (docs.next()) {
|
||||||
int docID = docs.doc();
|
int docID = docs.doc();
|
||||||
if (docIDStart+docID >= limit)
|
if (docIDStart+docID >= limit)
|
||||||
|
@ -990,9 +988,8 @@ final class DocumentsWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete by docID
|
// Delete by docID
|
||||||
iter = deletesFlushed.docIDs.iterator();
|
for (Integer docIdInt : deletesFlushed.docIDs) {
|
||||||
while(iter.hasNext()) {
|
int docID = docIdInt.intValue();
|
||||||
int docID = ((Integer) iter.next()).intValue();
|
|
||||||
if (docID >= docIDStart && docID < docEnd) {
|
if (docID >= docIDStart && docID < docEnd) {
|
||||||
reader.deleteDocument(docID-docIDStart);
|
reader.deleteDocument(docID-docIDStart);
|
||||||
any = true;
|
any = true;
|
||||||
|
@ -1001,11 +998,9 @@ final class DocumentsWriter {
|
||||||
|
|
||||||
// Delete by query
|
// Delete by query
|
||||||
IndexSearcher searcher = new IndexSearcher(reader);
|
IndexSearcher searcher = new IndexSearcher(reader);
|
||||||
iter = deletesFlushed.queries.entrySet().iterator();
|
for (Entry<Query, Integer> entry : deletesFlushed.queries.entrySet()) {
|
||||||
while(iter.hasNext()) {
|
Query query = entry.getKey();
|
||||||
Entry entry = (Entry) iter.next();
|
int limit = entry.getValue().intValue();
|
||||||
Query query = (Query) entry.getKey();
|
|
||||||
int limit = ((Integer) entry.getValue()).intValue();
|
|
||||||
Weight weight = query.weight(searcher);
|
Weight weight = query.weight(searcher);
|
||||||
Scorer scorer = weight.scorer(reader, true, false);
|
Scorer scorer = weight.scorer(reader, true, false);
|
||||||
if (scorer != null) {
|
if (scorer != null) {
|
||||||
|
@ -1027,7 +1022,7 @@ final class DocumentsWriter {
|
||||||
// delete term will be applied to those documents as well
|
// delete term will be applied to those documents as well
|
||||||
// as the disk segments.
|
// as the disk segments.
|
||||||
synchronized private void addDeleteTerm(Term term, int docCount) {
|
synchronized private void addDeleteTerm(Term term, int docCount) {
|
||||||
BufferedDeletes.Num num = (BufferedDeletes.Num) deletesInRAM.terms.get(term);
|
BufferedDeletes.Num num = deletesInRAM.terms.get(term);
|
||||||
final int docIDUpto = flushedDocCount + docCount;
|
final int docIDUpto = flushedDocCount + docCount;
|
||||||
if (num == null)
|
if (num == null)
|
||||||
deletesInRAM.terms.put(term, new BufferedDeletes.Num(docIDUpto));
|
deletesInRAM.terms.put(term, new BufferedDeletes.Num(docIDUpto));
|
||||||
|
|
|
@ -73,7 +73,7 @@ public final class SegmentInfo {
|
||||||
// and true for newly created merged segments (both
|
// and true for newly created merged segments (both
|
||||||
// compound and non compound).
|
// compound and non compound).
|
||||||
|
|
||||||
private List files; // cached list of files that this segment uses
|
private List<String> files; // cached list of files that this segment uses
|
||||||
// in the Directory
|
// in the Directory
|
||||||
|
|
||||||
long sizeInBytes = -1; // total byte size of all of our files (computed on demand)
|
long sizeInBytes = -1; // total byte size of all of our files (computed on demand)
|
||||||
|
@ -583,14 +583,14 @@ public final class SegmentInfo {
|
||||||
* modify it.
|
* modify it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public List files() throws IOException {
|
public List<String> files() throws IOException {
|
||||||
|
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
// Already cached:
|
// Already cached:
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
files = new ArrayList();
|
files = new ArrayList<String>();
|
||||||
|
|
||||||
boolean useCompoundFile = getUseCompoundFile();
|
boolean useCompoundFile = getUseCompoundFile();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import java.util.Map;
|
||||||
* <p><b>NOTE:</b> This API is new and still experimental
|
* <p><b>NOTE:</b> This API is new and still experimental
|
||||||
* (subject to change suddenly in the next release)</p>
|
* (subject to change suddenly in the next release)</p>
|
||||||
*/
|
*/
|
||||||
public final class SegmentInfos extends Vector {
|
public final class SegmentInfos extends Vector<SegmentInfo> {
|
||||||
|
|
||||||
/** The file format version, a negative number. */
|
/** The file format version, a negative number. */
|
||||||
/* Works since counter, the old 1st entry, is always >= 0 */
|
/* Works since counter, the old 1st entry, is always >= 0 */
|
||||||
|
@ -103,7 +103,7 @@ public final class SegmentInfos extends Vector {
|
||||||
// or wrote; this is normally the same as generation except if
|
// or wrote; this is normally the same as generation except if
|
||||||
// there was an IOException that had interrupted a commit
|
// there was an IOException that had interrupted a commit
|
||||||
|
|
||||||
private Map userData = Collections.EMPTY_MAP; // Opaque Map<String, String> that user can specify during IndexWriter.commit
|
private Map<String,String> userData = Collections.<String,String>emptyMap(); // Opaque Map<String, String> that user can specify during IndexWriter.commit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If non-null, information about loading segments_N files
|
* If non-null, information about loading segments_N files
|
||||||
|
@ -269,10 +269,10 @@ public final class SegmentInfos extends Vector {
|
||||||
} else if (0 != input.readByte()) {
|
} else if (0 != input.readByte()) {
|
||||||
userData = Collections.singletonMap("userData", input.readString());
|
userData = Collections.singletonMap("userData", input.readString());
|
||||||
} else {
|
} else {
|
||||||
userData = Collections.EMPTY_MAP;
|
userData = Collections.<String,String>emptyMap();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userData = Collections.EMPTY_MAP;
|
userData = Collections.<String,String>emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format <= FORMAT_CHECKSUM) {
|
if (format <= FORMAT_CHECKSUM) {
|
||||||
|
@ -372,9 +372,9 @@ public final class SegmentInfos extends Vector {
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
SegmentInfos sis = (SegmentInfos) super.clone();
|
SegmentInfos sis = (SegmentInfos) super.clone();
|
||||||
for(int i=0;i<sis.size();i++) {
|
for(int i=0;i<sis.size();i++) {
|
||||||
sis.set(i, sis.info(i).clone());
|
sis.set(i, (SegmentInfo) sis.info(i).clone());
|
||||||
}
|
}
|
||||||
sis.userData = new HashMap(userData);
|
sis.userData = new HashMap<String, String>(userData);
|
||||||
return sis;
|
return sis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ public final class SegmentInfos extends Vector {
|
||||||
* @throws CorruptIndexException if the index is corrupt
|
* @throws CorruptIndexException if the index is corrupt
|
||||||
* @throws IOException if there is a low-level IO error
|
* @throws IOException if there is a low-level IO error
|
||||||
*/
|
*/
|
||||||
public static Map readCurrentUserData(Directory directory)
|
public static Map<String,String> readCurrentUserData(Directory directory)
|
||||||
throws CorruptIndexException, IOException {
|
throws CorruptIndexException, IOException {
|
||||||
SegmentInfos sis = new SegmentInfos();
|
SegmentInfos sis = new SegmentInfos();
|
||||||
sis.read(directory);
|
sis.read(directory);
|
||||||
|
@ -814,8 +814,8 @@ public final class SegmentInfos extends Vector {
|
||||||
* associated with any "external" segments are skipped).
|
* associated with any "external" segments are skipped).
|
||||||
* The returned collection is recomputed on each
|
* The returned collection is recomputed on each
|
||||||
* invocation. */
|
* invocation. */
|
||||||
public Collection files(Directory dir, boolean includeSegmentsFile) throws IOException {
|
public Collection<String> files(Directory dir, boolean includeSegmentsFile) throws IOException {
|
||||||
HashSet files = new HashSet();
|
HashSet<String> files = new HashSet<String>();
|
||||||
if (includeSegmentsFile) {
|
if (includeSegmentsFile) {
|
||||||
files.add(getCurrentSegmentFileName());
|
files.add(getCurrentSegmentFileName());
|
||||||
}
|
}
|
||||||
|
@ -909,13 +909,13 @@ public final class SegmentInfos extends Vector {
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getUserData() {
|
public Map<String,String> getUserData() {
|
||||||
return userData;
|
return userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUserData(Map data) {
|
void setUserData(Map<String,String> data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
userData = Collections.EMPTY_MAP;
|
userData = Collections.<String,String>emptyMap();
|
||||||
} else {
|
} else {
|
||||||
userData = data;
|
userData = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.*;
|
||||||
* queries, e.g. {@link TermQuery}s, {@link PhraseQuery}s or other
|
* queries, e.g. {@link TermQuery}s, {@link PhraseQuery}s or other
|
||||||
* BooleanQuerys.
|
* BooleanQuerys.
|
||||||
*/
|
*/
|
||||||
public class BooleanQuery extends Query {
|
public class BooleanQuery extends Query implements Iterable<BooleanClause> {
|
||||||
|
|
||||||
private static int maxClauseCount = 1024;
|
private static int maxClauseCount = 1024;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class BooleanQuery extends Query {
|
||||||
BooleanQuery.maxClauseCount = maxClauseCount;
|
BooleanQuery.maxClauseCount = maxClauseCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList clauses = new ArrayList();
|
private ArrayList<BooleanClause> clauses = new ArrayList<BooleanClause>();
|
||||||
private boolean disableCoord;
|
private boolean disableCoord;
|
||||||
|
|
||||||
/** Constructs an empty boolean query. */
|
/** Constructs an empty boolean query. */
|
||||||
|
@ -158,11 +158,17 @@ public class BooleanQuery extends Query {
|
||||||
|
|
||||||
/** Returns the set of clauses in this query. */
|
/** Returns the set of clauses in this query. */
|
||||||
public BooleanClause[] getClauses() {
|
public BooleanClause[] getClauses() {
|
||||||
return (BooleanClause[])clauses.toArray(new BooleanClause[clauses.size()]);
|
return clauses.toArray(new BooleanClause[clauses.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the list of clauses in this query. */
|
/** Returns the list of clauses in this query. */
|
||||||
public List clauses() { return clauses; }
|
public List<BooleanClause> clauses() { return clauses; }
|
||||||
|
|
||||||
|
/** Returns an iterator on the clauses in this query. It implements the {@link Iterable} interface to
|
||||||
|
* make it possible to do:
|
||||||
|
* <pre>for (BooleanClause clause : booleanQuery) {}</pre>
|
||||||
|
*/
|
||||||
|
public final Iterator<BooleanClause> iterator() { return clauses().iterator(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expert: the Weight for BooleanQuery, used to
|
* Expert: the Weight for BooleanQuery, used to
|
||||||
|
@ -174,21 +180,25 @@ public class BooleanQuery extends Query {
|
||||||
protected class BooleanWeight extends Weight {
|
protected class BooleanWeight extends Weight {
|
||||||
/** The Similarity implementation. */
|
/** The Similarity implementation. */
|
||||||
protected Similarity similarity;
|
protected Similarity similarity;
|
||||||
protected ArrayList weights;
|
protected ArrayList<Weight> weights;
|
||||||
|
|
||||||
public BooleanWeight(Searcher searcher)
|
public BooleanWeight(Searcher searcher)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
this.similarity = getSimilarity(searcher);
|
this.similarity = getSimilarity(searcher);
|
||||||
weights = new ArrayList(clauses.size());
|
weights = new ArrayList<Weight>(clauses.size());
|
||||||
for (int i = 0 ; i < clauses.size(); i++) {
|
for (int i = 0 ; i < clauses.size(); i++) {
|
||||||
BooleanClause c = (BooleanClause)clauses.get(i);
|
BooleanClause c = (BooleanClause)clauses.get(i);
|
||||||
weights.add(c.getQuery().createWeight(searcher));
|
weights.add(c.getQuery().createWeight(searcher));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Query getQuery() { return BooleanQuery.this; }
|
public Query getQuery() { return BooleanQuery.this; }
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getValue() { return getBoost(); }
|
public float getValue() { return getBoost(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
public float sumOfSquaredWeights() throws IOException {
|
public float sumOfSquaredWeights() throws IOException {
|
||||||
float sum = 0.0f;
|
float sum = 0.0f;
|
||||||
for (int i = 0 ; i < weights.size(); i++) {
|
for (int i = 0 ; i < weights.size(); i++) {
|
||||||
|
@ -207,15 +217,16 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void normalize(float norm) {
|
public void normalize(float norm) {
|
||||||
norm *= getBoost(); // incorporate boost
|
norm *= getBoost(); // incorporate boost
|
||||||
for (Iterator iter = weights.iterator(); iter.hasNext();) {
|
for (Weight w : weights) {
|
||||||
Weight w = (Weight) iter.next();
|
|
||||||
// normalize all clauses, (even if prohibited in case of side affects)
|
// normalize all clauses, (even if prohibited in case of side affects)
|
||||||
w.normalize(norm);
|
w.normalize(norm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Explanation explain(IndexReader reader, int doc)
|
public Explanation explain(IndexReader reader, int doc)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final int minShouldMatch =
|
final int minShouldMatch =
|
||||||
|
@ -227,9 +238,10 @@ public class BooleanQuery extends Query {
|
||||||
float sum = 0.0f;
|
float sum = 0.0f;
|
||||||
boolean fail = false;
|
boolean fail = false;
|
||||||
int shouldMatchCount = 0;
|
int shouldMatchCount = 0;
|
||||||
for (Iterator wIter = weights.iterator(), cIter = clauses.iterator(); wIter.hasNext();) {
|
Iterator<BooleanClause> cIter = clauses.iterator();
|
||||||
Weight w = (Weight) wIter.next();
|
for (Iterator<Weight> wIter = weights.iterator(); wIter.hasNext();) {
|
||||||
BooleanClause c = (BooleanClause) cIter.next();
|
Weight w = wIter.next();
|
||||||
|
BooleanClause c = cIter.next();
|
||||||
if (w.scorer(reader, true, true) == null) {
|
if (w.scorer(reader, true, true) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -287,14 +299,15 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
|
public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
List required = new ArrayList();
|
List<Scorer> required = new ArrayList<Scorer>();
|
||||||
List prohibited = new ArrayList();
|
List<Scorer> prohibited = new ArrayList<Scorer>();
|
||||||
List optional = new ArrayList();
|
List<Scorer> optional = new ArrayList<Scorer>();
|
||||||
for (Iterator wIter = weights.iterator(), cIter = clauses.iterator(); wIter.hasNext();) {
|
Iterator<BooleanClause> cIter = clauses.iterator();
|
||||||
Weight w = (Weight) wIter.next();
|
for (Weight w : weights) {
|
||||||
BooleanClause c = (BooleanClause) cIter.next();
|
BooleanClause c = cIter.next();
|
||||||
Scorer subScorer = w.scorer(reader, true, false);
|
Scorer subScorer = w.scorer(reader, true, false);
|
||||||
if (subScorer == null) {
|
if (subScorer == null) {
|
||||||
if (c.isRequired()) {
|
if (c.isRequired()) {
|
||||||
|
@ -328,10 +341,10 @@ public class BooleanQuery extends Query {
|
||||||
return new BooleanScorer2(similarity, minNrShouldMatch, required, prohibited, optional);
|
return new BooleanScorer2(similarity, minNrShouldMatch, required, prohibited, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean scoresDocsOutOfOrder() {
|
public boolean scoresDocsOutOfOrder() {
|
||||||
int numProhibited = 0;
|
int numProhibited = 0;
|
||||||
for (Iterator cIter = clauses.iterator(); cIter.hasNext();) {
|
for (BooleanClause c : clauses) {
|
||||||
BooleanClause c = (BooleanClause) cIter.next();
|
|
||||||
if (c.isRequired()) {
|
if (c.isRequired()) {
|
||||||
return false; // BS2 (in-order) will be used by scorer()
|
return false; // BS2 (in-order) will be used by scorer()
|
||||||
} else if (c.isProhibited()) {
|
} else if (c.isProhibited()) {
|
||||||
|
@ -349,10 +362,12 @@ public class BooleanQuery extends Query {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Weight createWeight(Searcher searcher) throws IOException {
|
public Weight createWeight(Searcher searcher) throws IOException {
|
||||||
return new BooleanWeight(searcher);
|
return new BooleanWeight(searcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Query rewrite(IndexReader reader) throws IOException {
|
public Query rewrite(IndexReader reader) throws IOException {
|
||||||
if (minNrShouldMatch == 0 && clauses.size() == 1) { // optimize 1-clause queries
|
if (minNrShouldMatch == 0 && clauses.size() == 1) { // optimize 1-clause queries
|
||||||
BooleanClause c = (BooleanClause)clauses.get(0);
|
BooleanClause c = (BooleanClause)clauses.get(0);
|
||||||
|
@ -372,7 +387,7 @@ public class BooleanQuery extends Query {
|
||||||
|
|
||||||
BooleanQuery clone = null; // recursively rewrite
|
BooleanQuery clone = null; // recursively rewrite
|
||||||
for (int i = 0 ; i < clauses.size(); i++) {
|
for (int i = 0 ; i < clauses.size(); i++) {
|
||||||
BooleanClause c = (BooleanClause)clauses.get(i);
|
BooleanClause c = clauses.get(i);
|
||||||
Query query = c.getQuery().rewrite(reader);
|
Query query = c.getQuery().rewrite(reader);
|
||||||
if (query != c.getQuery()) { // clause rewrote: must clone
|
if (query != c.getQuery()) { // clause rewrote: must clone
|
||||||
if (clone == null)
|
if (clone == null)
|
||||||
|
@ -387,20 +402,22 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
// inherit javadoc
|
// inherit javadoc
|
||||||
|
@Override
|
||||||
public void extractTerms(Set<Term> terms) {
|
public void extractTerms(Set<Term> terms) {
|
||||||
for (Iterator i = clauses.iterator(); i.hasNext();) {
|
for (BooleanClause clause : clauses) {
|
||||||
BooleanClause clause = (BooleanClause) i.next();
|
|
||||||
clause.getQuery().extractTerms(terms);
|
clause.getQuery().extractTerms(terms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
BooleanQuery clone = (BooleanQuery)super.clone();
|
BooleanQuery clone = (BooleanQuery)super.clone();
|
||||||
clone.clauses = (ArrayList)this.clauses.clone();
|
clone.clauses = (ArrayList<BooleanClause>)this.clauses.clone();
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prints a user-readable version of this query. */
|
/** Prints a user-readable version of this query. */
|
||||||
|
@Override
|
||||||
public String toString(String field) {
|
public String toString(String field) {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
boolean needParens=(getBoost() != 1.0) || (getMinimumNumberShouldMatch()>0) ;
|
boolean needParens=(getBoost() != 1.0) || (getMinimumNumberShouldMatch()>0) ;
|
||||||
|
@ -409,7 +426,7 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0 ; i < clauses.size(); i++) {
|
for (int i = 0 ; i < clauses.size(); i++) {
|
||||||
BooleanClause c = (BooleanClause)clauses.get(i);
|
BooleanClause c = clauses.get(i);
|
||||||
if (c.isProhibited())
|
if (c.isProhibited())
|
||||||
buffer.append("-");
|
buffer.append("-");
|
||||||
else if (c.isRequired())
|
else if (c.isRequired())
|
||||||
|
@ -450,6 +467,7 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true iff <code>o</code> is equal to this. */
|
/** Returns true iff <code>o</code> is equal to this. */
|
||||||
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof BooleanQuery))
|
if (!(o instanceof BooleanQuery))
|
||||||
return false;
|
return false;
|
||||||
|
@ -460,6 +478,7 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a hash code value for this object.*/
|
/** Returns a hash code value for this object.*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Float.floatToIntBits(getBoost()) ^ clauses.hashCode()
|
return Float.floatToIntBits(getBoost()) ^ clauses.hashCode()
|
||||||
+ getMinimumNumberShouldMatch();
|
+ getMinimumNumberShouldMatch();
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.lucene.search;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
@ -182,13 +181,12 @@ final class BooleanScorer extends Scorer {
|
||||||
private int doc = -1;
|
private int doc = -1;
|
||||||
|
|
||||||
BooleanScorer(Similarity similarity, int minNrShouldMatch,
|
BooleanScorer(Similarity similarity, int minNrShouldMatch,
|
||||||
List optionalScorers, List prohibitedScorers) throws IOException {
|
List<Scorer> optionalScorers, List<Scorer> prohibitedScorers) throws IOException {
|
||||||
super(similarity);
|
super(similarity);
|
||||||
this.minNrShouldMatch = minNrShouldMatch;
|
this.minNrShouldMatch = minNrShouldMatch;
|
||||||
|
|
||||||
if (optionalScorers != null && optionalScorers.size() > 0) {
|
if (optionalScorers != null && optionalScorers.size() > 0) {
|
||||||
for (Iterator si = optionalScorers.iterator(); si.hasNext();) {
|
for (Scorer scorer : optionalScorers) {
|
||||||
Scorer scorer = (Scorer) si.next();
|
|
||||||
maxCoord++;
|
maxCoord++;
|
||||||
if (scorer.nextDoc() != NO_MORE_DOCS) {
|
if (scorer.nextDoc() != NO_MORE_DOCS) {
|
||||||
scorers = new SubScorer(scorer, false, false, bucketTable.newCollector(0), scorers);
|
scorers = new SubScorer(scorer, false, false, bucketTable.newCollector(0), scorers);
|
||||||
|
@ -197,8 +195,7 @@ final class BooleanScorer extends Scorer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prohibitedScorers != null && prohibitedScorers.size() > 0) {
|
if (prohibitedScorers != null && prohibitedScorers.size() > 0) {
|
||||||
for (Iterator si = prohibitedScorers.iterator(); si.hasNext();) {
|
for (Scorer scorer : prohibitedScorers) {
|
||||||
Scorer scorer = (Scorer) si.next();
|
|
||||||
int mask = nextMask;
|
int mask = nextMask;
|
||||||
nextMask = nextMask << 1;
|
nextMask = nextMask << 1;
|
||||||
prohibitedMask |= mask; // update prohibited mask
|
prohibitedMask |= mask; // update prohibited mask
|
||||||
|
|
|
@ -31,9 +31,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
class BooleanScorer2 extends Scorer {
|
class BooleanScorer2 extends Scorer {
|
||||||
|
|
||||||
private final List requiredScorers;
|
private final List<Scorer> requiredScorers;
|
||||||
private final List optionalScorers;
|
private final List<Scorer> optionalScorers;
|
||||||
private final List prohibitedScorers;
|
private final List<Scorer> prohibitedScorers;
|
||||||
|
|
||||||
private class Coordinator {
|
private class Coordinator {
|
||||||
float[] coordFactors = null;
|
float[] coordFactors = null;
|
||||||
|
@ -81,7 +81,7 @@ class BooleanScorer2 extends Scorer {
|
||||||
* the list of optional scorers.
|
* the list of optional scorers.
|
||||||
*/
|
*/
|
||||||
public BooleanScorer2(Similarity similarity, int minNrShouldMatch,
|
public BooleanScorer2(Similarity similarity, int minNrShouldMatch,
|
||||||
List required, List prohibited, List optional) throws IOException {
|
List<Scorer> required, List<Scorer> prohibited, List<Scorer> optional) throws IOException {
|
||||||
super(similarity);
|
super(similarity);
|
||||||
if (minNrShouldMatch < 0) {
|
if (minNrShouldMatch < 0) {
|
||||||
throw new IllegalArgumentException("Minimum number of optional scorers should not be negative");
|
throw new IllegalArgumentException("Minimum number of optional scorers should not be negative");
|
||||||
|
@ -138,7 +138,7 @@ class BooleanScorer2 extends Scorer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Scorer countingDisjunctionSumScorer(final List scorers,
|
private Scorer countingDisjunctionSumScorer(final List<Scorer> scorers,
|
||||||
int minNrShouldMatch) throws IOException {
|
int minNrShouldMatch) throws IOException {
|
||||||
// each scorer from the list counted as a single matcher
|
// each scorer from the list counted as a single matcher
|
||||||
return new DisjunctionSumScorer(scorers, minNrShouldMatch) {
|
return new DisjunctionSumScorer(scorers, minNrShouldMatch) {
|
||||||
|
@ -162,7 +162,7 @@ class BooleanScorer2 extends Scorer {
|
||||||
|
|
||||||
private static final Similarity defaultSimilarity = Similarity.getDefault();
|
private static final Similarity defaultSimilarity = Similarity.getDefault();
|
||||||
|
|
||||||
private Scorer countingConjunctionSumScorer(List requiredScorers) throws IOException {
|
private Scorer countingConjunctionSumScorer(List<Scorer> requiredScorers) throws IOException {
|
||||||
// each scorer from the list counted as a single matcher
|
// each scorer from the list counted as a single matcher
|
||||||
final int requiredNrMatchers = requiredScorers.size();
|
final int requiredNrMatchers = requiredScorers.size();
|
||||||
return new ConjunctionScorer(defaultSimilarity, requiredScorers) {
|
return new ConjunctionScorer(defaultSimilarity, requiredScorers) {
|
||||||
|
@ -220,7 +220,7 @@ class BooleanScorer2 extends Scorer {
|
||||||
|
|
||||||
private Scorer makeCountingSumScorerSomeReq() throws IOException { // At least one required scorer.
|
private Scorer makeCountingSumScorerSomeReq() throws IOException { // At least one required scorer.
|
||||||
if (optionalScorers.size() == minNrShouldMatch) { // all optional scorers also required.
|
if (optionalScorers.size() == minNrShouldMatch) { // all optional scorers also required.
|
||||||
ArrayList allReq = new ArrayList(requiredScorers);
|
ArrayList<Scorer> allReq = new ArrayList<Scorer>(requiredScorers);
|
||||||
allReq.addAll(optionalScorers);
|
allReq.addAll(optionalScorers);
|
||||||
return addProhibitedScorers(countingConjunctionSumScorer(allReq));
|
return addProhibitedScorers(countingConjunctionSumScorer(allReq));
|
||||||
} else { // optionalScorers.size() > minNrShouldMatch, and at least one required scorer
|
} else { // optionalScorers.size() > minNrShouldMatch, and at least one required scorer
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class DisjunctionMaxQuery extends Query implements Iterable<Query> {
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
|
DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
|
||||||
clone.disjuncts = (ArrayList)this.disjuncts.clone();
|
clone.disjuncts = (ArrayList<Query>)this.disjuncts.clone();
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,9 +228,8 @@ public abstract class IndexInput implements Cloneable {
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns Map<String, String>
|
public Map<String,String> readStringStringMap() throws IOException {
|
||||||
public Map readStringStringMap() throws IOException {
|
final Map<String,String> map = new HashMap<String,String>();
|
||||||
final Map map = new HashMap();
|
|
||||||
final int count = readInt();
|
final int count = readInt();
|
||||||
for(int i=0;i<count;i++) {
|
for(int i=0;i<count;i++) {
|
||||||
final String key = readString();
|
final String key = readString();
|
||||||
|
|
Loading…
Reference in New Issue