Changeset: 145921496428 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/145921496428
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
monetdb5/modules/mal/heapn.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/rel_pptopn.c
sql/backends/monet5/rel_pptopn.h
Branch: pp_hashjoin
Log Message:
implemented the offset bits of limit/offset as post operation on the heap order
output
diffs (truncated from 669 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -47466,7 +47466,12 @@ return new heap sink
heapn
order
command heapn.order(X_0:bat[:oid]):bat[:oid]
-HEAPorder
+HEAPorder1
+Order.
+heapn
+order
+command heapn.order(X_0:bat[:oid], X_1:lng):bat[:oid]
+HEAPorder2
Order.
heapn
projection
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -35861,7 +35861,12 @@ return new heap sink
heapn
order
command heapn.order(X_0:bat[:oid]):bat[:oid]
-HEAPorder
+HEAPorder1
+Order.
+heapn
+order
+command heapn.order(X_0:bat[:oid], X_1:lng):bat[:oid]
+HEAPorder2
Order.
heapn
projection
diff --git a/monetdb5/modules/mal/heapn.c b/monetdb5/modules/mal/heapn.c
--- a/monetdb5/modules/mal/heapn.c
+++ b/monetdb5/modules/mal/heapn.c
@@ -61,7 +61,7 @@ typedef struct heapn {
BAT *grpb;
oid *grp;
BAT *usedb;
- int *useda;
+ size_t *useda;
BAT *fullb;
bte *fulla;
bool grouped;
@@ -86,11 +86,11 @@ _heap_init( heapn *hp )
return NULL;
hp->grp = Tloc(hp->grpb, 0);
- hp->usedb = COLnew(0, TYPE_int, hp->gsize, TRANSIENT);
+ hp->usedb = COLnew(0, TYPE_lng, hp->gsize, TRANSIENT);
if (!hp->usedb)
return NULL;
hp->useda = Tloc(hp->usedb, 0);
- memset(hp->useda, 0, hp->gsize*sizeof(int));
+ memset(hp->useda, 0, hp->gsize*sizeof(size_t));
hp->fullb = COLnew(0, TYPE_bte, hp->gsize, TRANSIENT);
if (!hp->fullb)
@@ -109,7 +109,7 @@ _heap_init( heapn *hp )
return hp;
}
-static int
+static size_t
subheap_down( heapn *hp, subheap *sh, size_t q, size_t l)
{
char *vals = sh->vals;
@@ -125,10 +125,10 @@ subheap_down( heapn *hp, subheap *sh, si
q = l;
else if (!sh->min && cmp < 0)
q = l;
- return (int)q;
+ return q;
}
-static int
+static size_t
subheap_up( heapn *hp, subheap *sh, size_t q, size_t p)
{
int cmp = 0;
@@ -144,10 +144,10 @@ subheap_up( heapn *hp, subheap *sh, size
q = p;
else if (!sh->min && cmp > 0)
q = p;
- return (int)q;
+ return q;
}
-static int
+static size_t
gsubheap_down( heapn *hp, subheap *sh, oid g, size_t q, size_t l)
{
oid *pos = hp->pos + g * hp->size;
@@ -164,10 +164,10 @@ gsubheap_down( heapn *hp, subheap *sh, o
q = l;
else if (!sh->min && cmp < 0)
q = l;
- return (int)q;
+ return q;
}
-static int
+static size_t
gsubheap_up( heapn *hp, subheap *sh, oid g, size_t q, size_t p)
{
oid *pos = hp->pos + g * hp->size;
@@ -184,7 +184,7 @@ gsubheap_up( heapn *hp, subheap *sh, oid
q = p;
else if (!sh->min && cmp > 0)
q = p;
- return (int)q;
+ return q;
}
@@ -259,13 +259,13 @@ subheap_ins( subheap *sh, size_t pos, si
return 0;
}
-static int
-heap_down_any( heapn *hp, int p)
+static size_t
+heap_down_any( heapn *hp, size_t p)
{
subheap *sh = hp->sub;
- int l = p*2+1, r = p*2+2, q = p;
+ size_t l = p*2+1, r = p*2+2, q = p;
- if (l < (int)hp->used) {
+ if (l < hp->used) {
int cmp = sh->cmp(BUNtvar(&sh->vbi, hp->pos[q]),
BUNtvar(&sh->vbi, hp->pos[l]), sh);
if (!cmp && sh->sub)
@@ -275,7 +275,7 @@ heap_down_any( heapn *hp, int p)
else if (!sh->min && cmp < 0)
q = l;
}
- if (r < (int)hp->used) {
+ if (r < hp->used) {
int cmp = sh->cmp(BUNtvar(&sh->vbi, hp->pos[q]),
BUNtvar(&sh->vbi, hp->pos[r]), sh);
if (!cmp && sh->sub)
@@ -292,15 +292,15 @@ heap_down_any( heapn *hp, int p)
hp->pos[q] = vpos;
return heap_down_any(hp, q);
}
- return (int)(p+1);
+ return p+1;
}
-static int
+static size_t
heap_up_any( heapn *hp, size_t p)
{
subheap *sh = hp->sub;
if (p == 0)
- return (int)(p+1);
+ return p+1;
size_t q = (p-1)/2;
/* todo get real bat var atom offsets */
int cmp = sh->cmp(BUNtvar(&sh->vbi, hp->pos[q]), BUNtvar(&sh->vbi,
hp->pos[p]), sh);
@@ -318,11 +318,11 @@ heap_up_any( heapn *hp, size_t p)
hp->pos[p] = hp->pos[q];
hp->pos[q] = vpos;
if (q == 0)
- return (int)(q+1);
+ return q+1;
return heap_up_any(hp, q);
}
p++;
- return (int)p;
+ return p;
}
static gid
@@ -385,13 +385,13 @@ gsubheap_newroot( heapn *hp, subheap *sh
return newroot;
}
-static int
+static size_t
gheap_up_any( heapn *hp, gid g, size_t p)
{
subheap *sh = hp->sub;
oid *pos = hp->pos + g * hp->size; \
if (p == 0)
- return (int)(p+1);
+ return p+1;
size_t q = (p-1)/2;
/* todo get real bat var atom offsets */
int cmp = sh->cmp(BUNtvar(&sh->vbi, pos[q]), BUNtvar(&sh->vbi, pos[p]),
sh);
@@ -409,21 +409,21 @@ gheap_up_any( heapn *hp, gid g, size_t p
pos[p] = pos[q];
pos[q] = vpos;
if (q == 0)
- return (int)(q+1);
+ return q+1;
return gheap_up_any(hp, g, q);
}
p++;
- return (int)p;
+ return p;
}
-static int
-gheap_down_any( heapn *hp, gid g, int p)
+static size_t
+gheap_down_any( heapn *hp, gid g, size_t p)
{
oid *pos = hp->pos + g * hp->size; \
subheap *sh = hp->sub;
- int l = p*2+1, r = p*2+2, q = p;
+ size_t l = p*2+1, r = p*2+2, q = p;
- if (l < (int)hp->used) {
+ if (l < hp->used) {
int cmp = sh->cmp(BUNtvar(&sh->vbi, pos[q]), BUNtvar(&sh->vbi,
pos[l]), sh);
if (!cmp && sh->sub)
@@ -433,7 +433,7 @@ gheap_down_any( heapn *hp, gid g, int p)
else if (!sh->min && cmp < 0)
q = l;
}
- if (r < (int)hp->used) {
+ if (r < hp->used) {
int cmp = sh->cmp(BUNtvar(&sh->vbi, pos[q]), BUNtvar(&sh->vbi,
pos[r]), sh);
if (!cmp && sh->sub)
@@ -494,13 +494,13 @@ gheap_ins_any( heapn *hp, size_t pos, in
*err = subheap_ins( sh->sub, pos, vpos);
}
hp->useda[g]++;
- hp->fulla[g] = (hp->useda[g] == (int)hp->size);
+ hp->fulla[g] = (hp->useda[g] == hp->size);
if (sh)
(void) gheap_up_any(hp, g, p);
return vpos;
}
-static int heap_up_lng( heapn *hp, size_t p);
+static size_t heap_up_lng( heapn *hp, size_t p);
static gid
heap_ins_void( heapn *hp, size_t pos, oid val, int *err)
@@ -593,15 +593,15 @@ heap_down_##T( heapn *hp, size_t p) \
hp->pos[q] = vpos; \
return heap_down_##T(hp, q); \
}
\
- return (int)(p+1);
\
+ return p+1; \
}
\
\
-static int \
+static size_t \
heap_up_##T( heapn *hp, size_t p) \
{
\
subheap *sh = hp->sub; \
if (p == 0) \
- return (int)(p+1);
\
+ return p+1; \
T *vals = sh->vals; \
size_t q = (p-1)/2; \
int cmp = sh->nlarge?type_cmp(T, vals[hp->pos[q]] ,
vals[hp->pos[p]]):type_cmp_nsmall(T, vals[hp->pos[q]], vals[hp->pos[p]]);
\
@@ -619,11 +619,11 @@ heap_up_##T( heapn *hp, size_t p) \
hp->pos[p] = hp->pos[q]; \
hp->pos[q] = vpos; \
if (q == 0) \
- return (int)(q+1);
\
+ return q+1; \
return heap_up_##T(hp, q); \
}
\
p++; \
- return (int)p; \
+ return p; \
}
\
\
static gid \
@@ -695,16 +695,16 @@ gheap_down_##T( heapn *hp, gid g, size_t
pos[q] = vpos; \
return gheap_down_##T(hp, g, q); \
}
\
- return (int)(p+1);
\
+ return p+1; \
}
\
\
-static int \
+static size_t \
gheap_up_##T( heapn *hp, gid g, size_t p) \
{
\
subheap *sh = hp->sub; \
oid *pos = hp->pos + g * hp->size; \
if (p == 0) \
- return (int)(p+1);
\
+ return p+1; \
T *vals = sh->vals; \
size_t q = (p-1)/2; \
int cmp = sh->nlarge?type_cmp(T, vals[pos[q]] ,
vals[pos[p]]):type_cmp_nsmall(T, vals[pos[q]], vals[pos[p]]);
\
@@ -722,11 +722,11 @@ gheap_up_##T( heapn *hp, gid g, size_t p
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]