World: r3wp
[!REBOL3-OLD1]
older newer | first last |
[unknown: 5] 9-Feb-2009 [10822x2] | >> c: make vector! [32 100] == vector! >> c/1 == 0 >> c/1: 100000 == 100000 >> c/2: 200000 == 200000 >> c/1 == 100000 >> c/2 == 200000 >> to-block c == [vector!] |
the last piece seems abnormal to me. | |
Oldes 9-Feb-2009 [10824] | I don't think is't ready already. Also map! still has some issues. |
BrianH 9-Feb-2009 [10825x3] | Map! has issues for now (see CureCode), and the traversal thing is being worked on. Vector! is almost completely nonfunctional now. |
There are plans to extend FOREACH to map! and object!, and MAP could make sense too I suppose, but no plans for that. What did you use hash! for that wasn't keyed search, Doc, and what advantages did it give you over block! aside from a different datatype? | |
Also, don't forget user-defined datatypes. We are only including the most useful datatypes by default - you will be able to add your own later once we have user-defined datatypes. | |
Dockimbel 9-Feb-2009 [10828] | Multiple keys pointing on the same data (I'm using traversal to locate the value once the key is found). I guess that using map!, it would require to duplicate the value for each key? |
BrianH 9-Feb-2009 [10829] | No, just duplicate *references* to the same value. |
Pavel 9-Feb-2009 [10830] | Paul if I understand documentation Vector must be one type (homogenous) ie good for file pointer, bad for records (multiple type) |
BrianH 9-Feb-2009 [10831] | It only becomes duplicate values if the value is not a reference type (numbers, characters, etc.). |
Dockimbel 9-Feb-2009 [10832] | Brian: Good to know. |
BrianH 9-Feb-2009 [10833] | Pavel, yes, the homogenous type is the only main difference relative to blocks. Only use vectors if you need that, else use blocks. |
Dockimbel 9-Feb-2009 [10834] | So, if I understand correctly, map! offers a superset of hash! features (without giving up anything)? |
Pavel 9-Feb-2009 [10835] | Not bad if the performance would be good (especially for quite large pointer table to database file), save in size was already mentioned |
BrianH 9-Feb-2009 [10836x2] | You give up position and persistent ordering, and in theory you also give up duplicate keys though there is a bug ticket about that. |
You also have to conform to the key/value pattern. Map! is more comparable to object! nowadays. | |
Pavel 9-Feb-2009 [10838] | Doc question arise when large insert into large table comes, in hash inserting is the slower the bigger is table (maybe even nonlinear) |
BrianH 9-Feb-2009 [10839x2] | It can be key/[block of values] though. |
We are extending support of many of the functions that people traditionally associated with series to objects and maps, without making them into series. So that means that APPEND works, but INSERT doesn't because of the position stuff. | |
Pavel 9-Feb-2009 [10841] | For Map also limit about 500000 items was mentioned, it suggest an idea use Map in pagged manner. Ie for larger set use multiple Maps rather fixed size in the manner of cache. |
Dockimbel 9-Feb-2009 [10842] | Pavel: is map! any better in that case? |
Pavel 9-Feb-2009 [10843] | I have no exact comparison all mentioned is only ideas |
BrianH 9-Feb-2009 [10844] | SELECT works on object! and map! but FIND doesn't. PICK and POKE work, but they take keys rather than indexes. There are some (at this point undocumented) limits on what can be used as keys too (at least you can't use a block as a key in practice), but that may be a bug. |
Dockimbel 9-Feb-2009 [10845] | Lot of new exceptions to remember... |
Pavel 9-Feb-2009 [10846] | Brian Block as key would be good for reversed index IMO. Question if it would be usefull. |
BrianH 9-Feb-2009 [10847] | Well, in some cases to fix, but yes, lots of exceptions. The guideline is that maps and objects don't have position, but series do. So the position-dependent functions don't work but their non-position-dependent counterparts do. Ports don't work like series either, so there is another whole set of differences to remember. |
Dockimbel 9-Feb-2009 [10848] | Good point Pavel, how does map! handle the key/key case? (being able to exchange the role of key<=>value). Would it require to use two map! to being able to do fast lookups in both cases? So n-tuple stored => n map! value to hash everything? |
BrianH 9-Feb-2009 [10849x2] | Pavel, the problem is that we can't hash complex structures (for now) so there is no advantage to using them as keys. I want a keys-of function though that returns a block of the keys that reference a value (by same? semantics for the value, perhaps). |
The words-of function already returns *all* of the keys of a map!, just like it does for objects. | |
Pavel 9-Feb-2009 [10851] | I dont want to use keys in this way (difficult keys) the opposite is true, keys should be simplest possible. |
BrianH 9-Feb-2009 [10852] | Well then you have no problem then :) |
Pavel 9-Feb-2009 [10853x3] | Doc I think so |
But it is not necessary week point if the design of data would be good | |
Anyway it leads to multiple lookup when data is difficult | |
BrianH 9-Feb-2009 [10856x2] | I agree, Doc, that sounds like a good plan. Map! storage and implementation is in theory more efficient than hash!, so having two of them shouldn't be a problem, as long as your wrapper functions keep track of the mirroring. |
The only trick is that you remember that none means nothing, so don't bother with a none key. The theory of map! is either: - Keys that are associated with none don't exist in the map!, so assigning none to a key makes it go away. - All possible keys are in the map! but only the ones associated with something other than none are displayed. There is no difference between these two theories in practice, and whether there is memory allocated for keys that you can't see is an implementation detail that is irrelevant to the use of map! (though there is usually not). | |
Steeve 9-Feb-2009 [10858] | something related, in the past i made some tests to simulate hashs with integer keys in R2. I used a bitset as an index, mixed with block of blocks to store data. my tests show that for 10000 records, finding data is near as fast as with hashs. actually it's incomplete but you have the idea with this: REBOL [] f: fast-dic: context [ size: 100000 hash: 128 - 1 ;** hash size speed up the search, must be a power of 2 - 1 (ie. 15, 31, 63, 127, 257 ...) master: copy/deep head insert/dup/only [] [] hash + 1 index: make bitset! size flag: func [idx [integer!]][ unless find index idx [ insert index idx insert/only insert tail pick master idx and hash + 1 idx copy [] ] ] flag?: func [idx [integer!]][find index idx] deflag: func [idx [integer!]][ remove/part index idx remove/part find pick master idx and hash + 1 idx 2 ] ] t: now/time/precise loop 10000 bind [flag random 99999] f print now/time/precise - t t: now/time/precise loop 10000 bind [flag? random 99999] f print now/time/precise - t |
GiuseppeC 9-Feb-2009 [10859] | Just a question. Is there a way to rappresent Unicode Characters inside a string with an escape sequence ? |
BrianH 9-Feb-2009 [10860x2] | ^(hex characters) . The console may not render the character properly if the font doesn't support it though - it may look like a space. |
Same as R2, but you can provide more hex characters. | |
[unknown: 5] 9-Feb-2009 [10862] | Yes Pavel, that is the way it looks to me also regarding the vector. |
BrianH 9-Feb-2009 [10863] | Yeah, vector! doesn't work yet. There are a lot of tickets for vector!, all deferred. That to-block bug is not there, but not unexpected. |
[unknown: 5] 9-Feb-2009 [10864x2] | Brian, I think we need to address the lack of list in R3. Maybe a list like handling of block data that still returns a block. |
at the performance level of list. | |
BrianH 9-Feb-2009 [10866x4] | I think that would be an excellent thing to address with a user-defined datatype. |
People in general didn't use list!, because of the bugs and because block! was good enough for most uses. We haven't felt its lack for a year now. Most of the advantage of list! in regular code was handled by allowing insert and remove at the head of a block! to expand or contract the block, just like it does at the end, without a block copy. Just by making block! more efficient for inserts and removes, we have made list! even less necessary. | |
For that matter, you can make blocks even faster by getting rid of list!, just by enabling more optimizations. | |
The real advantage of list! wasn't the speed though, it was the alias persistancy. That was the source of the bugs in list! too. | |
Rebolek 9-Feb-2009 [10870] | I tested vector! extensively about one and half year ago. Not much changed, I think. The BIGGEST problem with vector! is that it's zero based. |
BrianH 9-Feb-2009 [10871] | Trust me, vector! has bigger problems than that right now. I expect that it will not end up 0-based though, even with all of the advantages that 0-based vectors give us. It is likely that we will instead have 0-based versions of PICK and POKE that work on all series. |
older newer | first last |