当前位置: 首页>>代码示例>>Java>>正文


Java FixedBitSet.clear方法代码示例

本文整理汇总了Java中org.apache.lucene.util.FixedBitSet.clear方法的典型用法代码示例。如果您正苦于以下问题:Java FixedBitSet.clear方法的具体用法?Java FixedBitSet.clear怎么用?Java FixedBitSet.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.util.FixedBitSet的用法示例。


在下文中一共展示了FixedBitSet.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:30,代码来源:KrillCollection.java

示例2: writeDoc

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
protected void writeDoc(SortDoc sortDoc,
                        List<AtomicReaderContext> leaves,
                        FieldWriter[] fieldWriters,
                        FixedBitSet[] sets,
                        Writer out) throws IOException{

  int ord = sortDoc.ord;
  FixedBitSet set = sets[ord];
  set.clear(sortDoc.docId);
  AtomicReaderContext context = leaves.get(ord);
  boolean needsComma = false;
  for(FieldWriter fieldWriter : fieldWriters) {
    if(needsComma) {
      out.write(',');
    }
    fieldWriter.write(sortDoc.docId, context.reader(), out);
    needsComma = true;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SortingResponseWriter.java

示例3: andNot

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
public DocSet andNot(DocSet other) {
  FixedBitSet newbits = bits.clone();
  if (other instanceof BitDocSet) {
    newbits.andNot(((BitDocSet) other).bits);
  } else {
    DocIterator iter = other.iterator();
    while (iter.hasNext()) {
      int doc = iter.nextDoc();
      if (doc < newbits.length()) {
        newbits.clear(doc);
      }
    }
  }
  return new BitDocSet(newbits);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:BitDocSet.java

示例4: testTwoDocuments

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
/** 
 * test version lookup with two documents matching the ID
 */
public void testTwoDocuments() throws Exception {
    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
    Document doc = new Document();
    doc.add(new Field(UidFieldMapper.NAME, "6", UidFieldMapper.Defaults.FIELD_TYPE));
    doc.add(new NumericDocValuesField(VersionFieldMapper.NAME, 87));
    writer.addDocument(doc);
    writer.addDocument(doc);
    DirectoryReader reader = DirectoryReader.open(writer);
    LeafReaderContext segment = reader.leaves().get(0);
    PerThreadIDAndVersionLookup lookup = new PerThreadIDAndVersionLookup(segment.reader());
    // return the last doc when there are duplicates
    DocIdAndVersion result = lookup.lookup(new BytesRef("6"), null, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId);
    // delete the first doc only
    FixedBitSet live = new FixedBitSet(2);
    live.set(1);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId);
    // delete the second doc only
    live.clear(1);
    live.set(0);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(0, result.docId);
    // delete both docs
    assertNull(lookup.lookup(new BytesRef("6"), new Bits.MatchNoBits(2), segment));
    reader.close();
    writer.close();
    dir.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:VersionLookupTests.java

示例5: advanceRpts

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
/** pp was just advanced. If that caused a repeater collision, resolve by advancing the lesser
 * of the two colliding pps. Note that there can only be one collision, as by the initialization
 * there were no collisions before pp was advanced.  */
private boolean advanceRpts(PhrasePositions pp) throws IOException {
  if (pp.rptGroup < 0) {
    return true; // not a repeater
  }
  PhrasePositions[] rg = rptGroups[pp.rptGroup];
  FixedBitSet bits = new FixedBitSet(rg.length); // for re-queuing after collisions are resolved
  int k0 = pp.rptInd;
  int k;
  while((k=collide(pp)) >= 0) {
    pp = lesser(pp, rg[k]); // always advance the lesser of the (only) two colliding pps
    if (!advancePP(pp)) {
      return false; // exhausted
    }
    if (k != k0) { // careful: mark only those currently in the queue
      bits = FixedBitSet.ensureCapacity(bits, k);
      bits.set(k); // mark that pp2 need to be re-queued
    }
  }
  // collisions resolved, now re-queue
  // empty (partially) the queue until seeing all pps advanced for resolving collisions
  int n = 0;
  // TODO would be good if we can avoid calling cardinality() in each iteration!
  int numBits = bits.length(); // larges bit we set
  while (bits.cardinality() > 0) {
    PhrasePositions pp2 = pq.pop();
    rptStack[n++] = pp2;
    if (pp2.rptGroup >= 0 
        && pp2.rptInd < numBits  // this bit may not have been set
        && bits.get(pp2.rptInd)) {
      bits.clear(pp2.rptInd);
    }
  }
  // add back to queue
  for (int i=n-1; i>=0; i--) {
    pq.add(rptStack[i]);
  }
  return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:SloppyPhraseScorer.java

示例6: getDocIdSet

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  FixedBitSet bits = new FixedBitSet(context.reader().maxDoc());
  bits.set(doc);
  if (acceptDocs != null && !acceptDocs.get(doc)) bits.clear(doc);
  return bits;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:SingleDocTestFilter.java

示例7: fastBits

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
private FixedBitSet fastBits(AtomicReader reader, Bits acceptDocs) throws IOException {
  FixedBitSet bits = new FixedBitSet(reader.maxDoc());
  bits.set(0, reader.maxDoc()); //assume all are valid
  Terms terms = reader.fields().terms(fieldName);

  if (terms == null) {
    return bits;
  }

  TermsEnum termsEnum = terms.iterator(null);
  DocsEnum docs = null;
  while (true) {
    BytesRef currTerm = termsEnum.next();
    if (currTerm == null) {
      break;
    } else {
      if (termsEnum.docFreq() > 1) {
        // unset potential duplicates
        docs = termsEnum.docs(acceptDocs, docs, DocsEnum.FLAG_NONE);
        int doc = docs.nextDoc();
        if (doc != DocIdSetIterator.NO_MORE_DOCS) {
          if (keepMode == KeepMode.KM_USE_FIRST_OCCURRENCE) {
            doc = docs.nextDoc();
          }
        }

        int lastDoc = -1;
        while (true) {
          lastDoc = doc;
          bits.clear(lastDoc);
          doc = docs.nextDoc();
          if (doc == DocIdSetIterator.NO_MORE_DOCS) {
            break;
          }
        }

        if (keepMode == KeepMode.KM_USE_LAST_OCCURRENCE) {
          // restore the last bit
          bits.set(lastDoc);
        }
      }
    }
  }

  return bits;
}
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:DuplicateFilter.java


注:本文中的org.apache.lucene.util.FixedBitSet.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。