[DGD] Re: Clones and very large arrays
Robert Forshaw
iouswuoibev at hotmail.com
Sun Apr 4 17:08:04 CEST 2004
>From: Par Winzell <zell at skotos.net>
>Yes, they are, at least to some extent. I believe the contract with the
>driver is that references last as long as you stay either inside one thread
>or inside one object. In other words, if you store a reference in one
>object, export it to another, and the thread ends, DGD reserves the right
>to create a private copy of the mapping/array in the other object. So you
>can't keep long-term references to data inside another object.
Are there any other data structures that are, or can be passed by reference,
or is it just mappings and objects?
>As for the iterator, there's a lot of ways you could implement it. There
>are two basic kinds of iterators in the world; one that promises it will
>capture the state of the data-structure when iterator() is called and so
>even if the data structure itself changes later, the iterator will still
>enumerate precisely what was there when the snapshot was made...
>
>... and one kind of iterator that makes no such promise. Obviously the
>former kind has to either use more memory, or special tricks. If you don't
>mind the iterator using a fair bit of memory (temporarily) you can simply
>let the iterator LWO make a private copy of the bigmap, keep two index
>counters (one to index the mapping of mappings, one to index the current
>inner mapping), and step through the whole thing step by step as next() is
>called.
I would have thought this method to be quicker than the find_object method
you described.
>The nice bit about generalized iterators is that you are free to vary your
>internal implementation both of the datastructure and of the iterator as
>you please. All the caller cares about is being returned an object that
>keeps track of the iteration state. For example, the Skotos
>all-clones-of-a-certain-clonable data structure uses a SINGLE mapping only.
But you still use bigmaps to store the actual clones, right?
>If the number of clones of a clonable grows beyound 1024 or so (maybe we
>use 2048 or 4096), we just empty the data structure (!). Why? Because DGD
>offers a second method to enumerate all the clones of a given clonable,
>namly find_object().
>
>Thus, for clonables with lots of clones, we return an iterator that reads
>basically:
>
>
>string clonable;
>object next;
>int ix;
>
>static atomic
>void configure(string str) {
> clonable = str;
> ix = 1; forward();
>}
>
>int has_next() {
> return !!next;
>}
>
>object next() {
> if (next) {
> object ob;
>
> ob = next;
> forward();
>
> return ob;
> }
> error("read past end");
>}
>
>private
>void forward() {
> while (ix <= status()[ST_OTABSZ]) {
> next = find_object(clonable + "#" + ix);
> ix ++;
>
> if (next) {
> return next;
> }
> }
> next = nil;
>}
So as I understand it, the iterator is just a way of retrieving the contents
of the datastructure?
I'd like to go back to a question I made earlier,
>As I think about a linked list and the implied inefficiency (assuming I
>understand it right) I am also wondering what the purpose of storing a list
>of clones would be. Initially it was 'just because', I imagined I'd need
>the
>information stored, but really I've never been sure about what situation
>knowing what an objects' clones are would be useful.
And Bart mentioned that it is a useful method of getting rid of 'stray
clones'. Unfortunately I don't see how. If you have a 'stray clone' lying
around, how are you going to spot it from within a gigantic datastructure?
Also, as people left me with the impression that they don't often recall the
entire list of clones (those who use linked lists), what kind of useful
information are they deriving from it?
Ideally I'd like to see an example, or perhaps two, of where the ability to
retrieve a list of clones that a cloneable has would be useful. I'm
especially confused by the idea of a stray-clone; if it is 'stray' that
means it is not being looked after and kept track of - but since it is not
being kept a track of, how do you know anything about it, including whether
it is a 'stray' or not? The answer probably lies in the fact that all clones
are kept in a nice little array, mapping, bigmap or whatever, but that
doesn't make it any easier to identify the 'stray'.
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list