Skip to content

Add Spliterator on NodesQuadTree - #243

Merged
mbastian merged 19 commits into
masterfrom
242-spliterator-spatial
Oct 3, 2025
Merged

Add Spliterator on NodesQuadTree#243
mbastian merged 19 commits into
masterfrom
242-spliterator-spatial

Conversation

@mbastian

@mbastian mbastian commented Sep 26, 2025

Copy link
Copy Markdown
Member

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/test/java/org/gephi/graph/impl/SpatialIndexImplTest.java
Comment thread src/main/java/org/gephi/graph/impl/NodesQuadTree.java Outdated
Comment thread src/main/java/org/gephi/graph/impl/NodesQuadTree.java Outdated
Comment thread src/main/java/org/gephi/graph/impl/GraphViewDecorator.java
Comment thread src/main/java/org/gephi/graph/impl/GraphStoreConfiguration.java
Comment thread src/main/java/org/gephi/graph/impl/GraphStoreConfiguration.java
Comment thread src/main/java/org/gephi/graph/impl/NodesQuadTree.java Outdated
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
MattArtzAnthro pushed a commit to MattArtzAnthro/graphstore that referenced this pull request Aug 28, 2026
* Change default config for block size and default dict size

* Replace LinkedHashSet with arrays and implement spliterator

* Add multi-node edge iterator

* Refactoring to remove duplicate getNodes methods in quadtree

* Add edge iteration support in quadtree

* Add global quad tree edge iterator option

* Refactor to configure edge inout iterator locking and test all edges in quadtree spliterator

* Formatting

* Git ignore

* Non approximate support for global iterator and bugfix

* Add additional tests

* Quadtree versioning

* Tweak boundaries

* Documentation

* Update src/main/java/org/gephi/graph/impl/NodesQuadTree.java

Remove distinct from spliterator as edges can be returned twice

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix locking function name clash in view decorator

* Fix toArray

* Reduce memory overhead of quad node array init

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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