datafolder 1.0.6 → 1.0.8

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.
Files changed (159) hide show
  1. package/README.md +7 -2
  2. package/index.js +1 -1
  3. package/internal.md +121 -0
  4. package/package.json +8 -6
  5. package/scripts/airbnb.js +77 -72
  6. package/scripts/airbnb2.js +78 -73
  7. package/scripts/airbnb2_queries.js +181 -229
  8. package/scripts/airbnb_queries.js +214 -265
  9. package/scripts/convertBinFiles.js +47 -0
  10. package/scripts/downloadFile.js +41 -40
  11. package/scripts/express.js +44 -48
  12. package/scripts/fastify.js +71 -80
  13. package/scripts/flights.js +71 -75
  14. package/scripts/flights2.js +78 -81
  15. package/scripts/flights2_queries.js +417 -455
  16. package/scripts/flights_queries.js +381 -407
  17. package/src/QyAcl.d.ts +17 -0
  18. package/src/QyAcl.js +113 -116
  19. package/src/QyAclSaver.d.ts +4 -0
  20. package/src/QyAclSaver.js +3 -3
  21. package/src/QyAclSaver_Worker.d.ts +9 -0
  22. package/src/QyAclSaver_Worker.js +2 -4
  23. package/src/QyAclWriter.d.ts +5 -0
  24. package/src/QyBatch.d.ts +42 -0
  25. package/src/QyBatch.js +8 -8
  26. package/src/QyBinWriter.d.ts +15 -0
  27. package/src/QyCD.d.ts +37 -0
  28. package/src/QyCD.js +27 -16
  29. package/src/QyCache.d.ts +44 -0
  30. package/src/QyCache.js +71 -59
  31. package/src/QyCompressor.d.ts +9 -0
  32. package/src/QyCompressor.js +29 -29
  33. package/src/QyCompressor_Worker.d.ts +1 -0
  34. package/src/QyDB.d.ts +42 -0
  35. package/src/QyDB.js +13 -11
  36. package/src/QyDefaultOptions.d.ts +1 -0
  37. package/src/QyDefaultOptions.js +3 -0
  38. package/src/QyDir.d.ts +48 -0
  39. package/src/QyDir.js +41 -41
  40. package/src/QyFetch.d.ts +7 -0
  41. package/src/QyFetch.js +3 -4
  42. package/src/QyFile.d.ts +19 -0
  43. package/src/QyFile.js +35 -34
  44. package/src/QyFileContentUtils.d.ts +13 -0
  45. package/src/QyFileContentUtils.js +126 -126
  46. package/src/QyFileLogger.d.ts +11 -0
  47. package/src/QyIndex.d.ts +6 -0
  48. package/src/QyIndex.js +73 -75
  49. package/src/QyIndexPropTree.d.ts +7 -0
  50. package/src/QyIndexPropTree.js +24 -24
  51. package/src/QyIntersectNode.d.ts +7 -0
  52. package/src/QyIntersectNode.js +15 -15
  53. package/src/QyItem.d.ts +30 -0
  54. package/src/QyItem.js +32 -28
  55. package/src/QyJsonSaver.d.ts +6 -0
  56. package/src/QyKVData.d.ts +12 -0
  57. package/src/QyKVData.js +30 -20
  58. package/src/QyKVDataCleaner.d.ts +4 -0
  59. package/src/QyKVDataCleaner.js +1 -1
  60. package/src/QyKVDataCleaner_Worker.d.ts +13 -0
  61. package/src/QyKVDataCleaner_Worker.js +2 -4
  62. package/src/QyKVDataLoader.d.ts +9 -0
  63. package/src/QyKVDataLoader.js +11 -11
  64. package/src/QyKVDataSaver.d.ts +4 -0
  65. package/src/QyKVDataSaver.js +6 -6
  66. package/src/QyKVDataSaver_Worker.d.ts +13 -0
  67. package/src/QyKVDataSaver_Worker.js +11 -13
  68. package/src/QyLogFileSaver.d.ts +4 -0
  69. package/src/QyLogFileSaver.js +1 -1
  70. package/src/QyLogFileSaver_Worker.d.ts +8 -0
  71. package/src/QyLogFileSaver_Worker.js +2 -4
  72. package/src/QyLogger.d.ts +10 -0
  73. package/src/QyLogger.js +40 -40
  74. package/src/QyMessageWorker.d.ts +5 -0
  75. package/src/QyMessageWorker.js +7 -7
  76. package/src/QyMessager.d.ts +7 -0
  77. package/src/QyMessager.js +30 -27
  78. package/src/QyMessager_Run.d.ts +1 -0
  79. package/src/QyMessager_Run.js +11 -6
  80. package/src/QyMod.d.ts +1 -0
  81. package/src/QyMod.js +6 -6
  82. package/src/QyOpRunner.d.ts +10 -0
  83. package/src/QyOpRunner.js +39 -39
  84. package/src/QyQueue.d.ts +11 -0
  85. package/src/QySaver.d.ts +10 -0
  86. package/src/QySnapshotCompactor.d.ts +4 -0
  87. package/src/QySnapshotCompactor.js +1 -1
  88. package/src/QySnapshotCompactor_Worker.d.ts +11 -0
  89. package/src/QySnapshotCompactor_Worker.js +21 -22
  90. package/src/QySnapshotSaver.d.ts +4 -0
  91. package/src/QySnapshotSaver.js +1 -1
  92. package/src/QySnapshotSaver_Worker.d.ts +16 -0
  93. package/src/QySnapshotSaver_Worker.js +56 -53
  94. package/src/QySnapshots.d.ts +27 -0
  95. package/src/QySnapshots.js +74 -66
  96. package/src/QyStructure.d.ts +1 -0
  97. package/src/QyStructure.js +18 -18
  98. package/src/QyTrigger.d.ts +9 -0
  99. package/src/QyTrigger.js +30 -30
  100. package/src/QyUnionNode.d.ts +17 -0
  101. package/src/QyUnionNode.js +2 -2
  102. package/src/QyUtils.d.ts +53 -0
  103. package/src/QyUtils.js +140 -117
  104. package/src/QyWorker.d.ts +5 -0
  105. package/src/QyWorker.js +18 -18
  106. package/src/hackernews.d.ts +1 -0
  107. package/src/hackernews.js +59 -47
  108. package/src/rpc/getRpcFiles.js +1 -0
  109. package/src/rpc/getTriggerFiles.js +1 -0
  110. package/src/simulate.d.ts +1 -0
  111. package/src/simulate2.d.ts +1 -0
  112. package/src/soc_pokec.d.ts +1 -0
  113. package/src/soc_pokec.js +7 -7
  114. package/static/codemirror.bundle/editor.bundle.js +370 -166
  115. package/static/datafolderui/QyStyledElement.js +8 -17
  116. package/static/datafolderui/QyUIFolderViewer.js +230 -0
  117. package/static/datafolderui/QyUIUtils.js +5 -5
  118. package/static/datafolderui/code-mirror.js +7 -7
  119. package/static/datafolderui/display-tree.js +22 -58
  120. package/static/datafolderui/explore-tree.js +10 -10
  121. package/static/datafolderui/folder-tree.js +71 -2
  122. package/static/datafolderui/hscrpt.js +26 -7
  123. package/static/datafolderui/json-view.js +34 -3
  124. package/static/datafolderui/main-page.js +67 -36
  125. package/static/datafolderui/query-editor.js +9 -9
  126. package/static/datafolderui/rpc-editor.js +31 -0
  127. package/static/datafolderui/trigger-editor.js +33 -0
  128. package/data/sampleDataFolder/qykv/history/acl/1_acl.txt +0 -1
  129. package/data/sampleDataFolder/qykv/history/acl/2_acl.txt +0 -1
  130. package/data/sampleDataFolder/qykv/history/acl/3_acl.txt +0 -1
  131. package/data/sampleDataFolder/qykv/history/acl/4_acl.txt +0 -1
  132. package/data/sampleDataFolder/qykv/history/acl/5_acl.txt +0 -1
  133. package/data/sampleDataFolder/qykv/snapshot/1/1_pM.txt +0 -0
  134. package/data/sampleDataFolder/qykv/snapshot/1/1_prefixPM.txt +0 -0
  135. package/data/sampleDataFolder/qykv/snapshot/1/1_vL.txt +0 -10
  136. package/data/sampleDataFolder/qykv/snapshot/2/1_pM.txt +0 -0
  137. package/data/sampleDataFolder/qykv/snapshot/2/1_prefixPM.txt +0 -0
  138. package/data/sampleDataFolder/qykv/snapshot/2/1_vL.txt +0 -1
  139. package/data/sampleDataFolder/qykv/snapshot/3/1_pM.txt +0 -0
  140. package/data/sampleDataFolder/qykv/snapshot/3/1_prefixPM.txt +0 -0
  141. package/data/sampleDataFolder/qykv/snapshot/3/1_vL.txt +0 -1
  142. package/data/sampleDataFolder/qykv/snapshot/4/1_pM.txt +0 -0
  143. package/data/sampleDataFolder/qykv/snapshot/4/1_prefixPM.txt +0 -0
  144. package/data/sampleDataFolder/qykv/snapshot/4/1_vL.txt +0 -1
  145. package/data/sampleDataFolder/qykv/snapshot/4/2_pM.txt +0 -0
  146. package/data/sampleDataFolder/qykv/snapshot/4/2_prefixPM.txt +0 -0
  147. package/data/sampleDataFolder/qykv/snapshot/4/2_vL.txt +0 -9
  148. package/data/sampleDataFolder/qykv/snapshot/5/1_pM.txt +0 -0
  149. package/data/sampleDataFolder/qykv/snapshot/5/1_prefixPM.txt +0 -0
  150. package/data/sampleDataFolder/qykv/snapshot/5/1_vL.txt +0 -55
  151. package/data/sampleDataFolder/qykv/snapshot/info/1.json +0 -1
  152. package/data/sampleDataFolder/qykv/snapshot/info/2.json +0 -1
  153. package/data/sampleDataFolder/qykv/snapshot/info/3.json +0 -1
  154. package/data/sampleDataFolder/qykv/snapshot/info/4.json +0 -1
  155. package/data/sampleDataFolder/qykv/snapshot/info/5.json +0 -1
  156. package/data/sampleDataFolder/qylog/2026/02/15/08/change.txt +0 -58
  157. package/data/sampleDataFolder/qylog/2026/02/15/08/stderr.txt +0 -11
  158. package/data/sampleDataFolder/qylog/2026/02/15/08/stdout.txt +0 -36
  159. package/static/datafolderui/QyUIFolderTree.js +0 -179
@@ -1,265 +1,214 @@
1
- import { deepEqual } from "node:assert/strict";
2
-
3
- function query1(qyDB) {
4
- console.time("query1");
5
- deepEqual(
6
- qyDB
7
- .queryFiles("airbnb1", {
8
- property_type: "Loft",
9
- room_type: "Entire home/apt",
10
- bed_type: "Real Bed",
11
- address: { street: "Porto, Porto, Portugal" },
12
- })
13
- .map((x) => x.prop("name")),
14
- [
15
- "Porto city centre apartment H",
16
- "Romantic loft near historic center",
17
- "Lovely sun light in a stylish loft, Downtown Spot",
18
- "Charming & Sunny Mezzanine Loft",
19
- "Be Happy in Porto",
20
- "Quarry Apartment",
21
- "Loft with balcony and view of Casa da Música PORTO",
22
- "For 4 or 6 - Wonderful Apartment downtown",
23
- "Clérigos Apartments - Apt. 4E for 2/3 Pax",
24
- "Bright Top Floor Two Rooms Apartment w/ Terrace",
25
- "ReUrban Flats - Santa Catarina #3",
26
- "The Blue and White Porto House - Vintage",
27
- "4twoLoft at Great Location",
28
- "Step In Porto - Loft w/Mezzanine",
29
- "Your OWM Invicta",
30
- "Pury Apartments",
31
- "Live Porto & Douro - Breiner III",
32
- ],
33
- );
34
- console.timeEnd("query1");
35
- }
36
- function query2(qyDB) {
37
- console.time("query2");
38
- deepEqual(
39
- qyDB
40
- .queryFiles(
41
- "airbnb1",
42
- {
43
- property_type: "Loft",
44
- room_type: "Entire home/apt",
45
- bed_type: "Real Bed",
46
- address: { street: "Porto, Porto, Portugal" },
47
- },
48
- 9,
49
- )
50
- .map((x) => x.prop("name")),
51
- [
52
- "Porto city centre apartment H",
53
- "Romantic loft near historic center",
54
- "Lovely sun light in a stylish loft, Downtown Spot",
55
- "Charming & Sunny Mezzanine Loft",
56
- "Be Happy in Porto",
57
- "Quarry Apartment",
58
- "Loft with balcony and view of Casa da Música PORTO",
59
- "For 4 or 6 - Wonderful Apartment downtown",
60
- "Clérigos Apartments - Apt. 4E for 2/3 Pax",
61
- ],
62
- );
63
- console.timeEnd("query2");
64
- }
65
- function query3(qyDB) {
66
- console.time("query3");
67
- deepEqual(
68
- qyDB
69
- .queryFiles(
70
- "airbnb1",
71
- {
72
- property_type: "Loft",
73
- room_type: "Entire home/apt",
74
- bed_type: "Real Bed",
75
- address: { street: "Porto, Porto, Portugal" },
76
- },
77
- 9,
78
- 9,
79
- )
80
- .map((x) => x.prop("name")),
81
- [
82
- "Bright Top Floor Two Rooms Apartment w/ Terrace",
83
- "ReUrban Flats - Santa Catarina #3",
84
- "The Blue and White Porto House - Vintage",
85
- "4twoLoft at Great Location",
86
- "Step In Porto - Loft w/Mezzanine",
87
- "Your OWM Invicta",
88
- "Pury Apartments",
89
- "Live Porto & Douro - Breiner III",
90
- ],
91
- );
92
- console.timeEnd("query3");
93
- }
94
- function query4(qyDB) {
95
- console.time("query4");
96
- deepEqual(
97
- qyDB
98
- .queryFiles("airbnb1", {
99
- $or: [
100
- {
101
- property_type: "Loft",
102
- room_type: "Entire home/apt",
103
- bed_type: "Real Bed",
104
- address: { street: "Porto, Porto, Portugal" },
105
- },
106
- { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
107
- ],
108
- })
109
- .map((x) => x.prop("name"))
110
- .sort(),
111
- [
112
- "Porto city centre apartment H",
113
- "Romantic loft near historic center",
114
- "Lovely sun light in a stylish loft, Downtown Spot",
115
- "Charming & Sunny Mezzanine Loft",
116
- "Brand New Luxury Downtown Studio",
117
- "Be Happy in Porto",
118
- "Quarry Apartment",
119
- "Loft with balcony and view of Casa da Música PORTO",
120
- "For 4 or 6 - Wonderful Apartment downtown",
121
- "Clérigos Apartments - Apt. 4E for 2/3 Pax",
122
- "Bright Top Floor Two Rooms Apartment w/ Terrace",
123
- "ReUrban Flats - Santa Catarina #3",
124
- "The Blue and White Porto House - Vintage",
125
- "4twoLoft at Great Location",
126
- "Step In Porto - Loft w/Mezzanine",
127
- "Your OWM Invicta",
128
- "Pury Apartments",
129
- "Live Porto & Douro - Breiner III",
130
- ].sort(),
131
- );
132
- console.timeEnd("query4");
133
- }
134
- function query5(qyDB) {
135
- console.time("query5");
136
- deepEqual(
137
- qyDB
138
- .queryFiles(
139
- "airbnb1",
140
- {
141
- $or: [
142
- {
143
- property_type: "Loft",
144
- room_type: "Entire home/apt",
145
- bed_type: "Real Bed",
146
- address: { street: "Porto, Porto, Portugal" },
147
- },
148
- { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
149
- ],
150
- },
151
- 3,
152
- )
153
- .map((x) => x.prop("name")),
154
- [
155
- "Porto city centre apartment H",
156
- "Romantic loft near historic center",
157
- "Lovely sun light in a stylish loft, Downtown Spot",
158
- ],
159
- );
160
- console.timeEnd("query5");
161
- }
162
- function query6(qyDB) {
163
- console.time("query6");
164
- deepEqual(
165
- qyDB
166
- .queryFiles(
167
- "airbnb1",
168
- {
169
- $or: [
170
- {
171
- property_type: "Loft",
172
- room_type: "Entire home/apt",
173
- bed_type: "Real Bed",
174
- address: { street: "Porto, Porto, Portugal" },
175
- },
176
- { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
177
- ],
178
- },
179
- 20,
180
- 10,
181
- )
182
- .map((x) => x.prop("name")),
183
- [
184
- "ReUrban Flats - Santa Catarina #3",
185
- "The Blue and White Porto House - Vintage",
186
- "4twoLoft at Great Location",
187
- "Step In Porto - Loft w/Mezzanine",
188
- "Your OWM Invicta",
189
- "Pury Apartments",
190
- "Live Porto & Douro - Breiner III",
191
- "Brand New Luxury Downtown Studio",
192
- ],
193
- );
194
- console.timeEnd("query6");
195
- }
196
- function query7(qyDB) {
197
- console.time("query7");
198
- deepEqual(
199
- qyDB
200
- .queryFiles("airbnb1", { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 })
201
- .map((x) => x.prop("name")),
202
- ["Romantic loft near historic center", "Brand New Luxury Downtown Studio"],
203
- );
204
- console.timeEnd("query7");
205
- }
206
- function query8(qyDB) {
207
- console.time("query8");
208
- deepEqual(
209
- qyDB
210
- .queryFiles("airbnb1", { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 }, 10, 10)
211
- .map((x) => x.prop("name")),
212
- [],
213
- );
214
- console.timeEnd("query8");
215
- }
216
- function query9(qyDB) {
217
- console.time("query9");
218
- deepEqual(
219
- qyDB
220
- .queryFiles(
221
- "airbnb1",
222
- {
223
- $or: [
224
- {
225
- property_type: "Loft",
226
- room_type: "Entire home/apt",
227
- bed_type: "Real Bed",
228
- address: { street: "Porto, Porto, Portugal" },
229
- },
230
- { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
231
- ],
232
- },
233
- 3,
234
- )
235
- .map((x) => x.prop("name")),
236
- [
237
- "Porto city centre apartment H",
238
- "Romantic loft near historic center",
239
- "Lovely sun light in a stylish loft, Downtown Spot",
240
- ],
241
- );
242
- console.timeEnd("query9");
243
- }
244
- function runQueries(qyDB) {
245
- query1(qyDB);
246
- query1(qyDB);
247
- query2(qyDB);
248
- query2(qyDB);
249
- query3(qyDB);
250
- query3(qyDB);
251
- query4(qyDB);
252
- query4(qyDB);
253
- query5(qyDB);
254
- query5(qyDB);
255
- query6(qyDB);
256
- query6(qyDB);
257
- query7(qyDB);
258
- query7(qyDB);
259
- query8(qyDB);
260
- query8(qyDB);
261
- query9(qyDB);
262
- query9(qyDB);
263
- }
264
-
265
- export { runQueries };
1
+ import { deepEqual } from "node:assert/strict";
2
+ function query1(qyDB) {
3
+ console.time("query1");
4
+ deepEqual(qyDB
5
+ .queryFiles("airbnb1", {
6
+ property_type: "Loft",
7
+ room_type: "Entire home/apt",
8
+ bed_type: "Real Bed",
9
+ address: { street: "Porto, Porto, Portugal" },
10
+ })
11
+ .map((x) => x.prop("name")), [
12
+ "Porto city centre apartment H",
13
+ "Romantic loft near historic center",
14
+ "Lovely sun light in a stylish loft, Downtown Spot",
15
+ "Charming & Sunny Mezzanine Loft",
16
+ "Be Happy in Porto",
17
+ "Quarry Apartment",
18
+ "Loft with balcony and view of Casa da Música PORTO",
19
+ "For 4 or 6 - Wonderful Apartment downtown",
20
+ "Clérigos Apartments - Apt. 4E for 2/3 Pax",
21
+ "Bright Top Floor Two Rooms Apartment w/ Terrace",
22
+ "ReUrban Flats - Santa Catarina #3",
23
+ "The Blue and White Porto House - Vintage",
24
+ "4twoLoft at Great Location",
25
+ "Step In Porto - Loft w/Mezzanine",
26
+ "Your OWM Invicta",
27
+ "Pury Apartments",
28
+ "Live Porto & Douro - Breiner III",
29
+ ]);
30
+ console.timeEnd("query1");
31
+ }
32
+ function query2(qyDB) {
33
+ console.time("query2");
34
+ deepEqual(qyDB
35
+ .queryFiles("airbnb1", {
36
+ property_type: "Loft",
37
+ room_type: "Entire home/apt",
38
+ bed_type: "Real Bed",
39
+ address: { street: "Porto, Porto, Portugal" },
40
+ }, 9)
41
+ .map((x) => x.prop("name")), [
42
+ "Porto city centre apartment H",
43
+ "Romantic loft near historic center",
44
+ "Lovely sun light in a stylish loft, Downtown Spot",
45
+ "Charming & Sunny Mezzanine Loft",
46
+ "Be Happy in Porto",
47
+ "Quarry Apartment",
48
+ "Loft with balcony and view of Casa da Música PORTO",
49
+ "For 4 or 6 - Wonderful Apartment downtown",
50
+ "Clérigos Apartments - Apt. 4E for 2/3 Pax",
51
+ ]);
52
+ console.timeEnd("query2");
53
+ }
54
+ function query3(qyDB) {
55
+ console.time("query3");
56
+ deepEqual(qyDB
57
+ .queryFiles("airbnb1", {
58
+ property_type: "Loft",
59
+ room_type: "Entire home/apt",
60
+ bed_type: "Real Bed",
61
+ address: { street: "Porto, Porto, Portugal" },
62
+ }, 9, 9)
63
+ .map((x) => x.prop("name")), [
64
+ "Bright Top Floor Two Rooms Apartment w/ Terrace",
65
+ "ReUrban Flats - Santa Catarina #3",
66
+ "The Blue and White Porto House - Vintage",
67
+ "4twoLoft at Great Location",
68
+ "Step In Porto - Loft w/Mezzanine",
69
+ "Your OWM Invicta",
70
+ "Pury Apartments",
71
+ "Live Porto & Douro - Breiner III",
72
+ ]);
73
+ console.timeEnd("query3");
74
+ }
75
+ function query4(qyDB) {
76
+ console.time("query4");
77
+ deepEqual(qyDB
78
+ .queryFiles("airbnb1", {
79
+ $or: [
80
+ {
81
+ property_type: "Loft",
82
+ room_type: "Entire home/apt",
83
+ bed_type: "Real Bed",
84
+ address: { street: "Porto, Porto, Portugal" },
85
+ },
86
+ { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
87
+ ],
88
+ })
89
+ .map((x) => x.prop("name"))
90
+ .sort(), [
91
+ "Porto city centre apartment H",
92
+ "Romantic loft near historic center",
93
+ "Lovely sun light in a stylish loft, Downtown Spot",
94
+ "Charming & Sunny Mezzanine Loft",
95
+ "Brand New Luxury Downtown Studio",
96
+ "Be Happy in Porto",
97
+ "Quarry Apartment",
98
+ "Loft with balcony and view of Casa da Música PORTO",
99
+ "For 4 or 6 - Wonderful Apartment downtown",
100
+ "Clérigos Apartments - Apt. 4E for 2/3 Pax",
101
+ "Bright Top Floor Two Rooms Apartment w/ Terrace",
102
+ "ReUrban Flats - Santa Catarina #3",
103
+ "The Blue and White Porto House - Vintage",
104
+ "4twoLoft at Great Location",
105
+ "Step In Porto - Loft w/Mezzanine",
106
+ "Your OWM Invicta",
107
+ "Pury Apartments",
108
+ "Live Porto & Douro - Breiner III",
109
+ ].sort());
110
+ console.timeEnd("query4");
111
+ }
112
+ function query5(qyDB) {
113
+ console.time("query5");
114
+ deepEqual(qyDB
115
+ .queryFiles("airbnb1", {
116
+ $or: [
117
+ {
118
+ property_type: "Loft",
119
+ room_type: "Entire home/apt",
120
+ bed_type: "Real Bed",
121
+ address: { street: "Porto, Porto, Portugal" },
122
+ },
123
+ { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
124
+ ],
125
+ }, 3)
126
+ .map((x) => x.prop("name")), [
127
+ "Porto city centre apartment H",
128
+ "Romantic loft near historic center",
129
+ "Lovely sun light in a stylish loft, Downtown Spot",
130
+ ]);
131
+ console.timeEnd("query5");
132
+ }
133
+ function query6(qyDB) {
134
+ console.time("query6");
135
+ deepEqual(qyDB
136
+ .queryFiles("airbnb1", {
137
+ $or: [
138
+ {
139
+ property_type: "Loft",
140
+ room_type: "Entire home/apt",
141
+ bed_type: "Real Bed",
142
+ address: { street: "Porto, Porto, Portugal" },
143
+ },
144
+ { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
145
+ ],
146
+ }, 20, 10)
147
+ .map((x) => x.prop("name")), [
148
+ "ReUrban Flats - Santa Catarina #3",
149
+ "The Blue and White Porto House - Vintage",
150
+ "4twoLoft at Great Location",
151
+ "Step In Porto - Loft w/Mezzanine",
152
+ "Your OWM Invicta",
153
+ "Pury Apartments",
154
+ "Live Porto & Douro - Breiner III",
155
+ "Brand New Luxury Downtown Studio",
156
+ ]);
157
+ console.timeEnd("query6");
158
+ }
159
+ function query7(qyDB) {
160
+ console.time("query7");
161
+ deepEqual(qyDB
162
+ .queryFiles("airbnb1", { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 })
163
+ .map((x) => x.prop("name")), ["Romantic loft near historic center", "Brand New Luxury Downtown Studio"]);
164
+ console.timeEnd("query7");
165
+ }
166
+ function query8(qyDB) {
167
+ console.time("query8");
168
+ deepEqual(qyDB
169
+ .queryFiles("airbnb1", { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 }, 10, 10)
170
+ .map((x) => x.prop("name")), []);
171
+ console.timeEnd("query8");
172
+ }
173
+ function query9(qyDB) {
174
+ console.time("query9");
175
+ deepEqual(qyDB
176
+ .queryFiles("airbnb1", {
177
+ $or: [
178
+ {
179
+ property_type: "Loft",
180
+ room_type: "Entire home/apt",
181
+ bed_type: "Real Bed",
182
+ address: { street: "Porto, Porto, Portugal" },
183
+ },
184
+ { property_type: (x) => x == "Loft", minimum_nights: (x) => x >= 60 },
185
+ ],
186
+ }, 3)
187
+ .map((x) => x.prop("name")), [
188
+ "Porto city centre apartment H",
189
+ "Romantic loft near historic center",
190
+ "Lovely sun light in a stylish loft, Downtown Spot",
191
+ ]);
192
+ console.timeEnd("query9");
193
+ }
194
+ function runQueries(qyDB) {
195
+ query1(qyDB);
196
+ query1(qyDB);
197
+ query2(qyDB);
198
+ query2(qyDB);
199
+ query3(qyDB);
200
+ query3(qyDB);
201
+ query4(qyDB);
202
+ query4(qyDB);
203
+ query5(qyDB);
204
+ query5(qyDB);
205
+ query6(qyDB);
206
+ query6(qyDB);
207
+ query7(qyDB);
208
+ query7(qyDB);
209
+ query8(qyDB);
210
+ query8(qyDB);
211
+ query9(qyDB);
212
+ query9(qyDB);
213
+ }
214
+ export { runQueries };
@@ -0,0 +1,47 @@
1
+ import { join, basename } from "node:path";
2
+ import { readFile, readdir, writeFile } from "node:fs/promises";
3
+ import { iterPMBuffer, loadPrefixPMFile } from "../src/QySnapshots.js";
4
+ import { ensureDir, folderOrFileExists } from "../src/QyUtils.js";
5
+ logger.level = "info";
6
+ run();
7
+ async function loadPosMapFile(posMapFilePath) {
8
+ const buffer = await readFile(posMapFilePath);
9
+ const posMap = {};
10
+ iterPMBuffer(buffer, (key, nums) => (posMap[key] = nums));
11
+ return posMap;
12
+ }
13
+ async function run() {
14
+ const folderPath = process.argv[2];
15
+ let destFolderPath = process.argv[3];
16
+ if (!folderPath || !destFolderPath) {
17
+ console.log(`Usage: node ${basename(import.meta.filename)} folder/to/convert folder/to/save or inplace`);
18
+ }
19
+ else {
20
+ if (destFolderPath == "inplace")
21
+ destFolderPath = folderPath;
22
+ await convertFolder(folderPath, destFolderPath);
23
+ }
24
+ }
25
+ async function convertFolder(folder, destFolder) {
26
+ const promises = [];
27
+ for (const item of await readdir(folder, { withFileTypes: true })) {
28
+ const { name } = item;
29
+ if (item.isDirectory()) {
30
+ promises.push(convertFolder(join(folder, name), join(destFolder, name)));
31
+ }
32
+ else {
33
+ const match = /^[0-9]+_(pM|prefixPM)\.txt/.exec(name);
34
+ if (match) {
35
+ const filePath = join(folder, name);
36
+ const destFilePath = join(destFolder, "dump_" + name + ".json");
37
+ if (await folderOrFileExists(destFilePath))
38
+ continue;
39
+ await ensureDir(destFolder);
40
+ console.log(`Converting ${filePath} -> ${destFilePath}`);
41
+ const map = await (match[1] == "pM" ? loadPosMapFile(filePath) : loadPrefixPMFile(filePath));
42
+ promises.push(writeFile(destFilePath, JSON.stringify(map, null, 2)));
43
+ }
44
+ }
45
+ }
46
+ await Promise.all(promises);
47
+ }
@@ -1,40 +1,41 @@
1
- import { createWriteStream } from "fs";
2
- import { get } from "https";
3
- import { ensureParentDir, folderOrFileExists } from "../src/QyUtils.js";
4
- import { logger } from "../src/QyLogger.js";
5
-
6
- async function downloadFile(fileUrl, filePath) {
7
- if (await folderOrFileExists(filePath)) return;
8
- await ensureParentDir(filePath);
9
- let resolve, reject;
10
- const promise = new Promise((res, rej) => {
11
- resolve = res;
12
- reject = rej;
13
- });
14
- get(fileUrl, (response) => {
15
- if (response.statusCode !== 200) {
16
- logger.error(`Download failed: Status Code ${response.statusCode}`);
17
- reject(response.statusCode);
18
- } else {
19
- const fileStream = createWriteStream(filePath);
20
- let accu = 0;
21
- response.on("data", (chunk) => {
22
- fileStream.write(chunk);
23
- accu += chunk.length;
24
- if (accu >= 1000_000) {
25
- process.stdout.write(".");
26
- accu = 0;
27
- }
28
- });
29
- response.on("end", () => {
30
- fileStream.close();
31
- resolve();
32
- });
33
- }
34
- }).on("error", (err) => {
35
- logger.error(`Request error: ${err.message}`);
36
- reject(err.message);
37
- });
38
- return promise;
39
- }
40
- export { downloadFile };
1
+ import { createWriteStream } from "fs";
2
+ import { get } from "https";
3
+ import { ensureParentDir, folderOrFileExists } from "../src/QyUtils.js";
4
+ import { logger } from "../src/QyLogger.js";
5
+ async function downloadFile(fileUrl, filePath) {
6
+ if (await folderOrFileExists(filePath))
7
+ return;
8
+ await ensureParentDir(filePath);
9
+ let resolve, reject;
10
+ const promise = new Promise((res, rej) => {
11
+ resolve = res;
12
+ reject = rej;
13
+ });
14
+ get(fileUrl, (response) => {
15
+ if (response.statusCode !== 200) {
16
+ logger.error(`Download failed: Status Code ${response.statusCode}`);
17
+ reject(response.statusCode);
18
+ }
19
+ else {
20
+ const fileStream = createWriteStream(filePath);
21
+ let accu = 0;
22
+ response.on("data", (chunk) => {
23
+ fileStream.write(chunk);
24
+ accu += chunk.length;
25
+ if (accu >= 1000_000) {
26
+ process.stdout.write(".");
27
+ accu = 0;
28
+ }
29
+ });
30
+ response.on("end", () => {
31
+ fileStream.close();
32
+ resolve();
33
+ });
34
+ }
35
+ }).on("error", (err) => {
36
+ logger.error(`Request error: ${err.message}`);
37
+ reject(err.message);
38
+ });
39
+ return promise;
40
+ }
41
+ export { downloadFile };