perf(open): answer "are there any entities?" with one directory read
The 7.x-to-8.0 layout probe runs on the open path of every store that does not
yet carry its completion marker — a restore, a store built by an older release
— and asked whether the canonical tree holds anything by LISTING it: a
recursive walk of every file in every entity directory, to learn a boolean. It
now asks the one-level door added for generation discovery, falling back to the
listing on an adapter that lacks it.
Also files a defect found while ratifying the operator set: the VFS builds its
path-prefix filter as `$startsWith`, an operator no engine spelling accepts,
so vfs.searchFiles({ path }) throws INVALID_QUERY on every call that passes a
path. Pre-existing, unrelated to the operator work, and left as a filing —
a path-prefix search needs a design answer, not a spelling correction.
This commit is contained in:
parent
9dd399216b
commit
417ddb5143
1 changed files with 13 additions and 2 deletions
|
|
@ -16732,8 +16732,19 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
if (legacyEntityPaths.length === 0) {
|
if (legacyEntityPaths.length === 0) {
|
||||||
// Already flat (root entities, no head-branch entities) → stamp the marker
|
// Already flat (root entities, no head-branch entities) → stamp the marker
|
||||||
// so future opens short-circuit. A genuinely empty/fresh dir gets no marker.
|
// so future opens short-circuit. A genuinely empty/fresh dir gets no marker.
|
||||||
const rootEntities = await probe.listRawObjects('entities')
|
// "Are there any entities?" is answered by ONE directory read, not by a
|
||||||
if (rootEntities.length > 0) {
|
// recursive listing of every file in the tree: this runs on the open path
|
||||||
|
// of every store that does not yet carry the marker (a restore, a store
|
||||||
|
// built by an older release), and on a large store that listing walks the
|
||||||
|
// whole canonical tree to learn a boolean.
|
||||||
|
const oneLevel = (
|
||||||
|
probe as unknown as { listRawPrefixes?: (prefix: string) => Promise<string[]> }
|
||||||
|
).listRawPrefixes
|
||||||
|
const hasRootEntities =
|
||||||
|
typeof oneLevel === 'function'
|
||||||
|
? (await oneLevel.call(probe, 'entities')).length > 0
|
||||||
|
: (await probe.listRawObjects('entities')).length > 0
|
||||||
|
if (hasRootEntities) {
|
||||||
await probe.writeRawObject('_system/migration-layout.json', {
|
await probe.writeRawObject('_system/migration-layout.json', {
|
||||||
layout: 'flat-v8',
|
layout: 'flat-v8',
|
||||||
version: 8,
|
version: 8,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue