/** * reload a file to the selectionTable * * @param file input file * @param password password * @param pageSelection page selection */ public synchronized void reloadFile(File file, String password, String pageSelection, int index) { if (file != null) { workQueue.execute( new ReloadThread(file, password, pageSelection, index), (file.length() < (LOW_PRIORITY_SIZE)) ? WorkQueue.HIGH : WorkQueue.LOW); } }
/** * adds files to the selectionTable * * @param files * @param ordered files are added keeping order */ public synchronized void addFiles(File[] files, boolean ordered) { if (files != null) { for (int i = 0; i < files.length; i++) { Integer priority = (ordered) ? WorkQueue.SINGLE : (files[i].length() < (LOW_PRIORITY_SIZE)) ? WorkQueue.HIGH : WorkQueue.LOW; workQueue.execute(new AddThread(files[i]), priority); } } }
/** * Search the query file to find the query words and add them in to an array list. * * @param filename : file of queries */ public void search(String filename, InvertedIndex index) { Path file = Paths.get(filename); try (BufferedReader reader = Files.newBufferedReader(file, Charset.forName("UTF-8"))) { String parseWord; while ((parseWord = reader.readLine()) != null) { lock.acquireWriteLock(); map.put(parseWord, null); lock.releaseWriteLock(); workers.execute(new Searcher(parseWord, index)); } finish(); } catch (IOException e) { System.out.println("The file " + filename + " could not be read."); } }
/** * Add task to the work queue of the JMS communication thread. * * @param task Task that will be executed by the communication thread. * @see Executor */ @Override public void execute(final Runnable task) { queue.execute(task); }
/** * add a file to the selectionTable * * @param file input file * @param password password * @param pageSelection page selection */ public synchronized void addFile(File file, String password, String pageSelection) { if (file != null) { workQueue.execute(new AddThread(file, password, pageSelection), WorkQueue.SINGLE); } }