@Override public int length() { return in.length(); } }
@Override public int length() { return hardLiveDocs.length(); } };
public LegacyNumericDocValuesWrapper(Bits docsWithField, LegacyNumericDocValues values) { this.docsWithField = docsWithField; this.values = values; this.maxDoc = docsWithField.length(); }
public LegacyBinaryDocValuesWrapper(Bits docsWithField, LegacyBinaryDocValues values) { this.docsWithField = docsWithField; this.values = values; this.maxDoc = docsWithField.length(); }
@Override public int length() { return inBits.length(); }
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; }
@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(); }
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; }
} 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.");
@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); } }
/** * 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; } }
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; }
assert liveDocs != null; assert liveDocs.length() == info.info.maxDoc();
public LegacyNumericDocValuesWrapper(Bits docsWithField, LegacyNumericDocValues values) { this.docsWithField = docsWithField; this.values = values; this.maxDoc = docsWithField.length(); }
@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); } }
@Override public int length() { return hardLiveDocs.length(); } };
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; }