/** * This is the main entry point into the program. */ static public void main(String[] args) { System.out.println("Starting SimpleSearchStream"); // Create an input string containing the lyrics to the // do-re-mi song. String input = TestDataFactory.getInput(sINPUT_FILE, "@").get(0); // Get the list of words to find. List<String> wordsToFind = TestDataFactory.getWordList(sWORD_LIST_FILE); // Create an object that can be used to search for words in // the input. WordSearcher wordSearcher = new WordSearcher(input); // Print all matching words. wordSearcher.findAndPrintWords(wordsToFind); System.out.println("Ending SimpleSearchStream"); } }
/** * Create a new folder asynchronously. * * @return A future to the folder that completes when the folder * is created */ private static CompletableFuture<Dirent> createFolder() { // Asynchronously create and return a folder containing all // the works in the sWORKs directory. return Folder .fromDirectory(TestDataFactory .getRootFolderFile(sWORKs)); }
TestDataFactory.getInput(sSHAKESPEARE_DATA_FILE, TestDataFactory.getSharedInput(sSHAKESPEARE_DATA_FILE, .getPhraseList(sPHRASE_LIST_FILE);
/** * Warm up the fork-join pool to account for any instruction/data * caching effects. */ private static void warmUpForkJoinPool(SearchWithForkJoinTaskFactory consRef) throws IOException, URISyntaxException { System.out.println("Warming up the fork-join pool"); // This object is used to search a recursive directory // containing the complete works of William Shakespeare. List<CharSequence> inputList = TestDataFactory .getInput(sSHAKESPEARE_FOLDER, true); // Create the appropriate type of object. SearchWithForkJoinTask forkJoinTask = consRef.apply(inputList, mPhrasesToFind, true, true, true); @SuppressWarnings("unused") // Search the input looking for phrases that match. List<List<SearchResults>> listOfListOfSearchResults = ForkJoinPool.commonPool() .invoke(forkJoinTask); // Help the GC. //noinspection UnusedAssignment forkJoinTask = null; // Run the garbage collector after each test. System.gc(); }
.getPhraseList(sPHRASE_LIST_FILE);
/** * Warm up the fork-join pool to account for any instruction/data * caching effects. */ private static void warmUpForkJoinPool() throws IOException, URISyntaxException { System.out.println("Warming up the fork-join pool"); // This object is used to search a recursive directory // containing the complete works of William Shakespeare. Folder folder = TestDataFactory .getRootFolder(sSHAKESPEARE_FOLDER, true); // Create the appropriate type of object. SearchWithForkJoinTask forkJoinTask = new SearchWithForkJoinTask(folder, mPhrasesToFind, true, true, true, true); // Use the common fork-join pool to search the input looking // for phrases that match. List<List<SearchResults>> listOfListOfSearchResults = ForkJoinPool.commonPool() .invoke(forkJoinTask); // Help the GC. //noinspection UnusedAssignment forkJoinTask = null; // Run the garbage collector after each test. System.gc(); }
TestDataFactory.getInput(sSHAKESPEARE_DATA_FILE,
.getPhraseList(sPHRASE_LIST_FILE);
/** * @return The input data in the given @a rootFolderName as a list * of CharSequences. */ public static List<CharSequence> getInput(String rootFolderName, boolean parallel) throws IOException, URISyntaxException { // Return the input data in the given @a rootFolderName as a // list of CharSequences. return new GetInputListTask(getRootFolder(rootFolderName, parallel) // Get all the subfolders. .getSubFolders(), parallel).compute(); }
/** * Return a folder object that's used to search a recursive * directory containing the complete works of William Shakespeare. */ public static CompletableFuture<Dirent> getRootFolder(String rootFolderName) { return Folder.fromDirectory(getRootFolderFile(rootFolderName) .toPath()); } }
/** * Return a folder object that's used to search a recursive * directory containing the complete works of William Shakespeare. */ public static Dirent getRootFolder(String rootFolderName, boolean parallel) throws URISyntaxException, IOException { return Folder .fromDirectory(getRootFolderFile(rootFolderName) .toPath(), parallel); } }
/** * Create a new folder. * * @return An open folder */ private static Dirent createFolder(boolean parallel) { // Count the time needed to create and return a folder // containing all the works in the sWORKs directory. return Folder .fromDirectory(TestDataFactory .getRootFolderFile(sWORKs), parallel); }