本文整理了Java中org.apache.lucene.util.Bits.get()
方法的一些代码示例,展示了Bits.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bits.get()
方法的具体详情如下:
包路径:org.apache.lucene.util.Bits
类名称:Bits
方法名:get
[英]Returns the value of the bit with the specified index
.
[中]返回具有指定index
的位的值。
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean match( int doc )
{
return liveDocs.get( doc );
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean get(int index) {
return hardLiveDocs.get(index) && wrappedLiveDocs.get(index);
}
@Override
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int nextDoc() {
docID++;
while (docID < maxDoc) {
if (docsWithField.get(docID)) {
return docID;
}
docID++;
}
docID = NO_MORE_DOCS;
return NO_MORE_DOCS;
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean advanceExact(int target) throws IOException {
docID = target;
return docsWithField.get(target);
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean get(int index) {
return !inBits.get(index);
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean advanceExact(int target) throws IOException {
docID = target;
value = values.get(docID);
return value != 0 || docsWithField.get(docID);
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean get(int doc) {
FutureObjects.checkIndex(doc, length);
return parent.get(doc+start);
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int get(int docID) {
if (liveDocs == null) {
return docBase + docID;
} else if (liveDocs.get(docID)) {
return docBase + (int) delDocMap.get(docID);
} else {
return -1;
}
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int get(int docID) {
if (liveDocs == null || liveDocs.get(docID)) {
return (int) remapped.get(docID);
} else {
return -1;
}
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean get(int index) {
return in.get(docMap.newToOld(index));
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int nextDoc() {
docID++;
while (docID < maxDoc) {
value = values.get(docID);
if (value != 0 || docsWithField.get(docID)) {
return docID;
}
docID++;
}
docID = NO_MORE_DOCS;
return NO_MORE_DOCS;
}
代码示例来源:origin: org.apache.lucene/lucene-core
static int countSoftDeletes(DocIdSetIterator softDeletedDocs, Bits hardDeletes) throws IOException {
int count = 0;
if (softDeletedDocs != null) {
int doc;
while ((doc = softDeletedDocs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (hardDeletes == null || hardDeletes.get(doc)) {
count++;
}
}
}
return count;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
private boolean assertCheckLiveDocs(Bits bits, int expectedLength, int expectedDeleteCount) {
assert bits.length() == expectedLength;
int deletedCount = 0;
for (int i = 0; i < bits.length(); i++) {
if (bits.get(i) == false) {
deletedCount++;
}
}
assert deletedCount == expectedDeleteCount : "deleted: " + deletedCount + " != expected: " + expectedDeleteCount;
return true;
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean get(int doc) {
final int reader = ReaderUtil.subIndex(doc, starts);
assert reader != -1;
final Bits bits = subs[reader];
if (bits == null) {
return defaultValue;
} else {
assert checkLength(reader, doc);
return bits.get(doc-starts[reader]);
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
static PackedLongValues removeDeletes(final int maxDoc, final Bits liveDocs) {
final PackedLongValues.Builder docMapBuilder = PackedLongValues.monotonicBuilder(PackedInts.COMPACT);
int del = 0;
for (int i = 0; i < maxDoc; ++i) {
docMapBuilder.add(i - del);
if (liveDocs.get(i) == false) {
++del;
}
}
return docMapBuilder.build();
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Expert: low-level implementation method
* Returns an Explanation that describes how <code>doc</code> scored against
* <code>weight</code>.
*
* <p>This is intended to be used in developing Similarity implementations,
* and, for good performance, should not be displayed with every hit.
* Computing an explanation is as expensive as executing the query over the
* entire index.
* <p>Applications should call {@link IndexSearcher#explain(Query, int)}.
* @throws BooleanQuery.TooManyClauses If a query would exceed
* {@link BooleanQuery#getMaxClauseCount()} clauses.
*/
protected Explanation explain(Weight weight, int doc) throws IOException {
int n = ReaderUtil.subIndex(doc, leafContexts);
final LeafReaderContext ctx = leafContexts.get(n);
int deBasedDoc = doc - ctx.docBase;
final Bits liveDocs = ctx.reader().getLiveDocs();
if (liveDocs != null && liveDocs.get(deBasedDoc) == false) {
return Explanation.noMatch("Document " + doc + " is deleted");
}
return weight.explain(ctx, deBasedDoc);
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Specialized method to bulk-score all hits; we
* separate this from {@link #scoreRange} to help out
* hotspot.
* See <a href="https://issues.apache.org/jira/browse/LUCENE-5487">LUCENE-5487</a> */
static void scoreAll(LeafCollector collector, DocIdSetIterator iterator, TwoPhaseIterator twoPhase, Bits acceptDocs) throws IOException {
if (twoPhase == null) {
for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc()) {
if (acceptDocs == null || acceptDocs.get(doc)) {
collector.collect(doc);
}
}
} else {
// The scorer has an approximation, so run the approximation first, then check acceptDocs, then confirm
final DocIdSetIterator approximation = twoPhase.approximation();
for (int doc = approximation.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = approximation.nextDoc()) {
if ((acceptDocs == null || acceptDocs.get(doc)) && twoPhase.matches()) {
collector.collect(doc);
}
}
}
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
private FixedBitSet sortLiveDocs(Bits liveDocs, Sorter.DocMap sortMap) throws IOException {
assert liveDocs != null && sortMap != null;
FixedBitSet sortedLiveDocs = new FixedBitSet(liveDocs.length());
sortedLiveDocs.set(0, liveDocs.length());
for (int i = 0; i < liveDocs.length(); i++) {
if (liveDocs.get(i) == false) {
sortedLiveDocs.clear(sortMap.oldToNew(i));
}
}
return sortedLiveDocs;
}
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Make a copy of the given bits.
*/
public static FixedBitSet copyOf(Bits bits) {
if (bits instanceof FixedBits) {
// restore the original FixedBitSet
FixedBits fixedBits = (FixedBits) bits;
bits = new FixedBitSet(fixedBits.bits, fixedBits.length);
}
if (bits instanceof FixedBitSet) {
return ((FixedBitSet)bits).clone();
} else {
int length = bits.length();
FixedBitSet bitSet = new FixedBitSet(length);
bitSet.set(0, length);
for (int i = 0; i < length; ++i) {
if (bits.get(i) == false) {
bitSet.clear(i);
}
}
return bitSet;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
boolean verifyDocCounts(CodecReader reader) {
int count = 0;
Bits liveDocs = getLiveDocs();
if (liveDocs != null) {
for(int docID = 0; docID < info.info.maxDoc(); docID++) {
if (liveDocs.get(docID)) {
count++;
}
}
} else {
count = info.info.maxDoc();
}
assert numDocs() == count: "info.maxDoc=" + info.info.maxDoc() + " info.getDelCount()=" + info.getDelCount() +
" info.getSoftDelCount()=" + info.getSoftDelCount() +
" pendingDeletes=" + toString() + " count=" + count + " numDocs: " + numDocs();
assert reader.numDocs() == numDocs() : "reader.numDocs() = " + reader.numDocs() + " numDocs() " + numDocs();
assert reader.numDeletedDocs() <= info.info.maxDoc(): "delCount=" + reader.numDeletedDocs() + " info.maxDoc=" +
info.info.maxDoc() + " rld.pendingDeleteCount=" + numPendingDeletes() +
" info.getDelCount()=" + info.getDelCount();
return true;
}
内容来源于网络,如有侵权,请联系作者删除!