org.apache.lucene.util.Bits.length()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.lucene.util.Bits.length()方法的一些代码示例,展示了Bits.length()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bits.length()方法的具体详情如下:
包路径:org.apache.lucene.util.Bits
类名称:Bits
方法名:length

Bits.length介绍

[英]Returns the number of bits in this set
[中]返回此集合中的位数

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
 public int length() {
  return in.length();
 }
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
 public int length() {
  return hardLiveDocs.length();
 }
};

代码示例来源:origin: org.apache.lucene/lucene-core

public LegacyNumericDocValuesWrapper(Bits docsWithField, LegacyNumericDocValues values) {
 this.docsWithField = docsWithField;
 this.values = values;
 this.maxDoc = docsWithField.length();
}

代码示例来源:origin: org.apache.lucene/lucene-core

public LegacyBinaryDocValuesWrapper(Bits docsWithField, LegacyBinaryDocValues values) {
 this.docsWithField = docsWithField;
 this.values = values;
 this.maxDoc = docsWithField.length();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public int length() {
 return inBits.length();
}

代码示例来源: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 String toString() {
 StringBuilder b = new StringBuilder();
 b.append(subs.length + " subs: ");
 for(int i=0;i<subs.length;i++) {
  if (i != 0) {
   b.append("; ");
  }
  if (subs[i] == null) {
   b.append("s=" + starts[i] + " l=null");
  } else {
   b.append("s=" + starts[i] + " l=" + subs[i].length() + " b=" + subs[i]);
  }
 }
 b.append(" end=" + starts[subs.length]);
 return b.toString();
}

代码示例来源: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

} else {
 int numLive = 0;
 for (int j = 0; j < liveDocs.length(); j++) {
  if (liveDocs.get(j)) {
   numLive++;
if (liveDocs != null) {
 for (int j = 0; j < liveDocs.length(); j++) {
  if (!liveDocs.get(j)) {
   throw new RuntimeException("liveDocs mismatch: info says no deletions but doc " + j + " is deleted.");

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public void writeLiveDocs(Bits bits, Directory dir, SegmentCommitInfo info, int newDelCount, IOContext context) throws IOException {
 long gen = info.getNextDelGen();
 String name = IndexFileNames.fileNameFromGeneration(info.info.name, EXTENSION, gen);
 int delCount = 0;
 try (IndexOutput output = dir.createOutput(name, context)) {
  CodecUtil.writeIndexHeader(output, CODEC_NAME, VERSION_CURRENT, info.info.getId(), Long.toString(gen, Character.MAX_RADIX));
  final int longCount = FixedBitSet.bits2words(bits.length());
  for (int i = 0; i < longCount; ++i) {
   long currentBits = 0;
   for (int j = i << 6, end = Math.min(j + 63, bits.length() - 1); j <= end; ++j) {
    if (bits.get(j)) {
     currentBits |= 1L << j; // mod 64
    } else {
     delCount += 1;
    }
   }
   output.writeLong(currentBits);
  }
  CodecUtil.writeFooter(output);
 }
 if (delCount != info.getDelCount() + newDelCount) {
  throw new CorruptIndexException("bits.deleted=" + delCount + 
    " info.delcount=" + info.getDelCount() + " newdelcount=" + newDelCount, name);
 }
}

代码示例来源:origin: org.apache.lucene/lucene-core

throw new IllegalArgumentException("numDocs=" + numDocs + " but maxDoc=" + si.info.maxDoc());
if (liveDocs != null && liveDocs.length() != si.info.maxDoc()) {
 throw new IllegalArgumentException("maxDoc=" + si.info.maxDoc() + " but liveDocs.size()=" + liveDocs.length());

代码示例来源:origin: org.apache.lucene/lucene-core

assert mergeLiveDocs == null || mergeLiveDocs.length() == maxDoc;
 assert prevHardLiveDocs.length() == maxDoc;
 assert currentHardLiveDocs.length() == maxDoc;
 assert currentHardLiveDocs.length() == maxDoc;

代码示例来源: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.elasticsearch/elasticsearch

@Override
public int length() {
  return Math.min(a.length(), b.length());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private static int popCount(Bits bits) {
  assert bits != null;
  int onBits = 0;
  for (int i = 0; i < bits.length(); i++) {
    if (bits.get(i)) {
      onBits++;
    }
  }
  return onBits;
}

代码示例来源:origin: org.apache.lucene/lucene-core

assert liveDocs != null;
assert liveDocs.length() == info.info.maxDoc();

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

public LegacyNumericDocValuesWrapper(Bits docsWithField, LegacyNumericDocValues values) {
 this.docsWithField = docsWithField;
 this.values = values;
 this.maxDoc = docsWithField.length();
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
public long ramBytesUsed() {
 long base = RamUsageEstimator.NUM_BYTES_OBJECT_REF;
 if (bits instanceof Bits.MatchAllBits || bits instanceof Bits.MatchNoBits) {
  return base;
 } else {
  return base + (bits.length() >>> 3);
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

@Override
 public int length() {
  return hardLiveDocs.length();
 }
};

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

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;
}

相关文章