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


Java FixedBitSet.get方法代码示例

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


在下文中一共展示了FixedBitSet.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openBitSetContains

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
private boolean openBitSetContains(int[] expectedDocs, FixedBitSet actual, int maxDoc) throws IOException {
  if (expectedDocs.length != actual.cardinality()) {
    return false;
  }

  FixedBitSet expected = new FixedBitSet(maxDoc);
  for (int expectedDoc : expectedDocs) {
    expected.set(expectedDoc);
  }

  int docId;
  DocIdSetIterator iterator = expected.iterator();
  while ((docId = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (!actual.get(docId)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:AllGroupHeadsCollectorTest.java

示例2: randomLiveDocs

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
Bits randomLiveDocs(int maxDoc) {
  if (rarely()) {
    if (random().nextBoolean()) {
      return null;
    } else {
      return new Bits.MatchNoBits(maxDoc);
    }
  }
  final FixedBitSet bits = new FixedBitSet(maxDoc);
  final int bitsSet = TestUtil.nextInt(random(), 1, maxDoc - 1);
  for (int i = 0; i < bitsSet; ++i) {
    while (true) {
      final int index = random().nextInt(maxDoc);
      if (!bits.get(index)) {
        bits.set(index);
        break;
      }
    }
  }
  return bits;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SorterTestBase.java

示例3: fillDocsAndScores

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
@Override
protected void fillDocsAndScores(FixedBitSet matchingDocs, Bits acceptDocs, TermsEnum termsEnum) throws IOException {
  BytesRef spare = new BytesRef();
  DocsEnum docsEnum = null;
  for (int i = 0; i < terms.size(); i++) {
    if (termsEnum.seekExact(terms.get(ords[i], spare))) {
      docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
      float score = TermsIncludingScoreQuery.this.scores[ords[i]];
      for (int doc = docsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = docsEnum.nextDoc()) {
        // I prefer this:
        /*if (scores[doc] < score) {
          scores[doc] = score;
          matchingDocs.set(doc);
        }*/
        // But this behaves the same as MVInnerScorer and only then the tests will pass:
        if (!matchingDocs.get(doc)) {
          scores[doc] = score;
          matchingDocs.set(doc);
        }
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TermsIncludingScoreQuery.java

示例4: generate

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
static void generate(int maxSize, int bitsToSet) {
  bs = new FixedBitSet(maxSize);
  ids = new int[bitsToSet];
  int count=0;
  if (maxSize>0) {
    for (int i=0; i<bitsToSet; i++) {
      int id=rand.nextInt(maxSize);
      if (!bs.get(id)) {
        bs.set(id);
        ids[count++]=id;
      }
    }
  }
  bds = new BitDocSet(bs,bitsToSet);
  hds = new HashDocSet(ids,0,count);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:DocSetPerf.java

示例5: weightedSuperposition

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
public static Vector weightedSuperposition(
    BinaryVector v1, double weight1, BinaryVector v2, double weight2) {
  BinaryVector conclusion = (BinaryVector) VectorFactory.createZeroVector(VectorType.BINARY, v1.getDimension());
  FixedBitSet cVote = conclusion.bitSet;
  FixedBitSet v1vote = v1.bitSet;
  FixedBitSet v2vote = v2.bitSet;

  Random random = new Random();
  random.setSeed(Bobcat.asLong(v1.writeLongToString())); 

  for (int x = 0; x < v1.getDimension(); x++) {
    double probability = 0;
    if (v1vote.get(x)) probability += weight1 / (weight1 + weight2);
    if (v2vote.get(x)) probability += weight2 / (weight1 + weight2);

    if (random.nextDouble() <= probability)
      cVote.set(x);
  }
  return conclusion;
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:21,代码来源:BinaryVectorUtils.java

示例6: randomInnerDocs

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
private static FixedBitSet randomInnerDocs(FixedBitSet rootDocs) {
    FixedBitSet innerDocs = new FixedBitSet(rootDocs.length());
    for (int i = 0; i < innerDocs.length(); ++i) {
        if (!rootDocs.get(i) && randomBoolean()) {
            innerDocs.set(i);
        }
    }
    return innerDocs;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:MultiValueModeTests.java

示例7: 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

示例8: testBuildDocMap

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
public void testBuildDocMap() {
  final int maxDoc = TestUtil.nextInt(random(), 1, 128);
  final int numDocs = TestUtil.nextInt(random(), 0, maxDoc);
  final int numDeletedDocs = maxDoc - numDocs;
  final FixedBitSet liveDocs = new FixedBitSet(maxDoc);
  for (int i = 0; i < numDocs; ++i) {
    while (true) {
      final int docID = random().nextInt(maxDoc);
      if (!liveDocs.get(docID)) {
        liveDocs.set(docID);
        break;
      }
    }
  }

  final MergeState.DocMap docMap = MergeState.DocMap.build(maxDoc, liveDocs);

  assertEquals(maxDoc, docMap.maxDoc());
  assertEquals(numDocs, docMap.numDocs());
  assertEquals(numDeletedDocs, docMap.numDeletedDocs());
  // assert the mapping is compact
  for (int i = 0, del = 0; i < maxDoc; ++i) {
    if (!liveDocs.get(i)) {
      assertEquals(-1, docMap.get(i));
      ++del;
    } else {
      assertEquals(i - del, docMap.get(i));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestSegmentMerger.java


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