- improvements to subsequence and translate/replace   as suggested by Jan Rittinger:
- improvements to subsequence and translate/replace
  as suggested by Jan Rittinger:



You however ignore the return code of the first two arguments and just
assume that they are DBL and not NORMAL. Some operators can only return
their results in NORMAL mode. Thus we *always* have to support the
NORMAL version (-- the other variants are only optimizations).

>
> Now I put an assert in the replace/translate code to only work for VALUES.
> Is actually possible that the strictly xs:string typed functions
> replace/translate will ever be called with NORMAL?
> If so, is there an easy way to convert STR to NORMAL?

Yes -- just use 'addValues'.

e.g. if your result is in a MIL variable 'str_res' just add:
         if (code == NORMAL)
             addValues (f, str_container(), "str_res", "item");
         else
             milprintf(f, "item%s := str_res;\n", item_ext);

>
> Peter
>
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
> retrieving revision 1.284
> diff -r1.284 milprint_summer.c
> 240c240
> <         return "";
> ---
>>         mps_error ("kind_str: VALUES is no valid reference.");
> 4984a4985,4986
>>     assert(code == VALUES);
>>
> 5118c5120
> <     return VALUES;
> ---
>>     return STR;
> 7205c7207
> <                         kind_str(code), kind_str(code), counter-1);
> ---
>>                         kind_str(rc), kind_str(rc), counter-1);
> 7226c7228
> <                 "}\n", kind_str(code), kind_str(code));
> ---
>>                 "}\n", kind_str(rc), kind_str(rc));
>
>
>
> -----Original Message-----
> From: Jan Rittinger [mailto:rittinge@in.tum.de]
> Sent: 18 October 2006 09:24
> To: Peter Boncz
> Cc: monetdb-pf-checkins@lists.sourceforge.net
> Subject: Re: [Monetdb-pf-checkins] pathfinder/compiler/mil
> milprint_summer.c, 1.283, 1.284
>
>
> Hi Peter,
>
> could you please roll back this checkin. The code is there to check for
> inconsistencies. By just ignoring error messages and removing them you
> will probably get into trouble!!
>
> Perhaps it would be better to look into the translation of
> fn_replace_translate and subsequence. These are at least two places
> where the code does not match the intended behaviour.
>
> Just a small recap:
> I introduced the VALUES, NORMAL, INT, ... codes to avoid a lot of
> mapping between value containers (if the next consumer already needs the
> values again). Thus translate2MIL() has a code parameter as input (which
> is the required representation of the ouput) and also returns a code
> (that refers to the BAT the item values are stored).
>
> The input code is either NORMAL (store values in the container), NODE
> (return values in document representation - pre|size|level|kind|...), or
> VALUES (return the real values instead of a reference).
>
> The output code is either NORMAL (values *are* stored in the container),
> NODE (the result *is* returned in document representation), STR (values
> *are* returned as strings in the BAT item_str_), INT (values *are*
> returned as integers in the BAT item_int_), ...
>
> What you shouldn't find in the output code is VALUES!! This is the
> reason for the error message!
>
> In practice you have to collect the return codes and use these output
> codes for processing (e.g., in kind_str in subsequence) as well as
> return the correct output code for the BATs you are generating (see
> fn_replace_translate).
>
> Jan
>
> On 10/18/2006 01:56 AM, Peter Boncz wrote with possible deletions:
>> Update of /cvsroot/monetdb/pathfinder/compiler/mil
>> In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20738/compiler/mil
>>
>> Modified Files:
>> 	milprint_summer.c
>> Log Message:
>>
>>
>> Index: milprint_summer.c
>> ===================================================================
>> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
>> retrieving revision 1.283
>> retrieving revision 1.284
>> diff -u -d -r1.283 -r1.284
>> --- milprint_summer.c	7 Oct 2006 01:21:52 -0000	1.283
>> +++ milprint_summer.c	17 Oct 2006 23:56:07 -0000	1.284
>> @@ -237,7 +237,7 @@
>>      else if (i == NODE)
>>          mps_error ("kind_str: NODE is no valid reference.");
>>      else if (i == VALUES)
>> -        mps_error ("kind_str: VALUES is no valid reference.");
>> +        return "";
>>      else
>>          mps_error ("kind_str: no valid reference (%i).", i);
>>
>>

zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb