Changeset: ec8f27a7e3ff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ec8f27a7e3ff
Modified Files:
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tablet.h
sql/backends/monet5/sql_result.c
Branch: nested
Log Message:
print vector
diffs (95 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
@@ -495,6 +495,28 @@ output_multiset(allocator *ma, char **bu
return fill;
}
+static inline ssize_t
+output_vector(allocator*ma, char **buf, size_t *len, ssize_t fill, char
**localbuf, size_t *locallen,
+ Column *fmt, BUN nr_attrs)
+{
+ int first = 1;
+ (*buf)[fill++] = '\'';
+ (*buf)[fill++] = '{';
+ (*buf)[fill] = 0;
+ for (size_t i = 0; fill > 0 && i < nr_attrs; i++) {
+ if (!first)
+ (*buf)[fill++] = ',';
+ fill = output_value(ma, buf, len, fill, localbuf, locallen, fmt
+ i);
+ first = 0;
+ }
+ if (fill < 0)
+ return fill;
+ (*buf)[fill++] = '}';
+ (*buf)[fill++] = '\'';
+ (*buf)[fill] = 0;
+ return fill;
+}
+
static ssize_t
output_line_complex(allocator *ma, char **buf, size_t *len, ssize_t fill, char
**localbuf, size_t *locallen,
Column *fmt, BUN nr_attrs)
@@ -505,7 +527,12 @@ output_line_complex(allocator *ma, char
Column *f = fmt + j;
const char *p;
- if (f->multiset) {
+ if (f->ms_vector) {
+ int nr_attrs = f->nrfields - 1;
+ fill = output_vector(ma, buf, len, fill, localbuf,
locallen, fmt + j + 1, nr_attrs-2);
+ f = fmt + j + nr_attrs; /* closing bracket */
+ j += nr_attrs + 1;
+ } else if (f->multiset) {
int nr_attrs = f->nrfields - 1;
Column *rowid = fmt+j+nr_attrs;
p = BUNtail(rowid->ci, rowid->p);
diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h
--- a/monetdb5/modules/mal/tablet.h
+++ b/monetdb5/modules/mal/tablet.h
@@ -44,7 +44,10 @@ typedef struct Column_t {
unsigned int width; /* actual column width */
unsigned int maxwidth; /* permissible width */
int composite; /* number of composite fields */
- int multiset; /* type of multiset */
+ uint8_t multiset:3,
+ ms_array:1,
+ ms_vector:1,
+ ms_setof:1;
int nrfields; /* nr columns which together
form an output column */
bool virt; /* not part of output */
int fieldstart; /* Fixed character field load
positions */
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1346,6 +1346,7 @@ mvc_export_table_(allocator *sa, mvc *m,
fmt[i].rsep = rsep;
}
fmt[i].multiset = c->type.multiset;
+ fmt[i].ms_vector = c->type.multiset == MS_VECTOR;
fmt[i].composite =
c->type.type->composite?list_length(c->type.type->d.fields):0;
fmt[i].virt = c->virt;
@@ -1715,7 +1716,21 @@ mvc_export_affrows(backend *b, stream *s
static inline int
next_col(res_col *c)
{
- int res =
(c->type.multiset==MS_VALUE)?0:(c->type.multiset==MS_ARRAY)?3:2;
+ //int res =
(c->type.multiset==MS_VALUE)?0:(c->type.multiset==MS_ARRAY)?3:2;
+ int res = 0;
+ switch(c->type.multiset) {
+ case MS_VALUE:
+ res = 0;
+ break;
+ case MS_ARRAY:
+ res = 3;
+ break;
+ case MS_VECTOR:
+ res = c->type.digits + 1; // all the dimensions + ms_id
+ break;
+ default:
+ res = 2; // MS_SETOF?
+ }
if (c->virt)
res++;
if (c->type.type && c->type.type->composite) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]