IndexDatabase.java revision 1461
260N/A * The contents of this file are subject to the terms of the 260N/A * Common Development and Distribution License (the "License"). 260N/A * You may not use this file except in compliance with the License. 260N/A * language governing permissions and limitations under the License. 260N/A * When distributing Covered Code, include this CDDL HEADER in each 260N/A * If applicable, add the following below this CDDL HEADER, with the 260N/A * fields enclosed by brackets "[]" replaced with your own identifying 260N/A * information: Portions Copyright [yyyy] [name of copyright owner] 260N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 260N/A * This class is used to create / update the index databases. Currently we use 260N/A * one index database per project. 260N/A * @author Lubos Kosco , update for lucene 3.0.0 260N/A * Create a new instance of the Index Database. Use this constructor if 260N/A * you don't use any projects 260N/A * @throws java.io.IOException if an error occurs while creating directories 260N/A * Create a new instance of an Index Database for a given project 260N/A * @param project the project to create the database for 260N/A * @throws java.io.IOException if an errror occurs while creating directories 260N/A * Update the index database for all of the projects. Print progress to 260N/A * @param executor An executor to run the job 260N/A * @throws IOException if an error occurs 260N/A * Update the index database for all of the projects 260N/A * @param executor An executor to run the job 260N/A * @param listener where to signal the changes to the database 260N/A * @throws IOException if an error occurs 260N/A * Update the index database for a number of sub-directories 260N/A * @param executor An executor to run the job 260N/A * @param listener where to signal the changes to the database // to avoid race conditions, just recheck.. * By default the indexer will traverse all directories in the project. * If you add directories with this function update will just process * the specified directories. * @param dir The directory to scan * @return <code>true</code> if the file is added, false oth * Update the content of this index database * @throws IOException if an error occurs * @throws HistoryException if an error occurs when accessing the history logger.
warning(
"Unable to run ctags! Searching definitions will not work!");
//TODO we might need to add writer.commit after certain phases of // index generation, right now it will only happen in the end //iwc.setRAMBufferSizeMB(256.0); //TODO check what is the sweet spot //writer.setMaxFieldLength(RuntimeEnvironment.getInstance().getIndexWordLimit()); //TODO below should be optional, since it traverses the tree once more to get total count! :( +
"'used for timestamping the index database");
+
"', used for timestamping the index database");
* Optimize all index databases * @param executor An executor to run the job * @throws IOException if an error occurs * Optimize the index database logger.
warning(
"Optimize terminated... Someone else is updating / optimizing it!");
* Generate a spelling suggestion for the definitions stored in defs logger.
info(
"Generating spelling suggestions for " +
this +
" ...");
//TODO below seems only to index "defs" , possible bug ? logger.
info(
"Generating spelling suggestions for " +
this +
" done");
logger.
warning(
"Problem when generating spelling suggestions for " * Remove a stale file (uidIter.term().text()) from the index database * @throws java.io.IOException if an error occurs // Remove the parent directory if it's empty * Add a file to the Lucene index (and generate a xref file) * @param file The file to add * @param path The path to the file (from source root) * @throws java.io.IOException if an error occurs "Skipped file ''{0}'' because the analyzer didn''t " +
// If mkdirs() returns false, the failure is most likely // because the file already exists. But to check for the // file first and only add it if it doesn't exists would // only increase the file IO... * Check if I should accept this file into the index database * @param file the file to check * @return true if the file should be included, false otherwise // the filter should not affect directory names //below will only let go files and directories, anything else is considered special and is not added // always accept directories so that their files can be examined // versioned files should always be accepted // this is an unversioned file, check if it should be indexed // Now, let's verify that it's not a link back up the chain... * Check if I should accept the path containing a symlink * @param absolutePath the path with a symlink to check * @param canonicalPath the canonical path to the file * @return true if the file should be accepted, false otherwise // Always accept local symlinks * Check if a file is local to the current project. If we don't have * projects, check if the file is in the source root. * @param path the path to a file * @return true if the file is local to the current repository // File is under the current project, so it's local. // File is under source root, and we don't have projects, so * Generate indexes recursively * @param dir the root indexDirectory to generate indexes for * @param count_only if true will just traverse the source root and count files * @param cur_count current count during the traversal of the tree * @param est_total estimate total files to process * Interrupt the index generation (and the index generation will stop as * Register an object to receive events when modifications is done to the * @param listener the object to receive the events * Remove an object from the lists of objects to receive events when * modifications is done to the index database * @param listener the object to remove * List all files in all of the index databases * @throws IOException if an error occurs * List all files in some of the index databases * @param subFiles Subdirectories for the various projects to list the files * for (or null or an empty list to dump all projects) * @throws IOException if an error occurs * List all of the files in this index database * @throws IOException If an IO error occurs while reading from the database * Get an indexReader for the Index database where a given file * @param path the file to get the database for * @return The index database where the file should be located or null if * Get the latest definitions for a file from the index. * @param file the file whose definitions to find * @return definitions for the file, or {@code null} if they could not * @throws IOException if an error happens when accessing the index * @throws ParseException if an error happens when building the Lucene query * @throws ClassNotFoundException if the class for the stored definitions * instance cannot be found // No index, no definitions... // No hits, no definitions... // Only use the definitions if we found an exact match. // Didn't find any definitions.