Skip to content

feat(retrieval): HYPERMATCH structural matching (HGMatch, MaCH filter) - #116

Merged
venkat1701 merged 5 commits into
mainfrom
feature/hypergraph-match
Nov 23, 2026
Merged

venkat1701 merged 5 commits into
mainfrom
feature/hypergraph-match

Conversation

@venkat1701

Copy link
Copy Markdown
Collaborator

Stacked on #115: it reads the signature slots that #115 adds. Merge #115 first, then retarget this to main.

HYPERMATCH finds every exact occurrence of a pattern of hyperedges: an injective, type-preserving map from the pattern's vertices to atoms, where each pattern hyperedge maps to a stored hyperedge with exactly the same members. It follows HGMatch (Yang et al., ICDE 2023) and binds one whole hyperedge per search level instead of one vertex.

How it works

  • Candidates: the hyperedges of the step's signature (slot 48), intersected with the reverse-index postings of the already-matched atoms in each class of earlier pattern hyperedges.
  • Validation: a candidate is accepted when its matched members fall into those classes with the pattern's multiplicities. No vertex assignment is ever searched.
  • MODE MACH (from MaCH, arXiv 2512.10621): first cuts each candidate set to hyperedges supported by some candidate of every adjacent pattern hyperedge. AUTO picks it for unanchored patterns of three or more hyperedges.
  • WHERE u = @… pins vertices to atoms. BINDINGS lists vertex assignments, generated one at a time. COUNT counts tuples. EXPLAIN HYPERMATCH shows the order.
  • Parallel search: a large first step is split over one shared fork/join pool, but only for snapshot reads, and each worker runs under the statement's page budget.
  • Isolation: a candidate with a member the reader cannot see (another tenant's, or a type without a grant) is rejected.

The syntax is open for renaming before merge:

hypermatch = "HYPERMATCH" hyperedge { "," hyperedge } [ "WHERE" anchor { "AND" anchor } ]
             [ "MODE" ( "AUTO" | "HGMATCH" | "MACH" ) ] ( "COUNT" | [ "BINDINGS" ] [ "LIMIT" integer ] ) ;
hyperedge  = identifier ":" identifier "(" vertex { "," vertex } ")" ;
vertex     = identifier [ ":" identifier ] ;
anchor     = identifier "=" ref ;

Testing

  • Full build: engine 269, database 194, server 41, all passing.
  • Brute force: results are compared with an independent vertex-by-vertex search over random data with duplicate hyperedges, for 120 random patterns each across HGMatch, MaCH, parallel and anchored runs, plus the paper's running example.
  • Mutation checks: ignoring class counts, letting one stored hyperedge serve two pattern hyperedges, admitting invisible members, and over-pruning in MaCH each make a test fail.
  • Security: SecurityTest covers tenant scoping, anchors to another tenant's atoms, and cross-tenant memberships.
  • Concurrency: a type-granted user runs the parallel search while commits land.

Independent review. It found one critical and three important issues, all fixed with tests:

  • BINDINGS built every permutation in memory before LIMIT applied (now lazy and budgeted).
  • The type-grant cache was mutated by parallel workers; the old code threw ConcurrentModificationException in one of two runs of the new test.
  • The MaCH filter had no limits.
  • Every statement created its own thread pool.

It also found two smaller issues, fixed here: the signature-collision filter, and a doubled page budget.

Not done here

  • First-step candidates are all built before the split.
  • COUNT of a one-hyperedge pattern still walks the candidates.
  • A failing task does not cancel its siblings.
  • MaCH's in-search forward checking and dynamic order.
  • Untyped pattern vertices and hyperedges.

… patterns

HYPERMATCH finds every injective, type-preserving map from a connected
pattern of hyperedges to stored hyperedges with exactly the same members.
It binds one whole hyperedge per search level: candidates are the
hyperedges of the query hyperedge's signature (slot 48) intersected with
the reverse-index postings of the matched atoms in each class of earlier
query hyperedges, and a candidate is accepted when its matched members
fall into those classes with the query's multiplicities, so no vertex
assignment is ever searched.

MODE MACH first cuts every candidate set to hyperedges supported by a
candidate of each adjacent query hyperedge; AUTO picks it for unanchored
patterns of three or more hyperedges. WHERE pins vertices to atoms,
BINDINGS expands tuples into vertex assignments, and large first steps
are searched on a fork/join pool under the statement's page budget.
Candidates with a member the reader cannot see are rejected.

No issue tracks this work.
BINDINGS expanded every vertex permutation of a tuple before LIMIT or the
budget applied, so one symmetric hyperedge with a dozen members could
exhaust the heap. Bindings are now generated one at a time and each
counts against the row budget.

The reader's type-grant cache was a HashMap that parallel search mutated
from several threads; it is now a concurrent map replaced per generation.
The MACH candidate filter charges the budget per probe, keeps its
witnesses in arrays, is refused when the pattern has more than 2^20
candidates, and is not run by EXPLAIN or a second time for the trace.
Parallel search uses one shared pool, a signature lookup returns nothing
unless the key's name list holds that exact signature and tenant, and the
statement reports the page budget of the read it runs in.

No issue tracks this work.
# Conflicts:
#	database/src/main/java/io/hstore/db/Reader.java
@venkat1701
venkat1701 changed the base branch from feature/temporal-retrieval to main November 23, 2026 10:53
@venkat1701
venkat1701 merged commit 2719542 into main Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant