[ANN] Find

  • Thread starter Bertram Scharpf
  • Start date
D

Daniel Berger

Time to merge stuff into Ruby proper if so many (...) people see the need
to improve the aparently meager features of the built-in find?
*t

My experience on ruby-core tells me that the odds of getting the
radical changes we would want into the stdlib are about nil unless
there's a general outcry.

Regards,

Dan
 
G

gga

Both seem complementary. Bertram has sorting built-in and is not
backwards compatible.

After a quick look, Bertram's code also has silly inefficient things
like:
dir = (Dir.open @fullpath do |d| d.entries end) - SPECIAL_DIRS
which can just be:
dir = Dir.entries(@fullpath) - SPECIAL_DIRS
and the Etc module may be checked several times depending on what you
request.

Daniel's has searching based on different much more rich criteria and
also breaks backwards compatibility. It lacks sorting and the docs
lack simple examples. I did not check the code yet.
 
B

Bertram Scharpf

Hi,

Am Montag, 08. Okt 2007, 20:35:04 +0900 schrieb gga:
Both seem complementary. Bertram has sorting built-in and is not
backwards compatible.

After a quick look, Bertram's code also has silly inefficient things
like:
dir = (Dir.open @fullpath do |d| d.entries end) - SPECIAL_DIRS
which can just be:
dir = Dir.entries(@fullpath) - SPECIAL_DIRS
Argh!

and the Etc module may be checked several times depending on what you
request.

I already corrected this yesterday and upload it now.

Bertram
 
A

ara.t.howard

Hi,

the Ruby built-in Find module lacks a lot of features the
GNU find tools has. I wrote a new one (~170 lines).

<http://www.bertram-scharpf.de/tmp/find.rb>

Maybe somebody likes it.

this is one of the very smallest directories i am working with:

[cfadmin@yacht cfadmin]$ find /mnt/yacht0/data/night_files/|wc -l
69287


[cfadmin@yacht cfadmin]$ ruby a.rb
user system total real
bertram.scharpf.find 2.140000 1.230000 3.370000 ( 7.602333)
alib.util.find 1.360000 0.440000 1.800000 ( 1.812519)


[cfadmin@yacht cfadmin]$ cat a.rb
require 'benchmark'
require 'alib'
require 'bertram.scharpf.find.rb'

top = '/mnt/yacht0/data/night_files/'

Benchmark.bm do |b|
b.report('bertram.scharpf.find'){ Find.open(top){|x|} }
b.report('alib.util.find'){ alib.util.find(top){|x|} }
end


also there is alib.util.find2 which yields the stat together with the
path, preventing and extra stat on the pathname. in practice doing
something like

def method_missing m, *a, &b
stat.send m, *a, &b
end

means you have to use a ton of code since it's possible that

f.size ### no error
f.mtime ### ENOENT

btw mine

http://codeforpeople.com/lib/ruby/alib/alib-0.5.0/lib/alib-0.5.0/
find2.rb

isn't a spectacular implementation, it is based on Motoyuki
Kasahara's 2001 lib, which used to be on the raa, called find2 - but
it's reasonably fast, does depth and breath, caches stats, and
handles files evaporation from the filesystem or not being accessible
due to permissions errors.

i think all these libraries prove that a new find mechanism needs to
be incorporated into the stdlib! we should take the best features
from all the various libs and propose a new library that is backward
compatible with the built-in find.


kind regards.

a @ http://codeforpeople.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,344
Members
48,020
Latest member
upendra1234

Latest Threads

Top