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

Another hash! question

 [1/3] from: m:s:licholai:ieee at: 28-Jan-2002 19:43


In the past several weeks there have been several discussions about the hash! datatype and I hate to start another one, but as I was playing with speeding up some scripts and timing results I found some aspects of hash! behavior I cannot explain. It seems that when repeatedly (over 1000 times) using find on sparse hash! block then changing the next item I get incorrect behavior or system lock ups. When using a regular block! the code runs fine, but replacing the block! with a hash! causes problems. Here is code I have been using to try to determine the source problem (try making sum-data a hash! instead of a block!): stats: func [ data ][ ; sum-data: make hash! 100 sum-data: copy [] forskip data 2 [ id: first data this-time: second data either (datum: find/skip sum-data id 3) [ total-nr: 1 + second datum total-spent: this-time + third datum change datum: next datum :total-nr change next datum :total-spent ][ append sum-data :id append sum-data 1 append sum-data this-time ] ] sps: " " print ["id count sum"] forskip sum-data 3 [ print [first sum-data sps second sum-data sps third sum-data] ] ] I ran the above code with this test harness: REBOL [] print "prep data" random/seed now/time/precise test-blk: copy [] t-blk: ["t1" "t2" "t3" "t8" "t876" "u76"] loop 1000 [ id: first random t-blk append append test-blk id random 100 ] print "process" stats test-blk Does anyone have any suggestions? Is the problem in writing to the hash! such a large number of times? Recognizing that inserting values into a hash is not efficient, but is there another other choice for a fast associative data structure? Puzzled, Matt

 [2/3] from: joel::neely::fedex::com at: 27-Jan-2002 17:23


Hi, Matt, [m--s--licholai--ieee--org] wrote:
> It seems that when repeatedly (over 1000 times) using find on sparse > hash! block then changing the next item I get incorrect behavior or > system lock ups... >
I reran your test using REBOL/Core 2.5.0.3.1 and got a fatal error on REBOL when using the HASH! version. It looks like a real bug to me. I suggest you report it to feedback. -jn- -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;

 [3/3] from: rotenca:telvia:it at: 28-Jan-2002 1:25


Hi, Matt
> It seems that when repeatedly (over 1000 times) using find on sparse > hash! block then changing the next item I get incorrect behavior or > system lock ups. When using a regular block! the code runs fine, > but replacing the block! with a hash! causes problems. Here is > code I have been using to try to determine the source problem > (try making sum-data a hash! instead of a block!):
It seems to me a bug of the 'change native that manifest itself with the 'next native. --- Ciao Romano