mirror of https://github.com/apache/lucene.git
whitespace cleanup only (no more tabs/spaces mix)
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@165552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8fd6b347c
commit
b8dfd507eb
|
@ -27,6 +27,7 @@ import java.util.Date;
|
|||
import java.util.Arrays;
|
||||
|
||||
class IndexHTML {
|
||||
|
||||
private static boolean deleting = false; // true during deletion pass
|
||||
private static IndexReader reader; // existing index
|
||||
private static IndexWriter writer; // new index being built
|
||||
|
@ -41,32 +42,30 @@ class IndexHTML {
|
|||
String usage = "IndexHTML [-create] [-index <index>] <root_directory>";
|
||||
|
||||
if (argv.length == 0) {
|
||||
System.err.println("Usage: " + usage);
|
||||
return;
|
||||
System.err.println("Usage: " + usage);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
if (argv[i].equals("-index")) { // parse -index option
|
||||
index = argv[++i];
|
||||
} else if (argv[i].equals("-create")) { // parse -create option
|
||||
create = true;
|
||||
} else if (i != argv.length-1) {
|
||||
System.err.println("Usage: " + usage);
|
||||
return;
|
||||
} else
|
||||
root = new File(argv[i]);
|
||||
if (argv[i].equals("-index")) { // parse -index option
|
||||
index = argv[++i];
|
||||
} else if (argv[i].equals("-create")) { // parse -create option
|
||||
create = true;
|
||||
} else if (i != argv.length-1) {
|
||||
System.err.println("Usage: " + usage);
|
||||
return;
|
||||
} else
|
||||
root = new File(argv[i]);
|
||||
}
|
||||
|
||||
Date start = new Date();
|
||||
|
||||
if (!create) { // delete stale docs
|
||||
deleting = true;
|
||||
indexDocs(root, index, create);
|
||||
deleting = true;
|
||||
indexDocs(root, index, create);
|
||||
}
|
||||
|
||||
writer = new IndexWriter(index, new StandardAnalyzer(), create);
|
||||
writer.setMaxFieldLength(1000000);
|
||||
|
||||
indexDocs(root, index, create); // add new docs
|
||||
|
||||
System.out.println("Optimizing index...");
|
||||
|
@ -80,7 +79,7 @@ class IndexHTML {
|
|||
|
||||
} catch (Exception e) {
|
||||
System.out.println(" caught a " + e.getClass() +
|
||||
"\n with message: " + e.getMessage());
|
||||
"\n with message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,13 +99,13 @@ class IndexHTML {
|
|||
indexDocs(file);
|
||||
|
||||
if (deleting) { // delete rest of stale docs
|
||||
while (uidIter.term() != null && uidIter.term().field() == "uid") {
|
||||
System.out.println("deleting " +
|
||||
HTMLDocument.uid2url(uidIter.term().text()));
|
||||
reader.delete(uidIter.term());
|
||||
uidIter.next();
|
||||
}
|
||||
deleting = false;
|
||||
while (uidIter.term() != null && uidIter.term().field() == "uid") {
|
||||
System.out.println("deleting " +
|
||||
HTMLDocument.uid2url(uidIter.term().text()));
|
||||
reader.delete(uidIter.term());
|
||||
uidIter.next();
|
||||
}
|
||||
deleting = false;
|
||||
}
|
||||
|
||||
uidIter.close(); // close uid iterator
|
||||
|
@ -121,36 +120,36 @@ class IndexHTML {
|
|||
String[] files = file.list(); // list its files
|
||||
Arrays.sort(files); // sort the files
|
||||
for (int i = 0; i < files.length; i++) // recursively index them
|
||||
indexDocs(new File(file, files[i]));
|
||||
indexDocs(new File(file, files[i]));
|
||||
|
||||
} else if (file.getPath().endsWith(".html") || // index .html files
|
||||
file.getPath().endsWith(".htm") || // index .htm files
|
||||
file.getPath().endsWith(".txt")) { // index .txt files
|
||||
file.getPath().endsWith(".htm") || // index .htm files
|
||||
file.getPath().endsWith(".txt")) { // index .txt files
|
||||
|
||||
if (uidIter != null) {
|
||||
String uid = HTMLDocument.uid(file); // construct uid for doc
|
||||
String uid = HTMLDocument.uid(file); // construct uid for doc
|
||||
|
||||
while (uidIter.term() != null && uidIter.term().field() == "uid" &&
|
||||
uidIter.term().text().compareTo(uid) < 0) {
|
||||
if (deleting) { // delete stale docs
|
||||
System.out.println("deleting " +
|
||||
HTMLDocument.uid2url(uidIter.term().text()));
|
||||
reader.delete(uidIter.term());
|
||||
}
|
||||
uidIter.next();
|
||||
}
|
||||
if (uidIter.term() != null && uidIter.term().field() == "uid" &&
|
||||
uidIter.term().text().compareTo(uid) == 0) {
|
||||
uidIter.next(); // keep matching docs
|
||||
} else if (!deleting) { // add new docs
|
||||
Document doc = HTMLDocument.Document(file);
|
||||
System.out.println("adding " + doc.get("path"));
|
||||
writer.addDocument(doc);
|
||||
}
|
||||
while (uidIter.term() != null && uidIter.term().field() == "uid" &&
|
||||
uidIter.term().text().compareTo(uid) < 0) {
|
||||
if (deleting) { // delete stale docs
|
||||
System.out.println("deleting " +
|
||||
HTMLDocument.uid2url(uidIter.term().text()));
|
||||
reader.delete(uidIter.term());
|
||||
}
|
||||
uidIter.next();
|
||||
}
|
||||
if (uidIter.term() != null && uidIter.term().field() == "uid" &&
|
||||
uidIter.term().text().compareTo(uid) == 0) {
|
||||
uidIter.next(); // keep matching docs
|
||||
} else if (!deleting) { // add new docs
|
||||
Document doc = HTMLDocument.Document(file);
|
||||
System.out.println("adding " + doc.get("path"));
|
||||
writer.addDocument(doc);
|
||||
}
|
||||
} else { // creating a new index
|
||||
Document doc = HTMLDocument.Document(file);
|
||||
System.out.println("adding " + doc.get("path"));
|
||||
writer.addDocument(doc); // add docs unconditionally
|
||||
Document doc = HTMLDocument.Document(file);
|
||||
System.out.println("adding " + doc.get("path"));
|
||||
writer.addDocument(doc); // add docs unconditionally
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue