Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ python3 bench/props/props.py --seeds 7 --show
against the union of its two halves (split on a tile boundary where possible); a polygon
against itself reversed and starting at another vertex; the same filters in different orders;
`[bbox:]` against an inline bbox; `around` a point against `around` a node at that point;
`way(bn)` of the nodes in a box within `way(bbox)`; a way within `way(around.s:0)` of itself.
`way(bn)` of the nodes in a box within `way(bbox)`; a way within `way(around.s:0)` of itself;
`around` a set of relations against the union of `around` each one, collected in a `foreach`
(the same statement run again with another relation); and, on the history database at each
date, `around` a relation against `around` its direct member nodes and ways, preferring
relations edited after the date.
And translation: each seed is also imported shifted by an offset that isn't a multiple of the
tile size, and bbox, `poly:`, area and `is_in` queries must return the same elements on both.
Region comparisons leave out elements that come within one unit of the boundary without being
Expand Down
10 changes: 10 additions & 0 deletions bench/props/consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ def box():
f'node({i})->.c; {kind}(around.c:{r});')
wid = rnd.choice(list(data.ways))
add('way within around.self:0', f'way({wid});', f'way({wid})->.s; way(around.s:0);', 'subset')

# around a set of relations = the union of around each one, collected in a foreach. Each
# iteration runs the same around statement with another relation as input.
if len(data.rels) > 1:
ids = ','.join(str(r) for r in sorted(data.rels))
r = rnd.choice([0, 5, 50])
for kind in ('node', 'way'):
add(f'foreach around rel = around rels ({kind}s)',
f'relation(id:{ids})->.r; ()->.acc; foreach.r->.it {{ {kind}(around.it:{r})->.x; (.acc; .x;)->.acc; }} .acc;',
f'relation(id:{ids})->.r; {kind}(around.r:{r});')
return checks


Expand Down
21 changes: 21 additions & 0 deletions bench/props/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,24 @@ def gen_history_output_checks(h, seed):
checks.append(('adiff', f'[adiff:"{d1}","{d2}"];\n(way({world}); node({world}););\nout meta geom;\n',
props.no_verify))
return checks


def gen_history_consistency_checks(h, seed):
"""Pairs of queries at a past date that must agree: around a relation = around its direct
member nodes and ways, which make up its geometry. Prefers relations edited after the date,
so the relation used is an old version."""
rnd = random.Random(seed * 104729 + 11)
checks = []
for date in DATES:
rels = h.alive('relation', date)
if not rels:
continue
later = [r for r in sorted(rels) if any(v['ts'] > date for v in h.versions[('relation', r)])]
rid = rnd.choice(later or sorted(rels))
r = rnd.choice([0, 5, 50])
d = f'[date:"{date}"]'
for kind in ('node', 'way'):
checks.append((f'date around rel = around members ({kind}s)',
f'{d}; relation({rid})->.r; {kind}(around.r:{r});',
f'{d}; relation({rid})->.rr; (node(r.rr); way(r.rr);)->.m; {kind}(around.m:{r});', 'equal'))
return checks
74 changes: 73 additions & 1 deletion bench/props/mutants-all-changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,77 @@
"new": " { return !(b < a); }), current_objects.end());",
"note": "metadata dedup collapses each tile to one entry",
"expect_caught": "yes"
},
{
"commit": "2273b99",
"subject": "around: weight the time-limit check by the work done, and check inside long ways",
"file": "src/overpass_api/statements/around.cc",
"old": " if (work_done >= 64*1024)",
"new": " if (false && work_done >= 64*1024)",
"note": "the time-limit check never runs; it only decides when a query that is out of time stops, and props.py sets no time limit, so this can't change a result",
"expect_caught": "no"
},
{
"commit": "634d377",
"subject": "around: take candidate ranges for relations at a past date from their members",
"file": "src/overpass_api/statements/around.cc",
"old": " new_way_ranges = new_way_ranges.union_(ranges(relation_way_members(",
"new": " if (false) new_way_ranges = new_way_ranges.union_(ranges(relation_way_members(",
"note": "relations at a past date lose their way members' candidate ranges; caught by the history check 'date around rel = around members'",
"expect_caught": "yes"
},
{
"commit": "5df9912",
"subject": "around: look up the input relations' members once per input",
"file": "src/overpass_api/statements/around.cc",
"old": " || member_ranges_relations != relations || member_ranges_attic_relations != attic_relations)",
"new": " || false)",
"note": "the cached member ranges are kept when the input relations change. Needs data beyond the synthetic sets: the ranges are whole index tiles widened by the radius, and the synthetic data spans so few tiles that the first relation's ranges already cover the others, so the 'foreach around rel' check returns the same result. The targeted around check on the Nova Scotia history database caught it (see #38)",
"expect_caught": "no"
},
{
"commit": "358e322",
"subject": "collect_items: pass end iterators to reconstruct_items by reference",
"file": "src/overpass_api/data/collect_items.h",
"old": " Iterator& it, const Iterator& end, Index index,",
"new": " Iterator& it, Iterator end, Index index,",
"note": "equivalent: the commit only avoids copies and adds no logic, so the only mutant is reverting it",
"expect_caught": "no"
},
{
"commit": "4033566",
"subject": "collect_items_by_timestamp: keep the result size up to date instead of recounting it",
"file": "src/overpass_api/data/collect_items.h",
"old": " return it == m.end() ? 0 : eval_index_size + it->second.size()*eval_object_size((const Object*)0);",
"new": " return it == m.end() ? 0 : eval_index_size;",
"note": "the running size counts only indexes; that changes only where chunks end and which queries hit [maxsize:], never a result, and props.py's queries stay far below the limits",
"expect_caught": "no"
},
{
"commit": "7b7d798",
"subject": "tag_store: remove placeholder tags only from the entries just collected",
"file": "src/overpass_api/data/tag_store.h",
"old": " touched.push_back(&obj_vec);",
"new": " if (false) touched.push_back(&obj_vec);",
"note": "placeholder tags for tags added after the date stay in the output of objects at a past date",
"expect_caught": "yes"
},
{
"commit": "9945057",
"subject": "area and poly queries: build each way's geometry once in collect_ways",
"file": "src/overpass_api/statements/area_query.cc",
"old": " add_way_to_area_blocks(coords, it2->id.val(), way_segments);",
"new": " add_way_to_area_blocks(std::vector< Quad_Coord >(coords.begin(), coords.end() - (coords.empty() ? 0 : 1)), it2->id.val(), way_segments);",
"note": "area queries split each way into segments without its last vertex",
"expect_caught": "yes"
},
{
"commit": "e643105",
"subject": "tag_store: find tag entries' ids with a forward cursor instead of a binary search",
"file": "src/overpass_api/data/tag_store.h",
"old": " if (cursor != ids.begin() && !(*(cursor - 1) < id))",
"new": " if (false && cursor != ids.begin() && !(*(cursor - 1) < id))",
"note": "the cursor never starts over, so tags of a later tag group whose ids are below the cursor are lost",
"expect_caught": "yes"
}
]
]
1 change: 1 addition & 0 deletions bench/props/props.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ def run_seed(seed, args, tmp):
results += run_checks(args, hdb, h, hchecks, seed, prefix='h')
results += run_output_checks(args, hdb, h, history.gen_history_output_checks(h, seed), seed,
len(hchecks), prefix='h')
results += run_pairs(args, hdb, hdb, h, history.gen_history_consistency_checks(h, seed), seed, 'hc')
shutil.rmtree(hdb, ignore_errors=True)
return seed, data.scale, results

Expand Down