From a26574c894b3b41d5cfc7b6b55d879b3f86e4ea4 Mon Sep 17 00:00:00 2001 From: allo Date: Tue, 14 Feb 2006 10:00:12 +0000 Subject: [PATCH] Migration from tagName as key to wordhash(tagName) as key for bookmarkTags.db (just deleting the old db, rebuildTags does the rest) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1637 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/data/bookmarksDB.java | 6 +++--- .../de/anomic/plasma/plasmaSwitchboard.java | 19 +++++++++++-------- source/migration.java | 14 +++++++++++++- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java index c737bd7a8..ebbf337ab 100644 --- a/source/de/anomic/data/bookmarksDB.java +++ b/source/de/anomic/data/bookmarksDB.java @@ -139,13 +139,13 @@ public class bookmarksDB { tagsFile.delete(); tagsFile.getParentFile().mkdirs(); // max. 128 byte long tags - this.tagsTable = new kelondroMap(new kelondroDyn(tagsFile, bufferkb * 1024, 128, 256, '_', true)); + this.tagsTable = new kelondroMap(new kelondroDyn(tagsFile, bufferkb * 1024, 12, 256, '_', true)); rebuildTags(); } }else{ //new database tagsFile.getParentFile().mkdirs(); - this.tagsTable = new kelondroMap(new kelondroDyn(tagsFile, bufferkb * 1024, 128, 256, '_', true)); + this.tagsTable = new kelondroMap(new kelondroDyn(tagsFile, bufferkb * 1024, 12, 256, '_', true)); rebuildTags(); } // dates @@ -272,7 +272,7 @@ public class bookmarksDB { while (it.hasNext()) { bookmark = getBookmark((String) it.next()); tags = listManager.string2vector(bookmark.getTags()); - tags.remove(oldName); + tags.remove(oldName); //this will fail, if upper/lowercase is not matching tags.add(newName); bookmark.setTags(tags); bookmark.setBookmarksTable(); diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 37ca40072..32e141ada 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -305,10 +305,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser int ramRWI = (int) getConfigLong("ramCacheRWI", 1024) / 1024; int ramHTTP = (int) getConfigLong("ramCacheHTTP", 1024) / 1024; int ramMessage = (int) getConfigLong("ramCacheMessage", 1024) / 1024; - int ramWiki = (int) getConfigLong("ramCacheWiki", 1024) / 1024; int ramRobots = (int) getConfigLong("ramCacheRobots",1024) / 1024; int ramProfiles= (int) getConfigLong("ramCacheProfiles",1024) / 1024; int ramPreNURL = (int) getConfigLong("ramCachePreNURL", 1024) / 1024; + int ramWiki = (int) getConfigLong("ramCacheWiki", 1024) / 1024; this.log.logConfig("LURL Cache memory = " + ppRamString(ramLURL)); this.log.logConfig("NURL Cache memory = " + ppRamString(ramNURL)); this.log.logConfig("EURL Cache memory = " + ppRamString(ramEURL)); @@ -429,13 +429,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser ", " + ppRamString(userDbFile.length()/1024)); //Init bookmarks DB - this.log.logConfig("Loading Bookmarks DB"); - File bookmarksFile = new File(workPath, "bookmarks.db"); - File tagsFile = new File(workPath, "bookmarkTags.db"); - File datesFile = new File(workPath, "bookmarkDates.db"); - this.bookmarksDB = new bookmarksDB(bookmarksFile, tagsFile, datesFile, 512); - this.log.logConfig("Loaded Bookmarks DB from files "+ bookmarksFile.getName()+ ", "+tagsFile.getName()); - this.log.logConfig(this.bookmarksDB.tagsSize()+" Tag, "+this.bookmarksDB.bookmarksSize()+" Bookmarks"); + initBookmarks(); // init cookie-Monitor this.log.logConfig("Starting Cookie Monitor"); @@ -594,6 +588,15 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser ", " + this.wikiDB.size() + " entries" + ", " + ppRamString(wikiDbFile.length()/1024)); } + public void initBookmarks(){ + this.log.logConfig("Loading Bookmarks DB"); + File bookmarksFile = new File(workPath, "bookmarks.db"); + File tagsFile = new File(workPath, "bookmarkTags.db"); + File datesFile = new File(workPath, "bookmarkDates.db"); + this.bookmarksDB = new bookmarksDB(bookmarksFile, tagsFile, datesFile, 512); + this.log.logConfig("Loaded Bookmarks DB from files "+ bookmarksFile.getName()+ ", "+tagsFile.getName()); + this.log.logConfig(this.bookmarksDB.tagsSize()+" Tag, "+this.bookmarksDB.bookmarksSize()+" Bookmarks"); + } public static plasmaSwitchboard getSwitchboard(){ diff --git a/source/migration.java b/source/migration.java index b2cfb94b9..0ce4c98ae 100644 --- a/source/migration.java +++ b/source/migration.java @@ -50,6 +50,7 @@ import de.anomic.server.logging.serverLog; public class migration { //SVN constants public static final int USE_WORK_DIR=1389; //wiki & messages in DATA/WORK + public static final int TAGDB_WITH_TAGHASH=1635; //tagDB keys are tagHashes instead of plain tagname. public static void main(String[] args) { } @@ -60,11 +61,22 @@ public class migration { } public static void migrate(plasmaSwitchboard sb, int fromRev, int toRev){ if(fromRev < toRev){ + if(fromRev < TAGDB_WITH_TAGHASH){ + migrateBookmarkTagsDB(sb); + } serverLog.logInfo("MIGRATION", "Migrating from "+String.valueOf(fromRev)+ " to "+String.valueOf(toRev)); migrate(sb); } } - + public static void migrateBookmarkTagsDB(plasmaSwitchboard sb){ + sb.bookmarksDB.close(); + File tagsDBFile=new File(sb.workPath, "bookmarkTags.db"); + if(tagsDBFile.exists()){ + tagsDBFile.delete(); + serverLog.logInfo("MIGRATION", "Migrating bookmarkTags.db to use wordhashs as keys."); + } + sb.initBookmarks(); + } public static void migrateWorkFiles(plasmaSwitchboard sb){ File file=new File(sb.getRootPath(), "DATA/SETTINGS/wiki.db"); File file2;