MonetDB: Apr2019 - output all info of the problem
Changeset: 998c2ef7e29c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=998c2ef7e29c Modified Files: sql/backends/monet5/sql.c Branch: Apr2019 Log Message: output all info of the problem diffs (12 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -2240,7 +2240,7 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt diff = BATdiff(tids, d, NULL, NULL, false, BUN_NONE); // assert(pci->argc == 6 || BATcount(diff) == (nr-dcnt)); if( !(pci->argc == 6 || BATcount(diff) == (nr-dcnt)) ) - msg = createException(SQL, "sql.tid", SQLSTATE(0) "Invalid sqltid state argc= %d diff= %d, dcnt=%d", pci->argc, (int)nr, (int)dcnt); + msg = createException(SQL, "sql.tid", SQLSTATE(0) "Invalid sqltid state argc=%d diff=" BUNFMT ", nr=%zd, dcnt=%zd", pci->argc, BATcount(diff), nr, dcnt); BBPunfix(d->batCacheid); BBPunfix(tids->batCacheid); if (diff == NULL) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: candidate-exceptions - Converted BATproject to candidat...
Changeset: 2fc41c9723c4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2fc41c9723c4 Modified Files: gdk/gdk_project.c Branch: candidate-exceptions Log Message: Converted BATproject to candidate iterators. diffs (truncated from 366 to 300 lines): diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c --- a/gdk/gdk_project.c +++ b/gdk/gdk_project.c @@ -13,75 +13,57 @@ /* * BATproject returns a BAT aligned with the left input whose values * are the values from the right input that were referred to by the - * OIDs in the tail of the left input. + * OIDs in the left input. */ #define project_loop(TYPE) \ static gdk_return \ -project_##TYPE(BAT *bn, BAT *l, BAT *r, bool nilcheck) \ +project_##TYPE(BAT *bn, BAT *l, struct canditer *restrict ci, BAT *r, bool nilcheck) \ { \ - oid lo, hi; \ + BUN lo, hi; \ const TYPE *restrict rt;\ TYPE *restrict bt; \ TYPE v; \ - const oid *restrict o; \ oid rseq, rend; \ + bool hasnil = false;\ \ - o = (const oid *) Tloc(l, 0); \ rt = (const TYPE *) Tloc(r, 0); \ bt = (TYPE *) Tloc(bn, 0); \ rseq = r->hseqbase; \ rend = rseq + BATcount(r); \ - lo = 0; \ - hi = lo + BATcount(l); \ - if (nilcheck) { \ - for (; lo < hi; lo++) { \ - if (o[lo] < rseq || o[lo] >= rend) {\ - if (is_oid_nil(o[lo])) {\ - bt[lo] = TYPE##_nil;\ - bn->tnonil = false; \ - bn->tnil = true;\ - bn->tsorted = false;\ - bn->trevsorted = false; \ - bn->tkey = false; \ - lo++; \ - break; \ - } else {\ - GDKerror("BATproject: does not match always\n"); \ - return GDK_FAIL;\ - } \ + if (ci) { \ + for (lo = 0, hi = ci->ncand; lo < hi; lo++) { \ + oid o = canditer_next(ci); \ + if (o < rseq || o >= rend) {\ + GDKerror("BATproject: does not match always\n"); \ + return GDK_FAIL;\ + } \ + v = rt[o - rseq]; \ + bt[lo] = v; \ + hasnil |= is_##TYPE##_nil(v); \ + } \ + } else {\ + const oid *restrict o = (const oid *) Tloc(l, 0); \ + for (lo = 0, hi = BATcount(l); lo < hi; lo++) { \ + if (is_oid_nil(o[lo])) {\ + assert(nilcheck); \ + bt[lo] = TYPE##_nil;\ + hasnil = true; \ + } else if (o[lo] < rseq || o[lo] >= rend) { \ + GDKerror("BATproject: does not match always\n"); \ + return GDK_FAIL;\ } else {
MonetDB: candidate-exceptions - Accept candidates with exception...
Changeset: ca0392d75ac5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ca0392d75ac5 Modified Files: gdk/gdk_project.c Branch: candidate-exceptions Log Message: Accept candidates with exceptions in BATprojectchain. diffs (227 lines): diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c --- a/gdk/gdk_project.c +++ b/gdk/gdk_project.c @@ -416,6 +416,7 @@ BATprojectchain(BAT **bats) BAT *b; /* the BAT */ oid hlo;/* lowest allowed oid to index the BAT */ BUN cnt;/* size of allowed index range */ + struct canditer ci; /* candidate iterator for cand w/ except. */ } *ba; int i, n, tpe; BAT *b, *bn; @@ -431,7 +432,7 @@ BATprojectchain(BAT **bats) * temporary work space */ for (n = 0; bats[n]; n++) ; - ba = GDKmalloc(sizeof(*ba) * n); + ba = GDKzalloc(sizeof(*ba) * n); if (ba == NULL) return NULL; b = *bats++; @@ -444,7 +445,7 @@ BATprojectchain(BAT **bats) issorted &= b->tsorted; if (!allnil) { if (n > 0 && ba[i-1].vals == NULL) { - /* previous BAT was dense-tailed: we will + /* previous BAT was dense: we will * combine it with this one */ i--; assert(off == 0); @@ -483,6 +484,11 @@ BATprojectchain(BAT **bats) is_oid_nil(b->tseqbase)) { tseq = oid_nil; allnil = true; + } else if (b->ttype == TYPE_void) { + assert(b->tvheap != NULL); + canditer_init(&ba[i].ci, NULL, b); + /* make sure .vals != NULL */ + ba[i].vals = ba[i].ci.oids; } else ba[i].vals = (const oid *) Tloc(b, off); } @@ -498,7 +504,11 @@ BATprojectchain(BAT **bats) if (b->ttype == TYPE_void && is_oid_nil(b->tseqbase)) allnil = true; - else + else if (b->ttype == TYPE_void) { + assert(b->tvheap != NULL); + /* make sure .vals != NULL */ + ba[i].vals = (const oid *) b->tvheap->base; + } else ba[i].vals = (const oid *) Tloc(b, 0); } } @@ -587,19 +597,19 @@ BATprojectchain(BAT **bats) offset = (lng) tseq - (lng) ba[n].hlo; ba[n].cnt += ba[n].hlo; /* upper bound of last BAT */ for (p = 0; p < cnt; p++) { - o = ba[0].vals[p]; + o = ba[0].ci.oids ? canditer_next(&ba[0].ci) : ba[0].vals[p]; for (i = 1; i < n; i++) { + if (is_oid_nil(o)) { + bn->tnil = true; + o = oid_nil; + break; + } o -= ba[i].hlo; if (o >= ba[i].cnt) { - if (o == oid_nil - ba[i].hlo) { - bn->tnil = true; - o = oid_nil; - break; - } GDKerror("BATprojectchain: does not match always\n"); goto bunins_failed; } - o = ba[i].vals[o]; + o = ba[i].ci.oids ? canditer_idx(&ba[i].ci, (BUN) o) : ba[i].vals[o]; } if (is_oid_nil(o)) { *v++ = *(oid *) nil; @@ -614,19 +624,19 @@ BATprojectchain(BAT **bats) } else { /* last BAT is materialized */ for (p =
MonetDB: candidate-exceptions - Teach BATslice and BATassertProp...
Changeset: 9272c3dac104 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9272c3dac104 Modified Files: gdk/gdk_bat.c gdk/gdk_batop.c Branch: candidate-exceptions Log Message: Teach BATslice and BATassertProps about candidates with exceptions. diffs (49 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2224,10 +2224,29 @@ BATassertProps(BAT *b) assert(b->twidth == 0); assert(b->tsorted); if (is_oid_nil(b->tseqbase)) { + assert(b->tvheap == NULL); assert(BATcount(b) == 0 || !b->tnonil); assert(BATcount(b) <= 1 || !b->tkey); assert(b->trevsorted); } else { + if (b->tvheap != NULL) { + /* candidate list with exceptions */ + assert(b->batRole == TRANSIENT); + assert(b->tvheap->free <= b->tvheap->size); + assert(b->tvheap->free % SIZEOF_OID == 0); + if (b->tvheap->free > 0) { + const oid *oids = (const oid *) b->tvheap->base; + q = b->tvheap->free / SIZEOF_OID; + assert(oids != NULL); + assert(b->tseqbase + BATcount(b) + q <= GDK_oid_max); + /* exceptions within range */ + assert(oids[0] >= b->tseqbase); + assert(oids[q - 1] < b->tseqbase + BATcount(b) + q); + /* exceptions sorted */ + for (p = 1; p < q; p++) + assert(oids[p - 1] < oids[p]); + } + } assert(b->tseqbase + b->batCount <= GDK_oid_max); assert(BATcount(b) == 0 || !b->tnil); assert(BATcount(b) <= 1 || !b->trevsorted); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -926,6 +926,12 @@ BATslice(BAT *b, BUN l, BUN h) return NULL; } + if (b->ttype == TYPE_void && b->tvheap != NULL) { + /* slicing a candidate list with exceptions */ + struct canditer ci; + canditer_init(&ci, NULL, b); + return canditer_slice(&ci, l, h); + } /* If the source BAT is readonly, then we can obtain a VIEW * that just reuses the memory of the source. */ if (b->batRestricted == BAT_READ && ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: candidate-exceptions - Some cleanup.
Changeset: 41e7377cc1e7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41e7377cc1e7 Modified Files: gdk/gdk.h gdk/gdk_cand.c Branch: candidate-exceptions Log Message: Some cleanup. diffs (37 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1471,7 +1471,8 @@ gdk_export void GDKqsort(void *restrict #define BATtordered(b) ((b)->tsorted) #define BATtrevordered(b) ((b)->trevsorted) /* BAT is dense (i.e., BATtvoid() is true and tseqbase is not NIL) */ -#define BATtdense(b) (!is_oid_nil((b)->tseqbase) && (b)->tvheap == NULL) +#define BATtdense(b) (!is_oid_nil((b)->tseqbase) && \ +((b)->tvheap == NULL || (b)->tvheap->free == 0)) /* BATtvoid: BAT can be (or actually is) represented by TYPE_void */ #define BATtvoid(b)(BATtdense(b) || (b)->ttype==TYPE_void) #define BATtkey(b) ((b)->tkey || BATtdense(b)) diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -397,8 +397,6 @@ canditer_init(struct canditer *ci, BAT * *ci = (struct canditer) { .tpe = cand_dense, .s = s, - .seq = 0, - .ncand = 0, }; return 0; } @@ -807,8 +805,9 @@ canditer_slice(struct canditer *ci, BUN o = canditer_idx(ci, lo); add = o - ci->seq - lo; assert(add <= ci->noids); - if (add == ci->noids) { - /* after last exception: return dense sequence */ + if (add == ci->noids || o + hi - lo < ci->oids[add]) { + /* after last exception or before next +* exception: return dense sequence */ return BATdense(0, o, hi - lo); } bn = COLnew(0, TYPE_oid, hi - lo, TRANSIENT); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: candidate-exceptions - Merge with default branch.
Changeset: 507bae38bf6d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=507bae38bf6d Added Files: sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.sql sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.stable.err sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.stable.out sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.sql sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.stable.err sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.stable.out sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out common/utils/msabaoth.c common/utils/msabaoth.h gdk/gdk_select.c monetdb5/mal/mal.c monetdb5/modules/atoms/uuid.c monetdb5/modules/atoms/uuid.mal monetdb5/modules/atoms/xml.c monetdb5/modules/atoms/xml.h monetdb5/modules/atoms/xml.mal sql/backends/monet5/sql_cat.c sql/server/rel_sequence.c sql/server/sql_parser.y sql/server/sql_scan.c sql/storage/bat/bat_storage.c sql/storage/store.c sql/test/BugTracker-2018/Tests/remote-table-where-is-null.Bug-6601.stable.out sql/test/BugTracker-2018/Tests/remote-table-where-not-equal.Bug-6621.stable.out sql/test/BugTracker-2019/Tests/All sql/test/wlcr/Tests/wlc01.py sql/test/wlcr/Tests/wlc01.stable.out sql/test/wlcr/Tests/wlc100.py sql/test/wlcr/Tests/wlc100.stable.out sql/test/wlcr/Tests/wlc20.py sql/test/wlcr/Tests/wlc20.stable.out sql/test/wlcr/Tests/wlc21.py sql/test/wlcr/Tests/wlc21.stable.out sql/test/wlcr/Tests/wlc30.py sql/test/wlcr/Tests/wlc30.stable.out sql/test/wlcr/Tests/wlc40.py sql/test/wlcr/Tests/wlc40.stable.out sql/test/wlcr/Tests/wlc50.py sql/test/wlcr/Tests/wlc50.stable.out sql/test/wlcr/Tests/wlc70.py sql/test/wlcr/Tests/wlc70.stable.out Branch: candidate-exceptions Log Message: Merge with default branch. diffs (truncated from 2060 to 300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -11983,6 +11983,7 @@ stdout of test 'MAL-signatures` in direc [ "uuid", "#read","command uuid.#read():void ", "UUIDread;", "" ] [ "uuid", "#tostr", "command uuid.#tostr():void ", "UUIDtoString;","" ] [ "uuid", "#write", "command uuid.#write():void ", "UUIDwrite;", "" ] +[ "uuid", "epilogue", "command uuid.epilogue():void ", "UUIDepilogue;","release the resources held by the uuid module" ] [ "uuid", "isaUUID", "command uuid.isaUUID(u:str):bit ", "UUIDisaUUID;", "Test a string for a UUID format" ] [ "uuid", "new", "unsafe command uuid.new():uuid ", "UUIDgenerateUuid;","Generate a new uuid" ] [ "uuid", "new", "unsafe command uuid.new(d:int):uuid ", "UUIDgenerateUuidInt;", "Generate a new uuid (dummy version for side effect free multiplex loop)" ] @@ -12154,6 +12155,7 @@ stdout of test 'MAL-signatures` in direc [ "xml", "document", "command xml.document(val:str):xml ", "XMLdocument;", "Check the value for compliance as XML document"] [ "xml", "element", "command xml.element(name:str, ns:xml, attr:xml, s:xml):xml ", "XMLelement;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] [ "xml", "element", "command xml.element(name:str, s:xml):xml ", "XMLelementSmall;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] +[ "xml", "epilogue", "command xml.epilogue():void ", "XMLepilogue;", "release the resources held by the xml module" ] [ "xml", "forest", "pattern xml.forest(val:xml...):xml ", "XMLforest;", "Construct an element list" ] [ "xml", "isdocument", "command xml.isdocument(val:str):bit ", "XMLisdocument;", "Validate the string as a document" ] [ "xml", "parse","command xml.parse(doccont:str, val:str, option:str):xml ", "XMLparse;","Parse the XML document or element string values " ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients
MonetDB: mosaic - Add extensive tests for linear compression.
Changeset: 2d4725d112dc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2d4725d112dc Added Files: monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.malC monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.stable.err monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.stable.out Modified Files: monetdb5/modules/mosaic/Tests/All Branch: mosaic Log Message: Add extensive tests for linear compression. diffs (truncated from 2975 to 300 lines): diff --git a/monetdb5/modules/mosaic/Tests/All b/monetdb5/modules/mosaic/Tests/All --- a/monetdb5/modules/mosaic/Tests/All +++ b/monetdb5/modules/mosaic/Tests/All @@ -37,3 +37,4 @@ mosaic_mix_joins mosaic_frame_lng_tmp mosaic_frame_oid_tmp mosaic_delta_lng_tmp +mosaic_linear_lng_tmp diff --git a/monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.malC b/monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.malC new file mode 100644 --- /dev/null +++ b/monetdb5/modules/mosaic/Tests/mosaic_linear_lng_tmp.malC @@ -0,0 +1,678 @@ +a:= bat.new(:lng); +bat.append(a,990:lng); +bat.append(a,991:lng); +bat.append(a,992:lng); +bat.append(a,993:lng); +bat.append(a,994:lng); +bat.append(a,995:lng); +bat.append(a,996:lng); +bat.append(a,997:lng); +bat.append(a,998:lng); +bat.append(a,999:lng); +bat.append(a,1000:lng); +bat.append(a,1001:lng); +bat.append(a,1002:lng); +bat.append(a,1003:lng); +bat.append(a,1004:lng); +bat.append(a,1005:lng); +bat.append(a,1006:lng); +bat.append(a,1007:lng); +bat.append(a,1008:lng); +bat.append(a,1009:lng); +bat.append(a,1010:lng); +mosaic.compress(a,"linear"); +c:= mosaic.decompress(a); +io.print(a, c); + +sa:= algebra.select(a,nil:lng, nil:lng,false,false,false); +sc:= mosaic.select (c,nil:lng, nil:lng,false,false,false); +io.print(sa, sc); + +sa:= algebra.select(a,nil:lng, nil:lng,false,false,true); +sc:= mosaic.select (c,nil:lng, nil:lng,false,false,true); +io.print(sa, sc); + +sa:= algebra.select(a,1000:lng, nil:lng,false,false,false); +sc:= mosaic.select (c,1000:lng, nil:lng,false,false,false); +tsa:= algebra.thetaselect(a,1000:lng, ">"); +tsc:= mosaic.thetaselect (c,1000:lng, ">"); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,nil:lng, 1000:lng,false,false,false); +sc:= mosaic.select (c,nil:lng, 1000:lng,false,false,false); +tsa:= algebra.thetaselect(a,1000:lng, "<"); +tsc:= mosaic.thetaselect (c,1000:lng, "<"); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,900:lng, nil:lng,false,false,false); +sc:= mosaic.select (c,900:lng, nil:lng,false,false,false); +tsa:= algebra.thetaselect(a,900:lng, ">"); +tsc:= mosaic.thetaselect (c,900:lng, ">"); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,nil:lng, 900:lng,false,false,false); +sc:= mosaic.select (c,nil:lng, 900:lng,false,false,false); +tsa:= algebra.thetaselect(a,900:lng, "<"); +tsc:= mosaic.thetaselect (c,900:lng, "<"); +#io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,900:lng, nil:lng,true,false,false); +sc:= mosaic.select (c,900:lng, nil:lng,true,false,false); +tsa:= algebra.thetaselect(a,900:lng, ">="); +tsc:= mosaic.thetaselect (c,900:lng, ">="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,nil:lng, 900:lng,false,true,false); +sc:= mosaic.select (c,nil:lng, 900:lng,false,true,false); +tsa:= algebra.thetaselect(a,900:lng, "<="); +tsc:= mosaic.thetaselect (c,900:lng, "<="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,1000:lng, nil:lng,true,false,false); +sc:= mosaic.select (c,1000:lng, nil:lng,true,false,false); +tsa:= algebra.thetaselect(a,1000:lng, ">="); +tsc:= mosaic.thetaselect (c,1000:lng, ">="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,nil:lng, 1000:lng,false,true,false); +sc:= mosaic.select (c,nil:lng, 1000:lng,false,true,false); +tsa:= algebra.thetaselect(a,1000:lng, "<="); +tsc:= mosaic.thetaselect (c,1000:lng, "<="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,1000:lng, 1000:lng,true,true,false); +sc:= mosaic.select (c,1000:lng, 1000:lng,true,true,false); +tsa:= algebra.thetaselect(a,1000:lng, "=="); +tsc:= mosaic.thetaselect (c,1000:lng, "=="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,1000:lng, 1000:lng,true,true,true); +sc:= mosaic.select (c,1000:lng, 1000:lng,true,true,true); +tsa:= algebra.thetaselect(a,1000:lng, "!="); +tsc:= mosaic.thetaselect (c,1000:lng, "!="); +io.print(sa, sc, tsa, tsc); + + +sa:= algebra.select(a,1003:lng, 1003:lng,true,true,false); +sc:= mosaic.select (c,1003:lng, 1003:lng,true,true,false); +tsa:= algebra.thetaselect(a,1003:lng, "=="); +tsc:= mosaic.thetaselect (c,1003:lng, "=="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,1003:lng, 1003:lng,true,true,true); +sc:= mosaic.select (c,1003:lng, 1003:lng,true,true,true); +tsa:= algebra.thetaselect(a,1003:lng, "!="); +tsc:= mosaic.thetaselect (c,1003:lng, "!="); +io.print(sa, sc, tsa, tsc); + +sa:= algebra.select(a,900:lng, 900:lng,true,true,false); +sc:= mosaic.select (c,900:lng, 900:lng,true,true,false); +tsa:= algebra.thetaselect(a,900:lng, "=="); +tsc:= mos
MonetDB: mosaic - Remove unused code and fix memory leak.
Changeset: 18d1dd2cb2cb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=18d1dd2cb2cb Modified Files: monetdb5/modules/mosaic/mosaic.c Branch: mosaic Log Message: Remove unused code and fix memory leak. diffs (28 lines): diff --git a/monetdb5/modules/mosaic/mosaic.c b/monetdb5/modules/mosaic/mosaic.c --- a/monetdb5/modules/mosaic/mosaic.c +++ b/monetdb5/modules/mosaic/mosaic.c @@ -254,7 +254,6 @@ str MOScompressInternal(BAT* bsrc, const char* compressions) { MOStask task; - BAT *o = NULL; // the BAT to be augmented with a compressed heap str msg = MAL_SUCCEED; int cand; int tpe, typewidth; @@ -429,14 +428,11 @@ MOScompressInternal(BAT* bsrc, const cha bsrc->batDirtydesc = true; task->hdr->ratio = (flt)task->bsrc->theap.free/ task->bsrc->tmosaic->free; finalize: + GDKfree(task); t1 = GDKusec(); ALGODEBUG fprintf(stderr, "#BATmosaic: mosaic construction " LLFMT " usec\n", t1 - t0); - if (o != NULL) { - o->tmosaic = NULL; /* views always keep null pointer and - need to obtain the latest mosaic - from the parent at query time */ - } + return msg; } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Apr2019 - small cleanup.
Changeset: 382d15e2f110 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=382d15e2f110 Modified Files: sql/backends/monet5/sql.c sql/storage/bat/bat_storage.c Branch: Apr2019 Log Message: small cleanup. switch back to assert, instead of warning message. diffs (45 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -2238,9 +2238,9 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt } diff = BATdiff(tids, d, NULL, NULL, false, BUN_NONE); - // assert(pci->argc == 6 || BATcount(diff) == (nr-dcnt)); - if( !(pci->argc == 6 || BATcount(diff) == (nr-dcnt)) ) - msg = createException(SQL, "sql.tid", SQLSTATE(0) "Invalid sqltid state argc=%d diff=" BUNFMT ", nr=%zd, dcnt=%zd", pci->argc, BATcount(diff), nr, dcnt); + assert(pci->argc == 6 || BATcount(diff) == (nr-dcnt)); + //if( !(pci->argc == 6 || BATcount(diff) == (nr-dcnt)) ) + //msg = createException(SQL, "sql.tid", SQLSTATE(0) "Invalid sqltid state argc=%d diff=" BUNFMT ", nr=%zd, dcnt=%zd", pci->argc, BATcount(diff), nr, dcnt); BBPunfix(d->batCacheid); BBPunfix(tids->batCacheid); if (diff == NULL) diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c --- a/sql/storage/bat/bat_storage.c +++ b/sql/storage/bat/bat_storage.c @@ -951,7 +951,7 @@ delta_delete_bat( sql_dbat *bat, BAT *i return LOG_ERR; bat_destroy(b); b = temp_descriptor(bat->dbid); - if(!b) + if (b == NULL) return LOG_ERR; } assert(b->theap.storage != STORE_PRIV); @@ -2089,7 +2089,7 @@ gtr_update_delta( sql_trans *tr, sql_del } bat_destroy(ins); - if ((cbat->ucnt && cbat->uibid) || cbat->cleared) { + if (cbat->ucnt) { BAT *ui = temp_descriptor(cbat->uibid); BAT *uv = temp_descriptor(cbat->uvbid); if(ui == NULL || uv == NULL) { @@ -2134,6 +2134,7 @@ gtr_update_dbat(sql_trans *tr, sql_dbat assert(ATOMIC_GET(&store_nr_active)==0); if (d->dbid == dbid) { + assert(!d->cleared); if (d->next) { ok = destroy_dbat(tr, d->next); d->next = NULL; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Apr2019 - Add missing XMLepilogue dummy in case of miss...
Changeset: 16667eb75b08 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=16667eb75b08 Modified Files: monetdb5/modules/atoms/xml.c Branch: Apr2019 Log Message: Add missing XMLepilogue dummy in case of missing libxml. diffs (15 lines): diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c --- a/monetdb5/modules/atoms/xml.c +++ b/monetdb5/modules/atoms/xml.c @@ -821,4 +821,11 @@ str XMLprelude(void *ret) { return MAL_SUCCEED; /* to not break init */ } +str +XMLepilogue(void *ret) +{ + (void) ret; + return GDKstrdup(NO_LIBXML_FATAL); +} + #endif ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Apr2019 - Should be succesful for epilogue.
Changeset: 12ec8fe8df35 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12ec8fe8df35 Modified Files: monetdb5/modules/atoms/xml.c Branch: Apr2019 Log Message: Should be succesful for epilogue. diffs (12 lines): diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c --- a/monetdb5/modules/atoms/xml.c +++ b/monetdb5/modules/atoms/xml.c @@ -825,7 +825,7 @@ str XMLepilogue(void *ret) { (void) ret; - return GDKstrdup(NO_LIBXML_FATAL); + return MAL_SUCCEED; } #endif ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Apr2019 - code style.
Changeset: 5d12479aab76 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d12479aab76 Modified Files: monetdb5/modules/atoms/xml.c Branch: Apr2019 Log Message: code style. diffs (14 lines): diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c --- a/monetdb5/modules/atoms/xml.c +++ b/monetdb5/modules/atoms/xml.c @@ -821,9 +821,7 @@ str XMLprelude(void *ret) { return MAL_SUCCEED; /* to not break init */ } -str -XMLepilogue(void *ret) -{ +str XMLepilogue(void *ret) { (void) ret; return MAL_SUCCEED; } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Apr2019 - Backed out changesets 8fe4665dc861, 99d9f7ccb...
Changeset: 6af7bd3d3465 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6af7bd3d3465 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out common/utils/msabaoth.c common/utils/msabaoth.h monetdb5/mal/mal.c monetdb5/modules/atoms/uuid.c monetdb5/modules/atoms/uuid.mal monetdb5/modules/atoms/xml.c monetdb5/modules/atoms/xml.h monetdb5/modules/atoms/xml.mal Branch: Apr2019 Log Message: Backed out changesets 8fe4665dc861, 99d9f7ccb780, 16667eb75b08, 12ec8fe8df35, 5d12479aab76. No ABI changes in stable branch. diffs (226 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -12047,7 +12047,6 @@ Ready. [ "uuid", "#read","command uuid.#read():void ", "UUIDread;", "" ] [ "uuid", "#tostr", "command uuid.#tostr():void ", "UUIDtoString;","" ] [ "uuid", "#write", "command uuid.#write():void ", "UUIDwrite;", "" ] -[ "uuid", "epilogue", "command uuid.epilogue():void ", "UUIDepilogue;","release the resources held by the uuid module" ] [ "uuid", "isaUUID", "command uuid.isaUUID(u:str):bit ", "UUIDisaUUID;", "Test a string for a UUID format" ] [ "uuid", "new", "unsafe command uuid.new():uuid ", "UUIDgenerateUuid;","Generate a new uuid" ] [ "uuid", "new", "unsafe command uuid.new(d:int):uuid ", "UUIDgenerateUuidInt;", "Generate a new uuid (dummy version for side effect free multiplex loop)" ] @@ -12219,7 +12218,6 @@ Ready. [ "xml", "document", "command xml.document(val:str):xml ", "XMLdocument;", "Check the value for compliance as XML document"] [ "xml", "element", "command xml.element(name:str, ns:xml, attr:xml, s:xml):xml ", "XMLelement;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] [ "xml", "element", "command xml.element(name:str, s:xml):xml ", "XMLelementSmall;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] -[ "xml", "epilogue", "command xml.epilogue():void ", "XMLepilogue;", "release the resources held by the xml module" ] [ "xml", "forest", "pattern xml.forest(val:xml...):xml ", "XMLforest;", "Construct an element list" ] [ "xml", "isdocument", "command xml.isdocument(val:str):bit ", "XMLisdocument;", "Validate the string as a document" ] [ "xml", "parse","command xml.parse(doccont:str, val:str, option:str):xml ", "XMLparse;","Parse the XML document or element string values " ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -16475,7 +16475,6 @@ Ready. [ "uuid", "#read","command uuid.#read():void ", "UUIDread;", "" ] [ "uuid", "#tostr", "command uuid.#tostr():void ", "UUIDtoString;","" ] [ "uuid", "#write", "command uuid.#write():void ", "UUIDwrite;", "" ] -[ "uuid", "epilogue", "command uuid.epilogue():void ", "UUIDepilogue;","release the resources held by the uuid module" ] [ "uuid", "isaUUID", "command uuid.isaUUID(u:str):bit ", "UUIDisaUUID;", "Test a string for a UUID format" ] [ "uuid", "new", "unsafe command uuid.new():uuid ", "UUIDgenerateUuid;","Generate a new uuid" ] [ "uuid", "new", "unsafe command uuid.new(d:int):uuid ", "UUIDgenerateUuidInt;", "Generate a new uuid (dummy version for side effect free multiplex loop)" ] @@ -16647,7 +16646,6 @@ Ready. [ "xml", "document", "command xml.document(val:str):xml ", "XMLdocument;", "Check the value for compliance as XML document"] [ "xml", "element", "command xml.element(name:str, ns:xml, attr:xml, s:xml):xml ", "XMLelement;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] [ "xml", "element", "command xml.element(name:str, s:xml):xml ", "XMLelementSmall;", "The basic building block for XML elements are namespaces, attributes and a sequence of xml elements. The name space and the attributes may be left unspecified(=nil:bat)." ] -[ "xml", "epilogue", "com
MonetDB: Apr2019 - When throwing an error, call createException,...
Changeset: 8f550a1b4124 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8f550a1b4124 Modified Files: monetdb5/modules/atoms/batxml.c monetdb5/modules/atoms/xml.c Branch: Apr2019 Log Message: When throwing an error, call createException, not GDKstrdup directly. diffs (279 lines): diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c --- a/monetdb5/modules/atoms/batxml.c +++ b/monetdb5/modules/atoms/batxml.c @@ -1453,82 +1453,82 @@ BATXMLxquery(bat *ret, const bat *bid, c str BATXMLxml2str(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.xml2str", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLxmltext(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.xmltext", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLstr2xml(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.str2xml", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLdocument(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.document", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLcontent(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.content", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLisdocument(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.isdocument", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLelementSmall(bat *ret, const char * const *name, const bat *bid) { (void) ret; (void) name; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.elementSmall", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLoptions(bat *ret, const char * const *name, const char * const *options, const bat *bid) { (void) ret; (void) name; (void) options; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.options", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLcomment(bat *ret, const bat *bid) { (void) ret; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.comment", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLparse(bat *ret, const char * const *doccont, const bat *bid, const char * const *option) { (void) ret; (void) doccont; (void) bid; (void) option; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.parse", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLxquery(bat *ret, const bat *bid, const char * const *expr) { (void) ret; (void) bid; (void) expr; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.xquery", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLpi(bat *ret, const char * const *tgt, const bat *bid) { (void) ret; (void) tgt; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.pi", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLroot(bat *ret, const bat *bid, const char * const *version, const char * const *standalone) { (void) ret; (void) bid; (void) version; (void) standalone; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.root", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLattribute(bat *ret, const char * const *name, const bat *bid) { (void) ret; (void) name; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.attribute", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLelement(bat *ret, const char * const *name, xml *ns, xml *attr, const bat *bid) { (void) ret; @@ -1536,25 +1536,25 @@ str BATXMLelement(bat *ret, const char * (void) ns; (void) attr; (void) bid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.element", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLconcat(bat *ret, const bat *bid, const bat *rid) { (void) ret; (void) bid; (void) rid; - return GDKstrdup(NO_LIBXML_FATAL); + return createException(MAL, "batxml.concat", SQLSTATE(HY005) NO_LIBXML_FATAL); } str BATXMLforest(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p) { (void) cntxt; (void) mb; (void) stk; (void) p; - return GDKstrdup(NO_LIBXML_FATAL); + return c
MonetDB: Apr2019 - Don't try to create the farm directory twice.
Changeset: f6d6b82da298 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f6d6b82da298 Modified Files: tools/mserver/mserver5.c Branch: Apr2019 Log Message: Don't try to create the farm directory twice. diffs (12 lines): diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -496,7 +496,7 @@ main(int argc, char **av) monet_script[i] = NULL; if (!dbpath) { dbpath = absolute_path(mo_find_option(set, setlen, "gdk_dbpath")); - if (dbpath == NULL || GDKcreatedir(dbpath) != GDK_SUCCEED) { + if (!dbpath) { fprintf(stderr, "!ERROR: cannot allocate memory for database directory \n"); exit(1); } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: candidate-exceptions - introduced BATnegcands and BATcands
Changeset: 6be8d05dfd8f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6be8d05dfd8f Modified Files: clients/Tests/exports.stable.out gdk/gdk_cand.c gdk/gdk_cand.h monetdb5/mal/mal_interpreter.c sql/backends/monet5/sql.c Branch: candidate-exceptions Log Message: introduced BATnegcands and BATcands sofar used in the SQLtids and mal main loop. (grafted from bc5533df50034ab8374cc13e3ba32e24f1d7f2df) diffs (240 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -107,6 +107,7 @@ dbl BATcalcvariance_sample(dbl *avgp, BA BAT *BATcalcxor(BAT *b1, BAT *b2, BAT *s); BAT *BATcalcxorcst(BAT *b, const ValRecord *v, BAT *s); bool BATcandcontains(BAT *s, oid o); +BAT *BATcands(BAT *negcands); gdk_return BATclear(BAT *b, bool force); void BATcommit(BAT *b); BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, role_t role); @@ -154,6 +155,7 @@ void *BATmin(BAT *b, void *aggr); void *BATmin_skipnil(BAT *b, void *aggr, bit skipnil); gdk_return BATmode(BAT *b, bool transient); void BATmsync(BAT *b); +int BATnegcands(BAT *cands, BAT *odels); bool BATordered(BAT *b); bool BATordered_rev(BAT *b); gdk_return BATorderidx(BAT *b, bool stable); diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -919,3 +919,73 @@ canditer_slice2(struct canditer *ci, BUN } return virtualize(bn); } + +int +BATnegcands(BAT *dense_cands, BAT *odels) +{ + const char *nme; + Heap *dels; + char *fname = 0; + + nme = BBP_physical(dense_cands->batCacheid); + if ((dels = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || + (dels->farmid = BBPselectfarm(dense_cands->batRole, dense_cands->ttype, varheap)) < 0 || +(fname = GDKfilepath(NOFARM, NULL, nme, "theap")) == NULL){ + if (fname) + GDKfree(fname); + GDKfree(dels); + return GDK_FAIL; + } + //dels->farmid = dense_cands->theap.farmid; + strncpy(dels->filename, fname, sizeof(dels->filename)); + + if (HEAPalloc(dels, BATcount(odels), sizeof(oid)) != GDK_SUCCEED) + return GDK_FAIL; + dels->parentid = dense_cands->batCacheid; + memcpy(dels->base, Tloc(odels,0), sizeof(oid)*BATcount(odels)); + dels->free += sizeof(oid)*BATcount(odels); + dense_cands->batDirtydesc = TRUE; + dense_cands->tvheap = dels; + return GDK_SUCCEED; +} + +BAT * +BATcands(BAT *neg_cands) +{ + BAT *bn; + size_t dcnt = neg_cands->tvheap->free/sizeof(oid); + oid ncf, ncl, *restrict p; + const oid *restrict dp, *dpe; + + bn = COLnew(0, TYPE_oid, BATcount(neg_cands), TRANSIENT); + if (bn == NULL) + return NULL; + ncf = BUNtoid(neg_cands, 0); + ncl = BUNtoid(neg_cands, BUNlast(neg_cands) - 1); + BAThseqbase(bn, ncf); + + /* neg_cands is dense */ + dp = (const oid *)neg_cands->tvheap->base; + dpe = dp + dcnt; + p = Tloc(bn, 0); + /* first skip deletes outside of the dense range */ + while (dp < dpe && *dp < ncf) + dp++; + while (ncf <= ncl && dp < dpe) { + if (ncf < *dp) { + *p++ = ncf++; + } else if (ncf == *dp) { + dp++; + ncf++; + } + } + while (ncf <= ncl) + *p++ = ncf++; + BATsetcount(bn, (BUN) (p - (oid *) Tloc(bn, 0))); + bn->trevsorted = BATcount(bn) <= 1; + bn->tsorted = true; + bn->tkey = true; + bn->tnil = false; + bn->tnonil = true; + return bn; +} diff --git a/gdk/gdk_cand.h b/gdk/gdk_cand.h --- a/gdk/gdk_cand.h +++ b/gdk/gdk_cand.h @@ -74,5 +74,7 @@ gdk_export void canditer_reset(struct ca gdk_export BUN canditer_search(struct canditer *ci, oid o, bool next); gdk_export BAT *canditer_slice(struct canditer *ci, BUN lo, BUN hi); gdk_export BAT *canditer_slice2(struct canditer *ci, BUN lo1, BUN hi1, BUN lo2, BUN hi2); +gdk_export int BATnegcands( BAT *cands, BAT *odels); +gdk_export BAT *BATcands( BAT *negcands); #endif /* _GDK_CAND_H_ */ diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c --- a/monetdb5/mal/mal_interpreter.c +++ b/monetdb5/mal/mal_interpreter.c @@ -18,6 +18,7 @@ #include "mal_debugger.h" /* for mdbStep() */ #include "mal_type.h" #include "mal_private.h" +#include "gdk_cand.h" static lng qptimeout = 0; /* how often we print still running queries (usec) */ @@ -443,6 +444,40 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS return ret; } + +static void +sqlHandleTids(Client cntxt, MalBlkPtr mb, InstrPtr pci, MalStkPtr stk, int cmd) +{ + int i; + + (void)cntxt; + (void)stk; + + for(i = pci->retc; i< pci->argc; i++) {
MonetDB: candidate-exceptions - Some updates to BATnegcands and ...
Changeset: 1c954d2d2533 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1c954d2d2533 Modified Files: clients/Tests/exports.stable.out gdk/gdk_cand.c gdk/gdk_cand.h gdk/gdk_project.c monetdb5/mal/mal_interpreter.c Branch: candidate-exceptions Log Message: Some updates to BATnegcands and its use; removed BATcands, sqlHandleTids. diffs (197 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -107,7 +107,6 @@ dbl BATcalcvariance_sample(dbl *avgp, BA BAT *BATcalcxor(BAT *b1, BAT *b2, BAT *s); BAT *BATcalcxorcst(BAT *b, const ValRecord *v, BAT *s); bool BATcandcontains(BAT *s, oid o); -BAT *BATcands(BAT *negcands); gdk_return BATclear(BAT *b, bool force); void BATcommit(BAT *b); BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, role_t role); @@ -155,7 +154,7 @@ void *BATmin(BAT *b, void *aggr); void *BATmin_skipnil(BAT *b, void *aggr, bit skipnil); gdk_return BATmode(BAT *b, bool transient); void BATmsync(BAT *b); -int BATnegcands(BAT *cands, BAT *odels); +gdk_return BATnegcands(BAT *cands, BAT *odels); bool BATordered(BAT *b); bool BATordered_rev(BAT *b); gdk_return BATorderidx(BAT *b, bool stable); diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -920,72 +920,42 @@ canditer_slice2(struct canditer *ci, BUN return virtualize(bn); } -int +gdk_return BATnegcands(BAT *dense_cands, BAT *odels) { const char *nme; Heap *dels; char *fname = 0; + assert(BATtdense(dense_cands)); + assert(dense_cands->ttype == TYPE_void); + assert(dense_cands->batRole == TRANSIENT); + assert(BATcount(dense_cands) >= BATcount(odels)); + + if (BATcount(odels) == 0) + return GDK_SUCCEED; + nme = BBP_physical(dense_cands->batCacheid); - if ((dels = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || + if ((dels = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || (dels->farmid = BBPselectfarm(dense_cands->batRole, dense_cands->ttype, varheap)) < 0 || (fname = GDKfilepath(NOFARM, NULL, nme, "theap")) == NULL){ - if (fname) - GDKfree(fname); + GDKfree(fname); GDKfree(dels); return GDK_FAIL; } //dels->farmid = dense_cands->theap.farmid; strncpy(dels->filename, fname, sizeof(dels->filename)); - - if (HEAPalloc(dels, BATcount(odels), sizeof(oid)) != GDK_SUCCEED) + GDKfree(fname); + + if (HEAPalloc(dels, BATcount(odels), sizeof(oid)) != GDK_SUCCEED) { + GDKfree(dels); return GDK_FAIL; + } dels->parentid = dense_cands->batCacheid; memcpy(dels->base, Tloc(odels,0), sizeof(oid)*BATcount(odels)); dels->free += sizeof(oid)*BATcount(odels); - dense_cands->batDirtydesc = TRUE; + dense_cands->batDirtydesc = true; dense_cands->tvheap = dels; + BATsetcount(dense_cands, dense_cands->batCount - odels->batCount); return GDK_SUCCEED; } - -BAT * -BATcands(BAT *neg_cands) -{ - BAT *bn; - size_t dcnt = neg_cands->tvheap->free/sizeof(oid); - oid ncf, ncl, *restrict p; - const oid *restrict dp, *dpe; - - bn = COLnew(0, TYPE_oid, BATcount(neg_cands), TRANSIENT); - if (bn == NULL) - return NULL; - ncf = BUNtoid(neg_cands, 0); - ncl = BUNtoid(neg_cands, BUNlast(neg_cands) - 1); - BAThseqbase(bn, ncf); - - /* neg_cands is dense */ - dp = (const oid *)neg_cands->tvheap->base; - dpe = dp + dcnt; - p = Tloc(bn, 0); - /* first skip deletes outside of the dense range */ - while (dp < dpe && *dp < ncf) - dp++; - while (ncf <= ncl && dp < dpe) { - if (ncf < *dp) { - *p++ = ncf++; - } else if (ncf == *dp) { - dp++; - ncf++; - } - } - while (ncf <= ncl) - *p++ = ncf++; - BATsetcount(bn, (BUN) (p - (oid *) Tloc(bn, 0))); - bn->trevsorted = BATcount(bn) <= 1; - bn->tsorted = true; - bn->tkey = true; - bn->tnil = false; - bn->tnonil = true; - return bn; -} diff --git a/gdk/gdk_cand.h b/gdk/gdk_cand.h --- a/gdk/gdk_cand.h +++ b/gdk/gdk_cand.h @@ -74,7 +74,6 @@ gdk_export void canditer_reset(struct ca gdk_export BUN canditer_search(struct canditer *ci, oid o, bool next); gdk_export BAT *canditer_slice(struct canditer *ci, BUN lo, BUN hi); gdk_export BAT *canditer_slice2(struct canditer *ci, BUN lo1, BUN hi1, BUN lo2, BUN hi2); -gdk_export int BATnegcands( BAT *cands, BAT *odels); -gdk_export BAT *BATcands( BAT *negcands); +gdk_export gdk_return BATnegcands( BAT *cands, BAT *odels); #endif /* _GDK_CAND_H_ */
MonetDB: candidate-exceptions - A bunch of candidate iterator fi...
Changeset: 596bf8c78699 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=596bf8c78699 Modified Files: gdk/gdk_cand.c gdk/gdk_project.c monetdb5/modules/mal/pcre.c Branch: candidate-exceptions Log Message: A bunch of candidate iterator fixes. diffs (192 lines): diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -925,37 +925,37 @@ BATnegcands(BAT *dense_cands, BAT *odels { const char *nme; Heap *dels; - char *fname = 0; + BUN lo, hi; assert(BATtdense(dense_cands)); assert(dense_cands->ttype == TYPE_void); assert(dense_cands->batRole == TRANSIENT); - assert(BATcount(dense_cands) >= BATcount(odels)); if (BATcount(odels) == 0) return GDK_SUCCEED; + lo = SORTfndfirst(odels, &dense_cands->tseqbase); + hi = SORTfndfirst(odels, &(oid) {dense_cands->tseqbase + BATcount(dense_cands)}); + if (lo == hi) + return GDK_SUCCEED; + nme = BBP_physical(dense_cands->batCacheid); if ((dels = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || - (dels->farmid = BBPselectfarm(dense_cands->batRole, dense_cands->ttype, varheap)) < 0 || -(fname = GDKfilepath(NOFARM, NULL, nme, "theap")) == NULL){ - GDKfree(fname); + (dels->farmid = BBPselectfarm(dense_cands->batRole, dense_cands->ttype, varheap)) < 0){ GDKfree(dels); return GDK_FAIL; } - //dels->farmid = dense_cands->theap.farmid; - strncpy(dels->filename, fname, sizeof(dels->filename)); - GDKfree(fname); + stpconcat(dels->filename, nme, ".theap", NULL); - if (HEAPalloc(dels, BATcount(odels), sizeof(oid)) != GDK_SUCCEED) { + if (HEAPalloc(dels, hi - lo, sizeof(oid)) != GDK_SUCCEED) { GDKfree(dels); return GDK_FAIL; } dels->parentid = dense_cands->batCacheid; - memcpy(dels->base, Tloc(odels,0), sizeof(oid)*BATcount(odels)); - dels->free += sizeof(oid)*BATcount(odels); + memcpy(dels->base, Tloc(odels, lo), sizeof(oid) * (hi - lo)); + dels->free += sizeof(oid) * (hi - lo); dense_cands->batDirtydesc = true; dense_cands->tvheap = dels; - BATsetcount(dense_cands, dense_cands->batCount - odels->batCount); + BATsetcount(dense_cands, dense_cands->batCount - (hi - lo)); return GDK_SUCCEED; } diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c --- a/gdk/gdk_project.c +++ b/gdk/gdk_project.c @@ -126,6 +126,53 @@ project_void(BAT *bn, BAT *l, struct can } static gdk_return +project_cand(BAT *bn, BAT *l, struct canditer *restrict lci, BAT *r) +{ + BUN lo, hi; + oid *restrict bt; + oid rseq, rend; + struct canditer rci; + + rseq = r->hseqbase; + rend = rseq + BATcount(r); + canditer_init(&rci, NULL, r); + bt = (oid *) Tloc(bn, 0); + bn->tsorted = l->tsorted; + bn->trevsorted = l->trevsorted; + bn->tkey = l->tkey; + bn->tnonil = true; + bn->tnil = false; + if (lci) { + for (lo = 0, hi = lci->ncand; lo < hi; lo++) { + oid o = canditer_next(lci); + if (o < rseq || o >= rend) { + GDKerror("BATproject: does not match always\n"); + return GDK_FAIL; + } + bt[lo] = canditer_idx(&rci, o - rseq); + } + } else { + const oid *o = (const oid *) Tloc(l, 0); + for (lo = 0, hi = BATcount(l); lo < hi; lo++) { + if (o[lo] < rseq || o[lo] >= rend) { + if (is_oid_nil(o[lo])) { + bt[lo] = oid_nil; + bn->tnonil = false; + bn->tnil = true; + } else { + GDKerror("BATproject: does not match always\n"); + return GDK_FAIL; + } + } else { + bt[lo] = canditer_idx(&rci, o[lo] - rseq); + } + } + } + BATsetcount(bn, lo); + return GDK_SUCCEED; +} + +static gdk_return project_any(BAT *bn, BAT *l, struct canditer *restrict ci, BAT *r, bool nilcheck) { BUN lo, hi; @@ -317,8 +364,11 @@ BATproject(BAT *l, BAT *r) break; #endif case TYPE_oid: - if (r->ttype == TYPE_void) { + if (BATtdense(r)) { res = project_void(bn, l, lci, r); + } else if (r->ttype == TYPE_void) { + assert(r->tvheap != NULL); + res = project_cand(bn, l, lci, r); } else {
MonetDB: candidate-exceptions - Candidate iterator fixes.
Changeset: b45fdc33d39f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b45fdc33d39f Modified Files: gdk/gdk_bat.c gdk/gdk_search.c monetdb5/modules/mal/pcre.c sql/backends/monet5/generator/generator.c Branch: candidate-exceptions Log Message: Candidate iterator fixes. diffs (truncated from 338 to 300 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1489,7 +1489,9 @@ BUNfnd(BAT *b, const void *v) if (!v) return r; if (b->ttype == TYPE_void && b->tvheap != NULL) { - /* must be a candidate list with exceptions */ + struct canditer ci; + canditer_init(&ci, NULL, b); + return canditer_search(&ci, * (const oid *) v, false); } if (BATtvoid(b)) return BUNfndVOID(b, v); diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c --- a/gdk/gdk_search.c +++ b/gdk/gdk_search.c @@ -385,6 +385,11 @@ SORTfnd(BAT *b, const void *v) return *(oid*)v - b->tseqbase; } if (b->ttype == TYPE_void) { + if (b->tvheap) { + struct canditer ci; + canditer_init(&ci, NULL, b); + return canditer_search(&ci, *(const oid*)v, false); + } assert(is_oid_nil(b->tseqbase)); if (is_oid_nil(*(const oid *) v)) return 0; @@ -423,6 +428,11 @@ SORTfndfirst(BAT *b, const void *v) return *(oid*)v - b->tseqbase; } if (b->ttype == TYPE_void) { + if (b->tvheap) { + struct canditer ci; + canditer_init(&ci, NULL, b); + return canditer_search(&ci, *(const oid*)v, true); + } assert(is_oid_nil(b->tseqbase)); return 0; } @@ -458,6 +468,11 @@ SORTfndlast(BAT *b, const void *v) return *(oid*)v - b->tseqbase; } if (b->ttype == TYPE_void) { + if (b->tvheap) { + struct canditer ci; + canditer_init(&ci, NULL, b); + return canditer_search(&ci, *(const oid*)v + 1, true); + } assert(is_oid_nil(b->tseqbase)); return BATcount(b); } diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -544,7 +544,6 @@ pcre_compile_wrap(pcre **res, const char v = BUNtvar(bi, r); \ if (TEST) \ bunfastappTYPE(oid, bn, &o); \ - p++; \ } \ } while (0) @@ -585,6 +584,9 @@ pcre_likeselect(BAT **bnp, BAT *b, BAT * BUN p, q; oid o, off; const char *v; + struct canditer ci; + + canditer_init(&ci, b, s); assert(ATOMstorage(b->ttype) == TYPE_str); @@ -611,7 +613,7 @@ pcre_likeselect(BAT **bnp, BAT *b, BAT * OPERATION_FAILED ": compilation of pattern \"%s\" failed\n", pat); } #endif - bn = COLnew(0, TYPE_oid, s ? BATcount(s) : BATcount(b), TRANSIENT); + bn = COLnew(0, TYPE_oid, ci.ncand, TRANSIENT); if (bn == NULL) { #ifdef HAVE_LIBPCRE pcre_free_study(pe); @@ -624,11 +626,8 @@ pcre_likeselect(BAT **bnp, BAT *b, BAT * off = b->hseqbase; if (s && !BATtdense(s)) { - struct canditer ci; BUN r; - canditer_init(&ci, b, s); - #ifdef HAVE_LIBPCRE #define BODY (pcre_exec(re, pe, v, (int) strlen(v), 0, 0, ovector, 9) >= 0) #else diff --git a/sql/backends/monet5/generator/generator.c b/sql/backends/monet5/generator/generator.c --- a/sql/backends/monet5/generator/generator.c +++ b/sql/backends/monet5/generator/generator.c @@ -24,12 +24,14 @@ /* * The noop simply means that we keep the properties for the generator object. */ -#define VLTnoop(TPE)\ - { TPE s;\ - s = pci->argc == 3 ? 1: *getArgReference_##TPE(stk,pci, 3);\ - zeroerror = (s == 0);\ - nullerr = is_##TPE##_nil(s);\ - } +#define VLTnoop(TPE) \ + do {\
MonetDB: candidate-exceptions - Candidate iterator cleaup.
Changeset: 96bae12b0d9a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=96bae12b0d9a Modified Files: gdk/gdk.h gdk/gdk_aggr.c gdk/gdk_batop.c gdk/gdk_cand.c gdk/gdk_cross.c gdk/gdk_hash.c gdk/gdk_private.h gdk/gdk_select.c monetdb5/mal/mal_interpreter.c monetdb5/modules/mal/pcre.c Branch: candidate-exceptions Log Message: Candidate iterator cleaup. diffs (154 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -2779,7 +2779,6 @@ gdk_export BAT *BATunique(BAT *b, BAT *s gdk_export BAT *BATmergecand(BAT *a, BAT *b); gdk_export BAT *BATintersectcand(BAT *a, BAT *b); gdk_export BAT *BATdiffcand(BAT *a, BAT *b); -gdk_export bool BATcandcontains(BAT *s, oid o); gdk_export gdk_return BATfirstn(BAT **topn, BAT **gids, BAT *b, BAT *cands, BAT *grps, BUN n, bool asc, bool nilslast, bool distinct) __attribute__((__warn_unused_result__)); diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -8,7 +8,6 @@ #include "monetdb_config.h" #include "gdk.h" -#include "gdk_cand.h" #include "gdk_private.h" #include "gdk_calc_private.h" #include diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -17,7 +17,6 @@ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" -#include "gdk_cand.h" gdk_return unshare_string_heap(BAT *b) diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -327,40 +327,6 @@ binsearchcand(const oid *cand, BUN hi, o return hi; } -bool -BATcandcontains(BAT *s, oid o) -{ - BUN p; - - if (s == NULL) - return true; - - assert(ATOMtype(s->ttype) == TYPE_oid); - assert(s->tsorted); - assert(s->tkey); - assert(s->tnonil); - - if (BATcount(s) == 0) - return false; - if (s->ttype == TYPE_void && s->tvheap) { - assert(s->tvheap->free % SIZEOF_OID == 0); - BUN nexc = (BUN) (s->tvheap->free / SIZEOF_OID); - if (o < s->tseqbase || - o >= s->tseqbase + BATcount(s) + nexc) - return false; - const oid *exc = (const oid *) s->tvheap->base; - if (nexc > 0) { - p = binsearchcand(exc, nexc - 1, o); - return p == nexc || exc[p] != o; - } - } - if (BATtdense(s)) - return s->tseqbase <= o && o < s->tseqbase + BATcount(s); - const oid *oids = Tloc(s, 0); - p = binsearchcand(oids, BATcount(s) - 1, o); - return p != BATcount(s) && oids[p] == o; -} - /* initialize a candidate iterator, return number of iterations */ BUN canditer_init(struct canditer *ci, BAT *b, BAT *s) diff --git a/gdk/gdk_cross.c b/gdk/gdk_cross.c --- a/gdk/gdk_cross.c +++ b/gdk/gdk_cross.c @@ -9,7 +9,6 @@ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" -#include "gdk_cand.h" /* Calculate a cross product between bats l and r with optional * candidate lists sl for l and sr for r. diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c --- a/gdk/gdk_hash.c +++ b/gdk/gdk_hash.c @@ -34,7 +34,6 @@ #include "monetdb_config.h" #include "gdk.h" -#include "gdk_cand.h" #include "gdk_private.h" static int diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -262,7 +262,7 @@ stpconcat(char *restrict dst, const char b->hseqbase,\ ATOMname(b->ttype), \ !b->batTransient ? "P" : isVIEW(b) ? "V" : "T", \ - BATtdense(b) ? "D" : "",\ + BATtdense(b) ? "D" : b->ttype == TYPE_void && b->tvheap ? "X" :"", \ b->tsorted ? "S" : "", \ b->trevsorted ? "R" : "", \ b->tkey ? "K" : "", \ @@ -282,7 +282,7 @@ stpconcat(char *restrict dst, const char b ? ATOMname(b->ttype) : "",\ b ? "]" : "", \ b ? !b->batTransient ? "P" : isVIEW(b) ? "V" : "T" : "", \ - b && BATtdense(b) ? "D" : "", \ + b && BATtdense(b) ? "D" : b && b->ttype == TYPE_void && b->tvheap ? "X" :"", \ b && b->tsorted ? "S" : "", \ b && b->trevsorted ? "R" : "", \ b && b->tkey ? "K" : "",\ diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -8,7 +8,6 @@ #include "monetdb_config.h" #include "gdk.h" -#include "gdk_cand.h" #include "gdk_private.h" #include diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c --- a/monetdb5/mal/mal
monetdb-java: default - Add a utility method to close objects ig...
Changeset: 8cc3b51d1984 for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=8cc3b51d1984 Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java Branch: default Log Message: Add a utility method to close objects ignoring any possible SQLExceptions thrown. Use it in finally clauses to reduce object code. diffs (149 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -1332,16 +1332,7 @@ public class MonetConnection } /* ignore stmt errors/exceptions, we are only testing if the connection is still alive and usable */ } finally { - if (rs != null) { - try { - rs.close(); - } catch (Exception e2) { /* ignore error */ } - } - if (stmt != null) { - try { - stmt.close(); - } catch (Exception e2) { /* ignore error */ } - } + closeResultsetStatement(rs, stmt); } return isValid; } @@ -1511,11 +1502,7 @@ public class MonetConnection st.execute("SET SCHEMA \"" + schema + "\""); // do not catch any Exception, just let it propagate } finally { - if (st != null) { - try { -st.close(); - } catch (SQLException e) { /* ignore */ } - } + closeResultsetStatement(null, st); } } @@ -1546,16 +1533,7 @@ public class MonetConnection } // do not catch any Exception, just let it propagate } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { /* ignore */ } - } - if (st != null) { - try { -st.close(); - } catch (SQLException e) { /* ignore */ } - } + closeResultsetStatement(rs, st); } if (cur_schema == null) throw new SQLException("Failed to fetch schema name", "02000"); @@ -1728,22 +1706,34 @@ public class MonetConnection } catch (SQLException se) { /* ignore */ } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { /* ignore */ } - } - if (stmt != null) { - try { -stmt.close(); - } catch (SQLException e) { /* ignore */ } - } + closeResultsetStatement(rs, stmt); } // for debug: System.out.println("testTableExists(" + tablename + ") returns: " + exists); return exists; } /** +* Closes a ResultSet and/or Statement object without throwing any SQLExceptions +* It can be used in the finally clause after creating a Statement and +* (optionally) executed a query which produced a ResultSet. +* +* @param rs ResultSet object to be closed. It may be null +* @param st Statement object to be closed. It may be null +*/ + static final void closeResultsetStatement(final ResultSet rs, final Statement st) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { /* ignore */ } + } + if (st != null) { + try { + st.close(); + } catch (SQLException e) { /* ignore */ } + } + } + + /** * Sends the given string to MonetDB as special transaction command. * All possible returned information is discarded. * Encountered errors are reported. diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/ma
monetdb-java: default - Resolve javac -Xlint warnings when compi...
Changeset: 59bc8bebbfe9 for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=59bc8bebbfe9 Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java tests/Bug_PrepStmtSetString_6382.java Branch: default Log Message: Resolve javac -Xlint warnings when compiled on Java 9 or higher nl/cwi/monetdb/jdbc/MonetPreparedStatement.java:1823: warning: [deprecation] ROUND_HALF_UP in BigDecimal has been deprecated setLong(parameterIndex, bd.setScale(scale, BigDecimal.ROUND_HALF_UP).longValue()); ^ nl/cwi/monetdb/jdbc/MonetPreparedStatement.java:1823: warning: [deprecation] setScale(int,int) in BigDecimal has been deprecated setLong(parameterIndex, bd.setScale(scale, BigDecimal.ROUND_HALF_UP).longValue()); ^ nl/cwi/monetdb/jdbc/MonetPreparedStatement.java:2631: warning: [deprecation] finalize() in Object has been deprecated protected void finalize() { ^ nl/cwi/monetdb/mcl/net/MapiSocket.java:1085: warning: [deprecation] finalize() in Object has been deprecated protected void finalize() throws Throwable { ^ nl/cwi/monetdb/mcl/net/MapiSocket.java:1087: warning: [deprecation] finalize() in Object has been deprecated super.finalize(); ^ tests/Bug_PrepStmtSetString_6382.java:85: warning: [deprecation] Integer(int) in Integer has been deprecated pstmt.setObject(1, new Integer(row)); ^ diffs (60 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java @@ -1820,7 +1820,7 @@ public class MonetPreparedStatement case Types.BIGINT: if (x instanceof BigDecimal) { BigDecimal bd = (BigDecimal)x; - setLong(parameterIndex, bd.setScale(scale, BigDecimal.ROUND_HALF_UP).longValue()); + setLong(parameterIndex, bd.setScale(scale, java.math.RoundingMode.HALF_UP).longValue()); } else { setLong(parameterIndex, num.longValue()); } @@ -2561,7 +2561,7 @@ public class MonetPreparedStatement * Note: This stream object can either be a standard Java stream object or * your own subclass that implements the standard interface. * -* @deprecated +* @deprecated Use setCharacterStream * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x a java.io.InputStream object that contains the Unicode * parameter value as two-byte Unicode characters @@ -2626,8 +2626,11 @@ public class MonetPreparedStatement /** * Call close to release the server-sided handle for this * PreparedStatement. +* +* @deprecated (since="9") */ @Override + @Deprecated protected void finalize() { close(); } diff --git a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java b/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java --- a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java @@ -1080,8 +1080,11 @@ public final class MapiSocket { * Destructor called by garbage collector before destroying this * object tries to disconnect the MonetDB connection if it has not * been disconnected already. +* +* @deprecated (since="9") */ @Override + @Deprecated protected void finalize() throws Throwable { close(); super.finalize(); diff --git a/tests/Bug_PrepStmtSetString_6382.java b/tests/Bug_PrepStmtSetString_6382.java --- a/tests/Bug_PrepStmtSetString_6382.java +++ b/tests/Bug_PrepStmtSetString_6382.java @@ -82,7 +82,7 @@ public class Bug_PrepStmtSetString_6382 /* also test generic setObject(int, String) */ row++; // row 7 - pstmt.setObject(1, new Integer(row)); + pstmt.setObject(1, Integer.valueOf​(row)); pstmt.setObject(2, "row " + row); pstmt.setObject(3, "{\"menu\": {
monetdb-java: default - Added table aliases and use them in all ...
Changeset: 1b6c514106ce for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=1b6c514106ce Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java Branch: default Log Message: Added table aliases and use them in all meta data SQL queries to reduce query size. Also use JOIN syntax in FROM clause instead of old way of joining in WHERE clause. This further reduces size. In getIndexInfo() no longer issue a SELECT COUNT(*) query when the schema or table name contains wildcard: %. In getIndexInfo() added missing join condition AND i.\"table_id\" = k.\"table_id\" to make sure the index and the key constraint both reference the same table and extended the output to also lists info for primary keys (which also use an internal hash index). diffs (truncated from 891 to 300 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @@ -21,7 +21,7 @@ import java.sql.Types; * A DatabaseMetaData object suitable for the MonetDB database. * * @author Fabian Groffen, Martin van Dinther - * @version 0.7 + * @version 0.8 */ public class MonetDatabaseMetaData extends MonetWrapper @@ -957,7 +957,7 @@ public class MonetDatabaseMetaData * primary and foreign keys with the requirement that no foreign key row may be inserted or * updated unless a matching primary key row exists. Check clauses allow specification of * inter-column constraints to be maintained by the database system. -* Default clauses provide optional default values for missing data. +* Default clauses provide optional default values for missing data. * * We currently do not supprt CHECK constraints (see bug 3568) nor deferrable FK constraints. * @@ -1714,22 +1714,22 @@ public class MonetDatabaseMetaData final boolean useCommentsTable = ((MonetConnection)con).commentsTableExists(); final StringBuilder query = new StringBuilder(980); query.append("SELECT cast(null as char(1)) AS \"PROCEDURE_CAT\", " + - "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " + - "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " + + "s.\"name\" AS \"PROCEDURE_SCHEM\", " + + "f.\"name\" AS \"PROCEDURE_NAME\", " + "cast(null as char(1)) AS \"Field4\", " + "cast(null as char(1)) AS \"Field5\", " + "cast(null as char(1)) AS \"Field6\", ") - .append(useCommentsTable ? "COALESCE(\"comments\".\"remark\", cast(\"functions\".\"func\" as varchar()))" : "cast(\"functions\".\"func\" as varchar())").append(" AS \"REMARKS\", " + + .append(useCommentsTable ? "COALESCE(cm.\"remark\", cast(f.\"func\" as varchar()))" : "cast(f.\"func\" as varchar())").append(" AS \"REMARKS\", " + // in MonetDB procedures have no return value by design. "cast(").append(DatabaseMetaData.procedureNoResult).append(" AS smallint) AS \"PROCEDURE_TYPE\", " + // only the id value uniquely identifies a procedure. Include it to be able to differentiate between multiple overloaded procedures with the same name - "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " + - "FROM \"sys\".\"functions\" JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") "); + "cast(f.\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " + + "FROM \"sys\".\"functions\" f JOIN \"sys\".\"schemas\" s ON (f.\"schema_id\" = s.\"id\") "); if (useCommentsTable) { - query.append("LEFT OUTER JOIN \"sys\".\"comments\" ON (\"functions\".\"id\" = \"comments\".\"id\") "); + query.append("LEFT OUTER JOIN \"sys\".\"comments\" cm ON (f.\"id\" = cm.\"id\") "); } // include procedures only (type = 2). Others will be returned via getFunctions() - query.append("WHERE \"functions\".\"type\" = 2"); + query.append("WHERE f.\"type\" = 2"); if (catalog != null && !catalog.isEmpty()) { // non-empty catalog selection. @@ -1737,10 +1737,10 @@ public class MonetDatabaseMetaData query.append(" AND 1 = 0"); } else { if (schemaPattern != null) { - query.append(" AND \"schemas\".\"name\" ").append(composeMatchPart(schemaPattern)); + query.append(" AND s.\"name\" ").append(composeMatchPart(s
monetdb-java: default - Small code and doc improvements. Moved h...
Changeset: a91168efdf27 for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=a91168efdf27 Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java Branch: default Log Message: Small code and doc improvements. Moved helper functions to the bottom. diffs (198 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @@ -74,7 +74,6 @@ public class MonetDatabaseMetaData // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_max_clients: " + env_max_clients); } - /** * Internal utility method to create a Statement object, execute a query and return the ResulSet object which allows scrolling. * As the Statement object is created internally (the caller does not see it and thus can not close it), @@ -225,8 +224,10 @@ public class MonetDatabaseMetaData public String getDatabaseProductVersion() throws SQLException { if (env_monet_version == null) getEnvValues(); + if (env_monet_version != null) + return env_monet_version; // always return a valid String to prevent NPE in getTables() and getTableTypes() - return (env_monet_version != null) ? env_monet_version : ""; + return ""; } /** @@ -1877,46 +1878,6 @@ public class MonetDatabaseMetaData return executeMetaDataQuery(query.toString()); } - - //== this is a helper method which does not belong to the interface - - /** -* Returns a SQL match part string where depending on the input value we -* compose an exact match (use =) or match with wildcards (use LIKE) or IS NULL -* -* @param in the string to match -* @return the SQL match part string -*/ - private static final String composeMatchPart(final String in) { - if (in == null) - return "IS NULL"; - - String sql = "= '"; - // check if SQL wildcards are used in the input, if so use LIKE - if (in.contains("%") || in.contains("_")) - sql = "LIKE '"; - - // all slashes and single quotes in input are escaped with a slash. - final String escaped = in.replaceAll("", "").replaceAll("'", "'"); - - return sql + escaped + "'"; - } - - /** -* Returns the given string between two double quotes for usage as -* exact column or table name in SQL queries. -* -* @param in the string to quote -* @return the quoted string -*/ -// @SuppressWarnings("unused") -// private static final String dq(String in) { -// return "\"" + in.replaceAll("", "").replaceAll("\"", "\"") + "\""; -// } - - //== end helper methods - - /** * Retrieves a description of the tables available in the given catalog. * Only table descriptions matching the catalog, schema, table name and type criteria are returned. @@ -2104,8 +2065,8 @@ public class MonetDatabaseMetaData } /** -* Get the table types available in this database. The results -* are ordered by table type. +* Get the table types available in this database. +* The results are ordered by table type. * * The table type is: * @@ -2114,25 +2075,24 @@ public class MonetDatabaseMetaData * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". * * -* @return ResultSet each row has a single String column that is a -* table type +* @return ResultSet each row has a single String column that is a table type * @throws SQLException if a database error occurs */ @Override public ResultSet getTableTypes() throws SQLException { // as of Jul2015 release we have a new table: sys.table_types with more table types + String query = "SELECT \"table_type_name\" AS \"TABLE_TYPE\" FROM \"sys\".\"table_types\" ORDER BY 1"; + // For old (pre jul2015) servers fall back to old behavior. - final boolean preJul2015 = ("11.19.15".compareTo(getDatabaseProductVersion()) >= 0); - final String query = preJul2015 - ? "SELECT 'SESSION TABLE' AS \"TABLE_TYPE\" UNION ALL " + - "SELECT 'SESSION VIEW' UNION ALL " + - "SELECT 'SYSTEM SESSION TABLE' UNION ALL " + - "SELECT 'SYSTEM SE
MonetDB: candidate-exceptions - Use linear scan.
Changeset: ba7fe8cd0d72 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ba7fe8cd0d72 Modified Files: gdk/gdk.h gdk/gdk_cand.c Branch: candidate-exceptions Log Message: Use linear scan. The weird binary search didn't work so great. diffs (60 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1254,26 +1254,10 @@ BUNtoid(BAT *b, BUN p) return o; } const oid *exc = (oid *) b->tvheap->base; - if (o < exc[0]) { - /* before first exception */ - return o; - } - BUN hi = nexc - 1; - if (o + hi >= exc[hi]) { - /* after last exception */ - return o + nexc; - } - BUN lo = 0; - /* perform binary search on exception list -* loop invariant: o + lo <= exc[lo] && o + hi > exc[hi] */ - while (lo + 1 < hi) { - BUN mid = (lo + hi) / 2; - if (o + mid <= exc[mid]) - lo = mid; - else - hi = mid; - } - return o + hi; + for (BUN i = 0; i < nexc; i++) + if (o + i < exc[i]) + return o + i; + return o + nexc; } static inline BATiter diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -667,18 +667,10 @@ canditer_idx(struct canditer *ci, BUN p) return o; if (o + ci->noids > ci->oids[ci->noids - 1]) return o + ci->noids; - /* perform binary search on exception list -* loop invariant: -* o + lo <= ci->oids[lo] && o + hi > ci->oids[hi] */ - BUN lo = 0, hi = ci->noids - 1; - while (lo + 1 < hi) { - BUN mid = (lo + hi) / 2; - if (o + mid <= ci->oids[mid]) - lo = mid; - else - hi = mid; - } - return o + hi; + for (BUN i = 0; i < ci->noids; i++) + if (o + i < ci->oids[i]) + return o + i; + return o + ci->noids; } void ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list