• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FixedBitSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: markSeqNoAsCompleted

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
/**
 * Marks the processing of the provided sequence number as completed as updates the checkpoint if possible.
 *
 * @param seqNo the sequence number to mark as completed
 */
public synchronized void markSeqNoAsCompleted(final long seqNo) {
    // make sure we track highest seen sequence number
    if (seqNo >= nextSeqNo) {
        nextSeqNo = seqNo + 1;
    }
    if (seqNo <= checkpoint) {
        // this is possible during recovery where we might replay an operation that was also replicated
        return;
    }
    final FixedBitSet bitSet = getBitSetForSeqNo(seqNo);
    final int offset = seqNoToBitSetOffset(seqNo);
    bitSet.set(offset);
    if (seqNo == checkpoint + 1) {
        updateCheckpoint();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:LocalCheckpointTracker.java


示例2: testSingleValuedLongs

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public void testSingleValuedLongs() throws Exception {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final long[] array = new long[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomLong();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDocValues singleValues = new NumericDocValues() {
        @Override
        public long get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDocValues multiValues = DocValues.singleton(singleValues, docsWithValue);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MultiValueModeTests.java


示例3: testSingleValuedDoubles

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public void testSingleValuedDoubles() throws Exception  {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final double[] array = new double[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomDouble();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDoubleValues singleValues = new NumericDoubleValues() {
        @Override
        public double get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDoubleValues multiValues = FieldData.singleton(singleValues, docsWithValue);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MultiValueModeTests.java


示例4: getSeqNosSet

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
private static FixedBitSet getSeqNosSet(final IndexReader reader, final long highestSeqNo) throws IOException {
    // _seq_no are stored as doc values for the time being, so this is how we get them
    // (as opposed to using an IndexSearcher or IndexReader)
    final FixedBitSet bitSet = new FixedBitSet((int) highestSeqNo + 1);
    final List<LeafReaderContext> leaves = reader.leaves();
    if (leaves.isEmpty()) {
        return bitSet;
    }

    for (int i = 0; i < leaves.size(); i++) {
        final LeafReader leaf = leaves.get(i).reader();
        final NumericDocValues values = leaf.getNumericDocValues(SeqNoFieldMapper.NAME);
        if (values == null) {
            continue;
        }
        final Bits bits = leaf.getLiveDocs();
        for (int docID = 0; docID < leaf.maxDoc(); docID++) {
            if (bits == null || bits.get(docID)) {
                final long seqNo = values.get(docID);
                assertFalse("should not have more than one document with the same seq_no[" + seqNo + "]", bitSet.get((int) seqNo));
                bitSet.set((int) seqNo);
            }
        }
    }
    return bitSet;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:InternalEngineTests.java


示例5: unionTermGroups

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
/** union (term group) bit-sets until they are disjoint (O(n^^2)), and each group have different terms */
private void unionTermGroups(ArrayList<FixedBitSet> bb) {
  int incr;
  for (int i=0; i<bb.size()-1; i+=incr) {
    incr = 1;
    int j = i+1;
    while (j<bb.size()) {
      if (bb.get(i).intersects(bb.get(j))) {
        bb.get(i).or(bb.get(j));
        bb.remove(j);
        incr = 0;
      } else {
        ++j;
      }
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SloppyPhraseScorer.java


示例6: addValue

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public void addValue(int docID, long value) {
  if (docID < pending.size()) {
    throw new IllegalArgumentException("DocValuesField \"" + fieldInfo.name + "\" appears more than once in this document (only one value is allowed per field)");
  }

  // Fill in any holes:
  for (int i = (int)pending.size(); i < docID; ++i) {
    pending.add(MISSING);
  }

  pending.add(value);
  if (docsWithField != null) {
    docsWithField = FixedBitSet.ensureCapacity(docsWithField, docID);
    docsWithField.set(docID);
  }

  updateBytesUsed();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:NumericDocValuesWriter.java


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


示例8: getLeafCollector

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
  current = new FixedBitSet(context.reader().maxDoc());
  fixedBitSets.add(context.ord, current);

  return new LeafCollector() {

    @Override
    public void setScorer(Scorer scorer) throws IOException {}

    @Override
    public void collect(int doc) throws IOException {
      current.set(doc);
      totalHits++;
    }

  };
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:19,代码来源:BitSetHitStream.java


示例9: deserialize

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public static FuzzySet deserialize(DataInput in) throws IOException
{
  int version=in.readInt();
  if (version == VERSION_SPI) {
    in.readString();
  }
  final HashFunction hashFunction = hashFunctionForVersion(version);
  int bloomSize=in.readInt();
  int numLongs=in.readInt();
  long[]longs=new long[numLongs];
  for (int i = 0; i < numLongs; i++) {
    longs[i]=in.readLong();
  }
  FixedBitSet bits = new FixedBitSet(longs,bloomSize+1);
  return new FuzzySet(bits,bloomSize,hashFunction);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:FuzzySet.java


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


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


示例12: createDocs

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
/**
 * Creates a {@link Docs} to record hits. The default uses {@link FixedBitSet}
 * to record hits and you can override to e.g. record the docs in your own
 * {@link DocIdSet}.
 */
protected Docs createDocs(final int maxDoc) {
  return new Docs() {
    private final FixedBitSet bits = new FixedBitSet(maxDoc);
    
    @Override
    public void addDoc(int docId) throws IOException {
      bits.set(docId);
    }
    
    @Override
    public DocIdSet getDocIdSet() {
      return bits;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:FacetsCollector.java


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


示例14: fillDocsAndScores

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
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()) {
        matchingDocs.set(doc);
        // In the case the same doc is also related to a another doc, a score might be overwritten. I think this
        // can only happen in a many-to-many relation
        scores[doc] = score;
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:TermsIncludingScoreQuery.java


示例15: superposeBitSet

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
/**
 * This method is the first of two required to facilitate superposition. The underlying representation
 * (i.e. the voting record) is an ArrayList of FixedBitSet, each with dimension "dimension", which can
 * be thought of as an expanding 2D array of bits. Each column keeps count (in binary) for the respective
 * dimension, and columns are incremented in parallel by sweeping a bitset across the rows. In any dimension
 * in which the BitSet to be added contains a "1", the effect will be that 1's are changed to 0's until a
 * new 1 is added (e.g. the column '110' would become '001' and so forth).
 * 
 * The first method deals with floating point issues, and accelerates superposition by decomposing
 * the task into segments.
 * 
 * @param incomingBitSet
 * @param weight
 */
protected synchronized void superposeBitSet(FixedBitSet incomingBitSet, double weight) {
  // If fractional weights are used, encode all weights as integers (1000 x double value).
  weight = (int) Math.round(weight * Math.pow(10, BINARY_VECTOR_DECIMAL_PLACES));
  if (weight == 0) return;

  // Keep track of number (or cumulative weight) of votes.
  totalNumberOfVotes.set(totalNumberOfVotes.get() + (int) weight);

  // Decompose superposition task such that addition of some power of 2 (e.g. 64) is accomplished
  // by beginning the process at the relevant row (e.g. 7) instead of starting multiple (e.g. 64)
  // superposition processes at the first row.
  int logFloorOfWeight = (int) (Math.floor(Math.log(weight)/Math.log(2)));

  if (logFloorOfWeight < votingRecord.size() - 1) {
    while (logFloorOfWeight > 0) {
      superposeBitSetFromRowFloor(incomingBitSet, logFloorOfWeight);	
      weight = weight - (int) Math.pow(2,logFloorOfWeight);
      logFloorOfWeight = (int) (Math.floor(Math.log(weight)/Math.log(2)));	
    }
  }

  // Add remaining component of weight incrementally.
  for (int x = 0; x < weight; x++)
    superposeBitSetFromRowFloor(incomingBitSet, 0);
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:40,代码来源:BinaryVector.java


示例16: testIsCacheAble

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public void testIsCacheAble() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  writer.addDocument(new Document());
  writer.close();

  IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));

  // not cacheable:
  assertDocIdSetCacheable(reader, new QueryWrapperFilter(new TermQuery(new Term("test","value"))), false);
  // returns default empty docidset, always cacheable:
  assertDocIdSetCacheable(reader, NumericRangeFilter.newIntRange("test", Integer.valueOf(10000), Integer.valueOf(-10000), true, true), true);
  // is cacheable:
  assertDocIdSetCacheable(reader, FieldCacheRangeFilter.newIntRange("test", Integer.valueOf(10), Integer.valueOf(20), true, true), false);
  // a fixedbitset filter is always cacheable
  assertDocIdSetCacheable(reader, new Filter() {
    @Override
    public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) {
      return new FixedBitSet(context.reader().maxDoc());
    }
  }, true);

  reader.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:TestCachingWrapperFilter.java


示例17: getDocIdSet

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  final int maxDoc = context.reader().maxDoc();
  final FieldCache.Ints idSource = FieldCache.DEFAULT.getInts(context.reader(), "id", false);
  assertNotNull(idSource);
  final FixedBitSet bits = new FixedBitSet(maxDoc);
  for(int docID=0;docID<maxDoc;docID++) {
    if (random.nextFloat() <= density && (acceptDocs == null || acceptDocs.get(docID))) {
      bits.set(docID);
      //System.out.println("  acc id=" + idSource.get(docID) + " docID=" + docID + " id=" + idSource.get(docID) + " v=" + docValues.get(idSource.get(docID)).utf8ToString());
      matchValues.add(docValues.get(idSource.get(docID)));
    }
  }

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


示例18: verifyCount

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
private void verifyCount(IndexReader ir) throws Exception {
  Fields fields = MultiFields.getFields(ir);
  if (fields == null) {
    return;
  }
  for (String field : fields) {
    Terms terms = fields.terms(field);
    if (terms == null) {
      continue;
    }
    int docCount = terms.getDocCount();
    FixedBitSet visited = new FixedBitSet(ir.maxDoc());
    TermsEnum te = terms.iterator(null);
    while (te.next() != null) {
      DocsEnum de = TestUtil.docs(random(), te, null, null, DocsEnum.FLAG_NONE);
      while (de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
        visited.set(de.docID());
      }
    }
    assertEquals(visited.cardinality(), docCount);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:TestDocCount.java


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


示例20: getCollapsedSet

import org.apache.lucene.util.FixedBitSet; //导入依赖的package包/类
public FixedBitSet getCollapsedSet() {
  if(nullDoc > -1) {
    this.collapsedSet.set(nullDoc);
  }

  if(this.boostOrds != null) {
    for(int i=0; i<this.boostOrds.length; i++) {
      ords[boostOrds[i]] = -1;
    }
  }

  for(int i=0; i<ords.length; i++) {
    int doc = ords[i];
    if(doc > -1) {
      collapsedSet.set(doc);
    }
  }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientContext类代码示例发布时间:2022-05-21
下一篇:
Java LayoutDialect类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap