Move pc_(point|patch)_(de)serialize into libpc.a#381
Open
estebanzimanyi wants to merge 1 commit intopgpointcloud:cmakefrom
Open
Move pc_(point|patch)_(de)serialize into libpc.a#381estebanzimanyi wants to merge 1 commit intopgpointcloud:cmakefrom
estebanzimanyi wants to merge 1 commit intopgpointcloud:cmakefrom
Conversation
The four functions pc_point_serialize, pc_point_deserialize,
pc_patch_serialize, and pc_patch_deserialize — together with
pc_patch_serialized_size, pc_patch_serialize_to_uncompressed, and
pc_patch_stats_deserialize — previously lived in pgsql/pc_pgsql.c and
were only reachable through the PostgreSQL extension shared object.
This commit moves them to a new lib/pc_serialize.c, which is compiled
into libpc.a. The SERIALIZED_POINT and SERIALIZED_PATCH struct
definitions are promoted from pgsql/pc_pgsql.h to lib/pc_api.h so that
non-PostgreSQL consumers can use the types without including PG headers.
Changes:
- lib/pc_serialize.c new file with the moved implementations
- lib/pc_api.h SERIALIZED_POINT/PATCH structs + new declarations
- lib/CMakeLists.txt add pc_serialize.c to PC_SOURCES
- pgsql/pc_pgsql.h remove duplicated structs/decls (now in pc_api.h)
- pgsql/pc_pgsql.c remove implementations (now in lib/pc_serialize.c)
Two minimal porting changes are made to work without PG headers:
- palloc → pcalloc in pc_point_serialize
- elog(ERROR,...) → pcerror(...) in pc_point_deserialize
- #ifndef SET_VARSIZE / VARSIZE fallbacks that are bit-compatible
with PostgreSQL's non-toasted varlena encoding
No on-disk format changes. No SQL surface changes. libpc.a grows by
~550 lines of C that were already exercised by the PG extension tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The four functions
pc_point_serialize,pc_point_deserialize,pc_patch_serialize, andpc_patch_deserialize— together withpc_patch_serialized_size,pc_patch_serialize_to_uncompressed, andpc_patch_stats_deserialize— currently live inpgsql/pc_pgsql.candare compiled only into the PostgreSQL extension shared object. They are
therefore unreachable from
libpc.aand from any non-PostgreSQL consumerthat links the static library.
Motivation
MobilityDB is adding
tpcpoint/tpcpatchtemporal types (PR #818). Per-point filteringoperations (
atTpcboxFine,eIntersects) need to decompose serializedpatches in C — roughly 10× faster than routing every patch through
PC_Explodein SQL. MEOS (the standalone C library at the core ofMobilityDB) links
libpc.abut cannot reach the serialize/deserializefunctions today.
This is the upstream change that closes that gap. See also
MobilityDB discussion #869
for the community RFC.
Changes
lib/pc_serialize.clib/pc_api.hSERIALIZED_POINT/SERIALIZED_PATCHstructs promoted here; new declarations addedlib/CMakeLists.txtpc_serialize.cadded toPC_SOURCESpgsql/pc_pgsql.hpc_api.h)pgsql/pc_pgsql.clib/pc_serialize.c)Minimal porting changes for PG-free compilation
To compile cleanly in
libpc.awithout PostgreSQL headers:palloc→pcallocinpc_point_serialize(the patch helpers already usedpcalloc)elog(ERROR, ...)→pcerror(...)inpc_point_deserialize#ifndef SET_VARSIZE/VARSIZEfallbacks added inpc_serialize.cthat are bit-for-bit compatible with PostgreSQL's 4-byte non-toasted varlena encodingNo breaking changes
libpc.a)libpc.a: additive onlyTesting
The cmake branch build (
libpc-statictarget) compiles cleanly with no new warnings.The existing PG extension test suite (
pgsql/expected/pointcloud.out) continues to cover all moved code paths.