Changeset: 36e3581e935b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/36e3581e935b
Modified Files:
monetdb5/modules/mal/pp_slicer.c
sql/backends/monet5/sql_pp_statement.c
Branch: pp_hashjoin
Log Message:
pass limit/offset directly to pp subslice
diffs (96 lines):
diff --git a/monetdb5/modules/mal/pp_slicer.c b/monetdb5/modules/mal/pp_slicer.c
--- a/monetdb5/modules/mal/pp_slicer.c
+++ b/monetdb5/modules/mal/pp_slicer.c
@@ -43,18 +43,18 @@ topn_create(void)
}
static str
-LALGsubslice(Client ctx, bat *gid, bat *rid, bat *tid, bat *bid, /*bat *sid,*/
lng *start, lng *end)
+LALGsubslice(Client ctx, bat *gid, bat *rid, bat *tid, bat *bid, /*bat *sid,*/
lng *limit, lng *offset)
{
(void)ctx;
str msg = MAL_SUCCEED;
Pipeline *p = pipeline_get_thread_private_pipeline();
BAT *g = NULL, *r = NULL, *t = NULL, *b = NULL;
- BUN s = *(BUN*)start, e = *(BUN*)end;
+ BUN l = *(BUN*)limit, o = *(BUN*)offset;
int fb = 1, locked = 0;
bool private = (!tid || is_bat_nil(*tid));
topn_t *n = NULL;
- if (*start < 0 || (*end < 0 && !is_lng_nil(*end)))
+ if (*offset < 0 || (*limit < 0 && !is_lng_nil(*limit)))
throw(MAL, "algebra.subslice", ILLEGAL_ARGUMENT);
if ((b = BATdescriptor(*bid)) == NULL)
return createException(SQL, "algebra.subslice", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
@@ -92,11 +92,13 @@ LALGsubslice(Client ctx, bat *gid, bat *
(void)p;
BUN cnt = BATcount(b);
+ BUN s = o, e = s;
+ e += l;
BUN rs = 0, re = 0;
rs = n->start;
re = n->end;
BUN off = b->hseqbase;
- e += 1; /* make range exclusive */
+ //e += 1; /* make range exclusive */
if (re < e) {
BUN ls = 0, lnr = cnt;
if (rs < s) {
@@ -216,7 +218,7 @@ SLICERno_slices(Client cntxt, MalBlkPtr
#include "mel.h"
static mel_func pp_slicer_init_funcs[] = {
- command("algebra", "subslice", LALGsubslice, false, "Returns the slice of a
pipelined result", args(3,6, batarg("gid", oid), batarg("rid", oid),
batarg("tid", oid), batargany("b", 1), arg("start", lng), arg("end", lng))),
+ command("algebra", "subslice", LALGsubslice, false, "Returns the slice of a
pipelined result", args(3,6, batarg("gid", oid), batarg("rid", oid),
batarg("tid", oid), batargany("b", 1), arg("limit", lng), arg("offset", lng))),
pattern("slicer", "nth_slice", SLICERnth_slice, false, "Return the n-th
slice, of SLICE_SIZE rrows, from the input BAT", args(1,3,
batargany("slice",1), batargany("b",1), arg("nr",int))),
pattern("slicer", "no_slices", SLICERno_slices, false, "Returns the number of
slices into which the input BAT is to be sliced", args(1,2, arg("slices", int),
batargany("b",1))),
{ .imp=NULL }
diff --git a/sql/backends/monet5/sql_pp_statement.c
b/sql/backends/monet5/sql_pp_statement.c
--- a/sql/backends/monet5/sql_pp_statement.c
+++ b/sql/backends/monet5/sql_pp_statement.c
@@ -245,7 +245,7 @@ stmt_limit_partitioned(backend *be, stmt
{
MalBlkPtr mb = be->mb;
InstrPtr q = NULL;
- int l, c, len;
+ int l, c;
if (col->nr < 0 || offset->nr < 0 || limit->nr < 0)
return NULL;
@@ -277,33 +277,14 @@ stmt_limit_partitioned(backend *be, stmt
c = k;
}
- q = newStmt(mb, calcRef, plusRef);
- q = pushArgument(mb, q, offset->nr);
- q = pushArgument(mb, q, limit->nr);
- if (q == NULL)
- return NULL;
- len = getDestVar(q);
- pushInstruction(mb, q);
-
- /* since both arguments of algebra.subslice are
- inclusive correct the LIMIT value by
- subtracting 1 */
- q = newStmt(mb, calcRef, minusRef);
- q = pushArgument(mb, q, len);
- q = pushInt(mb, q, 1);
- if (q == NULL)
- return NULL;
- len = getDestVar(q);
- pushInstruction(mb, q);
-
q = newStmtArgs(mb, algebraRef, subsliceRef, 6);
/* returns gid, rid, hid */
q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); /* rid */
q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); /* hid for
topn/heap sink */
q->inout = 2;
q = pushArgument(mb, q, c);
+ q = pushArgument(mb, q, limit->nr);
q = pushArgument(mb, q, offset->nr);
- q = pushArgument(mb, q, len);
if (q == NULL)
return NULL;
l = getDestVar(q);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]