[ANN] nmap-0.1.0 (narray + mmap = persistant grids)

A

Ara.T.Howard

NAME

nmap (reference ruby class which combines narray and mmap)
na_str (c extension)

REQUIREMENTS

mmap : http://moulon.inra.fr/ruby/mmap.html
narray : http://narray.rubyforge.org/

URIS

http://codeforpeople.com/lib/ruby/nmap/


SYNOPSIS

na_str is designed to allow data sharing between narray object and other ruby
objects. the shared data is that returned by the objects to_s or to_str method
and rb_string_new4. using this technique memory mapped (using guy's mmap
extensions) data can be altered with no explicit io on the users part and
partial changed to numerical grids can occur very quickly and persistently.

the nmap.rb reference impl is a concrete example of this usage and is
included in the distribution.


EXAMPLE USAGE

jib:~/eg/ruby/na_str > cat a.rb
#
# the nmap extension is installed along with na_str
#
require 'nmap'
#
# the NMap ctor interface is similar to NArray's, but a backing file must also
# be specified
#
path, x, y = 'int.data', 3, 4
nmap = NMap.int path, x, y
#
# copy the last row to the first
#
nmap.na[true, 0] = nmap.na[true, 3]
#
# set the last row to be the current time. if you run this a few times you'll
# notice that changes to the narray are automatically written to the to
# backing file via the magic of mmap
#
nmap.na[true, 3] = Time.now.to_i
#
# show the narray
#
p nmap.na


jib:~/eg/ruby/na_str > ruby a.rb
NArray(ref).int(3,4):
[ [ 0, 0, 0 ],
[ 0, 0, 0 ],
[ 0, 0, 0 ],
[ 1151439012, 1151439012, 1151439012 ] ]

jib:~/eg/ruby/na_str > ruby a.rb
NArray(ref).int(3,4):
[ [ 1151439012, 1151439012, 1151439012 ],
[ 0, 0, 0 ],
[ 0, 0, 0 ],
[ 1151439014, 1151439014, 1151439014 ] ]


SPEED

jib:~/eg/ruby/na_str > cat a.rb
#
# reference impl installed with na_str
#
require 'nmap'
#
# setup a narray grid containing 1 gb of ints
#
gb = 2 ** 30
mb = 2 ** 20
sizeof_int = [42].pack('i').size
gig_of_ints = gb / sizeof_int
nmap = NMap.int '1GB', gig_of_ints
#
# set about 1 million of the ints to 42
#
nmap.na[0 .. mb] = 42
#
# show that the data was written
#
p nmap.na[mb - 1]


jib:~/eg/ruby/na_str > time ruby a.rb
42

real 0m0.078s
user 0m0.020s
sys 0m0.020s


jib:~/eg/ruby/na_str > ls -ltar 1GB
-rw-rw-r-- 1 ahoward ahoward 1073741824 Jun 27 14:28 1GB


highly experimental. enjoy.

-a
 
J

Joel VanderWerf

Ara.T.Howard said:
NAME

nmap (reference ruby class which combines narray and mmap)

Ara, have you considered a name that won't get confused with the nmap
utility? Someone might want to write a ruby-nmap for port scanning etc.
 
A

ara.t.howard

Ara, have you considered a name that won't get confused with the nmap
utility? Someone might want to write a ruby-nmap for port scanning etc.

um. no. never heard of that! suggestions?

na_map?

-a
 
P

Phrogz

ohhhh. i like.

"Meeeemray
All alone, in the moonlight.
I can smile at the old days.
When my tests were not Zen.

I remember
The time I knew not what Narrays were
Let the memray live again"
 
A

ara.t.howard

"Meeeemray
All alone, in the moonlight.
I can smile at the old days.
When my tests were not Zen.

I remember
The time I knew not what Narrays were
Let the memray live again"

LOL!

-a
 
T

Tim Pease

One of these days, we'll have to name something eigeneigen.

eigeneigen = lambda {|obj| class << obj; class << self; self; end; end}

Should I make a gem?

TwP
 

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

Similar Threads

[ANN] nmap-1.1.0 3
using narray and mmap with HUGE data sets 0
[SOLUTION] Whiteout (#34) 0
[ANN] traits-0.1.0 1
ANN main-4.4.0 0
[ANN] arrayfields-4.3.0 2
[ANN] main-4.0.0 (for avdi) 0
[ANN] main-3.0.1 0

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top