Index.java revision 3c2aee4d6fd37062518aa6de5ad12d4967ebabc0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*/
/**
* Creates and updates an inverted source index
* as well as generates Xref, file stats etc., if specified
* in the options
*/
class Index {
private boolean deleting; // true during deletion pass
private boolean create = true;
private boolean changed;
private AnalyzerGuru af;
try {
} catch ( Exception e) {
System.err.println("Solution: If no other process is using the index, please remove the above lock file and run this command again");
} else {
// try {
// if (reader != null && dataRoot != null && reader.isLocked(dataRoot + "/index")) {
// reader.unlock(FSDirectory.getDirectory(dataRoot + "/index", false) );
// }
// } catch (IOException eio) {
// if (verbose) System.err.println("Warning: Could not delete lock file!");
// }
}
e.printStackTrace();
}
}
public void cancel() {
try {
} catch (IOException ex) {
}
}
try {
} catch (IOException ex) {
}
}
try {
} catch (IOException ex) {
}
}
try {
}
} catch (IOException e) {}
}
/*
* Runs the indexing from arguments
* @param dataRoot directory where search Index and all other data are stored
* @param srcRoot root of the source tree
* @param economical Should Xref HTML files be generated?
*/
boolean economical) throws IOException {
try {
}
try {
} catch(IOException e) {
}
if (!economical) {
}
}
create = false;
}
}
if (allSubFiles != null) {
}
}
}
}
continue;
}
parent = "";
} else {
}
}
} else {
}
} else {
}
}
boolean anythingChanged = create;
return 0;
}
changed = false;
if (!create) {
deleting = true;
}
if (changed) anythingChanged = true;
af = new AnalyzerGuru();
try {
} catch (IOException e) {
//forcefully unlock the index
try {
}
}
}
}
}
/*writer.mergeFactor = 1000;
writer.maxMergeDocs = 100000;
writer.minMergeDocs = 1000;*/
try {
} catch (IOException e) {
try {
}
} catch (IOException eio) {
}
throw e;
}
create = false;
}
}
if(!anythingChanged){
} else {
if(!economical) {
}
}
return 1;
} catch (RuntimeException e) {
}
throw e;
}
}
/*
* It is basically diffing two sorted lists of file names
* agumented with its last modified timestamp:
* (1) the list of files in the index
* The uidIter gives a list of files in index sorted.
* (2) the list of files on disk
* traversing the directory tree recursively gives list of files
* on disk
* Algorithm is simple:
* while(each list has elements) {
* if (elem1 < elem2)
* delete elem1
* list1.next()
* else if elem1 == elem2
* do nothing
* else
* add elem2
* list2.next()
* }
* delete all remaining elements of list1
* add all remaining elements of list2
*
* It makes a two pass over the file tree.
* Entire ON traversal took 10-20 secs.
* May need to optimize if this gets worse.
*/
if (!create) {
//System.out.println("Start uid = " + startuid);
if (deleting) { // delete rest of stale docs
while (uidIter.term() != null && uidIter.term().field().equals("u") && uidIter.term().text().startsWith(startuid)) {
}
deleting = false;
}
} else //creating
}
return;
}
return;
}
//SizeandLines rets = new SizeandLines();
if (file.isDirectory()) {
//SizeandLines ret = new SizeandLines();
}
}
}
}
}
} else {
return;
}
if (deleting) { // delete stale docs
changed = true;
}
}
} else {
if (!deleting) { // add new docs
if (d != null) {
}
} else {
}
} else {
changed = true;
}
}
} else { // creating a new index
if (d != null) {
}
} else {
}
}
}
}
/*
* Merges fragmented indexes
*/
if (indexDir.isDirectory()) {
try{
} catch (IOException e) {
}
} else {
}
}
/**
* Generate a sorted list of "word"s
*/
try {
}
} else {
break;
}
}
} catch (IOException e) {
System.err.println("ERROR: While generating dictionary " + dataRoot + ": " + e.getLocalizedMessage());
}
}
/**
* List all file names indexd
*/
try {
}
} catch (IOException e) {
System.err.println("ERROR: While listing files in index " + dataRoot + ": " + e.getLocalizedMessage());
}
}
}
// If no Path to CTags was specifyed we guess that its reachable ...
ctags = "ctags";
//Check if exub ctags is available
try {
} catch (Exception e) {
}
try {
} else {
"Please use option -c to specify path to a good Exuberant Ctags program");
return false;
}
} catch (Exception e) {
"\nPlease use option -c to specify path to a good Exuberant Ctags program");
return false;
}
return true;
}
}