private V getMaximum(final int filename, final K arg0) {
if (filename < 0) {
return null;
}
try {
final InputStream in = new PageInputStream(filename, this.pageManager);
final boolean leaf = InputHelper.readLuposBoolean(in);
if (leaf) { // leaf node reached!
V lastTriple = null;
K lastKey = null;
while (true) {
final DBBPTreeEntry<K, V> e = this.nodeDeSerializer
.getNextLeafEntry(in, lastKey, lastTriple);
if (e == null || e.key == null) {
in.close();
return lastTriple;
}
final K key = e.key;
final int compare = this.comparator.compare(key, arg0);
if (compare > 0) {
in.close();
return lastTriple;
}
if (e.value != null) {
lastTriple = e.value;
lastKey = e.key;
}
}
} else {
K lastKey = null;
int lastFilename = -1;
while (true) {
final Tuple<K, Integer> nextEntry = this.getNextInnerNodeEntry(
lastKey, in);
if (nextEntry == null || nextEntry.getSecond() == 0
|| nextEntry.getSecond() < 0) {
in.close();
return null;
}
if (nextEntry.getFirst() == null) {
in.close();
return this.getMaximum(nextEntry.getSecond(), arg0);
}
final int compare = this.comparator.compare(
nextEntry.getFirst(), arg0);
if (compare > 0) {
in.close();
final V t = this.getMaximum(nextEntry.getSecond(), arg0);
if (t != null) {
return t;
}
if (lastFilename > 0) {