datafolder 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +2 -0
- package/package.json +4 -4
- package/scripts/fastify.js +4 -3
- package/scripts/flights2.js +31 -13
- package/src/QyAcl.js +4 -4
- package/src/QyBatch.d.ts +7 -4
- package/src/QyBatch.js +169 -181
- package/src/QyBinWriter.js +6 -6
- package/src/QyCD.js +36 -36
- package/src/QyCache.js +38 -39
- package/src/QyDB.js +2 -2
- package/src/QyDefaultOptions.js +1 -1
- package/src/QyDir.js +4 -4
- package/src/QyEmbeddingWriter.js +1 -1
- package/src/QyEmbeddings.js +1 -1
- package/src/QyExpire.d.ts +1 -1
- package/src/QyExpire.js +3 -3
- package/src/QyExpire_Worker.js +37 -35
- package/src/QyFile.js +22 -23
- package/src/QyFileContentUtils.d.ts +1 -4
- package/src/QyFileContentUtils.js +90 -108
- package/src/QyIndex.d.ts +2 -6
- package/src/QyIndex.js +110 -140
- package/src/QyIndexPropTree.d.ts +25 -9
- package/src/QyIndexPropTree.js +101 -70
- package/src/QyIntersectNode.js +3 -3
- package/src/QyItem.d.ts +1 -1
- package/src/QyItem.js +2 -2
- package/src/QyKVData.js +14 -14
- package/src/QyKVDataCleaner_Worker.js +40 -40
- package/src/QyMessager.js +3 -3
- package/src/QyOpRunner.js +2 -2
- package/src/QySaver.js +2 -2
- package/src/QySnapshotCompactor_Worker.js +6 -6
- package/src/QySnapshotSaver_Worker.js +1 -1
- package/src/QySnapshots.js +1 -1
- package/src/QyStructure.js +6 -6
- package/src/QyTrigger.js +29 -29
- package/src/QyUnionNode.js +2 -2
- package/src/QyUtils.js +3 -3
- package/src/rpc/getFileContent.js +1 -1
- package/src/rpc/getSubItems.js +1 -1
- package/static/codemirror.bundle/editor.bundle.js +70 -37
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datafolder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "lysh",
|
|
6
6
|
"email": "datafolderdev@outlook.com"
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@fastify/compress": "^
|
|
46
|
-
"@fastify/express": "^4.0.
|
|
47
|
-
"@fastify/static": "^
|
|
45
|
+
"@fastify/compress": "^9.0.0",
|
|
46
|
+
"@fastify/express": "^4.0.0",
|
|
47
|
+
"@fastify/static": "^10.0.0",
|
|
48
48
|
"fastify": "^5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"exports": "./index.js",
|
package/scripts/fastify.js
CHANGED
|
@@ -14,10 +14,11 @@ const config = {
|
|
|
14
14
|
};
|
|
15
15
|
const { port, staticRoot } = config;
|
|
16
16
|
const fastify = Fastify({ logger: false, forceCloseConnections: true });
|
|
17
|
-
// const qyDB = new QyDB(join(__dirname, "../tmp/
|
|
17
|
+
// const qyDB = new QyDB(join(__dirname, "../tmp/flights2"));
|
|
18
|
+
// const qyDB = new QyDB(join(__dirname, "../tmp/QyIndex/1"));
|
|
18
19
|
// const qyDB = new QyDB(join(__dirname, "../tmp/QyEmbeddings/1"));
|
|
19
|
-
const qyDB = new QyDB("C:\\tmp\\hackernews");
|
|
20
|
-
|
|
20
|
+
// const qyDB = new QyDB("C:\\tmp\\hackernews");
|
|
21
|
+
const qyDB = new QyDB();
|
|
21
22
|
let sigintReceived = false;
|
|
22
23
|
process.on("SIGINT", async () => {
|
|
23
24
|
logger.log("SIGINT signal received: closing HTTP server");
|
package/scripts/flights2.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// node --prof profile.js
|
|
2
2
|
// node --prof-process isolate-0xnnnnnnnnnnnn-v8.log > processed.txt
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { rm } from "node:fs/promises";
|
|
4
|
+
import { rm, readFile } from "node:fs/promises";
|
|
6
5
|
import { QyDB } from "../src/QyDB.js";
|
|
7
6
|
import { folderOrFileExists } from "../src/QyUtils.js";
|
|
8
7
|
import { logger } from "../src/QyLogger.js";
|
|
@@ -11,13 +10,22 @@ logger.level = "info";
|
|
|
11
10
|
const arangoJsonFolderPath = "D:\\scripts\\GraphCourse_DemoData_ArangoDB-2";
|
|
12
11
|
const dataFolder = "./tmp/flights2";
|
|
13
12
|
const qyDB = new QyDB(dataFolder, { fileLogLevel: "basic", noAcl: false });
|
|
13
|
+
const maxBatchCount = 5000;
|
|
14
|
+
let airportsJson, flightsJson;
|
|
14
15
|
run();
|
|
16
|
+
async function loadData() {
|
|
17
|
+
const [airportsData, flightsData] = await Promise.all([
|
|
18
|
+
readFile(join(arangoJsonFolderPath, "airports.json")),
|
|
19
|
+
readFile(join(arangoJsonFolderPath, "flights.json")),
|
|
20
|
+
]);
|
|
21
|
+
airportsJson = JSON.parse(airportsData);
|
|
22
|
+
flightsJson = JSON.parse(flightsData);
|
|
23
|
+
}
|
|
15
24
|
function insertAirports() {
|
|
16
|
-
|
|
17
|
-
console.log(`airports:${data.length}`);
|
|
25
|
+
console.log(`airports:${airportsJson.length}`);
|
|
18
26
|
console.time("insertAirports");
|
|
19
27
|
const { batch } = qyDB;
|
|
20
|
-
for (const record of
|
|
28
|
+
for (const record of airportsJson) {
|
|
21
29
|
const { country, state, city } = record;
|
|
22
30
|
batch.insert(`airports/${country}/${state}/${city}/${record._key}`, record);
|
|
23
31
|
}
|
|
@@ -25,15 +33,20 @@ function insertAirports() {
|
|
|
25
33
|
console.timeEnd("insertAirports");
|
|
26
34
|
}
|
|
27
35
|
function insertFlights() {
|
|
28
|
-
const
|
|
29
|
-
console.log(`flights:${
|
|
36
|
+
const { length } = flightsJson;
|
|
37
|
+
console.log(`flights:${length}`);
|
|
30
38
|
console.time("insertFlights");
|
|
31
39
|
const { batch } = qyDB;
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
let count = 0;
|
|
41
|
+
for (let i = 0; i < length; ++i) {
|
|
42
|
+
const record = flightsJson[i];
|
|
34
43
|
const { Year, Month, Day } = record;
|
|
35
44
|
// batch.insert(`flights/${Year}/${Month}/${Day}/${i}`, record);
|
|
36
45
|
batch.insert(["flights", Year, Month, Day, i], record);
|
|
46
|
+
if (++count > maxBatchCount) {
|
|
47
|
+
batch.run();
|
|
48
|
+
count = 0;
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
batch.run();
|
|
39
52
|
console.timeEnd("insertFlights");
|
|
@@ -43,6 +56,10 @@ function insertFlights() {
|
|
|
43
56
|
for (const monthDir of yearDir.subdirList) {
|
|
44
57
|
for (const dayDir of monthDir.subdirList) {
|
|
45
58
|
batch.createIndex(dayDir, ["_from", "_to"]);
|
|
59
|
+
if (++count > maxBatchCount) {
|
|
60
|
+
batch.run();
|
|
61
|
+
count = 0;
|
|
62
|
+
}
|
|
46
63
|
}
|
|
47
64
|
}
|
|
48
65
|
}
|
|
@@ -50,25 +67,28 @@ function insertFlights() {
|
|
|
50
67
|
console.timeEnd("createFlightsIndex");
|
|
51
68
|
}
|
|
52
69
|
async function run() {
|
|
53
|
-
console.time("total");
|
|
54
70
|
if (process.argv[3]) {
|
|
55
71
|
logger.level = process.argv[3];
|
|
56
72
|
}
|
|
57
73
|
let shouldInsertData;
|
|
58
74
|
if (process.argv[2] === "true") {
|
|
75
|
+
console.time("rm");
|
|
59
76
|
try {
|
|
60
77
|
await rm(dataFolder, { recursive: true });
|
|
61
78
|
}
|
|
62
79
|
catch (exception) { }
|
|
80
|
+
console.timeEnd("rm");
|
|
63
81
|
shouldInsertData = true;
|
|
64
82
|
}
|
|
65
83
|
else if (!(await folderOrFileExists(dataFolder)))
|
|
66
84
|
shouldInsertData = true;
|
|
67
|
-
console.time("run");
|
|
68
85
|
console.time("start");
|
|
69
86
|
await qyDB.start();
|
|
70
87
|
console.timeEnd("start");
|
|
71
88
|
if (shouldInsertData) {
|
|
89
|
+
console.time("loadData");
|
|
90
|
+
await loadData();
|
|
91
|
+
console.timeEnd("loadData");
|
|
72
92
|
insertAirports();
|
|
73
93
|
insertFlights();
|
|
74
94
|
}
|
|
@@ -76,6 +96,4 @@ async function run() {
|
|
|
76
96
|
console.time("stop");
|
|
77
97
|
await qyDB.stop();
|
|
78
98
|
console.timeEnd("stop");
|
|
79
|
-
console.timeEnd("run");
|
|
80
|
-
console.timeEnd("total");
|
|
81
99
|
}
|
package/src/QyAcl.js
CHANGED
|
@@ -32,9 +32,9 @@ function r(r, t) {
|
|
|
32
32
|
}
|
|
33
33
|
for (i in f) {
|
|
34
34
|
var d = r[i];
|
|
35
|
-
if (d) {
|
|
35
|
+
if (null != d) {
|
|
36
36
|
var l = f[i];
|
|
37
|
-
if (l) {
|
|
37
|
+
if (void 0 !== l) {
|
|
38
38
|
for (var h of l) delete d[h];
|
|
39
39
|
v(d) && (r[i] = void 0);
|
|
40
40
|
}
|
|
@@ -101,7 +101,7 @@ class e {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
pushCmdArgAsListObj(r) {
|
|
104
|
-
if (r) {
|
|
104
|
+
if (void 0 !== r) {
|
|
105
105
|
for (var t in ++this.batchSize, r[f.D]) this.pushCmd(f.D, t);
|
|
106
106
|
for (var e of [ f.A, f.R ]) {
|
|
107
107
|
var a, i = r[e];
|
|
@@ -138,7 +138,7 @@ function u(r, t, e = 1) {
|
|
|
138
138
|
|
|
139
139
|
function c(r, t) {
|
|
140
140
|
let e = r.cmdArgAsMapChangeObj;
|
|
141
|
-
if (e
|
|
141
|
+
if (!(void 0 === e || void 0 === t || t.length <= 1)) {
|
|
142
142
|
for (let r = 0; r < t.length - 1; ++r) if (void 0 === (e = e[t[r]])) return;
|
|
143
143
|
delete e[t.at(-1)];
|
|
144
144
|
}
|
package/src/QyBatch.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { QyAclCmdGenerator } from "./QyAcl.ts";
|
|
1
2
|
import { QyCD } from "./QyCD.ts";
|
|
2
3
|
export declare class QyBatch extends QyCD {
|
|
3
4
|
fileLogLevel: any;
|
|
4
|
-
actionQueue: any;
|
|
5
5
|
changeId: any;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
actionQueue: any[];
|
|
7
|
+
changeList: any[];
|
|
8
|
+
syncList: any[];
|
|
9
9
|
qyCmdObjHistory: any;
|
|
10
10
|
running: any;
|
|
11
|
+
qyAclCmdGenerator: QyAclCmdGenerator;
|
|
12
|
+
options: any;
|
|
11
13
|
constructor(qyCache?: any, options?: any);
|
|
12
14
|
createDir(namePath: any, parentDir?: any): any;
|
|
13
15
|
delDir(namePath: any, parentDir?: any): any;
|
|
@@ -23,6 +25,7 @@ export declare class QyBatch extends QyCD {
|
|
|
23
25
|
removeDirExpire(namePath: any, infoFileOnly?: any, parentDir?: any): any;
|
|
24
26
|
removeContentExpire(namePath: any, expireInfoObj: any, infoFileOnly?: any, parentDir?: any): any;
|
|
25
27
|
createIndex(indexHostDirNamePath: any, indexPropPathList: any, parentDir?: any): any;
|
|
28
|
+
createIndexFromQuery(indexHostDirNamePath: any, queryObj: any, parentDir?: any): any;
|
|
26
29
|
delIndex(indexHostDirNamePath: any, indexPropPath: any, parentDir?: any): any;
|
|
27
30
|
insert(namePath: any, content: any, noClone?: boolean, noCreate?: boolean, parentDir?: any): any;
|
|
28
31
|
insertEmbedding(namePath: any, embedding: any, parentDir?: any): any;
|