BitSet addClause(BooleanQuery bq, BitSet result) { final BitSet rnd = sets[random().nextInt(sets.length)]; Query q = new ConstantScoreQuery(new Filter() { @Override public DocIdSet getDocIdSet (AtomicReaderContext context, Bits acceptDocs) { assertNull("acceptDocs should be null, as we have an index without deletions", acceptDocs); return new DocIdBitSet(rnd); } }); bq.add(q, BooleanClause.Occur.MUST); if (validate) { if (result==null) result = (BitSet)rnd.clone(); else result.and(rnd); } return result; }
private static Filter newStaticFilterB() { return new Filter() { @Override public DocIdSet getDocIdSet (AtomicReaderContext context, Bits acceptDocs) { if (acceptDocs == null) acceptDocs = new Bits.MatchAllBits(5); BitSet bitset = new BitSet(5); if (acceptDocs.get(1)) bitset.set(1); if (acceptDocs.get(3)) bitset.set(3); return new DocIdBitSet(bitset); } }; }
private static Filter newStaticFilterA() { return new Filter() { @Override public DocIdSet getDocIdSet (AtomicReaderContext context, Bits acceptDocs) { assertNull("acceptDocs should be null, as we have an index without deletions", acceptDocs); BitSet bitset = new BitSet(5); bitset.set(0, 5); return new DocIdBitSet(bitset); } }; }
@SuppressWarnings("deprecation") @Override public DocIdSet getDocIdSet(final IndexReader indexReader) throws IOException { final BitSet bitSet = new BitSet(indexReader.maxDoc()); final TermDocs termDocs = indexReader.termDocs(new Term(CommitIndexer.FIELD_PROJECTKEY, projectKey)); while (termDocs.next()) { final int docId = termDocs.doc(); final Document theDoc = indexReader.document(docId, issueKeysFieldSelector); boolean allow = false; final String[] issueKeys = theDoc.getValues(CommitIndexer.FIELD_ISSUEKEY); if (issueKeys != null) { for (final String issueKey : issueKeys) { final Issue anIssue = issueManager.getIssueObject(StringUtils.upperCase(issueKey)); if (anIssue != null && permissionManager.hasPermission(Permissions.VIEW_VERSION_CONTROL, anIssue, user)) { allow = true; break; } } } bitSet.set(docId, allow); } return new DocIdBitSet(bitSet); }
@Override public DocIdSet getDocIdSet(IndexReader indexReader) throws IOException { final BitSet bitSet = new BitSet(indexReader.maxDoc()); for (final String issueKey : permittedIssueKeys) { TermDocs termDocs = indexReader.termDocs(new Term(CommitIndexer.FIELD_ISSUEKEY, issueKey)); while (termDocs.next()) { bitSet.set(termDocs.doc(), true); } } return new DocIdBitSet(bitSet); }