24#include "lib/stringinfo.h"
25#include "utils/palloc.h"
42 appendStringInfo(&s,
"%d %d %d %d %d",
47 for (i = 0; i < cert->
natoms; i++)
50 for (i = 0; i < ncol; i++)
70#define READ_INT(dst) \
72 v = strtol(p, &end, 10); \
73 if (end == p) { pfree(cert); return NULL; } \
98 for (i = 0; i < cert->
natoms; i++)
102 cert->
atom_col_class = (
int *) palloc(
sizeof(
int) * (ncol > 0 ? ncol : 1));
103 for (i = 0; i < ncol; i++)
112 const char *sec,
size_t sec_len,
int factor)
117 appendStringInfo(&s,
"%d %zu:", factor, root_len);
118 appendBinaryStringInfo(&s, root, (
int) root_len);
119 appendStringInfo(&s,
"%zu:", sec_len);
120 appendBinaryStringInfo(&s, sec, (
int) sec_len);
126 const char *p, *limit;
135 limit = p + strlen(p);
138 k.
factor = (int) strtol(p, &end, 10);
139 if (end == p || *end !=
' ')
return false;
143 n = strtol(p, &end, 10);
144 if (end == p || n < 0 || *end !=
':')
return false;
146 if ((
size_t)(limit - p) < (
size_t) n)
return false;
152 n = strtol(p, &end, 10);
153 if (end == p || n < 0 || *end !=
':')
return false;
155 if ((
size_t)(limit - p) < (
size_t) n)
return false;
char * safe_cert_key_serialise(const char *root, size_t root_len, const char *sec, size_t sec_len, int factor)
Serialise a per-input order key to a compact K-prefixed string (palloc'd).
SafeCert * safe_cert_parse(const char *str)
Parse a C-prefixed recipe string (as produced by safe_cert_serialise and read back from an annotation...
char * safe_cert_serialise(const SafeCert *cert)
Serialise a SafeCert recipe to a compact, C-prefixed string (palloc'd in the current memory context).
bool safe_cert_key_parse(const char *str, SafeCertKey *out)
Parse a K-prefixed order-key string into out.
Tractability certificate for the inversion-free UCQ(OBDD) path.
SafeCertKind
Kind of tractability certificate carried on the provenance root.
#define SAFE_CERT_EXTRA_PREFIX_KEY
Input: per-variable order key.
#define SAFE_CERT_EXTRA_PREFIX_RECIPE
Discriminator prefixes for the annotation gate's extra payload.
Query-derived order recipe for the structured-d-DNNF builder.
int nclasses
Number of (compacted) equivalence classes.
int * atom_col_class
Flattened [natoms][maxarity]: compacted class anchored at (atom, column), or -1.
int root_class
Compacted id of the root class (touches every atom).
int natoms
Number of atoms (range-table entries).
int maxarity
Stride of atom_col_class (max columns per atom seen).
int * class_topo_order
Length nclasses: classes in G_prec topological order, root first.
int * atom_relation_rank
Length natoms: relation-symbol tie-break rank per atom.