final ZimbraQueryResults run(Mailbox mbox, MailboxIndex mbidx, byte[] types, SortBy searchOrder, int chunkSize, boolean prefetch, Mailbox.SearchResultMode mode) throws IOException, ServiceException
final ZimbraQueryResults run(Mailbox mbox, MailboxIndex mbidx, SearchParams params, int chunkSize) throws IOException, ServiceException
    final ZimbraQueryResults run(Mailbox mbox, MailboxIndex mbidx, byte[] types, SortBy searchOrder, int chunkSize, boolean prefetch, Mailbox.SearchResultMode mode) throws IOException, ServiceException    {        mIsToplevelQueryOp = true;        mSortOrder = searchOrder;        chunkSize++; // one extra for checking the "more" flag at the end of the results        if (chunkSize < MIN_CHUNK_SIZE) {            chunkSize = MIN_CHUNK_SIZE;        } else if (chunkSize > MAX_CHUNK_SIZE) {            chunkSize = MAX_CHUNK_SIZE;        }        int retType = MailboxIndex.SEARCH_RETURN_DOCUMENTS;        for (int i = 0; i < types.length; i++) {            if (types[i] == MailItem.TYPE_CONVERSATION) {                retType = MailboxIndex.SEARCH_RETURN_CONVERSATIONS;                break;            }            if (types[i] == MailItem.TYPE_MESSAGE) {                retType = MailboxIndex.SEARCH_RETURN_MESSAGES;                break;            }        }        // set me to TRUE if you're returning Conversations or something which could benefit from preloading                boolean preloadOuterResults = false;        int outerChunkSize = chunkSize;        switch (retType) {            case MailboxIndex.SEARCH_RETURN_CONVERSATIONS:                if (prefetch && USE_PRELOADING_GROUPER) {                    chunkSize+= 2; // one for the ConvQueryResults, one for the Grouper                      setupResults(mbox, new ConvQueryResults(new ItemPreloadingGrouper(this, chunkSize, mbox), types, searchOrder, mode));                    chunkSize*=2; // guess 2 msgs per conv                } else {                    chunkSize++; // one for the ConvQueryResults                    setupResults(mbox, new ConvQueryResults(this, types, searchOrder, mode));                    chunkSize*=2;                }                preloadOuterResults = true;                break;            case MailboxIndex.SEARCH_RETURN_MESSAGES:                if (prefetch && USE_PRELOADING_GROUPER) {                    chunkSize+= 2; // one for the MsgQueryResults, one for the Grouper                     setupResults(mbox, new MsgQueryResults(new ItemPreloadingGrouper(this, chunkSize, mbox), types, searchOrder, mode));                } else {                    chunkSize++; // one for the MsgQueryResults                    setupResults(mbox, new MsgQueryResults(this, types, searchOrder, mode));                }                break;            case MailboxIndex.SEARCH_RETURN_DOCUMENTS:                if (prefetch && USE_PRELOADING_GROUPER) {                    chunkSize++; // one for the grouper                    setupResults(mbox, new UngroupedQueryResults(new ItemPreloadingGrouper(this, chunkSize, mbox), types, searchOrder, mode));                } else {                    setupResults(mbox, new UngroupedQueryResults(this, types, searchOrder, mode));                }                break;        }        prepare(mMailbox, mResults, mbidx, chunkSize);        if (USE_PRELOADING_GROUPER && preloadOuterResults && prefetch) {            return new ItemPreloadingGrouper(mResults, outerChunkSize, mbox);        } else {            return mResults;        }    }