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