flowquery 1.0.85 → 1.0.87
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/README.md +101 -0
- package/dist/compute/flowquery.d.ts +18 -0
- package/dist/compute/flowquery.d.ts.map +1 -1
- package/dist/compute/flowquery.js +26 -0
- package/dist/compute/flowquery.js.map +1 -1
- package/dist/compute/runner.d.ts +29 -0
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +111 -3
- package/dist/compute/runner.js.map +1 -1
- package/dist/extensibility.d.ts +4 -1
- package/dist/extensibility.d.ts.map +1 -1
- package/dist/extensibility.js +14 -1
- package/dist/extensibility.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/data.d.ts +1 -0
- package/dist/graph/data.d.ts.map +1 -1
- package/dist/graph/data.js +3 -0
- package/dist/graph/data.js.map +1 -1
- package/dist/graph/data_cache.d.ts +3 -1
- package/dist/graph/data_cache.d.ts.map +1 -1
- package/dist/graph/data_cache.js +5 -4
- package/dist/graph/data_cache.js.map +1 -1
- package/dist/graph/data_resolver.d.ts +13 -0
- package/dist/graph/data_resolver.d.ts.map +1 -1
- package/dist/graph/data_resolver.js +52 -0
- package/dist/graph/data_resolver.js.map +1 -1
- package/dist/graph/database.d.ts +19 -0
- package/dist/graph/database.d.ts.map +1 -1
- package/dist/graph/database.js +76 -0
- package/dist/graph/database.js.map +1 -1
- package/dist/graph/node.d.ts +21 -0
- package/dist/graph/node.d.ts.map +1 -1
- package/dist/graph/node.js +147 -0
- package/dist/graph/node.js.map +1 -1
- package/dist/graph/pattern.d.ts +19 -1
- package/dist/graph/pattern.d.ts.map +1 -1
- package/dist/graph/pattern.js +279 -1
- package/dist/graph/pattern.js.map +1 -1
- package/dist/graph/pattern_expression.d.ts +3 -1
- package/dist/graph/pattern_expression.d.ts.map +1 -1
- package/dist/graph/pattern_expression.js +8 -3
- package/dist/graph/pattern_expression.js.map +1 -1
- package/dist/graph/patterns.d.ts +2 -1
- package/dist/graph/patterns.d.ts.map +1 -1
- package/dist/graph/patterns.js +3 -3
- package/dist/graph/patterns.js.map +1 -1
- package/dist/graph/physical_node.d.ts +10 -1
- package/dist/graph/physical_node.d.ts.map +1 -1
- package/dist/graph/physical_node.js +19 -2
- package/dist/graph/physical_node.js.map +1 -1
- package/dist/graph/physical_relationship.d.ts +10 -1
- package/dist/graph/physical_relationship.d.ts.map +1 -1
- package/dist/graph/physical_relationship.js +21 -2
- package/dist/graph/physical_relationship.js.map +1 -1
- package/dist/graph/relationship.d.ts +25 -1
- package/dist/graph/relationship.d.ts.map +1 -1
- package/dist/graph/relationship.js +135 -0
- package/dist/graph/relationship.js.map +1 -1
- package/dist/graph/relationship_match_collector.d.ts +1 -1
- package/dist/graph/relationship_match_collector.d.ts.map +1 -1
- package/dist/graph/relationship_match_collector.js +29 -3
- package/dist/graph/relationship_match_collector.js.map +1 -1
- package/dist/graph/relationship_reference.d.ts.map +1 -1
- package/dist/graph/relationship_reference.js +1 -2
- package/dist/graph/relationship_reference.js.map +1 -1
- package/dist/graph/source_access.d.ts +107 -0
- package/dist/graph/source_access.d.ts.map +1 -0
- package/dist/graph/source_access.js +726 -0
- package/dist/graph/source_access.js.map +1 -0
- package/dist/graph/source_context.d.ts +101 -0
- package/dist/graph/source_context.d.ts.map +1 -0
- package/dist/graph/source_context.js +392 -0
- package/dist/graph/source_context.js.map +1 -0
- package/dist/graph/source_provider.d.ts +263 -0
- package/dist/graph/source_provider.d.ts.map +1 -0
- package/dist/graph/source_provider.js +306 -0
- package/dist/graph/source_provider.js.map +1 -0
- package/dist/graph/statement_source.d.ts +27 -0
- package/dist/graph/statement_source.d.ts.map +1 -0
- package/dist/graph/statement_source.js +117 -0
- package/dist/graph/statement_source.js.map +1 -0
- package/dist/graph/virtual_statement.d.ts +19 -1
- package/dist/graph/virtual_statement.d.ts.map +1 -1
- package/dist/graph/virtual_statement.js +197 -5
- package/dist/graph/virtual_statement.js.map +1 -1
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +14 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.d.ts +3 -0
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +14 -1
- package/dist/index.node.js.map +1 -1
- package/dist/parsing/expressions/expression.d.ts +6 -0
- package/dist/parsing/expressions/expression.d.ts.map +1 -1
- package/dist/parsing/expressions/expression.js +30 -3
- package/dist/parsing/expressions/expression.js.map +1 -1
- package/dist/parsing/operations/aggregated_return.d.ts +2 -0
- package/dist/parsing/operations/aggregated_return.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_return.js +6 -0
- package/dist/parsing/operations/aggregated_return.js.map +1 -1
- package/dist/parsing/operations/aggregated_with.d.ts +2 -0
- package/dist/parsing/operations/aggregated_with.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_with.js +6 -0
- package/dist/parsing/operations/aggregated_with.js.map +1 -1
- package/dist/parsing/operations/create_node.d.ts +5 -1
- package/dist/parsing/operations/create_node.d.ts.map +1 -1
- package/dist/parsing/operations/create_node.js +20 -1
- package/dist/parsing/operations/create_node.js.map +1 -1
- package/dist/parsing/operations/create_relationship.d.ts +5 -1
- package/dist/parsing/operations/create_relationship.d.ts.map +1 -1
- package/dist/parsing/operations/create_relationship.js +21 -1
- package/dist/parsing/operations/create_relationship.js.map +1 -1
- package/dist/parsing/operations/limit.d.ts +1 -0
- package/dist/parsing/operations/limit.d.ts.map +1 -1
- package/dist/parsing/operations/limit.js +3 -0
- package/dist/parsing/operations/limit.js.map +1 -1
- package/dist/parsing/operations/match.d.ts +16 -0
- package/dist/parsing/operations/match.d.ts.map +1 -1
- package/dist/parsing/operations/match.js +104 -8
- package/dist/parsing/operations/match.js.map +1 -1
- package/dist/parsing/operations/operation.d.ts +6 -0
- package/dist/parsing/operations/operation.d.ts.map +1 -1
- package/dist/parsing/operations/operation.js +8 -0
- package/dist/parsing/operations/operation.js.map +1 -1
- package/dist/parsing/operations/return.d.ts +10 -0
- package/dist/parsing/operations/return.d.ts.map +1 -1
- package/dist/parsing/operations/return.js +23 -0
- package/dist/parsing/operations/return.js.map +1 -1
- package/dist/parsing/operations/unwind.d.ts +1 -0
- package/dist/parsing/operations/unwind.d.ts.map +1 -1
- package/dist/parsing/operations/unwind.js +9 -2
- package/dist/parsing/operations/unwind.js.map +1 -1
- package/dist/parsing/operations/where.d.ts +1 -0
- package/dist/parsing/operations/where.d.ts.map +1 -1
- package/dist/parsing/operations/where.js +4 -0
- package/dist/parsing/operations/where.js.map +1 -1
- package/dist/parsing/operations/with.d.ts +1 -0
- package/dist/parsing/operations/with.d.ts.map +1 -1
- package/dist/parsing/operations/with.js +4 -0
- package/dist/parsing/operations/with.js.map +1 -1
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +20 -2
- package/dist/parsing/parser.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
20
|
+
var i, p;
|
|
21
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
22
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
23
|
+
};
|
|
24
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
25
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
26
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
27
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
28
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
29
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
30
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
31
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
32
|
+
function fulfill(value) { resume("next", value); }
|
|
33
|
+
function reject(value) { resume("throw", value); }
|
|
34
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.MemoryRelationshipAccess = exports.MemoryNodeAccess = exports.RelationshipSourceAccess = exports.NodeSourceAccess = void 0;
|
|
41
|
+
exports.isStaticExpression = isStaticExpression;
|
|
42
|
+
exports.buildTerms = buildTerms;
|
|
43
|
+
exports.predicateFor = predicateFor;
|
|
44
|
+
const list_comprehension_1 = __importDefault(require("../parsing/data_structures/list_comprehension"));
|
|
45
|
+
const binding_reference_1 = __importDefault(require("../parsing/expressions/binding_reference"));
|
|
46
|
+
const reference_1 = __importDefault(require("../parsing/expressions/reference"));
|
|
47
|
+
const function_1 = __importDefault(require("../parsing/functions/function"));
|
|
48
|
+
const source_context_1 = require("./source_context");
|
|
49
|
+
const source_provider_1 = require("./source_provider");
|
|
50
|
+
/**
|
|
51
|
+
* True when the expression only depends on literals and query
|
|
52
|
+
* parameters, i.e. its value is fixed for the whole query.
|
|
53
|
+
*/
|
|
54
|
+
function isStaticExpression(node) {
|
|
55
|
+
if (node instanceof reference_1.default ||
|
|
56
|
+
node instanceof binding_reference_1.default ||
|
|
57
|
+
node instanceof function_1.default ||
|
|
58
|
+
node instanceof list_comprehension_1.default ||
|
|
59
|
+
// Pattern and sub-query expressions are evaluated per row.
|
|
60
|
+
typeof node.evaluate === "function") {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
for (const child of node.getChildren()) {
|
|
64
|
+
if (!isStaticExpression(child))
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
/** Evaluate static element properties and pushed WHERE predicates into push terms. */
|
|
70
|
+
function buildTerms(properties, pushed) {
|
|
71
|
+
const terms = [];
|
|
72
|
+
let args = null;
|
|
73
|
+
for (const [key, expression] of properties) {
|
|
74
|
+
if (!isStaticExpression(expression))
|
|
75
|
+
continue;
|
|
76
|
+
const value = expression.value();
|
|
77
|
+
args !== null && args !== void 0 ? args : (args = {});
|
|
78
|
+
args[key] = value;
|
|
79
|
+
terms.push({ op: "eq", property: key, value });
|
|
80
|
+
}
|
|
81
|
+
for (const p of pushed) {
|
|
82
|
+
const value = p.expression.value();
|
|
83
|
+
if (p.op === "in") {
|
|
84
|
+
if (Array.isArray(value))
|
|
85
|
+
terms.push({ op: "in", property: p.property, values: value });
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
terms.push({ op: p.op, property: p.property, value });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { terms, args };
|
|
92
|
+
}
|
|
93
|
+
function isPushablePrimitive(value) {
|
|
94
|
+
return typeof value === "string" || (typeof value === "number" && Number.isFinite(value));
|
|
95
|
+
}
|
|
96
|
+
/** Convert a term into a contract predicate the source can evaluate, or null. */
|
|
97
|
+
function toPredicate(caps, term) {
|
|
98
|
+
var _a;
|
|
99
|
+
if (caps === undefined || !caps.operators.includes(term.op))
|
|
100
|
+
return null;
|
|
101
|
+
if (caps.properties !== undefined && !caps.properties.includes(term.property))
|
|
102
|
+
return null;
|
|
103
|
+
switch (term.op) {
|
|
104
|
+
case "eq":
|
|
105
|
+
return isPushablePrimitive(term.value)
|
|
106
|
+
? { op: "eq", property: term.property, value: term.value }
|
|
107
|
+
: null;
|
|
108
|
+
case "in": {
|
|
109
|
+
const values = (_a = term.values) !== null && _a !== void 0 ? _a : [];
|
|
110
|
+
if (!values.every(isPushablePrimitive))
|
|
111
|
+
return null;
|
|
112
|
+
const seen = new Set();
|
|
113
|
+
const distinct = [];
|
|
114
|
+
for (const v of values) {
|
|
115
|
+
const key = (0, source_context_1.canonicalKey)(v);
|
|
116
|
+
if (!seen.has(key)) {
|
|
117
|
+
seen.add(key);
|
|
118
|
+
distinct.push(v);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return { op: "in", property: term.property, values: distinct };
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
if (typeof term.value === "number" && Number.isFinite(term.value)) {
|
|
125
|
+
return { op: term.op, property: term.property, value: term.value };
|
|
126
|
+
}
|
|
127
|
+
if (typeof term.value === "string" && caps.stringOrdering === "binary") {
|
|
128
|
+
return { op: term.op, property: term.property, value: term.value };
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function combine(predicates) {
|
|
134
|
+
if (predicates.length === 0)
|
|
135
|
+
return null;
|
|
136
|
+
if (predicates.length === 1)
|
|
137
|
+
return predicates[0];
|
|
138
|
+
return { op: "and", terms: predicates };
|
|
139
|
+
}
|
|
140
|
+
function predicateFor(caps, terms) {
|
|
141
|
+
const out = [];
|
|
142
|
+
for (const term of terms) {
|
|
143
|
+
const p = toPredicate(caps, term);
|
|
144
|
+
if (p !== null)
|
|
145
|
+
out.push(p);
|
|
146
|
+
}
|
|
147
|
+
return combine(out);
|
|
148
|
+
}
|
|
149
|
+
function supportsKeyIn(caps, field) {
|
|
150
|
+
return (caps !== undefined &&
|
|
151
|
+
caps.operators.includes("in") &&
|
|
152
|
+
(caps.properties === undefined || caps.properties.includes(field)));
|
|
153
|
+
}
|
|
154
|
+
const providerIds = new WeakMap();
|
|
155
|
+
let nextProviderId = 0;
|
|
156
|
+
function providerKey(provider) {
|
|
157
|
+
let id = providerIds.get(provider);
|
|
158
|
+
if (id === undefined) {
|
|
159
|
+
id = ++nextProviderId;
|
|
160
|
+
providerIds.set(provider, id);
|
|
161
|
+
}
|
|
162
|
+
return id;
|
|
163
|
+
}
|
|
164
|
+
function chunk(items, size) {
|
|
165
|
+
const out = [];
|
|
166
|
+
for (let i = 0; i < items.length; i += size)
|
|
167
|
+
out.push(items.slice(i, i + size));
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
function distinct(ids) {
|
|
171
|
+
const seen = new Set();
|
|
172
|
+
const out = [];
|
|
173
|
+
for (const id of ids) {
|
|
174
|
+
if (id === null || id === undefined)
|
|
175
|
+
continue;
|
|
176
|
+
const key = (0, source_context_1.canonicalKey)(id);
|
|
177
|
+
if (!seen.has(key)) {
|
|
178
|
+
seen.add(key);
|
|
179
|
+
out.push(id);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
const indexCache = new WeakMap();
|
|
185
|
+
function indexRows(rows, field) {
|
|
186
|
+
let byField = indexCache.get(rows);
|
|
187
|
+
if (byField === undefined) {
|
|
188
|
+
byField = new Map();
|
|
189
|
+
indexCache.set(rows, byField);
|
|
190
|
+
}
|
|
191
|
+
let index = byField.get(field);
|
|
192
|
+
if (index === undefined) {
|
|
193
|
+
index = new Map();
|
|
194
|
+
for (const row of rows) {
|
|
195
|
+
if (!(field in row))
|
|
196
|
+
continue;
|
|
197
|
+
const key = (0, source_context_1.canonicalKey)(row[field]);
|
|
198
|
+
let bucket = index.get(key);
|
|
199
|
+
if (bucket === undefined) {
|
|
200
|
+
bucket = [];
|
|
201
|
+
index.set(key, bucket);
|
|
202
|
+
}
|
|
203
|
+
bucket.push(row);
|
|
204
|
+
}
|
|
205
|
+
byField.set(field, index);
|
|
206
|
+
}
|
|
207
|
+
return index;
|
|
208
|
+
}
|
|
209
|
+
/** Common machinery for one provider bound to one label or relationship type. */
|
|
210
|
+
class SourceEntry {
|
|
211
|
+
constructor(ctx, provider, name, kind) {
|
|
212
|
+
this.ctx = ctx;
|
|
213
|
+
this.provider = provider;
|
|
214
|
+
this.name = name;
|
|
215
|
+
this.kind = kind;
|
|
216
|
+
this._unsupported = new Set();
|
|
217
|
+
}
|
|
218
|
+
get caps() {
|
|
219
|
+
return this.provider.capabilities;
|
|
220
|
+
}
|
|
221
|
+
get batchSize() {
|
|
222
|
+
var _a;
|
|
223
|
+
return Math.min(this.ctx.options.maxBatchSize, (_a = this.caps.maxBatchSize) !== null && _a !== void 0 ? _a : Infinity);
|
|
224
|
+
}
|
|
225
|
+
get cacheable() {
|
|
226
|
+
return this.caps.cacheable === true;
|
|
227
|
+
}
|
|
228
|
+
cacheKey(op, predicate, args, extra) {
|
|
229
|
+
return `${this.kind}|${providerKey(this.provider)}|${this.name}|${op}|${(0, source_context_1.canonicalKey)(predicate)}|${(0, source_context_1.canonicalKey)(args)}|${(0, source_context_1.canonicalKey)(extra)}`;
|
|
230
|
+
}
|
|
231
|
+
/** Stream scan pages, optionally constrained by an extra key predicate. */
|
|
232
|
+
scan(terms, args) {
|
|
233
|
+
return __asyncGenerator(this, arguments, function* scan_1() {
|
|
234
|
+
const predicate = predicateFor(this.caps.predicates, terms);
|
|
235
|
+
yield __await(yield* __asyncDelegator(__asyncValues(this.scanWith(predicate, args))));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
scanWith(predicate, args) {
|
|
239
|
+
return __asyncGenerator(this, arguments, function* scanWith_1() {
|
|
240
|
+
var _a, e_1, _b, _c;
|
|
241
|
+
const key = this.cacheable ? this.cacheKey("scan", predicate, args, null) : null;
|
|
242
|
+
if (key !== null) {
|
|
243
|
+
const cached = this.ctx.cacheGet(key);
|
|
244
|
+
if (cached !== undefined) {
|
|
245
|
+
yield yield __await(cached);
|
|
246
|
+
return yield __await(void 0);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const collected = key !== null ? [] : null;
|
|
250
|
+
let overflow = false;
|
|
251
|
+
try {
|
|
252
|
+
for (var _d = true, _e = __asyncValues(this.ctx.call(this.provider, "scan", this.name, this.kind, Object.assign(Object.assign({ operation: "scan" }, this.base()), { predicate,
|
|
253
|
+
args, pageSize: this.ctx.options.pageSize }))), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
254
|
+
_c = _f.value;
|
|
255
|
+
_d = false;
|
|
256
|
+
const page = _c;
|
|
257
|
+
const enriched = page.map((row) => this.enrich(row));
|
|
258
|
+
if (collected !== null && !overflow) {
|
|
259
|
+
if (collected.length + enriched.length > this.ctx.options.cacheCapacity) {
|
|
260
|
+
overflow = true;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
collected.push(...enriched);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
yield yield __await(enriched);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
270
|
+
finally {
|
|
271
|
+
try {
|
|
272
|
+
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
273
|
+
}
|
|
274
|
+
finally { if (e_1) throw e_1.error; }
|
|
275
|
+
}
|
|
276
|
+
if (key !== null && collected !== null && !overflow) {
|
|
277
|
+
this.ctx.cacheSet(key, collected);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
/** Fully materialize a scan (shared per query) as the last-resort fallback. */
|
|
282
|
+
materializeAll(args) {
|
|
283
|
+
const key = this.cacheKey("materialize", null, args, null);
|
|
284
|
+
return this.ctx.materialize(key, () => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
var _a, e_2, _b, _c;
|
|
286
|
+
const rows = [];
|
|
287
|
+
try {
|
|
288
|
+
for (var _d = true, _e = __asyncValues(this.scanWith(null, args)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
289
|
+
_c = _f.value;
|
|
290
|
+
_d = false;
|
|
291
|
+
const page = _c;
|
|
292
|
+
rows.push(...page);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
296
|
+
finally {
|
|
297
|
+
try {
|
|
298
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
299
|
+
}
|
|
300
|
+
finally { if (e_2) throw e_2.error; }
|
|
301
|
+
}
|
|
302
|
+
return rows;
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Fetch rows for a set of key values using the native keyed operation
|
|
307
|
+
* (`lookup`/`expand`) in batches, falling back to filtered scans or a
|
|
308
|
+
* materialized scan. Returns `null` when `maxRows` would be exceeded.
|
|
309
|
+
*/
|
|
310
|
+
fetchKeyed(operation_1, native_1, field_1, ids_1, terms_1, args_1, extra_1) {
|
|
311
|
+
return __awaiter(this, arguments, void 0, function* (operation, native, field, ids, terms, args, extra, maxRows = Infinity) {
|
|
312
|
+
var _a, e_3, _b, _c, _d, e_4, _e, _f;
|
|
313
|
+
var _g;
|
|
314
|
+
const predicate = predicateFor(this.caps.predicates, terms);
|
|
315
|
+
const result = new Map();
|
|
316
|
+
const pending = [];
|
|
317
|
+
for (const id of ids) {
|
|
318
|
+
const key = this.cacheable
|
|
319
|
+
? this.cacheKey(operation, predicate, args, Object.assign(Object.assign({}, extra), { id }))
|
|
320
|
+
: null;
|
|
321
|
+
const cached = key !== null ? this.ctx.cacheGet(key) : undefined;
|
|
322
|
+
if (cached !== undefined) {
|
|
323
|
+
result.set((0, source_context_1.canonicalKey)(id), cached);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
result.set((0, source_context_1.canonicalKey)(id), []);
|
|
327
|
+
pending.push(id);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const wanted = new Set(pending.map(source_context_1.canonicalKey));
|
|
331
|
+
if (pending.length === 0)
|
|
332
|
+
return result;
|
|
333
|
+
let total = 0;
|
|
334
|
+
const add = (row) => {
|
|
335
|
+
const k = (0, source_context_1.canonicalKey)(row[field]);
|
|
336
|
+
if (!wanted.has(k))
|
|
337
|
+
return true;
|
|
338
|
+
result.get(k).push(this.enrich(row));
|
|
339
|
+
total++;
|
|
340
|
+
return total <= maxRows;
|
|
341
|
+
};
|
|
342
|
+
const useNative = native && !this._unsupported.has(operation);
|
|
343
|
+
if (useNative) {
|
|
344
|
+
try {
|
|
345
|
+
for (const batch of chunk(pending, this.batchSize)) {
|
|
346
|
+
this.ctx.stats.batches++;
|
|
347
|
+
try {
|
|
348
|
+
for (var _h = true, _j = (e_3 = void 0, __asyncValues(this.ctx.call(this.provider, operation, this.name, this.kind, Object.assign(Object.assign(Object.assign({ operation }, this.base()), extra), { ids: batch, predicate,
|
|
349
|
+
args, pageSize: this.ctx.options.pageSize })))), _k; _k = yield _j.next(), _a = _k.done, !_a; _h = true) {
|
|
350
|
+
_c = _k.value;
|
|
351
|
+
_h = false;
|
|
352
|
+
const page = _c;
|
|
353
|
+
for (const row of page) {
|
|
354
|
+
if (!add(row))
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
this.ctx.notePeakBuffered(total);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
361
|
+
finally {
|
|
362
|
+
try {
|
|
363
|
+
if (!_h && !_a && (_b = _j.return)) yield _b.call(_j);
|
|
364
|
+
}
|
|
365
|
+
finally { if (e_3) throw e_3.error; }
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (e) {
|
|
370
|
+
if (!(e instanceof source_provider_1.SourceUnsupportedError) || total > 0)
|
|
371
|
+
throw e;
|
|
372
|
+
this._unsupported.add(operation);
|
|
373
|
+
return this.fetchKeyed(operation, false, field, ids, terms, args, extra, maxRows);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.ctx.stats.fallbacks++;
|
|
378
|
+
if (supportsKeyIn(this.caps.predicates, field)) {
|
|
379
|
+
for (const batch of chunk(pending, this.batchSize)) {
|
|
380
|
+
this.ctx.stats.batches++;
|
|
381
|
+
const keyed = combine([
|
|
382
|
+
...(predicate === null ? [] : [predicate]),
|
|
383
|
+
{ op: "in", property: field, values: batch },
|
|
384
|
+
]);
|
|
385
|
+
try {
|
|
386
|
+
for (var _l = true, _m = (e_4 = void 0, __asyncValues(this.scanWith(keyed, args))), _o; _o = yield _m.next(), _d = _o.done, !_d; _l = true) {
|
|
387
|
+
_f = _o.value;
|
|
388
|
+
_l = false;
|
|
389
|
+
const page = _f;
|
|
390
|
+
for (const row of page) {
|
|
391
|
+
if (!wanted.has((0, source_context_1.canonicalKey)(row[field])))
|
|
392
|
+
continue;
|
|
393
|
+
result.get((0, source_context_1.canonicalKey)(row[field])).push(row);
|
|
394
|
+
if (++total > maxRows)
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
400
|
+
finally {
|
|
401
|
+
try {
|
|
402
|
+
if (!_l && !_d && (_e = _m.return)) yield _e.call(_m);
|
|
403
|
+
}
|
|
404
|
+
finally { if (e_4) throw e_4.error; }
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
const index = indexRows(yield this.materializeAll(args), field);
|
|
410
|
+
for (const id of pending) {
|
|
411
|
+
const rows = (_g = index.get((0, source_context_1.canonicalKey)(id))) !== null && _g !== void 0 ? _g : [];
|
|
412
|
+
result.set((0, source_context_1.canonicalKey)(id), rows);
|
|
413
|
+
total += rows.length;
|
|
414
|
+
}
|
|
415
|
+
if (total > maxRows)
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (this.cacheable) {
|
|
420
|
+
for (const id of pending) {
|
|
421
|
+
this.ctx.cacheSet(this.cacheKey(operation, predicate, args, Object.assign(Object.assign({}, extra), { id })), result.get((0, source_context_1.canonicalKey)(id)));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return result;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
class NodeEntry extends SourceEntry {
|
|
429
|
+
constructor(ctx, provider, label) {
|
|
430
|
+
super(ctx, provider, label, "node");
|
|
431
|
+
this.label = label;
|
|
432
|
+
}
|
|
433
|
+
base() {
|
|
434
|
+
return { label: this.label };
|
|
435
|
+
}
|
|
436
|
+
enrich(row) {
|
|
437
|
+
return Object.assign(Object.assign({}, row), { _label: this.label });
|
|
438
|
+
}
|
|
439
|
+
get nativeLookup() {
|
|
440
|
+
return this.provider.capabilities.lookup === true;
|
|
441
|
+
}
|
|
442
|
+
lookup(ids, terms, args) {
|
|
443
|
+
return this.fetchKeyed("lookup", this.nativeLookup, "id", ids, terms, args, {});
|
|
444
|
+
}
|
|
445
|
+
estimate(terms, args) {
|
|
446
|
+
const provider = this.provider;
|
|
447
|
+
if (typeof provider.estimate !== "function")
|
|
448
|
+
return undefined;
|
|
449
|
+
return provider.estimate({
|
|
450
|
+
version: 1,
|
|
451
|
+
operation: "scan",
|
|
452
|
+
label: this.label,
|
|
453
|
+
predicate: predicateFor(this.caps.predicates, terms),
|
|
454
|
+
args,
|
|
455
|
+
pageSize: this.ctx.options.pageSize,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
pushes(terms) {
|
|
459
|
+
return predicateFor(this.caps.predicates, terms) !== null;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
class RelationshipEntry extends SourceEntry {
|
|
463
|
+
constructor(ctx, provider, type, sourceLabel, targetLabel) {
|
|
464
|
+
super(ctx, provider, `(:${sourceLabel !== null && sourceLabel !== void 0 ? sourceLabel : ""})-[:${type}]->(:${targetLabel !== null && targetLabel !== void 0 ? targetLabel : ""})`, "relationship");
|
|
465
|
+
this.type = type;
|
|
466
|
+
this.sourceLabel = sourceLabel;
|
|
467
|
+
this.targetLabel = targetLabel;
|
|
468
|
+
}
|
|
469
|
+
base() {
|
|
470
|
+
return { type: this.type, sourceLabel: this.sourceLabel, targetLabel: this.targetLabel };
|
|
471
|
+
}
|
|
472
|
+
enrich(row) {
|
|
473
|
+
return Object.assign(Object.assign({}, row), { _type: this.type });
|
|
474
|
+
}
|
|
475
|
+
nativeExpand(side) {
|
|
476
|
+
var _a;
|
|
477
|
+
return ((_a = this.provider.capabilities.expand) === null || _a === void 0 ? void 0 : _a[side]) === true;
|
|
478
|
+
}
|
|
479
|
+
expandBatch(side, ids, terms, args, maxRows) {
|
|
480
|
+
return this.fetchKeyed("expand", this.nativeExpand(side), `${side}_id`, ids, terms, args, { side }, maxRows);
|
|
481
|
+
}
|
|
482
|
+
/** Stream the relationships of one anchor without buffering. */
|
|
483
|
+
expandOne(side, id, terms, args) {
|
|
484
|
+
return __asyncGenerator(this, arguments, function* expandOne_1() {
|
|
485
|
+
var _a, e_5, _b, _c;
|
|
486
|
+
var _d;
|
|
487
|
+
const field = `${side}_id`;
|
|
488
|
+
const predicate = predicateFor(this.caps.predicates, terms);
|
|
489
|
+
const extra = { side, id };
|
|
490
|
+
const key = this.cacheable ? this.cacheKey("expand", predicate, args, extra) : null;
|
|
491
|
+
if (key !== null) {
|
|
492
|
+
const cached = this.ctx.cacheGet(key);
|
|
493
|
+
if (cached !== undefined) {
|
|
494
|
+
yield yield __await(cached);
|
|
495
|
+
return yield __await(void 0);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (!this.nativeExpand(side) || this._unsupported.has("expand")) {
|
|
499
|
+
const rows = yield __await(this.fetchKeyed("expand", false, field, [id], terms, args, { side }));
|
|
500
|
+
yield yield __await((_d = rows.get((0, source_context_1.canonicalKey)(id))) !== null && _d !== void 0 ? _d : []);
|
|
501
|
+
return yield __await(void 0);
|
|
502
|
+
}
|
|
503
|
+
const want = (0, source_context_1.canonicalKey)(id);
|
|
504
|
+
const collected = key !== null ? [] : null;
|
|
505
|
+
let overflow = false;
|
|
506
|
+
let yielded = false;
|
|
507
|
+
try {
|
|
508
|
+
try {
|
|
509
|
+
for (var _e = true, _f = __asyncValues(this.ctx.call(this.provider, "expand", this.name, this.kind, Object.assign(Object.assign({ operation: "expand" }, this.base()), { side, ids: [id], predicate,
|
|
510
|
+
args, pageSize: this.ctx.options.pageSize }))), _g; _g = yield __await(_f.next()), _a = _g.done, !_a; _e = true) {
|
|
511
|
+
_c = _g.value;
|
|
512
|
+
_e = false;
|
|
513
|
+
const page = _c;
|
|
514
|
+
const rows = page
|
|
515
|
+
.filter((r) => (0, source_context_1.canonicalKey)(r[field]) === want)
|
|
516
|
+
.map((r) => this.enrich(r));
|
|
517
|
+
if (collected !== null && !overflow) {
|
|
518
|
+
if (collected.length + rows.length > this.ctx.options.cacheCapacity)
|
|
519
|
+
overflow = true;
|
|
520
|
+
else
|
|
521
|
+
collected.push(...rows);
|
|
522
|
+
}
|
|
523
|
+
yielded = true;
|
|
524
|
+
yield yield __await(rows);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
528
|
+
finally {
|
|
529
|
+
try {
|
|
530
|
+
if (!_e && !_a && (_b = _f.return)) yield __await(_b.call(_f));
|
|
531
|
+
}
|
|
532
|
+
finally { if (e_5) throw e_5.error; }
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (e) {
|
|
536
|
+
if (!(e instanceof source_provider_1.SourceUnsupportedError) || yielded)
|
|
537
|
+
throw e;
|
|
538
|
+
this._unsupported.add("expand");
|
|
539
|
+
yield __await(yield* __asyncDelegator(__asyncValues(this.expandOne(side, id, terms, args))));
|
|
540
|
+
return yield __await(void 0);
|
|
541
|
+
}
|
|
542
|
+
if (key !== null && collected !== null && !overflow)
|
|
543
|
+
this.ctx.cacheSet(key, collected);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/** Provider-backed node access across one or more labels. */
|
|
548
|
+
class NodeSourceAccess {
|
|
549
|
+
constructor(ctx, entries) {
|
|
550
|
+
this.ctx = ctx;
|
|
551
|
+
this.deferred = true;
|
|
552
|
+
this._buffer = null;
|
|
553
|
+
this._entries = entries.map((e) => new NodeEntry(ctx, e.provider, e.label));
|
|
554
|
+
}
|
|
555
|
+
scan(terms, args) {
|
|
556
|
+
return __asyncGenerator(this, arguments, function* scan_2() {
|
|
557
|
+
for (const entry of this._entries)
|
|
558
|
+
yield __await(yield* __asyncDelegator(__asyncValues(entry.scan(terms, args))));
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
prefetch(ids, terms, args) {
|
|
562
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
563
|
+
const unique = distinct(ids);
|
|
564
|
+
const previous = this._buffer;
|
|
565
|
+
const buffer = new Map();
|
|
566
|
+
const missing = [];
|
|
567
|
+
for (const id of unique) {
|
|
568
|
+
const key = (0, source_context_1.canonicalKey)(id);
|
|
569
|
+
const kept = previous === null || previous === void 0 ? void 0 : previous.get(key);
|
|
570
|
+
if (kept !== undefined) {
|
|
571
|
+
buffer.set(key, kept);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
buffer.set(key, []);
|
|
575
|
+
missing.push(id);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (missing.length > 0) {
|
|
579
|
+
for (const entry of this._entries) {
|
|
580
|
+
const rows = yield entry.lookup(missing, terms, args);
|
|
581
|
+
for (const [key, list] of rows)
|
|
582
|
+
buffer.get(key).push(...list);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
this._buffer = buffer;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
lookup(id, terms, args) {
|
|
589
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
590
|
+
var _a, _b;
|
|
591
|
+
if (id === null || id === undefined)
|
|
592
|
+
return [];
|
|
593
|
+
const key = (0, source_context_1.canonicalKey)(id);
|
|
594
|
+
const buffered = (_a = this._buffer) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
595
|
+
if (buffered !== undefined)
|
|
596
|
+
return buffered;
|
|
597
|
+
const out = [];
|
|
598
|
+
for (const entry of this._entries) {
|
|
599
|
+
const rows = yield entry.lookup([id], terms, args);
|
|
600
|
+
out.push(...((_b = rows.get(key)) !== null && _b !== void 0 ? _b : []));
|
|
601
|
+
}
|
|
602
|
+
return out;
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
canLookup() {
|
|
606
|
+
return this._entries.every((e) => e.nativeLookup);
|
|
607
|
+
}
|
|
608
|
+
pushes(terms) {
|
|
609
|
+
return this._entries.every((e) => e.pushes(terms));
|
|
610
|
+
}
|
|
611
|
+
estimate(terms, args) {
|
|
612
|
+
let total = 0;
|
|
613
|
+
for (const entry of this._entries) {
|
|
614
|
+
const e = entry.estimate(terms, args);
|
|
615
|
+
if (e === undefined)
|
|
616
|
+
return undefined;
|
|
617
|
+
total += e;
|
|
618
|
+
}
|
|
619
|
+
return total;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
exports.NodeSourceAccess = NodeSourceAccess;
|
|
623
|
+
/** Provider-backed relationship access across one or more types/endpoints. */
|
|
624
|
+
class RelationshipSourceAccess {
|
|
625
|
+
constructor(ctx, entries) {
|
|
626
|
+
this.ctx = ctx;
|
|
627
|
+
this.deferred = true;
|
|
628
|
+
this._buffer = null;
|
|
629
|
+
this._bufferSide = null;
|
|
630
|
+
this._entries = entries.map((e) => new RelationshipEntry(ctx, e.provider, e.type, e.sourceLabel, e.targetLabel));
|
|
631
|
+
}
|
|
632
|
+
expand(anchor, side, terms, args) {
|
|
633
|
+
return __asyncGenerator(this, arguments, function* expand_1() {
|
|
634
|
+
var _a;
|
|
635
|
+
if (anchor === null || anchor === undefined)
|
|
636
|
+
return yield __await(void 0);
|
|
637
|
+
const buffered = this._bufferSide === side ? (_a = this._buffer) === null || _a === void 0 ? void 0 : _a.get((0, source_context_1.canonicalKey)(anchor)) : undefined;
|
|
638
|
+
if (buffered !== undefined) {
|
|
639
|
+
yield yield __await(buffered);
|
|
640
|
+
return yield __await(void 0);
|
|
641
|
+
}
|
|
642
|
+
for (const entry of this._entries)
|
|
643
|
+
yield __await(yield* __asyncDelegator(__asyncValues(entry.expandOne(side, anchor, terms, args))));
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
prefetch(anchors, side, terms, args) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
this._buffer = null;
|
|
649
|
+
this._bufferSide = null;
|
|
650
|
+
const unique = distinct(anchors);
|
|
651
|
+
if (unique.length < 2 || !this._entries.every((e) => e.nativeExpand(side)))
|
|
652
|
+
return null;
|
|
653
|
+
const buffer = new Map();
|
|
654
|
+
for (const id of unique)
|
|
655
|
+
buffer.set((0, source_context_1.canonicalKey)(id), []);
|
|
656
|
+
let remaining = this.ctx.options.maxPrefetchRows;
|
|
657
|
+
const all = [];
|
|
658
|
+
for (const entry of this._entries) {
|
|
659
|
+
const rows = yield entry.expandBatch(side, unique, terms, args, remaining);
|
|
660
|
+
if (rows === null)
|
|
661
|
+
return null;
|
|
662
|
+
for (const [key, list] of rows) {
|
|
663
|
+
buffer.get(key).push(...list);
|
|
664
|
+
all.push(...list);
|
|
665
|
+
remaining -= list.length;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
this.ctx.notePeakBuffered(all.length);
|
|
669
|
+
this._buffer = buffer;
|
|
670
|
+
this._bufferSide = side;
|
|
671
|
+
return all;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
exports.RelationshipSourceAccess = RelationshipSourceAccess;
|
|
676
|
+
/** In-memory node access over materialized legacy records (used by reversed plans). */
|
|
677
|
+
class MemoryNodeAccess {
|
|
678
|
+
constructor(_records) {
|
|
679
|
+
this._records = _records;
|
|
680
|
+
this.deferred = false;
|
|
681
|
+
}
|
|
682
|
+
scan() {
|
|
683
|
+
return __asyncGenerator(this, arguments, function* scan_3() {
|
|
684
|
+
yield yield __await(this._records);
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
lookup(id) {
|
|
688
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
689
|
+
var _a;
|
|
690
|
+
return (_a = indexRows(this._records, "id").get((0, source_context_1.canonicalKey)(id))) !== null && _a !== void 0 ? _a : [];
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
prefetch() {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
695
|
+
}
|
|
696
|
+
canLookup() {
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
pushes() {
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
estimate() {
|
|
703
|
+
return this._records.length;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
exports.MemoryNodeAccess = MemoryNodeAccess;
|
|
707
|
+
/** In-memory relationship access over materialized legacy records (used by reversed plans). */
|
|
708
|
+
class MemoryRelationshipAccess {
|
|
709
|
+
constructor(_records) {
|
|
710
|
+
this._records = _records;
|
|
711
|
+
this.deferred = false;
|
|
712
|
+
}
|
|
713
|
+
expand(anchor, side) {
|
|
714
|
+
return __asyncGenerator(this, arguments, function* expand_2() {
|
|
715
|
+
var _a;
|
|
716
|
+
yield yield __await((_a = indexRows(this._records, `${side}_id`).get((0, source_context_1.canonicalKey)(anchor))) !== null && _a !== void 0 ? _a : []);
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
prefetch() {
|
|
720
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
721
|
+
return null;
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
exports.MemoryRelationshipAccess = MemoryRelationshipAccess;
|
|
726
|
+
//# sourceMappingURL=source_access.js.map
|