@Test public void lazyInit() throws Exception { LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); DefaultIndexWriter writer = createWriter(defn, false); assertFalse(writer.close(0)); }
@Override public boolean close(long timestamp) throws IOException { if (reindex && writer == null){ getWriter(); } Calendar currentTime = Calendar.getInstance(); currentTime.setTimeInMillis(timestamp); boolean updateSuggestions = shouldUpdateSuggestions(currentTime); if (writer == null && updateSuggestions) { log.debug("Would update suggester dictionary although no index changes were detected in current cycle"); getWriter(); } if (writer != null) { if (log.isTraceEnabled()) { trackIndexSizeInfo(writer, definition, directory); } final long start = PERF_LOGGER.start(); if (updateSuggestions) { indexUpdated |= updateSuggester(writer.getAnalyzer(), currentTime); PERF_LOGGER.end(start, -1, "Completed suggester for directory {}", definition); } writer.close(); PERF_LOGGER.end(start, -1, "Closed writer for directory {}", definition); if (!indexUpdated){ long genAtEnd = getLatestGeneration(directory); indexUpdated = genAtEnd != genAtStart; } directory.close(); PERF_LOGGER.end(start, -1, "Closed directory for directory {}", definition); } return indexUpdated; }
DefaultIndexWriter implements LuceneIndexWriter { @Override public boolean close(long timestamp) throws IOException { if (reindex && writer == null){ getWriter(); } Calendar currentTime = Calendar.getInstance(); currentTime.setTimeInMillis(timestamp); boolean updateSuggestions = shouldUpdateSuggestions(currentTime); if (writer == null && updateSuggestions) { log.debug("Would update suggester dictionary although no index changes were detected in current cycle"); getWriter(); } if (writer != null) { if (log.isTraceEnabled()) { trackIndexSizeInfo(writer, definition, directory); } final long start = PERF_LOGGER.start(); if (updateSuggestions) { indexUpdated |= updateSuggester(writer.getAnalyzer(), currentTime); PERF_LOGGER.end(start, -1, "Completed suggester for directory {}", definition); } writer.close(); PERF_LOGGER.end(start, -1, "Closed writer for directory {}", definition); if (!indexUpdated){ long genAtEnd = getLatestGeneration(directory); indexUpdated = genAtEnd != genAtStart; } directory.close(); PERF_LOGGER.end(start, -1, "Closed directory for directory {}", definition); } return indexUpdated; } }
DefaultIndexWriter implements LuceneIndexWriter { @Override public boolean close(long timestamp) throws IOException { if (reindex && writer == null){ getWriter(); } Calendar currentTime = Calendar.getInstance(); currentTime.setTimeInMillis(timestamp); boolean updateSuggestions = shouldUpdateSuggestions(currentTime); if (writer == null && updateSuggestions) { log.debug("Would update suggester dictionary although no index changes were detected in current cycle"); getWriter(); } if (writer != null) { if (log.isTraceEnabled()) { trackIndexSizeInfo(writer, definition, directory); } final long start = PERF_LOGGER.start(); if (updateSuggestions) { indexUpdated |= updateSuggester(writer.getAnalyzer(), currentTime); PERF_LOGGER.end(start, -1, "Completed suggester for directory {}", definition); } writer.close(); PERF_LOGGER.end(start, -1, "Closed writer for directory {}", definition); if (!indexUpdated){ long genAtEnd = getLatestGeneration(directory); indexUpdated = genAtEnd != genAtStart; } directory.close(); PERF_LOGGER.end(start, -1, "Closed directory for directory {}", definition); } return indexUpdated; } DefaultIndexWriter(LuceneIndexDefinition definition, NodeBuilder definitionBuilder,
                              DirectoryFactory directoryFactory, String dirName, String suggestDirName,
                              boolean reindex, LuceneIndexWriterConfig writerConfig); }
DefaultIndexWriter implements LuceneIndexWriter { @Override public boolean close(long timestamp) throws IOException { if (reindex && writer == null){ getWriter(); } Calendar currentTime = Calendar.getInstance(); currentTime.setTimeInMillis(timestamp); boolean updateSuggestions = shouldUpdateSuggestions(currentTime); if (writer == null && updateSuggestions) { log.debug("Would update suggester dictionary although no index changes were detected in current cycle"); getWriter(); } if (writer != null) { if (log.isTraceEnabled()) { trackIndexSizeInfo(writer, definition, directory); } final long start = PERF_LOGGER.start(); if (updateSuggestions) { indexUpdated |= updateSuggester(writer.getAnalyzer(), currentTime); PERF_LOGGER.end(start, -1, "Completed suggester for directory {}", definition); } writer.close(); PERF_LOGGER.end(start, -1, "Closed writer for directory {}", definition); if (!indexUpdated){ long genAtEnd = getLatestGeneration(directory); indexUpdated = genAtEnd != genAtStart; } directory.close(); PERF_LOGGER.end(start, -1, "Closed directory for directory {}", definition); } return indexUpdated; } DefaultIndexWriter(LuceneIndexDefinition definition, NodeBuilder definitionBuilder,
                              DirectoryFactory directoryFactory, String dirName, String suggestDirName,
                              boolean reindex, LuceneIndexWriterConfig writerConfig); @Override void updateDocument(String path, Iterable<? extends IndexableField> doc); @Override void deleteDocuments(String path); @Override boolean close(long timestamp); }
DefaultIndexWriter implements LuceneIndexWriter { @Override public boolean close(long timestamp) throws IOException { if (reindex && writer == null){ getWriter(); } Calendar currentTime = Calendar.getInstance(); currentTime.setTimeInMillis(timestamp); boolean updateSuggestions = shouldUpdateSuggestions(currentTime); if (writer == null && updateSuggestions) { log.debug("Would update suggester dictionary although no index changes were detected in current cycle"); getWriter(); } if (writer != null) { if (log.isTraceEnabled()) { trackIndexSizeInfo(writer, definition, directory); } final long start = PERF_LOGGER.start(); if (updateSuggestions) { indexUpdated |= updateSuggester(writer.getAnalyzer(), currentTime); PERF_LOGGER.end(start, -1, "Completed suggester for directory {}", definition); } writer.close(); PERF_LOGGER.end(start, -1, "Closed writer for directory {}", definition); if (!indexUpdated){ long genAtEnd = getLatestGeneration(directory); indexUpdated = genAtEnd != genAtStart; } directory.close(); PERF_LOGGER.end(start, -1, "Closed directory for directory {}", definition); } return indexUpdated; } DefaultIndexWriter(LuceneIndexDefinition definition, NodeBuilder definitionBuilder,
                              DirectoryFactory directoryFactory, String dirName, String suggestDirName,
                              boolean reindex, LuceneIndexWriterConfig writerConfig); @Override void updateDocument(String path, Iterable<? extends IndexableField> doc); @Override void deleteDocuments(String path); @Override boolean close(long timestamp);  }