/** * Compute the results of matching the phrase in the input. */ @Override public List<SearchResults.Result> compute() { // Compute sequentially if the input is too small to split // further. if (mInput.length() < mMinSplitSize) return computeSequentially(); else { // Compute a candidate position for splitting the input. int startPos, splitPos = mInput.length() / 2; // Get the position to start determining if a phrase spans // the split position. if ((startPos = computeStartPos(splitPos)) < 0) return null; // Update splitPos if a phrase spans across the initial // splitPos. if ((splitPos = tryToUpdateSplitPos(startPos, splitPos)) < 0) return null; // Create a new PhraseMatchTask that handles the "left // hand" portion of the input, while the "this" object // handles the "right hand" portion of the input. return splitInput(splitPos); } }
new PhraseMatchTask(mInput.subSequence(0, splitPos), mPhrase, mPattern, mMinSplitSize, mOffset).fork(); List<SearchResults.Result> rightResult = compute();
/** * Search for a phrase in the input data. */ private static SearchResults searchForPhrase(String phrase, CharSequence inputData) { return new SearchResults (phrase, "", // Perform the processing (either sequentially or in // parallel) and return a list of Results. new PhraseMatchTask(inputData, phrase).compute()); }
new PhraseMatchTask(input, phrase).compute()))