# Nmap-1.1.0

**URL:** <https://www.ruby-forum.com/t/nmap-1-1-0/192175>\
**Category:** Ruby\
**Created:** [July 25, 2010, 5:33pm UTC](https://www.ruby-forum.com/t/nmap-1-1-0/192175 "2010-07-25T17:33:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahoward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@ahoward](https://www.ruby-forum.com/u/ahoward)\
**Post date:** [July 25, 2010, 5:33pm UTC](https://www.ruby-forum.com/t/nmap-1-1-0/192175/1 "2010-07-25T17:33:08Z")

</div>

NAME

nmap (reference ruby class which combines narray and mmap)  
na\_str (c extension)

REQUIREMENTS

mmap : [http://moulon.inra.fr/ruby/mmap.html](http://moulon.inra.fr/ruby/mmap.html)  
narray : [http://narray.rubyforge.org/](http://narray.rubyforge.org/)

URIS

[http://codeforpeople.com/lib/ruby/nmap/](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

---

<div class="post-metadata">

**Author:** ![ahoward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@ahoward](https://www.ruby-forum.com/u/ahoward)\
**Post date:** [July 25, 2010, 6:18pm UTC](https://www.ruby-forum.com/t/nmap-1-1-0/192175/2 "2010-07-25T18:18:47Z")

</div>

On Sun, Jul 25, 2010 at 11:24 PM, ara.t.howard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> nmap (reference ruby class which combines narray and mmap)

this uver cool, but i am lost. is that v 1.1.0 or 0.1.0?  
do you have gem for this?  
best regards -botp

---

<div class="post-metadata">

**Author:** ![ahoward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@ahoward](https://www.ruby-forum.com/u/ahoward)\
**Post date:** [July 27, 2010, 6:31pm UTC](https://www.ruby-forum.com/t/nmap-1-1-0/192175/3 "2010-07-27T18:31:07Z")

</div>

eeks. it’s 1.1.0

[GitHub - ahoward/nmap: narray + mmap = wicked fast persistent numerical arrays for ruby](http://github.com/ahoward/nmap)

the gem is here (search for ‘nmap’ on the page)

[http://rubyforge.org/frs/?group\_id=1024&release\_id=44198](http://rubyforge.org/frs/?group_id=1024&release_id=44198)

ps. as i’ve mentioned to nick/tom/eric - gem syncing is, and has  
been, broken ever since the move to gemcutter. i think i’m the only  
one who seems to notice/care - but it’s never worked and many, many  
gems, including this one, have been orphaned since then or, worse,  
stale versions are being served.

cfp:~ \> gem list|grep nmap  
nmap (1.1.0, 1.0.0)

cfp:~ \> gem list --remote|grep nmap  
nmap (0.1.0)  
…

fyi.

---

<div class="post-metadata">

**Author:** ![ahoward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@ahoward](https://www.ruby-forum.com/u/ahoward)\
**Post date:** [July 28, 2010, 12:49am UTC](https://www.ruby-forum.com/t/nmap-1-1-0/192175/4 "2010-07-28T00:49:21Z")

</div>

ara.t.howard wrote:

> eeks. it’s 1.1.0
> 
> [GitHub - ahoward/nmap: narray + mmap = wicked fast persistent numerical arrays for ruby](http://github.com/ahoward/nmap)
> 
> the gem is here (search for ‘nmap’ on the page)
> 
> [http://rubyforge.org/frs/?group\_id=1024&release\_id=44198](http://rubyforge.org/frs/?group_id=1024&release_id=44198)

Any idea why narray.h doesn’t get found (or more to the point, why the  
narray header dir doesn’t get put on the include path)?

This is via “gem install na\_str-0.1.0.gem”, with the gem downloaded from  
the above link:

Makefile:134: warning: overriding commands for target  
`/usr/local/lib/ruby/gems/1.8/gems/na_str-0.1.0/lib' Makefile:132: warning: ignoring old commands for target `/usr/local/lib/ruby/gems/1.8/gems/na\_str-0.1.0/lib’  
gcc -I. -I/usr/local/lib/ruby/1.8/x86\_64-linux  
-I/usr/local/lib/ruby/1.8/x86\_64-linux -I. -fPIC -g -O2 -I  
/usr/local/lib/ruby/site\_ruby/1.8/x86\_64-linux -c na\_str.c  
na\_str.c:3:20: error: narray.h: No such file or directory  
na\_str.c:4:27: error: narray\_config.h: No such file or directory

The extconf.rb assumes that narray is in sitearchdir, but  
my narray is installed as a gem and its headers are at:

/usr/local/lib/ruby/gems/1.8/gems/narray-0.5.9.7/narray.h  
/usr/local/lib/ruby/gems/1.8/gems/narray-0.5.9.7/src/narray.h

Does anyone know how to tell extconf to look for headers in the gem  
dirs?
