Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: mysql-protocol

From: tim:johnsons-web at: 7-Mar-2004 16:51

* Hallvard Ystad <[hallvard--ystad--oops-as--no]> [040307 15:20]:
> Hi, > > This is a late reply to a message from june last year. > > Dixit Tim Johnson (16.54 26.06.2003): > >Hello Rebols: > > DocKimbel and I had an OT exchange of emails early > >this year in which I posed the the following: > >That it would be convenient at times for me to have > >the selection set from a query returned as a 'flat' > >block. > > > >DocKimbel made the following code suggestions: > > > >Add 'flat' to locals-class. setting as either 'true > >or 'false. > > > >in 'convert-types change the following line > >if not empty? convert-body [foreach row rows :convert-body] > >;to > > if not empty? convert-body [ > > either p/locals/flat? [ > > row: rows > > forskip row length? cols :convert-body > > ][foreach row rows :convert-body] > > ] > >After implementing this - if memory serves me well - > >DocKimbel indicated that he had observed less memory fragmentation > >in comparison of the two methods. > > Why change in 'convert-types? Couldn't one just as well change these lines in 'read-rows: > row: make block! cols > parse/all/case row-data [any [read-field (append row field)]] > append/only rows row > to > either port/locals/flat? [ > parse/all/case row-data [any [read-field (append rows field)]] > ] [ > row: make block! cols > parse/all/case row-data [any [read-field (append row field)]] > append/only rows row > ] > ? I'm ignorant. Please tell me what way is the best.
<Grin>I'm sorry, but I can't. I'm currently using version 0.9.9 And below are the changes I have made: ; ====================================================================================================== locals-class: make object! [ ; original words here ... flat?: true ; add by Tim Johnson ] ; ====================================================================================================== convert-types: func [p [port!] rows [block!] /local row i convert-body action cols col conv-func tmp ][ cols: p/locals/columns convert-body: make block! 1 action: [if tmp: sys-pick row (i)] foreach col cols [ i: index? find cols col if 'none <> conv-func: select p/locals/conv-list col/type [ append convert-body append/only compose action head sys-insert at compose [change at row (i) :tmp] 5 conv-func ] ] ;if not empty? convert-body [foreach row rows :convert-body] ; replaced below by Tim Johnson ; Begin Replacement by Tim Johnson if not empty? convert-body [ ; this and rest of function changed by Tim Johnson either p/locals/flat? [ row: rows forskip row length? cols :convert-body ][foreach row rows :convert-body] ] ; End Replacement by Tim Johnson ] ; ====================================================================================================== read-rows: func [port [port!] /part n [integer!] /local row-data row rows cols count ][ ; rows: make block! max any [n 0] port/locals/rows ; replaced by Tim Johnson ; cols: length? port/locals/columns ; replaced by Tim Johnson ; Begin Replacement by Tim Johnson row-count: max any [n 0] port/locals/rows cols: length? port/locals/columns rows: make block! either port/locals/flat? [row-count * cols][row-count] ; End Replacement count: 0 forever [ row-data: read-packet-via port if empty? row-data [return []] ; empty set row: make block! cols parse/all/case row-data [any [read-field (append row field)]] ; append/only rows row ; this line replaced by line below: Tim Johnson either port/locals/flat? [append rows row][append/only rows row] if port/locals/stream-end? or all [part n = count: count + 1][break] ; end of stream or rows # reached ] if port/locals/auto-conv? [convert-types port rows] recycle ; lot of garbage to recycle here ! :) rows ] -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com