1 package org.paneris.bibliomania;
2
3 import java.sql.ResultSet;
4 import java.util.Hashtable;
5 import java.util.Properties;
6 import java.util.Vector;
7
8 import org.melati.poem.AccessToken;
9 import org.melati.poem.PoemTask;
10 import org.melati.poem.UnexpectedExceptionPoemException;
11 import org.melati.poem.util.EnumUtils;
12 import org.paneris.bibliomania.fti.IndexCursor;
13
14 public class ShowNotIndexed {
15
16 public static void showNotIndexed(BibliomaniaDatabase db
17
18 ) throws Exception {
19 Hashtable texts = new Hashtable();
20
21 System.err.println("Running through index: this will take a LONG time!");
22
23 int n = 1;
24 IndexCursor cursor = db.fti().allEntries();
25 try {
26 while (cursor.next()) {
27 texts.put(new Long(cursor.textID()), Boolean.TRUE);
28 if (n % 10000 == 0)
29 System.err.println("... " + n);
30 ++n;
31 }
32 }
33 finally {
34 try { cursor.close(); } catch (Exception e) {}
35 }
36
37 System.err.println("Running through chapters in database");
38
39 int currentBook = -1;
40 Vector chaps = new Vector();
41 String path = null;
42 n = 1;
43 for (ResultSet c = db.sqlQuery(
44 "SELECT textid, id, path, book FROM chapter ORDER BY textid");
45 c.next();) {
46 int book = c.getInt(4);
47 if (book != currentBook) {
48 if (chaps.size() != 0) {
49 System.out.println(currentBook + " " + path + " " +
50 EnumUtils.concatenated(" ", chaps.elements()));
51 chaps.setSize(0);
52 }
53
54 currentBook = book;
55 path = c.getString(3);
56 }
57
58 if (!texts.containsKey(new Long(c.getLong(1)))) {
59 if (chaps.size() < 10) chaps.addElement(new Integer(c.getInt(2)));
60 else if (chaps.size() == 10) chaps.addElement("...");
61 }
62
63 if (n % 1000 == 0)
64 System.err.println("... " + n);
65 ++n;
66 }
67 }
68
69 public static void main(String[] args) {
70
71 Properties conf = new Properties();
72 conf.put("idOfWord.cacheSize", "0");
73 conf.put("occurrences.cacheSize", "131072");
74 conf.put("anchorOfIndex.cacheSize", "0");
75
76 final BibliomaniaDatabase db = new BibliomaniaDatabase(false, true, conf);
77 db.connect("bibliomania","org.melati.poem.dbms.Postgresql",
78 "jdbc:postgresql:bibliomania", "postgres", "*",8);
79
80 db.inSession(
81 AccessToken.root,
82 new PoemTask() {
83 public void run() {
84 try {
85 showNotIndexed(db
86
87
88
89
90
91
92 );
93 }
94 catch (Exception e) {
95 throw new UnexpectedExceptionPoemException(e);
96 }
97 }
98 });
99 }
100 }