datafolder 1.0.31 → 1.0.33
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 +4 -0
- package/package.json +1 -1
- package/scripts/fastify.js +2 -2
- package/scripts/flights2.js +31 -13
- package/src/QyBatch.d.ts +2 -1
- package/src/QyBatch.js +144 -143
- package/src/QyCache.js +40 -41
- package/src/QyDB.js +1 -1
- package/src/QyDefaultOptions.js +1 -1
- package/src/QyFile.js +23 -25
- package/src/QyFileContentUtils.d.ts +1 -4
- package/src/QyFileContentUtils.js +87 -105
- package/src/QyIndex.d.ts +1 -2
- package/src/QyIndex.js +105 -126
- package/src/QyIndexPropTree.d.ts +9 -6
- package/src/QyIndexPropTree.js +85 -50
- package/src/QyItem.d.ts +1 -1
- package/src/QyItem.js +2 -2
- package/src/QyLogger.d.ts +3 -0
- package/src/QyLogger.js +80 -52
- package/src/QyMessager.js +1 -1
- package/src/QyTrigger.js +27 -27
- package/src/QyUtils.d.ts +0 -2
- package/src/QyUtils.js +64 -74
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/scripts/fastify.js
CHANGED
|
@@ -15,10 +15,10 @@ const config = {
|
|
|
15
15
|
const { port, staticRoot } = config;
|
|
16
16
|
const fastify = Fastify({ logger: false, forceCloseConnections: true });
|
|
17
17
|
// const qyDB = new QyDB(join(__dirname, "../tmp/flights2"));
|
|
18
|
-
const qyDB = new QyDB(join(__dirname, "../tmp/QyIndex/1"));
|
|
18
|
+
// const qyDB = new QyDB(join(__dirname, "../tmp/QyIndex/1"));
|
|
19
19
|
// const qyDB = new QyDB(join(__dirname, "../tmp/QyEmbeddings/1"));
|
|
20
20
|
// const qyDB = new QyDB("C:\\tmp\\hackernews");
|
|
21
|
-
|
|
21
|
+
const qyDB = new QyDB();
|
|
22
22
|
let sigintReceived = false;
|
|
23
23
|
process.on("SIGINT", async () => {
|
|
24
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/QyBatch.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare class QyBatch extends QyCD {
|
|
|
25
25
|
removeDirExpire(namePath: any, infoFileOnly?: any, parentDir?: any): any;
|
|
26
26
|
removeContentExpire(namePath: any, expireInfoObj: any, infoFileOnly?: any, parentDir?: any): any;
|
|
27
27
|
createIndex(indexHostDirNamePath: any, indexPropPathList: any, parentDir?: any): any;
|
|
28
|
+
createIndexFromQuery(indexHostDirNamePath: any, queryObj: any, parentDir?: any): any;
|
|
28
29
|
delIndex(indexHostDirNamePath: any, indexPropPath: any, parentDir?: any): any;
|
|
29
30
|
insert(namePath: any, content: any, noClone?: boolean, noCreate?: boolean, parentDir?: any): any;
|
|
30
31
|
insertEmbedding(namePath: any, embedding: any, parentDir?: any): any;
|
|
@@ -49,7 +50,7 @@ export declare class QyBatch extends QyCD {
|
|
|
49
50
|
_action_insertEmbedding(action: any): boolean;
|
|
50
51
|
_action_delEmbedding(action: any): true | undefined;
|
|
51
52
|
_action_put(action: any): boolean;
|
|
52
|
-
|
|
53
|
+
_action_setProp(file: any, propName: any, value: any): any;
|
|
53
54
|
_action_insert(action: any): boolean;
|
|
54
55
|
_action_createFile(action: any): boolean;
|
|
55
56
|
_action_createDir(action: any): boolean;
|