本文整理汇总了Java中org.apache.lucene.util.Bits.MatchNoBits方法的典型用法代码示例。如果您正苦于以下问题:Java Bits.MatchNoBits方法的具体用法?Java Bits.MatchNoBits怎么用?Java Bits.MatchNoBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.Bits
的用法示例。
在下文中一共展示了Bits.MatchNoBits方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLeafCollector
import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
final LeafBucketCollector sub) throws IOException {
final Bits docsWithValue;
if (valuesSource != null) {
docsWithValue = valuesSource.docsWithValue(ctx);
} else {
docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc());
}
return new LeafBucketCollectorBase(sub, docsWithValue) {
@Override
public void collect(int doc, long bucket) throws IOException {
if (docsWithValue != null && !docsWithValue.get(doc)) {
collectBucket(sub, doc, bucket);
}
}
};
}
示例2: ramBytesUsed
import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
public long ramBytesUsed() {
long base = RamUsageEstimator.NUM_BYTES_OBJECT_REF;
if (bits instanceof Bits.MatchAllBits || bits instanceof Bits.MatchNoBits) {
return base;
} else {
return base + (bits.length() >>> 3);
}
}
示例3: getDocsWithField
import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
public Bits getDocsWithField(AtomicReader reader, String field) throws IOException {
final FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
if (fieldInfo == null) {
// field does not exist or has no value
return new Bits.MatchNoBits(reader.maxDoc());
} else if (fieldInfo.hasDocValues()) {
return reader.getDocsWithField(field);
} else if (!fieldInfo.isIndexed()) {
return new Bits.MatchNoBits(reader.maxDoc());
}
BitsEntry entry = (BitsEntry) caches.get(DocsWithFieldCache.class).get(reader, new CacheKey(field, null), false);
return entry.bits;
}
示例4: getDocsWithField
import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
/**
* Returns Bits for the reader, or {@link Bits} matching nothing if it has none.
*/
public static Bits getDocsWithField(AtomicReader in, String field) throws IOException {
Bits dv = in.getDocsWithField(field);
if (dv == null) {
return new Bits.MatchNoBits(in.maxDoc());
} else {
return dv;
}
}
示例5: getDocsWithField
import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
/** Returns a Bits for a reader's docsWithField (potentially merging on-the-fly)
* <p>
* This is a slow way to access this bitset. Instead, access them per-segment
* with {@link AtomicReader#getDocsWithField(String)}
* </p>
* */
public static Bits getDocsWithField(final IndexReader r, final String field) throws IOException {
final List<AtomicReaderContext> leaves = r.leaves();
final int size = leaves.size();
if (size == 0) {
return null;
} else if (size == 1) {
return leaves.get(0).reader().getDocsWithField(field);
}
boolean anyReal = false;
boolean anyMissing = false;
final Bits[] values = new Bits[size];
final int[] starts = new int[size+1];
for (int i = 0; i < size; i++) {
AtomicReaderContext context = leaves.get(i);
Bits v = context.reader().getDocsWithField(field);
if (v == null) {
v = new Bits.MatchNoBits(context.reader().maxDoc());
anyMissing = true;
} else {
anyReal = true;
if (v instanceof Bits.MatchAllBits == false) {
anyMissing = true;
}
}
values[i] = v;
starts[i] = context.docBase;
}
starts[size] = r.maxDoc();
if (!anyReal) {
return null;
} else if (!anyMissing) {
return new Bits.MatchAllBits(r.maxDoc());
} else {
return new MultiBits(values, starts, false);
}
}