Skip to content

Commit edbc19c

Browse files
committed
make the correlation subquery O(1) instead of O(number of snapshots)
1 parent 067f9b6 commit edbc19c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Sources/UnidocQueries/Queries/WideQuery.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ extension WideQuery:VolumeLookupQuery
102102
$0[let: symbol] = Output.Principal[.master] / Volume.Vertex[.symbol]
103103
$0[let: hash] = Output.Principal[.master] / Volume.Vertex[.hash]
104104

105+
// ``namesOfLatest`` is always non-nil, so we don’t need to worry about
106+
// degenerate index behavior.
105107
$0[let: min] = Output.Principal[.namesOfLatest] / Volume.Names[.planes_min]
106108
$0[let: max] = Output.Principal[.namesOfLatest] / Volume.Names[.planes_max]
107109
}

Sources/UnidocQueries/Volumes/VolumeLookupQuery.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ extension VolumeLookupQuery
9494
$0[.replaceWith] = .init
9595
{
9696
$0[Self.names] = Mongo.Pipeline.ROOT
97+
98+
// ``Volume.Names`` is complex but not that large, and duplicating this
99+
// makes the rest of the query a lot simpler.
100+
if let names:Mongo.KeyPath = Self.namesOfLatest
101+
{
102+
$0[names] = Mongo.Pipeline.ROOT
103+
}
97104
}
98105
}
99106

0 commit comments

Comments
 (0)