return new SearchResults(Thread.currentThread().getId(), 0, phrase,
/** * Looks for all instances of @code phrase in @code inputData and * return a list of all the @code SearchResults (if any). */ public SearchResults searchForPhrase(String phrase, CharSequence input, String title, boolean parallel) { List<SearchResults.Result> resultList = // Use a PhraseMatchSpliterator to add the indices of all // places in the inputData where phrase matches. StreamSupport // Create a stream of Results to record the indices // (if any) where the phrase matched the input data. .stream(new PhraseMatchSpliterator(input, phrase), parallel) // This terminal operation triggers aggregate // operation processing and returns a list of Results. .collect(toList()); // Create/return SearchResults to keep track of relevant info. return new SearchResults(Thread.currentThread().getId(), currentCycle(), phrase, title, resultList); }
-> new SearchResults (Thread.currentThread().getId(), 1,
/** * 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()); }