Skip to content

Commit

Permalink
fixed a bug that was recently inserted which caused that no idx and g…
Browse files Browse the repository at this point in the history
…ap files were written.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6030 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jun 6, 2009
1 parent b6e274f commit 3029ef6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
30 changes: 0 additions & 30 deletions source/de/anomic/kelondro/blob/BLOBHeapModifier.java
Expand Up @@ -106,36 +106,6 @@ public synchronized void clear() throws IOException {
public synchronized void close(boolean writeIDX) {
shrinkWithGapsAtEnd();
super.close(writeIDX);

if (writeIDX && index != null && free != null && (index.size() > 3 || free.size() > 3)) {
// now we can create a dump of the index and the gap information
// to speed up the next start
try {
long start = System.currentTimeMillis();
String fingerprint = HeapWriter.fingerprintFileHash(this.heapFile);
if (fingerprint == null) {
Log.logSevere("kelondroBLOBHeap", "cannot write a dump for " + heapFile.getName()+ ": fingerprint is null");
} else {
free.dump(HeapWriter.fingerprintGapFile(this.heapFile, fingerprint));
}
free.clear();
free = null;
if (fingerprint != null) {
index.dump(HeapWriter.fingerprintIndexFile(this.heapFile, fingerprint));
Log.logInfo("kelondroBLOBHeap", "wrote a dump for the " + this.index.size() + " index entries of " + heapFile.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
}
index.close();
index = null;
} catch (IOException e) {
e.printStackTrace();
}
} else {
// this is small.. just free resources, do not write index
if (free != null) free.clear();
free = null;
if (index != null) index.close();
index = null;
}
}

/**
Expand Down
34 changes: 29 additions & 5 deletions source/de/anomic/kelondro/blob/HeapReader.java
Expand Up @@ -293,11 +293,35 @@ public synchronized long length(byte[] key) throws IOException {
public synchronized void close(boolean writeIDX) {
if (file != null) file.close();
file = null;
heapFile = null;
free.clear();
free = null;
index.close();
index = null;
if (writeIDX && index != null && free != null && (index.size() > 3 || free.size() > 3)) {
// now we can create a dump of the index and the gap information
// to speed up the next start
try {
long start = System.currentTimeMillis();
String fingerprint = HeapWriter.fingerprintFileHash(this.heapFile);
if (fingerprint == null) {
Log.logSevere("kelondroBLOBHeap", "cannot write a dump for " + heapFile.getName()+ ": fingerprint is null");
} else {
free.dump(HeapWriter.fingerprintGapFile(this.heapFile, fingerprint));
}
free.clear();
free = null;
if (fingerprint != null) {
index.dump(HeapWriter.fingerprintIndexFile(this.heapFile, fingerprint));
Log.logInfo("kelondroBLOBHeap", "wrote a dump for the " + this.index.size() + " index entries of " + heapFile.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
}
index.close();
index = null;
} catch (IOException e) {
e.printStackTrace();
}
} else {
// this is small.. just free resources, do not write index
if (free != null) free.clear();
free = null;
if (index != null) index.close();
index = null;
}
}

/**
Expand Down

0 comments on commit 3029ef6

Please sign in to comment.