Skip to content

Commit

Permalink
Updated binpred architecture (#1009)
Browse files Browse the repository at this point in the history
The last couple of PRs were very brittle w.r.t updating their functionality. This PR eliminates some of that brittleness by adding object inheritance for every combination of features for every binary predicate. Class choice is handled by type dispatching on the input columns.

The operation stack (`_preprocess`, `_op`, and `_postprocess`) is now chained to make debugging easier. Instead of calling the operations in sequence, they call one another.

Refactoring the existing modules to use the new architecture was trivial. I'm still interested in modifying the architecture so that the set operations that determine the final result are identifiable, and possibly composable.

Authors:
  - H. Thomson Comer (https://github.com/thomcom)

Approvers:
  - Michael Wang (https://github.com/isVoid)
  - Mark Harris (https://github.com/harrism)

URL: #1009
  • Loading branch information
thomcom authored Apr 4, 2023
1 parent fee47ef commit 7668fdc
Show file tree
Hide file tree
Showing 15 changed files with 1,642 additions and 872 deletions.
13 changes: 12 additions & 1 deletion python/cuspatial/cuspatial/core/_column/geocolumn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (c) 2021-2022 NVIDIA CORPORATION
# Copyright (c) 2021-2023 NVIDIA CORPORATION

from enum import Enum
from functools import cached_property
from typing import Tuple, TypeVar

Expand All @@ -11,6 +13,15 @@
from cuspatial.core._column.geometa import Feature_Enum, GeoMeta
from cuspatial.utils.column_utils import empty_geometry_column


class ColumnType(Enum):
MIXED = 0
POINT = 1
MULTIPOINT = 2
LINESTRING = 3
POLYGON = 4


T = TypeVar("T", bound="GeoColumn")


Expand Down
31 changes: 31 additions & 0 deletions python/cuspatial/cuspatial/core/binpreds/binpred_dispatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2023, NVIDIA CORPORATION.

"""`binpred_dispatch.py` contains a collection of dictionaries that
are used to dispatch binary predicate functions to the correct
implementation.
The dictionaries are collected here to make using the dispatch
functionality easier.
"""

from cuspatial.core.binpreds.feature_contains import ( # NOQA F401
DispatchDict as CONTAINS_DISPATCH,
)
from cuspatial.core.binpreds.feature_covers import ( # NOQA F401
DispatchDict as COVERS_DISPATCH,
)
from cuspatial.core.binpreds.feature_crosses import ( # NOQA F401
DispatchDict as CROSSES_DISPATCH,
)
from cuspatial.core.binpreds.feature_equals import ( # NOQA F401
DispatchDict as EQUALS_DISPATCH,
)
from cuspatial.core.binpreds.feature_intersects import ( # NOQA F401
DispatchDict as INTERSECTS_DISPATCH,
)
from cuspatial.core.binpreds.feature_overlaps import ( # NOQA F401
DispatchDict as OVERLAPS_DISPATCH,
)
from cuspatial.core.binpreds.feature_within import ( # NOQA F401
DispatchDict as WITHIN_DISPATCH,
)
Loading

0 comments on commit 7668fdc

Please sign in to comment.