Skip to content

perf: Implement faster implementation of st_has(z/m) using WKBBytesExecutor #170

@petern48

Description

@petern48

This PR introduced a new WkbBytesExecutor that was used to optimize the implementation of st_geometrytype. It allowed us to extract what we needed without parsing the entire buffer, saving a lot of time. I had the bright idea of leveraging this for the dimension calculation, so we can implement functions like st_hasz and st_hasm without parsing the entire geometry. The logic turns out to be more complicated than I originally expected (due to edge cases relating to inferring the dimensionality), but I still think this is doable.

To properly get the dimensionality, we need to OR all of the following (short circuiting permitted of course):

  • the dimensionality of the geometry type (the obvious one)
    • e.g POINT Z EMPTY
  • the dimensionality of the first nested geometry (if it's some sort of collection)
    • e.g GEOMETRYCOLLECTION (POINT Z (0 0 0)) -> xyz
  • the dimensionality of the first coordinate (in WKB this is actually represented as the dimensionality of the nested geometry object, not the first coordinate)
    • e.g POINT (0 0 0) -> xyz, POINT (0 0 0 0) -> xyzm

All of those examples are (apparently) valid.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions