本文整理汇总了Java中org.apache.lucene.search.DocIdSet.bits方法的典型用法代码示例。如果您正苦于以下问题:Java DocIdSet.bits方法的具体用法?Java DocIdSet.bits怎么用?Java DocIdSet.bits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.DocIdSet
的用法示例。
在下文中一共展示了DocIdSet.bits方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clone
import org.apache.lucene.search.DocIdSet; //导入方法依赖的package包/类
@Override
public AccessControlReader clone(AtomicReader in) throws IOException {
try {
FilterAccessControlReader filterAccessControlReader = (FilterAccessControlReader) super.clone();
filterAccessControlReader._isClone = true;
if (_readDocumentVisibilityFilter == null) {
filterAccessControlReader._noReadAccess = true;
} else {
DocIdSet readDocIdSet = _readDocumentVisibilityFilter.getDocIdSet(in.getContext(), in.getLiveDocs());
if (readDocIdSet == DocIdSet.EMPTY_DOCIDSET || readDocIdSet == null) {
filterAccessControlReader._noReadAccess = true;
} else {
filterAccessControlReader._readBits = readDocIdSet.bits();
if (filterAccessControlReader._readBits == null) {
throw new IOException("Read Bits can not be null.");
}
}
filterAccessControlReader._readDocIdSet = readDocIdSet;
}
if (_discoverDocumentVisibilityFilter == null) {
filterAccessControlReader._noDiscoverAccess = true;
} else {
DocIdSet discoverDocIdSet = _discoverDocumentVisibilityFilter.getDocIdSet(in.getContext(), in.getLiveDocs());
if (discoverDocIdSet == DocIdSet.EMPTY_DOCIDSET || discoverDocIdSet == null) {
filterAccessControlReader._noDiscoverAccess = true;
} else {
filterAccessControlReader._discoverBits = discoverDocIdSet.bits();
if (filterAccessControlReader._discoverBits == null) {
throw new IOException("Read Bits can not be null.");
}
}
filterAccessControlReader._discoverDocIdSet = discoverDocIdSet;
}
return filterAccessControlReader;
} catch (CloneNotSupportedException e) {
throw new IOException(e);
}
}
示例2: count
import org.apache.lucene.search.DocIdSet; //导入方法依赖的package包/类
private void count(ValueSource valueSource, List<MatchingDocs> matchingDocs) throws IOException {
DoubleRange[] ranges = (DoubleRange[]) this.ranges;
LongRange[] longRanges = new LongRange[ranges.length];
for(int i=0;i<ranges.length;i++) {
DoubleRange range = ranges[i];
longRanges[i] = new LongRange(range.label,
NumericUtils.doubleToSortableLong(range.minIncl), true,
NumericUtils.doubleToSortableLong(range.maxIncl), true);
}
LongRangeCounter counter = new LongRangeCounter(longRanges);
int missingCount = 0;
for (MatchingDocs hits : matchingDocs) {
FunctionValues fv = valueSource.getValues(Collections.emptyMap(), hits.context);
totCount += hits.totalHits;
Bits bits;
if (fastMatchFilter != null) {
DocIdSet dis = fastMatchFilter.getDocIdSet(hits.context, null);
if (dis == null) {
// No documents match
continue;
}
bits = dis.bits();
if (bits == null) {
throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
}
} else {
bits = null;
}
DocIdSetIterator docs = hits.bits.iterator();
int doc;
while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (bits != null && bits.get(doc) == false) {
doc++;
continue;
}
// Skip missing docs:
if (fv.exists(doc)) {
counter.add(NumericUtils.doubleToSortableLong(fv.doubleVal(doc)));
} else {
missingCount++;
}
}
}
missingCount += counter.fillCounts(counts);
totCount -= missingCount;
}
示例3: getFilter
import org.apache.lucene.search.DocIdSet; //导入方法依赖的package包/类
@Override
public Filter getFilter(final Filter fastMatchFilter, final ValueSource valueSource) {
return new Filter() {
@Override
public String toString() {
return "Filter(" + LongRange.this.toString() + ")";
}
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, final Bits acceptDocs) throws IOException {
// TODO: this is just like ValueSourceScorer,
// ValueSourceFilter (spatial),
// ValueSourceRangeFilter (solr); also,
// https://issues.apache.org/jira/browse/LUCENE-4251
final FunctionValues values = valueSource.getValues(Collections.emptyMap(), context);
final int maxDoc = context.reader().maxDoc();
final Bits fastMatchBits;
if (fastMatchFilter != null) {
DocIdSet dis = fastMatchFilter.getDocIdSet(context, null);
if (dis == null) {
// No documents match
return null;
}
fastMatchBits = dis.bits();
if (fastMatchBits == null) {
throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
}
} else {
fastMatchBits = null;
}
return new DocIdSet() {
@Override
public Bits bits() {
return new Bits() {
@Override
public boolean get(int docID) {
if (acceptDocs != null && acceptDocs.get(docID) == false) {
return false;
}
if (fastMatchBits != null && fastMatchBits.get(docID) == false) {
return false;
}
return accept(values.longVal(docID));
}
@Override
public int length() {
return maxDoc;
}
};
}
@Override
public DocIdSetIterator iterator() {
throw new UnsupportedOperationException("this filter can only be accessed via bits()");
}
};
}
};
}
示例4: getFilter
import org.apache.lucene.search.DocIdSet; //导入方法依赖的package包/类
@Override
public Filter getFilter(final Filter fastMatchFilter, final ValueSource valueSource) {
return new Filter() {
@Override
public String toString() {
return "Filter(" + DoubleRange.this.toString() + ")";
}
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, final Bits acceptDocs) throws IOException {
// TODO: this is just like ValueSourceScorer,
// ValueSourceFilter (spatial),
// ValueSourceRangeFilter (solr); also,
// https://issues.apache.org/jira/browse/LUCENE-4251
final FunctionValues values = valueSource.getValues(Collections.emptyMap(), context);
final int maxDoc = context.reader().maxDoc();
final Bits fastMatchBits;
if (fastMatchFilter != null) {
DocIdSet dis = fastMatchFilter.getDocIdSet(context, null);
if (dis == null) {
// No documents match
return null;
}
fastMatchBits = dis.bits();
if (fastMatchBits == null) {
throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
}
} else {
fastMatchBits = null;
}
return new DocIdSet() {
@Override
public Bits bits() {
return new Bits() {
@Override
public boolean get(int docID) {
if (acceptDocs != null && acceptDocs.get(docID) == false) {
return false;
}
if (fastMatchBits != null && fastMatchBits.get(docID) == false) {
return false;
}
return accept(values.doubleVal(docID));
}
@Override
public int length() {
return maxDoc;
}
};
}
@Override
public DocIdSetIterator iterator() {
throw new UnsupportedOperationException("this filter can only be accessed via bits()");
}
};
}
};
}
示例5: count
import org.apache.lucene.search.DocIdSet; //导入方法依赖的package包/类
private void count(ValueSource valueSource, List<MatchingDocs> matchingDocs) throws IOException {
LongRange[] ranges = (LongRange[]) this.ranges;
LongRangeCounter counter = new LongRangeCounter(ranges);
int missingCount = 0;
for (MatchingDocs hits : matchingDocs) {
FunctionValues fv = valueSource.getValues(Collections.emptyMap(), hits.context);
totCount += hits.totalHits;
Bits bits;
if (fastMatchFilter != null) {
DocIdSet dis = fastMatchFilter.getDocIdSet(hits.context, null);
if (dis == null) {
// No documents match
continue;
}
bits = dis.bits();
if (bits == null) {
throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
}
} else {
bits = null;
}
DocIdSetIterator docs = hits.bits.iterator();
int doc;
while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (bits != null && bits.get(doc) == false) {
doc++;
continue;
}
// Skip missing docs:
if (fv.exists(doc)) {
counter.add(fv.longVal(doc));
} else {
missingCount++;
}
}
}
int x = counter.fillCounts(counts);
missingCount += x;
//System.out.println("totCount " + totCount + " missingCount " + counter.missingCount);
totCount -= missingCount;
}