OSDN Git Service

Correct word index bug which excluded some words in error.
authorRandy Baumgarte <randy@fbn.cx>
Wed, 12 Jan 2011 16:23:49 +0000 (11:23 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 30 Jan 2011 13:36:09 +0000 (08:36 -0500)
src/cx/fbn/nevernote/threads/IndexRunner.java

index 1ace4c0..f9ff768 100644 (file)
@@ -109,6 +109,7 @@ public class IndexRunner extends QObject implements Runnable {
                while (keepRunning) {\r
                        idle=true;\r
                        try {\r
                while (keepRunning) {\r
                        idle=true;\r
                        try {\r
+                               //waitSeconds(1);\r
                                String work = workQueue.take();\r
                                idle=false;\r
                                if (work.startsWith("SCAN")) {\r
                                String work = workQueue.take();\r
                                idle=false;\r
                                if (work.startsWith("SCAN")) {\r
@@ -530,8 +531,8 @@ public class IndexRunner extends QObject implements Runnable {
 \r
        \r
        private void addToIndex(String guid, String word, String type) {\r
 \r
        \r
        private void addToIndex(String guid, String word, String type) {\r
-               if (!foundWords.contains(word))\r
-                       foundWords.add(word);\r
+               if (foundWords.contains(word))\r
+                       return;\r
                StringBuffer buffer = new StringBuffer(word.toLowerCase());\r
                for (int i=buffer.length()-1; i>=0; i--) {\r
                        if (!Character.isLetterOrDigit(buffer.charAt(i)))\r
                StringBuffer buffer = new StringBuffer(word.toLowerCase());\r
                for (int i=buffer.length()-1; i>=0; i--) {\r
                        if (!Character.isLetterOrDigit(buffer.charAt(i)))\r
@@ -551,6 +552,7 @@ public class IndexRunner extends QObject implements Runnable {
                        // We have a good word, now let's trim off junk at the beginning or end\r
                        if (!foundWords.contains(buffer.toString())) {\r
                                foundWords.add(buffer.toString());\r
                        // We have a good word, now let's trim off junk at the beginning or end\r
                        if (!foundWords.contains(buffer.toString())) {\r
                                foundWords.add(buffer.toString());\r
+                               foundWords.add(word);\r
                                conn.getWordsTable().addWordToNoteIndex(guid, buffer.toString(), type, 100);\r
                        }\r
                }\r
                                conn.getWordsTable().addWordToNoteIndex(guid, buffer.toString(), type, 100);\r
                        }\r
                }\r
@@ -568,6 +570,7 @@ public class IndexRunner extends QObject implements Runnable {
                for (int i=0; i<notes.size() && !interrupt && keepRunning; i++) {\r
                        guid = notes.get(i);\r
                        if (guid != null && keepRunning) {\r
                for (int i=0; i<notes.size() && !interrupt && keepRunning; i++) {\r
                        guid = notes.get(i);\r
                        if (guid != null && keepRunning) {\r
+                               //waitSeconds(1);\r
                                indexNoteContent();\r
                        }\r
                }\r
                                indexNoteContent();\r
                        }\r
                }\r
@@ -580,6 +583,7 @@ public class IndexRunner extends QObject implements Runnable {
                for (int i=0; i<unindexedResources.size()&& !interrupt && keepRunning; i++) {\r
                        guid = unindexedResources.get(i);\r
                        if (keepRunning) {\r
                for (int i=0; i<unindexedResources.size()&& !interrupt && keepRunning; i++) {\r
                        guid = unindexedResources.get(i);\r
                        if (keepRunning) {\r
+                               //waitSeconds(1);\r
                                indexResource();\r
                        }\r
                }\r
                                indexResource();\r
                        }\r
                }\r
@@ -598,4 +602,13 @@ public class IndexRunner extends QObject implements Runnable {
                conn.getNoteTable().noteResourceTable.reindexAll(); \r
        }\r
 \r
                conn.getNoteTable().noteResourceTable.reindexAll(); \r
        }\r
 \r
+//     private void waitSeconds(int len) {\r
+//             QDateTime currentdate = new QDateTime(QDateTime.currentDateTime());\r
+//             QDateTime futuredate = new QDateTime(QDateTime.currentDateTime());\r
+//             \r
+//             while (keepRunning && (futuredate.toTime_t() - currentdate.toTime_t() >=len) ) {\r
+//                     Thread.yield();\r
+//                     futuredate = new QDateTime(QDateTime.currentDateTime());\r
+//             }\r
+//     }\r
 }\r
 }\r