Changeset: 9fa383fb0c33 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9fa383fb0c33 Modified Files: clients/Tests/MAL-signatures_all.stable.out clients/Tests/MAL-signatures_fits_geom.stable.out clients/Tests/MAL-signatures_geom.stable.out clients/Tests/MAL-signatures_none.stable.out clients/Tests/exports.stable.out monetdb5/modules/atoms/json.c monetdb5/modules/atoms/json.h monetdb5/modules/atoms/json.mal Branch: Oct2014 Log Message:
json.filter() / JSONfilterArray(): fixed bug 3538: type-polymorphic MAL functions need proper type handling in their C implementation! diffs (286 lines): diff --git a/clients/Tests/MAL-signatures_all.stable.out b/clients/Tests/MAL-signatures_all.stable.out --- a/clients/Tests/MAL-signatures_all.stable.out +++ b/clients/Tests/MAL-signatures_all.stable.out @@ -39473,23 +39473,23 @@ address JSONfold; comment Combine the key-value pairs into a single json object list. command json.filter(name:json,idx:lng,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_lng; comment Extract a single array element command json.filter(name:json,idx:lng):json -address JSONfilterArray; +address JSONfilterArray_lng; command json.filter(name:json,idx:int,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_int; command json.filter(name:json,idx:int):json -address JSONfilterArray; +address JSONfilterArray_int; command json.filter(name:json,idx:sht,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_sht; command json.filter(name:json,idx:sht):json -address JSONfilterArray; +address JSONfilterArray_sht; command json.filter(name:json,idx:bte,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_bte; command json.filter(name:json,idx:bte):json -address JSONfilterArray; +address JSONfilterArray_bte; command json.filter(name:json,pathexpr:str):json address JSONfilter; comment Filter all members of an object by a path expression, returning an array.Non-matching elements are skipped. diff --git a/clients/Tests/MAL-signatures_fits_geom.stable.out b/clients/Tests/MAL-signatures_fits_geom.stable.out --- a/clients/Tests/MAL-signatures_fits_geom.stable.out +++ b/clients/Tests/MAL-signatures_fits_geom.stable.out @@ -39389,23 +39389,23 @@ address JSONfold; comment Combine the key-value pairs into a single json object list. command json.filter(name:json,idx:lng,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_lng; comment Extract a single array element command json.filter(name:json,idx:lng):json -address JSONfilterArray; +address JSONfilterArray_lng; command json.filter(name:json,idx:int,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_int; command json.filter(name:json,idx:int):json -address JSONfilterArray; +address JSONfilterArray_int; command json.filter(name:json,idx:sht,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_sht; command json.filter(name:json,idx:sht):json -address JSONfilterArray; +address JSONfilterArray_sht; command json.filter(name:json,idx:bte,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_bte; command json.filter(name:json,idx:bte):json -address JSONfilterArray; +address JSONfilterArray_bte; command json.filter(name:json,pathexpr:str):json address JSONfilter; comment Filter all members of an object by a path expression, returning an array.Non-matching elements are skipped. diff --git a/clients/Tests/MAL-signatures_geom.stable.out b/clients/Tests/MAL-signatures_geom.stable.out --- a/clients/Tests/MAL-signatures_geom.stable.out +++ b/clients/Tests/MAL-signatures_geom.stable.out @@ -39365,23 +39365,23 @@ address JSONfold; comment Combine the key-value pairs into a single json object list. command json.filter(name:json,idx:lng,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_lng; comment Extract a single array element command json.filter(name:json,idx:lng):json -address JSONfilterArray; +address JSONfilterArray_lng; command json.filter(name:json,idx:int,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_int; command json.filter(name:json,idx:int):json -address JSONfilterArray; +address JSONfilterArray_int; command json.filter(name:json,idx:sht,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_sht; command json.filter(name:json,idx:sht):json -address JSONfilterArray; +address JSONfilterArray_sht; command json.filter(name:json,idx:bte,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_bte; command json.filter(name:json,idx:bte):json -address JSONfilterArray; +address JSONfilterArray_bte; command json.filter(name:json,pathexpr:str):json address JSONfilter; comment Filter all members of an object by a path expression, returning an array.Non-matching elements are skipped. diff --git a/clients/Tests/MAL-signatures_none.stable.out b/clients/Tests/MAL-signatures_none.stable.out --- a/clients/Tests/MAL-signatures_none.stable.out +++ b/clients/Tests/MAL-signatures_none.stable.out @@ -39194,23 +39194,23 @@ address JSONfold; comment Combine the key-value pairs into a single json object list. command json.filter(name:json,idx:lng,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_lng; comment Extract a single array element command json.filter(name:json,idx:lng):json -address JSONfilterArray; +address JSONfilterArray_lng; command json.filter(name:json,idx:int,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_int; command json.filter(name:json,idx:int):json -address JSONfilterArray; +address JSONfilterArray_int; command json.filter(name:json,idx:sht,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_sht; command json.filter(name:json,idx:sht):json -address JSONfilterArray; +address JSONfilterArray_sht; command json.filter(name:json,idx:bte,other:str):json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_bte; command json.filter(name:json,idx:bte):json -address JSONfilterArray; +address JSONfilterArray_bte; command json.filter(name:json,pathexpr:str):json address JSONfilter; comment Filter all members of an object by a path expression, returning an array.Non-matching elements are skipped. 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 @@ -1383,8 +1383,14 @@ str ITRnext_oid(oid *i, oid *step, oid * str ITRnext_sht(sht *i, sht *step, sht *last); str JSONdump(int *ret, json *val); str JSONfilter(json *ret, json *js, str *expr); -str JSONfilterArray(json *ret, json *j, int *index); -str JSONfilterArrayDefault(json *ret, json *j, int *index, str *other); +str JSONfilterArrayDefault_bte(json *ret, json *j, bte *index, str *other); +str JSONfilterArrayDefault_int(json *ret, json *j, int *index, str *other); +str JSONfilterArrayDefault_lng(json *ret, json *j, lng *index, str *other); +str JSONfilterArrayDefault_sht(json *ret, json *j, sht *index, str *other); +str JSONfilterArray_bte(json *ret, json *j, bte *index); +str JSONfilterArray_int(json *ret, json *j, int *index); +str JSONfilterArray_lng(json *ret, json *j, lng *index); +str JSONfilterArray_sht(json *ret, json *j, sht *index); str JSONfold(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); int JSONfromString(str src, int *len, json *x); str JSONgroupStr(str *ret, const bat *bid); diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -841,21 +841,60 @@ JSONlength(int *ret, json *j) return MAL_SUCCEED; } -str -JSONfilterArray(json *ret, json *js, int *index) +static str +JSONfilterArrayDefault(json *ret, json *js, lng index, str other) { - char expr[BUFSIZ], *s = expr; - snprintf(expr,BUFSIZ,"[%d]",*index); - return JSONfilterInternal(ret, js, &s, 0); + snprintf(expr,BUFSIZ,"["LLFMT"]",index); + return JSONfilterInternal(ret, js, &s, other); } str -JSONfilterArrayDefault(json *ret, json *js, int *index, str *other) +JSONfilterArray_bte(json *ret, json *js, bte *index) { - char expr[BUFSIZ], *s = expr; - snprintf(expr,BUFSIZ,"[%d]",*index); - return JSONfilterInternal(ret, js, &s, *other); + return JSONfilterArrayDefault(ret, js, (lng) *index, 0); +} + +str +JSONfilterArrayDefault_bte(json *ret, json *js, bte *index, str *other) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, *other); +} + +str +JSONfilterArray_sht(json *ret, json *js, sht *index) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, 0); +} + +str +JSONfilterArrayDefault_sht(json *ret, json *js, sht *index, str *other) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, *other); +} + +str +JSONfilterArray_int(json *ret, json *js, int *index) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, 0); +} + +str +JSONfilterArrayDefault_int(json *ret, json *js, int *index, str *other) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, *other); +} + +str +JSONfilterArray_lng(json *ret, json *js, lng *index) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, 0); +} + +str +JSONfilterArrayDefault_lng(json *ret, json *js, lng *index, str *other) +{ + return JSONfilterArrayDefault(ret, js, (lng) *index, *other); } str diff --git a/monetdb5/modules/atoms/json.h b/monetdb5/modules/atoms/json.h --- a/monetdb5/modules/atoms/json.h +++ b/monetdb5/modules/atoms/json.h @@ -79,8 +79,14 @@ json_export str JSONjson2number(dbl *ret json_export str JSONjson2integer(lng *ret, json *arg); json_export str JSONfilter( json *ret, json *js, str *expr); -json_export str JSONfilterArray(json *ret, json *j, int *index); -json_export str JSONfilterArrayDefault(json *ret, json *j, int *index, str *other); +json_export str JSONfilterArray_bte(json *ret, json *j, bte *index); +json_export str JSONfilterArrayDefault_bte(json *ret, json *j, bte *index, str *other); +json_export str JSONfilterArray_sht(json *ret, json *j, sht *index); +json_export str JSONfilterArrayDefault_sht(json *ret, json *j, sht *index, str *other); +json_export str JSONfilterArray_int(json *ret, json *j, int *index); +json_export str JSONfilterArrayDefault_int(json *ret, json *j, int *index, str *other); +json_export str JSONfilterArray_lng(json *ret, json *j, lng *index); +json_export str JSONfilterArrayDefault_lng(json *ret, json *j, lng *index, str *other); json_export str JSONisvalid(bit *ret, json *j); json_export str JSONisobject(bit *ret, json *j); diff --git a/monetdb5/modules/atoms/json.mal b/monetdb5/modules/atoms/json.mal --- a/monetdb5/modules/atoms/json.mal +++ b/monetdb5/modules/atoms/json.mal @@ -66,21 +66,21 @@ comment "Filter all members of an object Non-matching elements are skipped."; command filter(name:json, idx:bte) :json -address JSONfilterArray; +address JSONfilterArray_bte; command filter(name:json, idx:bte,other:str) :json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_bte; command filter(name:json, idx:sht) :json -address JSONfilterArray; +address JSONfilterArray_sht; command filter(name:json, idx:sht,other:str) :json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_sht; command filter(name:json, idx:int) :json -address JSONfilterArray; +address JSONfilterArray_int; command filter(name:json, idx:int, other:str) :json -address JSONfilterArrayDefault; +address JSONfilterArrayDefault_int; command filter(name:json, idx:lng) :json -address JSONfilterArray; +address JSONfilterArray_lng; command filter(name:json, idx:lng, other:str) :json -address JSONfilterArrayDefault +address JSONfilterArrayDefault_lng comment "Extract a single array element"; command isvalid(val:json):bit _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list