lucene4: check liveDocs and acceptedDocs for null before trying to call get() on them

This commit is contained in:
Igor Motov 2012-11-04 12:52:52 -05:00 committed by Shay Banon
parent 3f3a95668b
commit 7aac88cf5c
4 changed files with 6 additions and 5 deletions

View File

@ -93,7 +93,7 @@ public class NotDeletedFilter extends Filter {
@Override
protected boolean match(int doc) {
return liveDocs.get(doc);
return liveDocs == null || liveDocs.get(doc);
}
}
}

View File

@ -178,7 +178,7 @@ public abstract class HasChildFilter extends Filter implements ScopePhase.Collec
}
public boolean get(int doc) {
return acceptDocs.get(doc) && parents.contains(typeCache.idByDoc(doc));
return (acceptDocs == null || acceptDocs.get(doc)) && parents.contains(typeCache.idByDoc(doc));
}
}

View File

@ -143,7 +143,7 @@ public abstract class HasParentFilter extends Filter implements ScopePhase.Colle
}
public boolean get(int doc) {
return acceptDocs.get(doc) && parents.contains(idReaderTypeCache.parentIdByDoc(doc));
return (acceptDocs == null || acceptDocs.get(doc)) && parents.contains(idReaderTypeCache.parentIdByDoc(doc));
}
}
@ -229,7 +229,7 @@ public abstract class HasParentFilter extends Filter implements ScopePhase.Colle
}
public boolean get(int doc) {
if (!acceptDocs.get(doc) || doc == -1) {
if ((acceptDocs != null && !acceptDocs.get(doc)) || doc == -1) {
return false;
}

View File

@ -138,7 +138,8 @@ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase {
for (AtomicReaderContext atomicReaderContext : context.searcher().getIndexReader().leaves()) {
AtomicReader indexReader = atomicReaderContext.reader();
int parentDocId = context.idCache().reader(indexReader).docById(parentType, parentId);
if (parentDocId != -1 && indexReader.getLiveDocs().get(parentDocId)) {
Bits liveDocs = indexReader.getLiveDocs();
if (parentDocId != -1 && (liveDocs == null || liveDocs.get(parentDocId))) {
// we found a match, add it and break
TIntObjectHashMap<ParentDoc> readerParentDocs = parentDocsPerReader.get(indexReader.getCoreCacheKey());