/** * Build a {@link DocIdSet} from the accumulated doc IDs. */ public DocIdSet build() { try { if (bitSet != null) { assert counter >= 0; final long cost = Math.round(counter / numValuesPerDoc); return new BitDocIdSet(bitSet, cost); } else { Buffer concatenated = concat(buffers); LSBRadixSorter sorter = new LSBRadixSorter(); sorter.sort(PackedInts.bitsRequired(maxDoc - 1), concatenated.array, concatenated.length); final int l; if (multivalued) { l = dedup(concatenated.array, concatenated.length); } else { assert noDups(concatenated.array, concatenated.length); l = concatenated.length; } assert l <= concatenated.length; concatenated.array[l] = DocIdSetIterator.NO_MORE_DOCS; return new IntArrayDocIdSet(concatenated.array, l); } } finally { this.buffers = null; this.bitSet = null; } }
/** * Build a {@link DocIdSet} from the accumulated doc IDs. */ public DocIdSet build() { try { if (bitSet != null) { assert counter >= 0; final long cost = Math.round(counter / numValuesPerDoc); return new BitDocIdSet(bitSet, cost); } else { Buffer concatenated = concat(buffers); LSBRadixSorter sorter = new LSBRadixSorter(); sorter.sort(PackedInts.bitsRequired(maxDoc - 1), concatenated.array, concatenated.length); final int l; if (multivalued) { l = dedup(concatenated.array, concatenated.length); } else { assert noDups(concatenated.array, concatenated.length); l = concatenated.length; } assert l <= concatenated.length; concatenated.array[l] = DocIdSetIterator.NO_MORE_DOCS; return new IntArrayDocIdSet(concatenated.array, l); } } finally { this.buffers = null; this.bitSet = null; } }
/** * Expert: build a {@link DocIdSet} with a hint on the cost that the resulting * {@link DocIdSet} would have. */ public DocIdSet build(long costHint) { try { if (bitSet != null) { if (costHint == -1) { return new BitDocIdSet(bitSet); } else { return new BitDocIdSet(bitSet, costHint); } } else { LSBRadixSorter sorter = new LSBRadixSorter(); sorter.sort(buffer, 0, bufferSize); final int l = dedup(buffer, bufferSize); assert l <= bufferSize; buffer = ArrayUtil.grow(buffer, l + 1); buffer[l] = DocIdSetIterator.NO_MORE_DOCS; return new IntArrayDocIdSet(buffer, l); } } finally { this.buffer = null; this.bufferSize = 0; this.bitSet = null; } }
/** * Expert: build a {@link DocIdSet} with a hint on the cost that the resulting * {@link DocIdSet} would have. */ public DocIdSet build(long costHint) { try { if (bitSet != null) { if (costHint == -1) { return new BitDocIdSet(bitSet); } else { return new BitDocIdSet(bitSet, costHint); } } else { LSBRadixSorter sorter = new LSBRadixSorter(); sorter.sort(buffer, 0, bufferSize); final int l = dedup(buffer, bufferSize); assert l <= bufferSize; buffer = ArrayUtil.grow(buffer, l + 1); buffer[l] = DocIdSetIterator.NO_MORE_DOCS; return new IntArrayDocIdSet(buffer, l); } } finally { this.buffer = null; this.bufferSize = 0; this.bitSet = null; } }