Author: j16sdiz
Date: 2008-12-30 03:50:36 +0000 (Tue, 30 Dec 2008)
New Revision: 24839

Modified:
   trunk/plugins/XMLSpider/db/Page.java
   trunk/plugins/XMLSpider/db/PerstRoot.java
Log:
Use FieldIndex, this seems to be faster.

This is not compatible to old database, please delete it.

Modified: trunk/plugins/XMLSpider/db/Page.java
===================================================================
--- trunk/plugins/XMLSpider/db/Page.java        2008-12-30 03:27:48 UTC (rev 
24838)
+++ trunk/plugins/XMLSpider/db/Page.java        2008-12-30 03:50:36 UTC (rev 
24839)
@@ -3,9 +3,9 @@
  */
 package plugins.XMLSpider.db;
 
+import plugins.XMLSpider.org.garret.perst.FieldIndex;
 import plugins.XMLSpider.org.garret.perst.IPersistentMap;
 import plugins.XMLSpider.org.garret.perst.Persistent;
-import plugins.XMLSpider.org.garret.perst.SortedCollection;
 import plugins.XMLSpider.org.garret.perst.Storage;
 
 public class Page extends Persistent implements Comparable<Page> {
@@ -120,7 +120,7 @@
 
                if (storage != null) {
                        PerstRoot root = (PerstRoot) storage.getRoot();
-                       SortedCollection<Page> coll = 
root.getPageCollection(status);
+                       FieldIndex<Page> coll = root.getPageIndex(status);
                        coll.remove(this);
                }
        }
@@ -134,8 +134,8 @@
 
                if (storage != null) {
                        PerstRoot root = (PerstRoot) storage.getRoot();
-                       SortedCollection<Page> coll = 
root.getPageCollection(status);
-                       coll.add(this);
+                       FieldIndex<Page> coll = root.getPageIndex(status);
+                       coll.put(this);
                }
        }
 }

Modified: trunk/plugins/XMLSpider/db/PerstRoot.java
===================================================================
--- trunk/plugins/XMLSpider/db/PerstRoot.java   2008-12-30 03:27:48 UTC (rev 
24838)
+++ trunk/plugins/XMLSpider/db/PerstRoot.java   2008-12-30 03:50:36 UTC (rev 
24839)
@@ -6,7 +6,6 @@
 import plugins.XMLSpider.org.garret.perst.FieldIndex;
 import plugins.XMLSpider.org.garret.perst.Key;
 import plugins.XMLSpider.org.garret.perst.Persistent;
-import plugins.XMLSpider.org.garret.perst.SortedCollection;
 import plugins.XMLSpider.org.garret.perst.Storage;
 import freenet.keys.FreenetURI;
 
@@ -16,9 +15,9 @@
 
        protected FieldIndex<Page> idPage;
        protected FieldIndex<Page> uriPage;
-       protected SortedCollection<Page> queuedPages;
-       protected SortedCollection<Page> failedPages;
-       protected SortedCollection<Page> succeededPages;
+       protected FieldIndex<Page> queuedPages;
+       protected FieldIndex<Page> failedPages;
+       protected FieldIndex<Page> succeededPages;
        
        private Config config;
 
@@ -33,9 +32,9 @@
 
                root.idPage = storage.createFieldIndex(Page.class, "id", true);
                root.uriPage = storage.createFieldIndex(Page.class, "uri", 
true);
-               root.queuedPages = storage.<Page> createSortedCollection(new 
PageTimeStampComparator(), false);
-               root.failedPages = storage.<Page> createSortedCollection(new 
PageTimeStampComparator(), false);
-               root.succeededPages = storage.<Page> createSortedCollection(new 
PageTimeStampComparator(), false);
+               root.queuedPages = storage.createFieldIndex(Page.class, 
"lastChange", false);
+               root.failedPages = storage.createFieldIndex(Page.class, 
"lastChange", false);
+               root.succeededPages = storage.createFieldIndex(Page.class, 
"lastChange", false);
                
                
                root.config = new Config(storage);
@@ -77,7 +76,7 @@
 
                        idPage.append(page);
                        uriPage.put(page);
-                       queuedPages.add(page);
+                       queuedPages.put(page);
                }
 
                return page;
@@ -88,7 +87,7 @@
                return page;
        }
        
-       SortedCollection<Page> getPageCollection(Status status) {
+       FieldIndex<Page> getPageIndex(Status status) {
                switch (status) {
                case FAILED:
                        return failedPages;
@@ -102,11 +101,11 @@
        }
 
        public synchronized Iterator<Page> getPages(Status status) {
-               return getPageCollection(status).iterator();
+               return getPageIndex(status).iterator();
        }
        
        public synchronized int getPageCount(Status status) {
-               return getPageCollection(status).size();
+               return getPageIndex(status).size();
        }
 
        public void setConfig(Config config) {

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to