Skip to content

Commit

Permalink
*) More debugging output for migrateWords
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1085 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed Nov 15, 2005
1 parent 9b35ae9 commit ca26aab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions source/de/anomic/plasma/parser/zip/zipParser.java
Expand Up @@ -169,6 +169,8 @@ public plasmaParserDocument parse(URL location, String mimeType, InputStream sou
docImages);
} catch (Exception e) {
throw new ParserException("Unable to parse the zip content. " + e.getMessage());
} catch (Error e) {
throw new ParserException("Unable to parse the zip content. " + e.getMessage());
}
}

Expand Down
14 changes: 7 additions & 7 deletions source/de/anomic/plasma/plasmaWordIndexCache.java
Expand Up @@ -550,19 +550,19 @@ public void close(int waitingSeconds) {
}
}

public int migrateWords2Assortment(String wordhash) throws IOException {
public Object migrateWords2Assortment(String wordhash) throws IOException {
// returns the number of entries that had been added to the assortments
// can be negative if some assortments have been moved to the backend
File db = plasmaWordIndexEntity.wordHash2path(databaseRoot, wordhash);
if (!(db.exists())) return 0;
if (!(db.exists())) return "not available";
plasmaWordIndexEntity entity = null;
try {
entity = new plasmaWordIndexEntity(databaseRoot, wordhash, true);
int size = entity.size();
if (size > assortmentCluster.clusterCapacity) {
// this will be too big to integrate it
entity.close(); entity = null;
return 0;
return "too big";
} else {
// take out all words from the assortment to see if it fits
// together with the extracted assortment
Expand All @@ -571,28 +571,28 @@ public int migrateWords2Assortment(String wordhash) throws IOException {
// this will also be too big to integrate, add to entity
entity.addEntries(container);
entity.close(); entity = null;
return -container.size();
return new Integer(-container.size());
} else {
// the combined container will fit, read the container
try {
Iterator entries = entity.elements(true);
plasmaWordIndexEntry entry;
while (entries.hasNext()) {
entry = (plasmaWordIndexEntry) entries.next();
System.out.println("ENTRY = " + entry.getUrlHash());
// System.out.println("ENTRY = " + entry.getUrlHash());
container.add(new plasmaWordIndexEntry[]{entry}, System.currentTimeMillis());
}
// we have read all elements, now delete the entity
entity.deleteComplete();
entity.close(); entity = null;
// integrate the container into the assortments; this will work
assortmentCluster.storeTry(wordhash, container);
return size;
return new Integer(size);
} catch (kelondroException e) {
// database corrupted, we simply give up the database and delete it
try {entity.close();} catch (Exception ee) {} entity = null;
try {db.delete();} catch (Exception ee) {}
return 0;
return "database corrupted; deleted";
}
}
}
Expand Down
21 changes: 13 additions & 8 deletions source/yacy.java
Expand Up @@ -622,18 +622,23 @@ public static void migrateWords(String homePath) {
enumerateFiles words = new enumerateFiles(new File(dbroot, "WORDS"), true, false, true, true);
String wordhash;
File wordfile;
int migration;
Object migrationStatus;
while (words.hasMoreElements()) try {
wordfile = (File) words.nextElement();
wordhash = wordfile.getName().substring(0, 12);
System.out.println("NOW: " + wordhash);
migration = wordIndexCache.migrateWords2Assortment(wordhash);
if (migration == 0)
log.logInfo("SKIPPED " + wordhash + ": " + ((wordfile.exists()) ? "too big" : "database corrupted; deleted"));
else if (migration > 0)
log.logInfo("MIGRATED " + wordhash + ": " + migration + " entries");
else
log.logInfo("REVERSED " + wordhash + ": " + (-migration) + " entries");
migrationStatus = wordIndexCache.migrateWords2Assortment(wordhash);
if (migrationStatus instanceof Integer) {
int migrationCount = ((Integer)migrationStatus).intValue();
if (migrationCount == 0)
log.logInfo("SKIPPED " + wordhash + ": empty");
else if (migrationCount > 0)
log.logInfo("MIGRATED " + wordhash + ": " + migrationCount + " entries");
else
log.logInfo("REVERSED " + wordhash + ": " + (-migrationCount) + " entries");
} else if (migrationStatus instanceof String) {
log.logInfo("SKIPPED " + wordhash + ": " + migrationStatus);
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit ca26aab

Please sign in to comment.