appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
491 stars 27 forks source link

Sorting with indexed field #75

Closed paradis-A closed 2 years ago

paradis-A commented 2 years ago

Using v1.15.0

load first 100 sort letter by a-z (non-indexed) √ (547ms)

load second 100 sort letter by a-z (non-indexed) √ (345ms)

load third 100 sort letter by a-z (non-indexed) √ (325ms)

load first 100 sort letter by z-a (non-indexed) √ (254ms)

load second 100 sort letter by z-a (non-indexed) √ (283ms)

load third 100 sort letter by z-a (non-indexed) √ (300ms)

load first 100 sort letter by a-z (indexed) 1)

load second 100 sort letter by a-z (indexed) Lock "./take_test.acebase/sort_indexed-letter.idx" timed out! lock.release() was not called in a timely fashion 2)

load third 100 sort letter by a-z (indexed) 3)

load first 100 sort letter by z-a (indexed) Lock "./take_test.acebase/sort_indexed-letter.idx" timed out! lock.release() was not called in a timely fashion 4)

load second 100 sort letter by a-z (indexed) 5)

load third 100 sort letter by a-z (indexed) Lock "./take_test.acebase/sort_indexed-letter.idx" timed out! lock.release() was not called in a timely fashion 6)

6 passing (3m) 6 failing

1) load first 100 sort letter by a-z (indexed) : Error: Error: ext_data values were not read yet. use entry.extData.loadValues() first at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at async Context. (acebasetake.spec.js:105:9)

2) load second 100 sort letter by a-z (indexed) : Error: Error: Could not achieve lock because the current lock ("./take_test.acebase/sort_indexed-letter.idx") was not released in time (and lock is flagged critical) at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Context. (acebasetake.spec.js:113:9)

3) load third 100 sort letter by a-z (indexed) : Error: Error: ext_data values were not read yet. use entry.extData.loadValues() first at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at async Context. (acebasetake.spec.js:121:9)

4) load first 100 sort letter by z-a (indexed) : Error: Error: Could not achieve lock because the current lock ("./take_test.acebase/sort_indexed-letter.idx") was not released in time (and lock is flagged critical) at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Context. (acebasetake.spec.js:130:9)

5) load second 100 sort letter by a-z (indexed) : Error: Error: ext_data values were not read yet. use entry.extData.loadValues() first at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at async Context. (acebasetake.spec.js:138:9)

6) load third 100 sort letter by a-z (indexed) : Error: Error: Could not achieve lock because the current lock ("./take_test.acebase/sort_indexed-letter.idx") was not released in time (and lock is flagged critical) at C:\System\lenlen\lendb-server\node_modules\acebase-core\dist\data-reference.js:845:19 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Context. (acebasetake.spec.js:146:9)

paradis-A commented 2 years ago

full test code:

const { AceBase, ID } = require("acebase");
var assert = require("assert");
const db = new AceBase("take_test", { logLevel: "error" });
const alphabet = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
];
const updates = {};
//Assuming that this already executed
// for (let i = 0; i < 2000; i++) {
//     updates[ID.generate()] = { letter: alphabet[Math.floor(Math.random() * 26)] };
// }
// describe("generate 2000 a-z non-indexed", function () {
//     this.timeout(Infinity);
//     it("", async function () {
//         await db.ref("sort").update(updates);
//         assert.ok(true);
//     });
// });

// describe("generate 2000 a-z indexed", function () {
//     this.timeout(Infinity);
//     it("", async function () {
//         await db.indexes.create("sort_indexed", "letter");
//         await db.ref("sort_indexed").update(updates);
//         assert.ok(true);
//     });
// });

describe("load first 100 sort letter by a-z (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter", true).take(100).get();
        assert.ok(true);
    });
});

describe("load second 100 sort letter by a-z (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter", true).skip(100).take(100).get();
        assert.ok(true);
    });
});

describe("load third 100 sort letter by a-z (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter", true).skip(200).take(100).get();
        assert.ok(true);
    });
});

describe("load first 100 sort letter by z-a (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter").take(100).get();
        assert.ok(true);
    });
});

describe("load second 100 sort letter by z-a (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter").skip(100).take(100).get();
        assert.ok(true);
    });
});

describe("load third 100 sort letter by z-a (non-indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort").sort("letter").skip(200).take(100).get();
        assert.ok(true);
    });
});

describe("load first 100 sort letter by a-z (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter", true).take(100).get();
        assert.ok(true);
    });
});

describe("load second 100 sort letter by a-z (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter", true).skip(100).take(100).get();
        assert.ok(true);
    });
});

describe("load third 100 sort letter by a-z (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter", true).skip(200).take(100).get();
        assert.ok(true);
    });
});

describe("load first 100 sort letter by z-a (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter").take(100).get();
        assert.ok(true);
    });
});

describe("load second 100 sort letter by a-z (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter").skip(100).take(100).get();
        assert.ok(true);
    });
});

describe("load third 100 sort letter by a-z (indexed)", function () {
    this.timeout(Infinity);
    it("", async function () {
        await db.query("sort_indexed").sort("letter").skip(200).take(100).get();
        assert.ok(true);
    });
});
appy-one commented 2 years ago

Fixed! Published with v1.15.1 Thanks for your report & tests @paradis-A 👍🏼