IndexDatabase.java revision 983
0N/A * See LICENSE.txt included in this distribution for the specific
0N/A * file and include the License file at LICENSE.txt.
public class IndexDatabase {
private boolean interrupted;
private boolean dirty;
private boolean running;
this(null);
initialize();
public void run() {
} catch (Exception e) {
public static void update(ExecutorService executor, IndexChangedListener listener, List<String> paths) throws IOException {
} catch (IOException e) {
public void run() {
} catch (Exception e) {
throw new FileNotFoundException("Failed to create root directory [" + indexDir.getAbsolutePath() + "]");
throw new FileNotFoundException("Failed to create root directory [" + spellDir.getAbsolutePath() + "]");
synchronized (lock) {
if (running) {
running = true;
interrupted = false;
//TODO we might need to add writer.commit after certain phases of index generation, right now it will only happen in the end
writer = new IndexWriter(indexDirectory, AnalyzerGuru.getAnalyzer(),IndexWriter.MaxFieldLength.UNLIMITED);
while (uidIter.term() != null && uidIter.term().field().equals("u") && uidIter.term().text().startsWith(startuid)) {
removeFile();
} catch (IOException e) {
} catch (IOException e) {
synchronized (lock) {
running = false;
optimize();
log.warning("Failed to set last modified time on '" + timestamp.getAbsolutePath() + "', used for timestamping the index database.");
log.warning("Failed to create file '" + timestamp.getAbsolutePath() + "', used for timestamping the index database.");
public void run() {
} catch (Exception e) {
public void optimize() {
synchronized (lock) {
if (running) {
running = true;
synchronized (lock) {
dirty = false;
} catch (IOException e) {
} catch (IOException e) {
synchronized (lock) {
running = false;
public void createSpellingSuggestions() {
} catch (IOException e) {
} catch (IOException e) {
private boolean isDirty() {
synchronized (lock) {
return dirty;
private void setDirty() {
synchronized (lock) {
dirty = true;
} catch (IOException e) {
setDirty();
Document d;
} catch (Exception e) {
path);
setDirty();
//below will only let go files and directories, anything else is considered special and is not added
if (isInterrupted()) {
String uid = Util.uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); // construct uid for doc
removeFile();
} catch (Exception e) {
public void interrupt() {
synchronized (lock) {
interrupted = true;
private boolean isInterrupted() {
synchronized (lock) {
return interrupted;
} catch (IOException e) {
} catch (IOException e) {
} catch (IOException e) {
} catch (IOException e) {
if (p == null) {
return null;
return ret;
if (this.project != other.project && (this.project == null || !this.project.equals(other.project))) {
public int hashCode() {
return hash;