[postgis-tickets] r16089 - Change "LANGUAGE c" to "LANGUAGE 'c'" for
Paul Ramsey
pramsey at cleverelephant.ca
Fri Nov 3 07:31:46 PDT 2017
Author: pramsey
Date: 2017-11-03 07:31:46 -0700 (Fri, 03 Nov 2017)
New Revision: 16089
Modified:
trunk/postgis/mvt.c
trunk/postgis/mvt.h
trunk/postgis/postgis.sql.in
Log:
Change "LANGUAGE c" to "LANGUAGE 'c'" for
new MVT functions to match all the other
functions
Modified: trunk/postgis/mvt.c
===================================================================
--- trunk/postgis/mvt.c 2017-10-31 15:35:36 UTC (rev 16088)
+++ trunk/postgis/mvt.c 2017-11-03 14:31:46 UTC (rev 16089)
@@ -845,45 +845,68 @@
parse_values(ctx);
}
-/**
- * Finalize aggregation.
- *
- * Encode keys and values and put the aggregated Layer message into
- * a Tile message and returns it packed as a bytea.
- */
-uint8_t *mvt_agg_finalfn(struct mvt_agg_context *ctx)
+static bytea *mvt_ctx_to_bytea(struct mvt_agg_context *ctx)
{
- VectorTile__Tile__Layer *layers[1];
- VectorTile__Tile tile = VECTOR_TILE__TILE__INIT;
- size_t len;
- uint8_t *buf;
+ /* Fill out the file slot, if it's not already filled. */
+ /* We should only have a filled slow when all the work of building */
+ /* out the data is complete, so after a serialize/deserialize cycle */
+ /* or after a context combine */
+ if (!ctx->tile)
+ {
+ VectorTile__Tile__Layer **layers = ;
+ VectorTile__Tile tile = VECTOR_TILE__TILE__INIT;
- POSTGIS_DEBUG(2, "mvt_agg_finalfn called");
- POSTGIS_DEBUGF(2, "mvt_agg_finalfn n_features == %zd", ctx->layer->n_features);
+ POSTGIS_DEBUG(2, "mvt_agg_finalfn called");
+ POSTGIS_DEBUGF(2, "mvt_agg_finalfn n_features == %zd", ctx->layer->n_features);
- /* Zero features => empty bytea output */
- if (ctx->layer->n_features == 0)
- {
- buf = palloc(VARHDRSZ);
- SET_VARSIZE(buf, VARHDRSZ);
- return buf;
+ /* Zero features => empty bytea output */
+ if (ctx->layer->n_features == 0)
+ {
+ buf = palloc(VARHDRSZ);
+ SET_VARSIZE(buf, VARHDRSZ);
+ return buf;
+ }
+
+ encode_keys(ctx);
+ encode_values(ctx);
+
+ int n_layers = 1;
+ ctx->tile = palloc(sizeof(VectorTile__Tile));
+ vector_tile__tile__init(ctx->tile);
+ ctx->tile->layers = palloc(sizeof(VectorTile__Tile__Layer*) * n_layers);
+ ctx->tile->layers[0] = ctx->layer;
+ ctx->tile->n_layers = n_layers;
}
- encode_keys(ctx);
- encode_values(ctx);
+ /* Serialize the Tile */
+ size_t len = VARHDRSZ + vector_tile__tile__get_packed_size(ctx->tile);
+ bytea *ba = palloc(len);
+ vector_tile__tile__pack(ctx->tile, VARDATA(ba));
+ SET_VARSIZE(ba, len);
+ return ba;
+}
- layers[0] = ctx->layer;
- tile.n_layers = 1;
- tile.layers = layers;
+bytea *mvt_ctx_serialize(struct mvt_agg_context *ctx)
+{
+ return mvt_ctx_to_bytea(ctx);
+}
- len = vector_tile__tile__get_packed_size(&tile);
- buf = palloc(sizeof(*buf) * (len + VARHDRSZ));
- vector_tile__tile__pack(&tile, buf + VARHDRSZ);
+mvt_agg_context * mvt_ctx_deserialize(const bytea *ba)
+{
- SET_VARSIZE(buf, VARHDRSZ + len);
+}
- return buf;
+/**
+ * Finalize aggregation.
+ *
+ * Encode keys and values and put the aggregated Layer message into
+ * a Tile message and returns it packed as a bytea.
+ */
+bytea *mvt_agg_finalfn(struct mvt_agg_context *ctx)
+{
+ return mvt_ctx_to_bytea(ctx);
}
+
#endif
Modified: trunk/postgis/mvt.h
===================================================================
--- trunk/postgis/mvt.h 2017-10-31 15:35:36 UTC (rev 16088)
+++ trunk/postgis/mvt.h 2017-11-03 14:31:46 UTC (rev 16089)
@@ -54,6 +54,7 @@
HeapTupleHeader row;
VectorTile__Tile__Feature *feature;
VectorTile__Tile__Layer *layer;
+ VectorTile__Tile *tile;
size_t features_capacity;
struct mvt_kv_key *keys_hash;
struct mvt_kv_string_value *string_values_hash;
Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in 2017-10-31 15:35:36 UTC (rev 16088)
+++ trunk/postgis/postgis.sql.in 2017-11-03 14:31:46 UTC (rev 16089)
@@ -4450,31 +4450,31 @@
CREATE OR REPLACE FUNCTION pgis_asmvt_transfn(internal, anyelement)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asmvt_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asmvt_transfn(internal, anyelement, text)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asmvt_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asmvt_transfn(internal, anyelement, text, int4)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asmvt_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asmvt_transfn(internal, anyelement, text, int4, text)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asmvt_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asmvt_finalfn(internal)
RETURNS bytea
AS 'MODULE_PATHNAME', 'pgis_asmvt_finalfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE AGGREGATE ST_AsMVT(anyelement)
@@ -4542,19 +4542,19 @@
CREATE OR REPLACE FUNCTION pgis_asgeobuf_transfn(internal, anyelement)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asgeobuf_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asgeobuf_transfn(internal, anyelement, text)
RETURNS internal
AS 'MODULE_PATHNAME', 'pgis_asgeobuf_transfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION pgis_asgeobuf_finalfn(internal)
RETURNS bytea
AS 'MODULE_PATHNAME', 'pgis_asgeobuf_finalfn'
- LANGUAGE c IMMUTABLE _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE _PARALLEL;
-- Availability: 2.4.0
CREATE AGGREGATE ST_AsGeobuf(anyelement)
More information about the postgis-tickets
mailing list