From: Javier Valencia Date: 2006-05-21T15:07:48+09:00 Subject: Re: Drb and PStore behaviour Joel VanderWerf wrote: >Javier Valencia wrote: > > >>I'm doing a remote database object so i can do: >> >>result = database.find do |record| >> record[:name] == "john" >>end >> >>in the server object i have something like: >> >>class Foo >> include DRb::DRbUndumped >> >> def find(&block) >> >> > ^^^^^^ >You don't need this, since you are using yield. > > > >> result = nil >> @store.transaction do >> result = @store[:records].find_all do |record| >> yield(record) >> end >> end >> return result >> end >>end >> >>well, the problem is yielding that block. All the database is >>"cloned/copied" (?) over the network when doing the find. I don't want >>to copy all that data, just return the found records. >> >> > >Yielding to a DRb client is not itself a problem. The block stays on the >client side. In some cases that's ok, but in this case, it generates too >much traffic because every record iterated over by find_all is >serialized to the client, so that the client can call the block on it. > > > >>I tried adding DRb::DRbUndumped to class PStore, but the same result. >>The database size is about 3 MB. >> >> > >I doubt the database object as a whole is being serialized, just each >record individually. > >Maybe you want do define query objects and pass them as an argument to find? > >result = database.find(QueryEqual.new(:name, "john")) > >Then only the query object and the results need to get serialized. > > > Interesting point, i'll try it. And thanks for the correction.