@Test public void testRemove() throws IOException { Directory dir = new ByteBuffersDirectory(); Path tempDir = Files.createTempDirectory("test"); try (IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig())) { Document doc = new Document(); doc.add(new TextField("test", "text", Field.Store.NO)); iw.addDocument(doc); } SuggesterProjectData data = new SuggesterProjectData(dir, tempDir, false, Collections.singleton("test")); data.init(); data.remove(); assertFalse(tempDir.toFile().exists()); }
public void remove() { lock.writeLock().lock(); try { try { close(); } catch (IOException e) { logger.log(Level.WARNING, "Could not close opened index directory {0}", indexDir); } try { FileUtils.deleteDirectory(suggesterDir.toFile()); } catch (IOException e) { logger.log(Level.WARNING, "Cannot remove suggester data: {0}", suggesterDir); } } finally { lock.writeLock().unlock(); } }
SuggesterProjectData implements Closeable { public void remove() { lock.writeLock().lock(); try { try { close(); } catch (IOException e) { logger.log(Level.WARNING, "Could not close opened index directory {0}", indexDir); } try { FileUtils.deleteDirectory(suggesterDir.toFile()); } catch (IOException e) { logger.log(Level.WARNING, "Cannot remove suggester data: {0}", suggesterDir); } } finally { lock.writeLock().unlock(); } } }
SuggesterProjectData implements Closeable { public void remove() { lock.writeLock().lock(); try { try { close(); } catch (IOException e) { logger.log(Level.WARNING, "Could not close opened index directory {0}", indexDir); } try { FileUtils.deleteDirectory(suggesterDir.toFile()); } catch (IOException e) { logger.log(Level.WARNING, "Cannot remove suggester data: {0}", suggesterDir); } } finally { lock.writeLock().unlock(); } } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); }
SuggesterProjectData implements Closeable { public void remove() { lock.writeLock().lock(); try { try { close(); } catch (IOException e) { logger.log(Level.WARNING, "Could not close opened index directory {0}", indexDir); } try { FileUtils.deleteDirectory(suggesterDir.toFile()); } catch (IOException e) { logger.log(Level.WARNING, "Cannot remove suggester data: {0}", suggesterDir); } } finally { lock.writeLock().unlock(); } } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); void init(); void rebuild(); List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize); void remove(); void incrementSearchCount(final Term term); boolean incrementSearchCount(final Term term, final int value); PopularityCounter getSearchCounts(final String field); @Override void close(); boolean tryLock(); void unlock(); List<Entry<BytesRef, Integer>> getSearchCountsSorted(final String field, int page, int pageSize); @Override String toString(); }
SuggesterProjectData implements Closeable { public void remove() { lock.writeLock().lock(); try { try { close(); } catch (IOException e) { logger.log(Level.WARNING, "Could not close opened index directory {0}", indexDir); } try { FileUtils.deleteDirectory(suggesterDir.toFile()); } catch (IOException e) { logger.log(Level.WARNING, "Cannot remove suggester data: {0}", suggesterDir); } } finally { lock.writeLock().unlock(); } } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); void init(); void rebuild(); List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize); void remove(); void incrementSearchCount(final Term term); boolean incrementSearchCount(final Term term, final int value); PopularityCounter getSearchCounts(final String field); @Override void close(); boolean tryLock(); void unlock(); List<Entry<BytesRef, Integer>> getSearchCountsSorted(final String field, int page, int pageSize); @Override String toString();  }