r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Graham
19-Apr-2007
[7645x2]
or, even send-page copy data mime
rather than mutating, we say "altering" :)
Terry
19-Apr-2007
[7647x2]
actually it worked fine the original way.. problem was  i set the 
out: "test" within tiny server's try block
sorry, not try.. in it's ANY[] block
Graham
19-Apr-2007
[7649]
whatever
Ladislav
19-Apr-2007
[7650]
:-)
Terry
19-Apr-2007
[7651x2]
so.. any [ out: "test"    send-page out mime] 
well.. out: "test" is any, isn't it ;)
but thanks for the quick response
Graham
19-Apr-2007
[7653x2]
I like that ... have a  "whatever [ ..  ] "
yes, so send-page never gets executed
Terry
19-Apr-2007
[7655]
hehe
Graham
19-Apr-2007
[7656x2]
send-page also doesn't return anything
you probably meant 

all [ out: "test" blah .. ]
Terry
19-Apr-2007
[7658x2]
here's another question..
if you have a block like so.. 

aaa: [bbb[ccc "string"]]


do the 'words  take up memory?  is there a limit to the number of 
'words in a block?
Sunanda
19-Apr-2007
[7660]
length? first system/words
== 1245
   aaa: [bbb[ccc "string"]]
== [bbb [ccc "string"]]
   length? first system/words
== 1248


Max words is around 8192 (varies by version). Note that 1000 or so 
are taken up when you start.
Terry
19-Apr-2007
[7661]
hmm, so that's not very practical way of storing a large flat DB 
?
Graham
19-Apr-2007
[7662]
Ashley's rebdb is an in memory db
Sunanda
19-Apr-2007
[7663]
That's *unique* words, not total words used

You can have as many aaa's as you like in different contexts; it 
adds only 1 to system/words
Terry
19-Apr-2007
[7664x3]
yeah.. i just need a simple hash table
but i like the  aaa/bbb/ccc  path syntax
a dictionary , for example..   cat ["def of cat" ] dog ["def of dog"]
run out of words real quick
Sunanda
19-Apr-2007
[7667]
But you may need to use strings or some other form of identifier 
-- REBOL words are rationed.
Terry
19-Apr-2007
[7668x2]
yeah
but then you lose the path syntax.
Sunanda
19-Apr-2007
[7670]
Use ordinals, then you can  go up to maximum integer with path syntax:
  database/1/234/4454/655/3

Slight problem there: when you delete things you have to leave empty 
slots or change all numbers.
Terry
19-Apr-2007
[7671]
given they would act as keys.. that would be more than a 'slight' 
problem
Sunanda
19-Apr-2007
[7672]
There's always a design trade-off.

I have various systems where real keys (usually strings) are mapped 
to surrogate keys (usually integers). It's a good compromise in many 
cases.
Terry
19-Apr-2007
[7673]
What is THE best way to store a large hash table in memory  like 
a dictionary, .. and access the data?
Henrik
19-Apr-2007
[7674]
terry, about accessing data, there is a speed issue with doing so 
with using indexes with paths, so data/2 is much slower than second 
data or pick data 2. that should solve at least that aspect.
Sunanda
19-Apr-2007
[7675]
Not sure there is one best way.....I have a structure that has 158,000 
keys indexing 120,000 documents. All in  memory. 
The index (when loaded) is nearly 6meg.

The code uses nested tables, hashes, surrogate keys and a couple 
of other tricks devised for the purpose.

It's worth playing with approaches. You can normally expect a  ten 
fold improvement between initial ideas and later improvements.
Terry
19-Apr-2007
[7676x5]
yeah, i see that just pokin around with some data now..
I take it your keys are string?
Just thinknig that even Carl's tiny web server, that loads the www 
content into a hash table would be a very fast server
Don't even need mod-rewrites.. just intercept the GET request and 
take it from there
I've been working with Apache and PHP quite a bit, and it just feels 
really bloated.
Oldes
19-Apr-2007
[7681]
Is there any reason why to write for example: [ b: make block! 100 
] instead of just  [ b: copy [] ] ?
Gabriele
19-Apr-2007
[7682]
make block! 100 means that you can insert at least 98 values before 
a reallocation is needed
Sunanda
19-Apr-2007
[7683]
Whereas.

copy [] reserves some other number (you can find out, more-or-less, 
by close observation of stats)
Gabriele
19-Apr-2007
[7684x3]
(the difference is an implementation quirk)
i mean the diff between 100 and 98
to say it another way, as long as length? b is less than 98, insert 
tail b is guaranteed to be O(1)
Oldes
19-Apr-2007
[7687]
it looks, that the copy is faster a little bit, at least if I don't 
know how big the block can be, so it's probably better to use copy 
[] (if I don't know precise size):

>> tm 1000 [b: make block! 20000 loop 5 [insert/dup tail b 0 1000]]
0:00:00.907
>> tm 1000 [b: make block! 200 loop 5 [insert/dup tail b 0 1000]]
0:00:00.453
>> tm 1000 [b: copy [] loop 5 [insert/dup tail b 0 1000]]
0:00:00.437

>> tm 1000 [b: make block! 5002 loop 5 [insert/dup tail b 0 1000]]
0:00:00.343
Geomol
19-Apr-2007
[7688]
Try do it several times and take the average.
Henrik
19-Apr-2007
[7689]
perhaps also make block! is easier to garbage collect?
Graham
20-Apr-2007
[7690]
Is there a rebol based wiki that has versioning?
Rebolek
20-Apr-2007
[7691]
This seems at least inconsistent to me:

>> to integer! none
== 0
>> to decimal! none
** Script Error: Invalid argument: none
** Near: to decimal! none
Henrik
20-Apr-2007
[7692]
also happens with empty strings
Gabriele
20-Apr-2007
[7693x2]
rebolek: i believe that is on rambo already. if not, feel free to 
add it.
oldes: i would guess that make block! n also clears the allocated 
memory, so it may be slower than a reallocation if you are using 
something like insert/dup etc. i think that when reallocating, the 
size is always doubled, up to a limit after which it is increased 
linearly.