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
pull/1/head
allo 19 years ago
parent eeba8b055e
commit a26574c894

@ -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();

@ -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(){

@ -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;

Loading…
Cancel
Save