public boolean next() throws IOException { position++; position = set.nextSetBit(position); return (position != -1); }
public boolean next() throws IOException { position++; position = set.nextSetBit(position); return (position != -1); }
/** * Create a SortedVIntList from an OpenBitSet. * @param bits A bit set representing a set of integers. */ public SortedVIntList(OpenBitSet bits) { SortedVIntListBuilder builder = new SortedVIntListBuilder(); int nextInt = bits.nextSetBit(0); while (nextInt != -1) { builder.addInt(nextInt); nextInt = bits.nextSetBit(nextInt + 1); } builder.done(); }
/** * Create a SortedVIntList from an OpenBitSet. * @param bits A bit set representing a set of integers. */ public SortedVIntList(OpenBitSet bits) { SortedVIntListBuilder builder = new SortedVIntListBuilder(); int nextInt = bits.nextSetBit(0); while (nextInt != -1) { builder.addInt(nextInt); nextInt = bits.nextSetBit(nextInt + 1); } builder.done(); }
private Set<String> getIssueIdsDirectly() throws IOException { final Set<String> issueIds = new TreeSet<String>(); FieldSelector selector = new FieldSelector() { @Override public FieldSelectorResult accept(final String fieldName) { return fieldName.equals(DocumentConstants.ISSUE_ID) ? FieldSelectorResult.LOAD_AND_BREAK : FieldSelectorResult.NO_LOAD; } }; // Do a virtual trim of the bit set so we don't unnecessarily scan to the end docIds.setNumWords(OpenBitSet.bits2words(maxDocId + 1)); for (int docId = docIds.nextSetBit(minDocId); docId >= 0; docId = docIds.nextSetBit(docId+1)) { Document doc = indexReader.document(docId, selector); issueIds.add(doc.get(DocumentConstants.ISSUE_ID)); } return issueIds; }
@Override public double getFacetSelectivity(BoboSegmentReader reader) { FacetDataCache<?> dataCache = facetDataCacheBuilder.build(reader); final OpenBitSet openBitSet = getBitSet(dataCache); int[] frequencies = dataCache.freqs; double selectivity = 0; int accumFreq = 0; int index = openBitSet.nextSetBit(0); while (index >= 0) { accumFreq += frequencies[index]; index = openBitSet.nextSetBit(index + 1); } int total = reader.maxDoc(); selectivity = (double) accumFreq / (double) total; if (selectivity > 0.999) { selectivity = 1.0; } return selectivity; } }
@Override public GroupResult perform(LucisSearcher searcher) { final long t0 = System.currentTimeMillis(); final AllCollector collector = new AllCollector(); searcher.search(query, filter, collector); final Group g = new Group(); final OpenBitSet bits = collector.getBits(); for (int i = bits.nextSetBit(0); i >= 0; i = bits.nextSetBit(i + 1)) { g.addHit(); final Document d = searcher.doc(i); if (fields != null && !fields.isEmpty()) { add(g, d, 0); } } final long t1 = System.currentTimeMillis(); return new GroupResult(g, collector.getMaxScore(), t1 - t0); }