do not reload keys, only values

pull/62/head
Zlatin Balevsky 2021-06-08 21:26:18 +01:00
parent 5b3416f7bb
commit e09b4c6621
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 9 additions and 17 deletions

View File

@ -227,7 +227,8 @@ public class BSkipSpan<K extends Comparable<? super K>, V> extends SkipSpan<K, V
} }
protected void reload() throws IOException { protected void reload() throws IOException {
BSkipSpan.load(this, bf, bsl, page, keySer, valSer); loadInit(this, bf, bsl, page, keySer, valSer);
loadData(true);
} }
/** /**
@ -265,7 +266,7 @@ public class BSkipSpan<K extends Comparable<? super K>, V> extends SkipSpan<K, V
* Load the whole span's keys and values into memory * Load the whole span's keys and values into memory
*/ */
protected void loadData() throws IOException { protected void loadData() throws IOException {
loadData(true); loadData(false);
} }
/** /**
@ -274,10 +275,11 @@ public class BSkipSpan<K extends Comparable<? super K>, V> extends SkipSpan<K, V
* @param flushOnError set to false if you are going to flush anyway * @param flushOnError set to false if you are going to flush anyway
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void loadData(boolean flushOnError) throws IOException { protected void loadData(boolean valsOnly) throws IOException {
if (isKilled) if (isKilled)
throw new IOException("Already killed!! " + this); throw new IOException("Already killed!! " + this);
this.keys = (K[]) new Comparable[this.spanSize]; if (!valsOnly)
this.keys = (K[]) new Comparable[this.spanSize];
this.vals = (V[]) new Object[this.spanSize]; this.vals = (V[]) new Object[this.spanSize];
int ksz, vsz; int ksz, vsz;
@ -316,24 +318,14 @@ public class BSkipSpan<K extends Comparable<? super K>, V> extends SkipSpan<K, V
break; break;
} }
// System.out.println("i=" + i + ", Page " + curPage + ", offset " + pageCounter[0] + " ksz " + ksz + " vsz " + vsz); // System.out.println("i=" + i + ", Page " + curPage + ", offset " + pageCounter[0] + " ksz " + ksz + " vsz " + vsz);
this.keys[i] = this.keySer.construct(k); if (!valsOnly)
this.keys[i] = this.keySer.construct(k);
this.vals[i] = this.valSer.construct(v); this.vals[i] = this.valSer.construct(v);
// Drop bad entry without throwing exception // Drop bad entry without throwing exception
if (this.keys[i] == null || this.vals[i] == null) { if (this.keys[i] == null || this.vals[i] == null) {
fail++; throw new IOException("deserialization failed for " + this + " value idx" + i);
nKeys--;
i--;
continue;
} }
} }
// free any excess overflow pages?
if (fail > 0) {
if (flushOnError)
fflush();
// FIXME can't get there from here
//bsl.size -= fail;
//bsl.flush();
}
} }
/** /**