PERF-2 P1.b: the polyline index prunes from the start with an upper bound from each chunk's first vertex (never the answer; the strict-minimum scan rule is unchanged), so a query near the polygon's far end no longer scans every chunk; pin unchanged, 0 mismatches
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Build (ubuntu-latest) (push) Failing after 4s
Documentation / Build API Documentation (push) Failing after 6s
Documentation / Build User Guide (push) Successful in 7s
CI / Build CPU-Only (Explicit) (push) Failing after 9s
CI / Format Check (push) Failing after 28s
CI / Clippy Check (push) Failing after 1m19s
Performance Benchmarks / Run Benchmarks (push) Successful in 2m26s
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Build (ubuntu-latest) (push) Failing after 4s
Documentation / Build API Documentation (push) Failing after 6s
Documentation / Build User Guide (push) Successful in 7s
CI / Build CPU-Only (Explicit) (push) Failing after 9s
CI / Format Check (push) Failing after 28s
CI / Clippy Check (push) Failing after 1m19s
Performance Benchmarks / Run Benchmarks (push) Successful in 2m26s
This commit is contained in:
@@ -330,10 +330,21 @@ impl<'a> PolylineIndex<'a> {
|
|||||||
let pts = self.pts;
|
let pts = self.pts;
|
||||||
let n = pts.len();
|
let n = pts.len();
|
||||||
let (mut best, mut best_d) = (pts[0], f64::INFINITY);
|
let (mut best, mut best_d) = (pts[0], f64::INFINITY);
|
||||||
|
// An UPPER bound on the minimum from each chunk's first vertex (a
|
||||||
|
// point of the polyline, so no segment can beat it by more than the
|
||||||
|
// rounding margin): chunks farther than it are pruned from the
|
||||||
|
// start, and the bound never becomes the answer — the scan below
|
||||||
|
// keeps the brute-force rule (first segment at the strict minimum).
|
||||||
|
let mut prune_d = f64::INFINITY;
|
||||||
|
for c in 0..self.boxes.len() {
|
||||||
|
let a = pts[c * self.chunk];
|
||||||
|
let d = (a[0] - q[0]).powi(2) + (a[1] - q[1]).powi(2);
|
||||||
|
prune_d = prune_d.min(d);
|
||||||
|
}
|
||||||
for (c, b) in self.boxes.iter().enumerate() {
|
for (c, b) in self.boxes.iter().enumerate() {
|
||||||
let dx = (b[0] - q[0]).max(0.0).max(q[0] - b[1]);
|
let dx = (b[0] - q[0]).max(0.0).max(q[0] - b[1]);
|
||||||
let dy = (b[2] - q[1]).max(0.0).max(q[1] - b[3]);
|
let dy = (b[2] - q[1]).max(0.0).max(q[1] - b[3]);
|
||||||
if dx * dx + dy * dy > best_d * (1.0 + 1e-12) {
|
if dx * dx + dy * dy > best_d.min(prune_d) * (1.0 + 1e-12) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let start = c * self.chunk;
|
let start = c * self.chunk;
|
||||||
|
|||||||
Reference in New Issue
Block a user