|
|
@ -29,7 +29,6 @@ import java.io.DataInputStream;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.Map.Entry;
|
|
|
@ -260,7 +259,7 @@ public class HeapReader {
|
|
|
|
file.readFully(keyf, 0, keyf.length);
|
|
|
|
file.readFully(keyf, 0, keyf.length);
|
|
|
|
if (!this.ordering.equal(key, keyf)) {
|
|
|
|
if (!this.ordering.equal(key, keyf)) {
|
|
|
|
// verification of the indexed access failed. we must re-read the index
|
|
|
|
// verification of the indexed access failed. we must re-read the index
|
|
|
|
Log.logWarning("kelondroBLOBHeap", "verification indexed access for " + heapFile.toString() + " failed, re-building index");
|
|
|
|
Log.logSevere("kelondroBLOBHeap", "verification indexed access for " + heapFile.toString() + " failed, re-building index");
|
|
|
|
// this is a severe operation, it should never happen.
|
|
|
|
// this is a severe operation, it should never happen.
|
|
|
|
// but if the process ends in this state, it would completely fail
|
|
|
|
// but if the process ends in this state, it would completely fail
|
|
|
|
// if the index is not rebuild now at once
|
|
|
|
// if the index is not rebuild now at once
|
|
|
@ -274,8 +273,18 @@ public class HeapReader {
|
|
|
|
return blob;
|
|
|
|
return blob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean checkKey(final byte[] key, final long pos) throws IOException {
|
|
|
|
|
|
|
|
file.seek(pos);
|
|
|
|
|
|
|
|
file.readInt(); // skip the size value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read the key
|
|
|
|
|
|
|
|
final byte[] keyf = new byte[index.row().primaryKeyLength];
|
|
|
|
|
|
|
|
file.readFully(keyf, 0, keyf.length);
|
|
|
|
|
|
|
|
return this.ordering.equal(key, keyf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* retrieve the size of the BLOB
|
|
|
|
* retrieve the size of the BLOB. This should not be used excessively, because it depends on IO operations.
|
|
|
|
* @param key
|
|
|
|
* @param key
|
|
|
|
* @return the size of the BLOB or -1 if the BLOB does not exist
|
|
|
|
* @return the size of the BLOB or -1 if the BLOB does not exist
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
@ -363,17 +372,6 @@ public class HeapReader {
|
|
|
|
return this.heapFile.length();
|
|
|
|
return this.heapFile.length();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String excave(final byte[] rawKey, char fillChar) {
|
|
|
|
|
|
|
|
int n = this.keylength - 1;
|
|
|
|
|
|
|
|
if (n >= rawKey.length) n = rawKey.length - 1;
|
|
|
|
|
|
|
|
while ((n > 0) && (rawKey[n] == (byte) fillChar)) n--;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return new String(rawKey, 0, n + 1, "UTF-8");
|
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
|
|
|
return new String(rawKey, 0, n + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* static iterator of entries in BLOBHeap files:
|
|
|
|
* static iterator of entries in BLOBHeap files:
|
|
|
|
* this is used to import heap dumps into a write-enabled index heap
|
|
|
|
* this is used to import heap dumps into a write-enabled index heap
|
|
|
|