Changeset: 9311a7c6a486 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9311a7c6a486
Modified Files:
monetdb5/modules/mal/tablet.c
Branch: nested
Log Message:
small fix for empty sets
diffs (70 lines):
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -452,6 +452,50 @@ output_multiset_sorted(char **buf, size_
}
static ssize_t
+output_multiset(char **buf, size_t *len, ssize_t fill, char **localbuf, size_t
*locallen,
+ Column *fmt, BUN nr_attrs, int multiset, int
composite, bool quoted, int id)
+{
+ nr_attrs -= (multiset == MS_ARRAY)?2:1;
+ Column *msid = fmt + nr_attrs;
+ /* how to also keep prev id */
+ BUN pos = msid->p;
+ int *idp = (int*)Tloc(msid->c, pos);
+ int first = 1;
+
+ if (id >= 0 && msid->p) {
+ while (pos > 0 && idp[-1] >= id) {
+ idp--;
+ pos--;
+ }
+ msid->p = pos;
+ }
+
+ if (!quoted)
+ (*buf)[fill++] = '\'';
+ (*buf)[fill++] = '{';
+ (*buf)[fill] = 0;
+ if (id >= 0)
+ for (; *idp == id && fill > 0; idp++, msid->p++, pos++) {
+ if (!first)
+ (*buf)[fill++] = ',';
+ if (composite) {
+ fill = output_composite(buf, len, fill, localbuf,
locallen, fmt, nr_attrs, composite, true);
+ } else {
+ fmt->p = pos;
+ fill = output_value(buf, len, fill, localbuf, locallen,
fmt);
+ }
+ first = 0;
+ }
+ if (fill < 0)
+ return fill;
+ (*buf)[fill++] = '}';
+ if (!quoted)
+ (*buf)[fill++] = '\'';
+ (*buf)[fill] = 0;
+ return fill;
+}
+
+static ssize_t
output_line_complex(char **buf, size_t *len, ssize_t fill, char **localbuf,
size_t *locallen,
Column *fmt, BUN nr_attrs)
{
@@ -466,11 +510,12 @@ output_line_complex(char **buf, size_t *
Column *rowid = fmt+j+nr_attrs;
p = BUNtail(rowid->ci, rowid->p);
- assert(rowid->c->tsorted);
- if (rowid->c->tkey)
+ if (rowid->c->tsorted && rowid->c->tkey)
fill = output_multiset_dense(buf, len, fill,
localbuf, locallen, fmt + j + 1, nr_attrs-1, f->multiset, f->composite, false,
*(int*)p);
+ else if (rowid->c->tsorted)
+ fill = output_multiset_sorted(buf, len, fill,
localbuf, locallen, fmt + j + 1, nr_attrs-1, f->multiset, f->composite, false,
*(int*)p);
else
- fill = output_multiset_sorted(buf, len, fill,
localbuf, locallen, fmt + j + 1, nr_attrs-1, f->multiset, f->composite, false,
*(int*)p);
+ fill = output_multiset(buf, len, fill, localbuf,
locallen, fmt + j + 1, nr_attrs-1, f->multiset, f->composite, false, *(int*)p);
fmt[j+nr_attrs].p++;
f = fmt + j + nr_attrs; /* closing bracket */
j += nr_attrs + 1;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]