[Pharo-project] Why Sets need to be rehashed when loading them from an ImageSegment?
siguctua at gmail.com
Mon Jan 10 07:25:18 EST 2011
#foo identityHash in one image
and same #foo identityHash
in another image could be different, because
these symbols could be interned in different time(s).
So, if you have a identity set or identity dictionary which using
symbols as keys,
which is often the case , you need to rehash them.
Just tried it
#awdqedqwd identityHash 633602048
#awdqedqwd identityHash 398196736
note that i specifically picked the symbol, which is not yet interned
(not exists) in image.
Obviously, you cannot change the identityHash of symbol(s) which
already present in image,
because you don't know where it used outside of object(s) you are loading.
On 10 January 2011 10:51, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
> Hi. I was almost sure that Set instances that were written in an
> ImageSegment, needed to be rehashed once they are swap in. And I even
> thought I was understanding why. But now, I don't understand at all why is
> that. I would really appreciate anyway that can give me a hint.
> So...ImageSegment rehashes all Set instances (at loading time) that were
> written in an ImageSegment, and then exported with ReferenceStream. Notice
> that this rehash is finally called from ImageSegment >> comeFullyUpOnReload:
> When you export an ImageSegment with a reference stream, you also serializer
> the "outPointers" array. This is usually the case when you want to load the
> object subgraph in another image or when do it backups so that to start with
> a clean image. Notice that the Set rehash only occurs in this case. If we
> use ImageSegment just to swap out / in, there is no Set rehash.
> So...I think that this has something to do about WHY Set instances need to
> be rehashed.
> For each object ImageSegment write into the file, it writes both: object
> header + slots. So....the hash (12 bits in the object header) is copied.
> When the object is loaded back, it continues to have the same hash. It
> doesn't change.
> So...if hash doesn't change, why Set instances need to be rehashes when they
> come back from an ImageSegment?
> Thanks in advance,
Igor Stasenko AKA sig.
More information about the Pharo-dev