PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_values()

static void parse_values ( mvt_agg_context ctx)
static

Definition at line 630 of file mvt.c.

631 {
632  uint32_t n_keys = ctx->keys_hash_i;
633  uint32_t *tags = palloc(n_keys * 2 * sizeof(*tags));
634  uint32_t i;
635  mvt_column_cache cc = ctx->column_cache;
636  uint32_t natts = (uint32_t) cc.tupdesc->natts;
637 
638  HeapTupleData tuple;
639 
640  POSTGIS_DEBUG(2, "parse_values called");
641  ctx->row_columns = 0;
642 
643  /* Build a temporary HeapTuple control structure */
644  tuple.t_len = HeapTupleHeaderGetDatumLength(ctx->row);
645  ItemPointerSetInvalid(&(tuple.t_self));
646  tuple.t_tableOid = InvalidOid;
647  tuple.t_data = ctx->row;
648 
649  /* We use heap_deform_tuple as it costs only O(N) vs O(N^2) of GetAttributeByNum */
650  heap_deform_tuple(&tuple, cc.tupdesc, cc.values, cc.nulls);
651 
652  POSTGIS_DEBUGF(3, "parse_values natts: %d", natts);
653 
654  for (i = 0; i < natts; i++)
655  {
656  char *key;
657  Oid typoid;
658  uint32_t k;
659  Datum datum = cc.values[i];
660 
661  if (i == ctx->geom_index)
662  continue;
663 
664  if (cc.nulls[i])
665  {
666  POSTGIS_DEBUG(3, "parse_values isnull detected");
667  continue;
668  }
669 
670 #if POSTGIS_PGSQL_VERSION < 110
671  key = cc.tupdesc->attrs[i]->attname.data;
672 #else
673  key = cc.tupdesc->attrs[i].attname.data;
674 #endif
675  k = cc.column_keys_index[i];
676  typoid = cc.column_oid[i];
677 
678 #if POSTGIS_PGSQL_VERSION >= 94
679  if (k == UINT32_MAX && typoid != JSONBOID)
680  elog(ERROR, "parse_values: unexpectedly could not find parsed key name '%s'", key);
681  if (typoid == JSONBOID)
682  {
683  tags = parse_jsonb(ctx, DatumGetJsonbP(datum), tags);
684  continue;
685  }
686 #else
687  if (k == UINT32_MAX)
688  elog(ERROR, "parse_values: unexpectedly could not find parsed key name '%s'", key);
689 #endif
690 
691  switch (typoid)
692  {
693  case BOOLOID:
694  MVT_PARSE_DATUM(protobuf_c_boolean, mvt_kv_bool_value,
695  bool_values_hash, bool_value,
696  DatumGetBool, sizeof(protobuf_c_boolean));
697  break;
698  case INT2OID:
699  MVT_PARSE_INT_DATUM(int16_t, DatumGetInt16);
700  break;
701  case INT4OID:
702  MVT_PARSE_INT_DATUM(int32_t, DatumGetInt32);
703  break;
704  case INT8OID:
705  MVT_PARSE_INT_DATUM(int64_t, DatumGetInt64);
706  break;
707  case FLOAT4OID:
709  float_values_hash, float_value,
710  DatumGetFloat4, sizeof(float));
711  break;
712  case FLOAT8OID:
714  double_values_hash, double_value,
715  DatumGetFloat8, sizeof(double));
716  break;
717  default:
718  parse_datum_as_string(ctx, typoid, datum, tags, k);
719  break;
720  }
721  ctx->row_columns++;
722  }
723 
724 
725  ctx->feature->n_tags = ctx->row_columns * 2;
726  ctx->feature->tags = tags;
727 
728  POSTGIS_DEBUGF(3, "parse_values n_tags %zd", ctx->feature->n_tags);
729 }
#define UINT32_MAX
Definition: lwin_wkt_lex.c:343
static void parse_datum_as_string(mvt_agg_context *ctx, Oid typoid, Datum datum, uint32_t *tags, uint32_t k)
Definition: mvt.c:537
#define MVT_PARSE_INT_DATUM(type, datumfunc)
Definition: mvt.c:504
static uint32_t * parse_jsonb(mvt_agg_context *ctx, Jsonb *jb, uint32_t *tags)
Definition: mvt.c:551
#define DatumGetJsonbP
Definition: mvt.c:36
#define MVT_PARSE_DATUM(type, kvtype, hash, valuefield, datumfunc, size)
Definition: mvt.c:498
uint32_t geom_index
Definition: mvt.h:63
uint32_t keys_hash_i
Definition: mvt.h:77
VectorTile__Tile__Feature * feature
Definition: mvt.h:65
HeapTupleHeader row
Definition: mvt.h:64
mvt_column_cache column_cache
Definition: mvt.h:79
uint32_t row_columns
Definition: mvt.h:78
bool * nulls
Definition: mvt.h:54
TupleDesc tupdesc
Definition: mvt.h:55
uint32_t * column_keys_index
Definition: mvt.h:51
Datum * values
Definition: mvt.h:53
uint32_t * column_oid
Definition: mvt.h:52
unsigned int uint32_t
Definition: uthash.h:78

References mvt_agg_context::column_cache, mvt_column_cache::column_keys_index, mvt_column_cache::column_oid, DatumGetJsonbP, mvt_agg_context::feature, mvt_agg_context::geom_index, mvt_agg_context::keys_hash_i, MVT_PARSE_DATUM, MVT_PARSE_INT_DATUM, mvt_column_cache::nulls, parse_datum_as_string(), parse_jsonb(), mvt_agg_context::row, mvt_agg_context::row_columns, mvt_column_cache::tupdesc, UINT32_MAX, and mvt_column_cache::values.

Referenced by mvt_agg_transfn().

Here is the call graph for this function:
Here is the caller graph for this function: