本文整理汇总了Java中org.apache.lucene.util.FixedBitSet.or方法的典型用法代码示例。如果您正苦于以下问题:Java FixedBitSet.or方法的具体用法?Java FixedBitSet.or怎么用?Java FixedBitSet.or使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.FixedBitSet
的用法示例。
在下文中一共展示了FixedBitSet.or方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bits
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
/**
* Create a bit vector representing the live documents of the
* virtual collection to be used in searches.
* This will respect deleted documents.
*
* @param The
* {@link LeafReaderContext} to search in.
* @return A bit vector representing the live documents of the
* virtual collection.
* @throws IOException
*/
public FixedBitSet bits (LeafReaderContext atomic) throws IOException {
LeafReader r = atomic.reader();
FixedBitSet bitset = new FixedBitSet(r.maxDoc());
DocIdSet docids = this.getDocIdSet(atomic, (Bits) r.getLiveDocs());
if (docids == null) {
if (this.cbi != null) {
bitset.clear(0, bitset.length());
}
else {
bitset.set(0, bitset.length());
};
}
else
bitset.or(docids.iterator());
return bitset;
}
示例2: docIdSetToCache
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
protected DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader)
throws IOException {
if (docIdSet == null) {
return EMPTY;
} else if (docIdSet instanceof FixedBitSet) {
// this is different from CachingWrapperFilter: even when the DocIdSet is
// cacheable, we convert it to a FixedBitSet since we require all the
// cached filters to be FixedBitSets
return docIdSet;
} else {
final DocIdSetIterator it = docIdSet.iterator();
if (it == null) {
return EMPTY;
} else {
final FixedBitSet copy = new FixedBitSet(reader.maxDoc());
copy.or(it);
return copy;
}
}
}
示例3: union
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
public DocSet union(DocSet other) {
FixedBitSet newbits = bits.clone();
if (other instanceof BitDocSet) {
BitDocSet otherDocSet = (BitDocSet) other;
newbits = FixedBitSet.ensureCapacity(newbits, otherDocSet.bits.length());
newbits.or(otherDocSet.bits);
} else {
DocIterator iter = other.iterator();
while (iter.hasNext()) {
int doc = iter.nextDoc();
newbits = FixedBitSet.ensureCapacity(newbits, doc);
newbits.set(doc);
}
}
return new BitDocSet(newbits);
}
示例4: initialResult
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
private FixedBitSet initialResult(AtomicReaderContext context, int logic, int[] index)
throws IOException {
AtomicReader reader = context.reader();
FixedBitSet result = new FixedBitSet(reader.maxDoc());
if (logic == AND) {
result.or(getDISI(chain[index[0]], context));
++index[0];
} else if (logic == ANDNOT) {
result.or(getDISI(chain[index[0]], context));
result.flip(0, reader.maxDoc()); // NOTE: may set bits for deleted docs.
++index[0];
}
return result;
}
示例5: cacheImpl
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
protected DocIdSet cacheImpl(DocIdSetIterator iterator, AtomicReader reader)
throws IOException {
final FixedBitSet cached = new FixedBitSet(reader.maxDoc());
cached.or(iterator);
return cached;
}
示例6: union
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
public DocSet union(DocSet other) {
FixedBitSet otherBits = toBitSet(other);
FixedBitSet newbits = FixedBitSet.ensureCapacity(getBits().clone(), otherBits.length());
newbits.or(otherBits);
return new BitDocSet(newbits);
}
示例7: doSingle
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
protected void doSingle(int maxSize) {
int sz = rand.nextInt(maxSize+1);
int sz2 = rand.nextInt(maxSize);
FixedBitSet bs1 = getRandomSet(sz, rand.nextInt(sz+1));
FixedBitSet bs2 = getRandomSet(sz, rand.nextInt(sz2+1));
DocSet a1 = new BitDocSet(bs1);
DocSet a2 = new BitDocSet(bs2);
DocSet b1 = getDocSet(bs1);
DocSet b2 = getDocSet(bs2);
checkEqual(bs1,b1);
checkEqual(bs2,b2);
iter(a1,b1);
iter(a2,b2);
FixedBitSet a_and = bs1.clone(); a_and.and(bs2);
FixedBitSet a_or = bs1.clone(); a_or.or(bs2);
// FixedBitSet a_xor = bs1.clone(); a_xor.xor(bs2);
FixedBitSet a_andn = bs1.clone(); a_andn.andNot(bs2);
checkEqual(a_and, b1.intersection(b2));
checkEqual(a_or, b1.union(b2));
checkEqual(a_andn, b1.andNot(b2));
assertEquals(a_and.cardinality(), b1.intersectionSize(b2));
assertEquals(a_or.cardinality(), b1.unionSize(b2));
assertEquals(a_andn.cardinality(), b1.andNotSize(b2));
}
示例8: getDocIdSet
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
/**
* Return the {@link DocIdSet} representing the documents of the
* virtual collection to be used in searches.
* This will respect deleted documents.
*
* @param atomic
* The {@link LeafReaderContext} to search in.
* @param accepted
* {@link Bits} vector of accepted documents.
* @throws IOException
*/
public DocIdSet getDocIdSet (LeafReaderContext atomic, Bits acceptDocs)
throws IOException {
int maxDoc = atomic.reader().maxDoc();
FixedBitSet bitset = new FixedBitSet(maxDoc);
Filter filter;
if (this.cbi == null || (filter = this.cbi.toFilter()) == null) {
if (acceptDocs == null)
return null;
bitset.set(0, maxDoc);
}
else {
// Init vector
DocIdSet docids = filter.getDocIdSet(atomic, null);
DocIdSetIterator filterIter = (docids == null) ? null
: docids.iterator();
if (filterIter == null) {
if (!this.cbi.isNegative())
return null;
bitset.set(0, maxDoc);
}
else {
// Or bit set
bitset.or(filterIter);
// Revert for negation
if (this.cbi.isNegative())
bitset.flip(0, maxDoc);
};
};
if (DEBUG) {
log.debug("Bit set is {}", _bits(bitset));
log.debug("Livedocs is {}", _bits(acceptDocs));
};
// Remove deleted docs
return (DocIdSet) BitsFilteredDocIdSet
.wrap((DocIdSet) new BitDocIdSet(bitset), acceptDocs);
}
示例9: doChain
import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
private void doChain(FixedBitSet result, int logic, DocIdSet dis) throws IOException {
if (dis instanceof FixedBitSet) {
// optimized case for FixedBitSets
switch (logic) {
case OR:
result.or((FixedBitSet) dis);
break;
case AND:
result.and((FixedBitSet) dis);
break;
case ANDNOT:
result.andNot((FixedBitSet) dis);
break;
case XOR:
result.xor((FixedBitSet) dis);
break;
default:
doChain(result, DEFAULT, dis);
break;
}
} else {
DocIdSetIterator disi;
if (dis == null) {
disi = DocIdSetIterator.empty();
} else {
disi = dis.iterator();
if (disi == null) {
disi = DocIdSetIterator.empty();
}
}
switch (logic) {
case OR:
result.or(disi);
break;
case AND:
result.and(disi);
break;
case ANDNOT:
result.andNot(disi);
break;
case XOR:
result.xor(disi);
break;
default:
doChain(result, DEFAULT, dis);
break;
}
}
}