aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-06-25 14:31:48 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-06-25 14:31:48 +0200
commitbf52d4b844cbcd9d6b7e25b5c4f004c8a3f0f891 (patch)
tree788b819db35979cf0046e5f88d2c9183e9d74a43
parentdf5619236b7328ce7cfb5d130948aa5200983919 (diff)
idb: make test pass
-rw-r--r--packages/idb-bridge/src/MemoryBackend.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts
index 694daacfa..bd9b8996d 100644
--- a/packages/idb-bridge/src/MemoryBackend.ts
+++ b/packages/idb-bridge/src/MemoryBackend.ts
@@ -780,16 +780,19 @@ export class MemoryBackend implements Backend {
) {
let pos = forward ? 0 : indexEntry.primaryKeys.length - 1;
console.log("number of primary keys", indexEntry.primaryKeys.length);
+ console.log("start pos is", pos);
// Advance past the lastObjectStorePosition
do {
const cmpResult = compareKeys(
req.lastObjectStorePosition,
indexEntry.primaryKeys[pos],
);
+ console.log("cmp result is", cmpResult);
if ((forward && cmpResult < 0) || (!forward && cmpResult > 0)) {
break;
}
pos += forward ? 1 : -1;
+ console.log("now pos is", pos);
} while (pos >= 0 && pos < indexEntry.primaryKeys.length);
// Make sure we're at least at advancedPrimaryPos
@@ -812,7 +815,8 @@ export class MemoryBackend implements Backend {
primkeySubPos = forward ? 0 : indexEntry.primaryKeys.length - 1;
}
- console.log("pos=", primkeySubPos);
+ console.log("subPos=", primkeySubPos);
+ console.log("indexPos=", indexPos);
while (1) {
if (req.limit != 0 && numResults == req.limit) {
@@ -831,12 +835,13 @@ export class MemoryBackend implements Backend {
primkeySubPos < 0 ||
primkeySubPos >= indexEntry.primaryKeys.length
) {
- console.log("moving subkey forward");
- primkeySubPos = forward ? 0 : indexEntry.primaryKeys.length - 1;
- const res = indexData.nextHigherPair(indexPos);
+ const res = forward
+ ? indexData.nextHigherPair(indexPos)
+ : indexData.nextLowerPair(indexPos);
if (res) {
indexPos = res[1].indexKey;
indexEntry = res[1];
+ primkeySubPos = forward ? 0 : indexEntry.primaryKeys.length - 1;
} else {
break;
}
@@ -862,9 +867,12 @@ export class MemoryBackend implements Backend {
}
}
if (!skip) {
+ console.log(`not skipping!, subPos=${primkeySubPos}`);
indexKeys.push(indexEntry.indexKey);
primaryKeys.push(indexEntry.primaryKeys[primkeySubPos]);
numResults++;
+ } else {
+ console.log("skipping!");
}
primkeySubPos += forward ? 1 : -1;
}
@@ -873,6 +881,8 @@ export class MemoryBackend implements Backend {
// if requested.
if (req.resultLevel === ResultLevel.Full) {
for (let i = 0; i < numResults; i++) {
+ console.log("getting value for index", i);
+ console.log("with key", primaryKeys[i]);
const result = storeData.get(primaryKeys[i]);
if (!result) {
throw Error("invariant violated");