Add an instance variable in object class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Add an instance variable in object class

Frederic Pluquet-3
Hi,

For performance reasons I want to add an instance variable in the  
object class. But when I add this one the message "Byte-type objects  
cannot have named instance variables. Do you want to continue ?"  
appears. If I chose "Yes", the same message appears yet, and yet, ...

What is the problem ? How can I add an instance variable in the  
Object class in a smart way ?

Best regards,

Pluquet Frédéric
Reply | Threaded
Open this post in threaded view
|

AW: Add an instance variable in object class

Georg Heeg
Frédéric,

The answer is simple: You can't.

What shall this instance variable provide, that each and every object in the
entire system should have it?

Georg

-----Ursprüngliche Nachricht-----
Von: Frédéric Pluquet [mailto:[hidden email]]
Gesendet: Dienstag, 29. August 2006 15:10
An: vwnc
Betreff: Add an instance variable in object class

Hi,

For performance reasons I want to add an instance variable in the  
object class. But when I add this one the message "Byte-type objects  
cannot have named instance variables. Do you want to continue ?"  
appears. If I chose "Yes", the same message appears yet, and yet, ...

What is the problem ? How can I add an instance variable in the  
Object class in a smart way ?

Best regards,

Pluquet Frédéric

Reply | Threaded
Open this post in threaded view
|

Re: Add an instance variable in object class

Reinout Heeck-2
In reply to this post by Frederic Pluquet-3
Frédéric Pluquet wrote:
>
> For performance reasons I want to add an instance variable in the object
> class.

Don't try that....
What problem are you trying to solve?

> But when I add this one the message "Byte-type objects cannot
> have named instance variables. Do you want to continue ?" appears. If I
> chose "Yes", the same message appears yet, and yet, ...
>
> What is the problem ?

ByteArray and other byte-type objects inherit indirectly from Object.
But in VW an object can hold either bytes or object pointers but not a
mixture. Hence you cannot add ivars to superclasses of byte-type objects.

> How can I add an instance variable in the Object
> class in a smart way ?

By storing them 'sideways' in a global dictionary. See for instance
Object>>myDependents




Cheers,

Reinout
-------

Reply | Threaded
Open this post in threaded view
|

Re: Add an instance variable in object class

Ricardo Birmann


On 8/29/06, Reinout Heeck <[hidden email]> wrote:
Frédéric Pluquet wrote:
>
> For performance reasons I want to add an instance variable in the object
> class.

Don't try that....
What problem are you trying to solve?

> But when I add this one the message "Byte-type objects cannot
> have named instance variables. Do you want to continue ?" appears. If I
> chose "Yes", the same message appears yet, and yet, ...
>
> What is the problem ?

ByteArray and other byte-type objects inherit indirectly from Object.
But in VW an object can hold either bytes or object pointers but not a
mixture. Hence you cannot add ivars to superclasses of byte-type objects.

> How can I add an instance variable in the Object
> class in a smart way ?

By storing them 'sideways' in a global dictionary. See for instance
Object>>myDependents


yes, but don't go global until you've really thought things through....

what is exactly the problem?
 

Cheers,

Reinout
-------


Reply | Threaded
Open this post in threaded view
|

Re: AW: Add an instance variable in object class

Frederic Pluquet-3
In reply to this post by Georg Heeg
Thank you for your answers.

I implemented a persistent mechanism in VW. I can save states of any  
object of the image in an efficient way.
But I have a global dictionary that map each object with its  
persistent object manager. Thus an 1 - 1 relation...
I lost a lot of time to search always in this dictionary and the  
unique solution I see is to add an attribute to Object class.

I think it is a good raison :-) But if I must hack the system to  
success I don't like this.

Would somebody have an another idea to reduce the time of dictionary  
search ?

Thank you,

Pluquet Frédéric


Le 29-août-06 à 15:20, Georg Heeg a écrit :

> Frédéric,
>
> The answer is simple: You can't.
>
> What shall this instance variable provide, that each and every  
> object in the
> entire system should have it?
>
> Georg
>
> -----Ursprüngliche Nachricht-----
> Von: Frédéric Pluquet [mailto:[hidden email]]
> Gesendet: Dienstag, 29. August 2006 15:10
> An: vwnc
> Betreff: Add an instance variable in object class
>
> Hi,
>
> For performance reasons I want to add an instance variable in the
> object class. But when I add this one the message "Byte-type objects
> cannot have named instance variables. Do you want to continue ?"
> appears. If I chose "Yes", the same message appears yet, and yet, ...
>
> What is the problem ? How can I add an instance variable in the
> Object class in a smart way ?
>
> Best regards,
>
> Pluquet Frédéric
>


       
 p5.vert.ukl.yahoo.com uncompressed Fri Sep  1 08:27:00 GMT 2006
       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com


Reply | Threaded
Open this post in threaded view
|

Re: AW: Add an instance variable in object class

Holger Kleinsorgen-4
> Would somebody have an another idea to reduce the time of dictionary
> search ?

If I remember it correctly, Objectivity (an OO-DB) uses "shadow"
classes. For each persistent class, it compiles a nearly invisible
subclass that adds the ability to store additional information directly
in the objects of this class. for byte-indexed classes, a global
dictionary approach would still be needed.


Reply | Threaded
Open this post in threaded view
|

Re: AW: Add an instance variable in object class

Janko Mivšek
In reply to this post by Frederic Pluquet-3
Hi Frédéric,

I would recommend you to flag such an object as immutable. That ways
you'll know it is a persistent one. But this then implies only one
persistent manager ...

Best regards
Janko


Frédéric Pluquet wrote:

> Thank you for your answers.
>
> I implemented a persistent mechanism in VW. I can save states of any
> object of the image in an efficient way.
> But I have a global dictionary that map each object with its persistent
> object manager. Thus an 1 - 1 relation...
> I lost a lot of time to search always in this dictionary and the unique
> solution I see is to add an attribute to Object class.
>
> I think it is a good raison :-) But if I must hack the system to success
> I don't like this.
>
> Would somebody have an another idea to reduce the time of dictionary
> search ?
>
> Thank you,
>
> Pluquet Frédéric
>
>
> Le 29-août-06 à 15:20, Georg Heeg a écrit :
>
>> Frédéric,
>>
>> The answer is simple: You can't.
>>
>> What shall this instance variable provide, that each and every object
>> in the
>> entire system should have it?
>>
>> Georg
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Frédéric Pluquet [mailto:[hidden email]]
>> Gesendet: Dienstag, 29. August 2006 15:10
>> An: vwnc
>> Betreff: Add an instance variable in object class
>>
>> Hi,
>>
>> For performance reasons I want to add an instance variable in the
>> object class. But when I add this one the message "Byte-type objects
>> cannot have named instance variables. Do you want to continue ?"
>> appears. If I chose "Yes", the same message appears yet, and yet, ...
>>
>> What is the problem ? How can I add an instance variable in the
>> Object class in a smart way ?
>>
>> Best regards,
>>
>> Pluquet Frédéric
>>
>
>
>    
> p5.vert.ukl.yahoo.com uncompressed Fri Sep  1 08:27:00 GMT 2006    
>        
> ___________________________________________________________________________Yahoo!
> Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son
> interface révolutionnaire.
> http://fr.mail.yahoo.com
>
>

--
Janko Mivšek
Svetovalec za informatiko
EraNova d.o.o.
Ljubljana, Slovenija
www.eranova.si
tel:  01 514 22 55
faks: 01 514 22 56
gsm: 031 674 565

Reply | Threaded
Open this post in threaded view
|

RE: AW: Add an instance variable in object class

Steven Kelly
In reply to this post by Frederic Pluquet-3
From: Frédéric Pluquet [mailto:[hidden email]]
> I implemented a persistent mechanism in VW. I can save states of any
> object of the image in an efficient way.
> But I have a global dictionary that map each object with its
> persistent object manager. Thus an 1 - 1 relation...
> I lost a lot of time to search always in this dictionary...
>
> Would somebody have an another idea to reduce the time of dictionary
> search ?

Presumably you have an IdentityDictionary? This uses #identityHash, which has too small a range [0..16383], see ObjectMemory maximumIdentityHashValue. Things start slowing down somewhere around a dictionary size of ten thousand objects, because there are too many hash collisions. If that's your problem, one way to increase the range might be to factor the object's class into a new myIdentityHash, e.g.:

myIdentityHash
        ^self identityHash + (self class identityHash bitShift: 14)

You'll also need to make a subclass of IdentityDictionary that uses myIdentityHash in findKeyOrNil:. Of course all this depends on whether your persistent objects' classes work well as a way of spreading the hash values around - if most of them are of the same class, this won't help. Watch out also for SmallInteger, whose identityHash is ^self - you'll probably want to use that for its myIdentityHash too.

You might want to take a look at OmniBase, which is a reasonably simple and efficient implementation of persistence, and a Google groups search for " identityHash group:comp.lang.smalltalk"

All the best,
Steve