dataply 0.0.22 → 0.0.23-alpha.0

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 (2) hide show
  1. package/dist/cjs/index.js +36 -14
  2. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -2182,17 +2182,24 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
2182
2182
  }
2183
2183
  return void 0;
2184
2184
  }
2185
- *keysStream(condition, filterValues, limit, order = "asc") {
2186
- const stream = this.whereStream(condition, limit, order);
2185
+ *keysStream(condition, options) {
2186
+ const { filterValues, limit, order = "asc" } = options ?? {};
2187
+ const stream = this.whereStream(condition, options);
2187
2188
  const intersection = filterValues && filterValues.size > 0 ? filterValues : null;
2189
+ let count = 0;
2188
2190
  for (const [key] of stream) {
2189
2191
  if (intersection && !intersection.has(key)) {
2190
2192
  continue;
2191
2193
  }
2192
2194
  yield key;
2195
+ count++;
2196
+ if (limit !== void 0 && count >= limit) {
2197
+ break;
2198
+ }
2193
2199
  }
2194
2200
  }
2195
- *whereStream(condition, limit, order = "asc") {
2201
+ *whereStream(condition, options) {
2202
+ const { filterValues, limit, order = "asc" } = options ?? {};
2196
2203
  const driverKey = this.getDriverKey(condition);
2197
2204
  if (!driverKey) return;
2198
2205
  const value = condition[driverKey];
@@ -2215,8 +2222,12 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
2215
2222
  earlyTerminate
2216
2223
  );
2217
2224
  let count = 0;
2225
+ const intersection = filterValues && filterValues.size > 0 ? filterValues : null;
2218
2226
  for (const pair of generator) {
2219
2227
  const [k, v] = pair;
2228
+ if (intersection && !intersection.has(k)) {
2229
+ continue;
2230
+ }
2220
2231
  let isMatch = true;
2221
2232
  for (const key in condition) {
2222
2233
  if (key === driverKey) continue;
@@ -2236,16 +2247,16 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
2236
2247
  }
2237
2248
  }
2238
2249
  }
2239
- keys(condition, filterValues, order = "asc") {
2250
+ keys(condition, options) {
2240
2251
  const set = /* @__PURE__ */ new Set();
2241
- for (const key of this.keysStream(condition, filterValues, void 0, order)) {
2252
+ for (const key of this.keysStream(condition, options)) {
2242
2253
  set.add(key);
2243
2254
  }
2244
2255
  return set;
2245
2256
  }
2246
- where(condition, order = "asc") {
2257
+ where(condition, options) {
2247
2258
  const map = /* @__PURE__ */ new Map();
2248
- for (const [key, value] of this.whereStream(condition, void 0, order)) {
2259
+ for (const [key, value] of this.whereStream(condition, options)) {
2249
2260
  map.set(key, value);
2250
2261
  }
2251
2262
  return map;
@@ -3249,17 +3260,24 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
3249
3260
  }
3250
3261
  return void 0;
3251
3262
  }
3252
- async *keysStream(condition, filterValues, limit, order = "asc") {
3253
- const stream = this.whereStream(condition, limit, order);
3263
+ async *keysStream(condition, options) {
3264
+ const { filterValues, limit, order = "asc" } = options ?? {};
3265
+ const stream = this.whereStream(condition, options);
3254
3266
  const intersection = filterValues && filterValues.size > 0 ? filterValues : null;
3267
+ let count = 0;
3255
3268
  for await (const [key] of stream) {
3256
3269
  if (intersection && !intersection.has(key)) {
3257
3270
  continue;
3258
3271
  }
3259
3272
  yield key;
3273
+ count++;
3274
+ if (limit !== void 0 && count >= limit) {
3275
+ break;
3276
+ }
3260
3277
  }
3261
3278
  }
3262
- async *whereStream(condition, limit, order = "asc") {
3279
+ async *whereStream(condition, options) {
3280
+ const { filterValues, limit, order = "asc" } = options ?? {};
3263
3281
  const driverKey = this.getDriverKey(condition);
3264
3282
  if (!driverKey) return;
3265
3283
  const value = condition[driverKey];
@@ -3282,8 +3300,12 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
3282
3300
  earlyTerminate
3283
3301
  );
3284
3302
  let count = 0;
3303
+ const intersection = filterValues && filterValues.size > 0 ? filterValues : null;
3285
3304
  for await (const pair of generator) {
3286
3305
  const [k, v] = pair;
3306
+ if (intersection && !intersection.has(k)) {
3307
+ continue;
3308
+ }
3287
3309
  let isMatch = true;
3288
3310
  for (const key in condition) {
3289
3311
  if (key === driverKey) continue;
@@ -3303,16 +3325,16 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
3303
3325
  }
3304
3326
  }
3305
3327
  }
3306
- async keys(condition, filterValues, order = "asc") {
3328
+ async keys(condition, options) {
3307
3329
  const set = /* @__PURE__ */ new Set();
3308
- for await (const key of this.keysStream(condition, filterValues, void 0, order)) {
3330
+ for await (const key of this.keysStream(condition, options)) {
3309
3331
  set.add(key);
3310
3332
  }
3311
3333
  return set;
3312
3334
  }
3313
- async where(condition, order = "asc") {
3335
+ async where(condition, options) {
3314
3336
  const map = /* @__PURE__ */ new Map();
3315
- for await (const [key, value] of this.whereStream(condition, void 0, order)) {
3337
+ for await (const [key, value] of this.whereStream(condition, options)) {
3316
3338
  map.set(key, value);
3317
3339
  }
3318
3340
  return map;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataply",
3
- "version": "0.0.22",
3
+ "version": "0.0.23-alpha.0",
4
4
  "description": "A lightweight storage engine for Node.js with support for MVCC, WAL.",
5
5
  "license": "MIT",
6
6
  "author": "izure <admin@izure.org>",
@@ -49,6 +49,6 @@
49
49
  "hookall": "^2.2.0",
50
50
  "mvcc-api": "^1.3.4",
51
51
  "ryoiki": "^1.2.0",
52
- "serializable-bptree": "^8.1.7"
52
+ "serializable-bptree": "^8.2.0"
53
53
  }
54
54
  }