Skip to content

Conversation

@mbastian
Copy link
Member

@mbastian mbastian commented Sep 26, 2025

This adds the ability to query the quadtree using (parallel) streams.

  • An "approximate" mode has been added to speed up performance. In this mode, element retrieval is purely based on quad node intersection, avoiding to test intersection of many objects.
  • Edge query has been revamped and extended. We added support for a "global" iterator that directly iterates edges instead of edges within nodes. This is much faster when the visible objects are large. We've put a threshold at 30% of visible nodes. Above that threshold, we use a global iterator.
  • Added additional unit tests.

@mbastian mbastian added this to the 0.8.0 milestone Sep 26, 2025
@mbastian mbastian marked this pull request as ready for review October 3, 2025 12:59
@mbastian mbastian requested a review from Copilot October 3, 2025 12:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds spliterator support and predicate/approximate querying to the spatial (quadtree) index, introduces multi-node edge iteration, and updates the SpatialIndex API. Also refactors internal quad tree storage from Set to array plus versioning and adjusts configuration defaults (larger capacities).

  • Added Node & Edge spliterators (including filtered and approximate variants) and exposed readLock/readUnlock plus approximate query methods in SpatialIndex.
  • Reworked quad tree node storage to fixed-size expandable arrays, added versioning and multi-node edge iterators; edge area queries now may return duplicates (tests updated).
  • Increased several default storage and spatial index capacity constants.

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
SpatialIndexImplTest.java Adjusts expectations for edge queries (now allowing duplicate edges) and adds clear test.
NodesQuadTreeTest.java Extensive new tests for counts, iterator/spliterator behavior, predicates, approximate queries, edges, and performance scenarios.
GraphGenerator.java Adds node generation within an optional Rect2D region.
EdgeStoreTest.java Updates iterator calls with new locking flag; adds multi-node edge iterator tests.
UndirectedDecorator.java Adapts to new edge iterator signature with locking flag.
SpatialNodeDataImpl.java Adds array index tracking and clear() helper for quad tree storage.
SpatialIndexImpl.java Refactors to delegate edge/node area queries directly to NodesQuadTree, adds approximate & predicate-aware methods, locking passthrough, object count accessor.
NodesQuadTree.java Major refactor: array-based storage, versioning, predicates, approximate search, edge iteration & spliterators, global edge spliterator, counting APIs.
NodeStore.java Updates edge iterator usage with new signature (locking flag).
GraphViewImpl.java Uses spatial index predicate-based filtering; exposes approximate queries; delegates boundaries computation to spatial index.
GraphViewDecorator.java Adapts view-level area queries to new spatial index methods and iterator signature; simplifies boundary retrieval.
GraphStoreConfiguration.java Increases edge store and spatial index sizing constants; adds config flags for approximate search and iterator threshold.
GraphStore.java Updates iterator calls with new edgeIterator signature.
EdgeStore.java Introduces abstract & multi-node edge iterators; propagates spatial index version bumps; adds iterator/spliterator factory changes.
SpatialIndex.java Expands API (approximate queries, locking methods) and updates documentation (edges may be duplicated).
Rect2D.java Changes toString format and adds containsOrIntersects utility methods.
Comments suppressed due to low confidence (1)

src/main/java/org/gephi/graph/api/SpatialIndex.java:1

  • [nitpick] Exposing explicit readLock()/readUnlock() in the public SpatialIndex API leaks internal locking strategy and invites misuse (e.g., forgotten unlocks). Consider providing higher-level safe streaming helpers or auto-closeable scopes (e.g., try-with-resources) instead, or confine locking to iterator/spliterator implementations.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

mbastian and others added 5 commits October 3, 2025 15:05
@mbastian mbastian self-assigned this Oct 3, 2025
@mbastian mbastian merged commit f1d27ba into master Oct 3, 2025
1 check passed
@mbastian mbastian linked an issue Oct 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Spliterator support for Spatial Index

2 participants