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


Java FixedBitSet.ensureCapacity方法代码示例

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


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

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

示例2: 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);
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:BitDocSet.java

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

示例4: addValue

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
public void addValue(int docID, BytesRef value) {
  if (docID < addedValues) {
    throw new IllegalArgumentException("DocValuesField \"" + fieldInfo.name + "\" appears more than once in this document (only one value is allowed per field)");
  }
  if (value == null) {
    throw new IllegalArgumentException("field=\"" + fieldInfo.name + "\": null value not allowed");
  }
  if (value.length > MAX_LENGTH) {
    throw new IllegalArgumentException("DocValuesField \"" + fieldInfo.name + "\" is too large, must be <= " + MAX_LENGTH);
  }

  // Fill in any holes:
  while(addedValues < docID) {
    addedValues++;
    lengths.add(0);
  }
  addedValues++;
  lengths.add(value.length);
  try {
    bytesOut.writeBytes(value.bytes, value.offset, value.length);
  } catch (IOException ioe) {
    // Should never happen!
    throw new RuntimeException(ioe);
  }
  docsWithField = FixedBitSet.ensureCapacity(docsWithField, docID);
  docsWithField.set(docID);
  updateBytesUsed();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:BinaryDocValuesWriter.java

示例5: toBitSet

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
public static FixedBitSet toBitSet(DocSet set) {
  if (set instanceof DocSetBase) {
    return ((DocSetBase) set).getBits();
  } else {
    FixedBitSet bits = new FixedBitSet(64);
    for (DocIterator iter = set.iterator(); iter.hasNext();) {
      int nextDoc = iter.nextDoc();
      bits = FixedBitSet.ensureCapacity(bits, nextDoc);
      bits.set(nextDoc);
    }
    return bits;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:DocSetBase.java

示例6: getBits

import org.apache.lucene.util.FixedBitSet; //导入方法依赖的package包/类
/**
 * Return a {@link FixedBitSet} with a bit set for every document in this
 * {@link DocSet}. The default implementation iterates on all docs and sets
 * the relevant bits. You should override if you can provide a more efficient
 * implementation.
 */
protected FixedBitSet getBits() {
  FixedBitSet bits = new FixedBitSet(64);
  for (DocIterator iter = iterator(); iter.hasNext();) {
    int nextDoc = iter.nextDoc();
    bits = FixedBitSet.ensureCapacity(bits, nextDoc);
    bits.set(nextDoc);
  }
  return bits;
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:DocSetBase.java

示例7: 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);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:DocSetBase.java


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