Need unique number for some objects ...

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

Need unique number for some objects ...

Dennis smith-4
We normally run against gemstone and we use the gemstone "oop" as
a unique number of objects.  This is fine.

However, during development we don't use gemstone but work with just
a memory-based system.

We need a "unique number" for our high-level objects (Customer, Order,
Person, ...).

Anyone have thoughts on how to do this easily?  We current keep a weak array
and use the index, but we have issues as to when to erase it and start
over, so before
I go "fix that" -- I thought I would ask if anyone else has had a
similar need and how the
solved it??

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

davidbuck
Your only option is to explicitly implement something like you're doing. Objects will frequently move in memory from one memory space to another so the address of the object is useless.  Using an identity hash gives you a number but it's not guaranteed to be unique.  It's possible to allocate the objects in Fixed Space and use their addresses, but that's a pain and won't work across image saves and re-launching.

I'd probably take a similar approach to yours using some sort of weak collection.

Good luck
David Buck
Simberon Inc.
www.simberon.com

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: Dennis Smith <[hidden email]>
Sender: [hidden email]
Date: Fri, 04 Feb 2011 08:43:56
To: VWNC,<[hidden email]>
Subject: [vwnc] Need unique number for some objects ...

We normally run against gemstone and we use the gemstone "oop" as
a unique number of objects.  This is fine.

However, during development we don't use gemstone but work with just
a memory-based system.

We need a "unique number" for our high-level objects (Customer, Order,
Person, ...).

Anyone have thoughts on how to do this easily?  We current keep a weak array
and use the index, but we have issues as to when to erase it and start
over, so before
I go "fix that" -- I thought I would ask if anyone else has had a
similar need and how the
solved it??

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Paul Baumann
In reply to this post by Dennis smith-4
Dennis,

Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.

Paul Baumann



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
Sent: Friday, February 04, 2011 08:44
To: VWNC,
Subject: [vwnc] Need unique number for some objects ...

We normally run against gemstone and we use the gemstone "oop" as
a unique number of objects.  This is fine.

However, during development we don't use gemstone but work with just
a memory-based system.

We need a "unique number" for our high-level objects (Customer, Order,
Person, ...).

Anyone have thoughts on how to do this easily?  We current keep a weak array
and use the index, but we have issues as to when to erase it and start
over, so before
I go "fix that" -- I thought I would ask if anyone else has had a
similar need and how the
solved it??

--
Dennis Smith                                     +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada                           http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Dennis smith-4
We do use the identityHash for non-critical itentification (we modified
Trippy to show the hash
as part of every object so we can tell if two trippy windows are showing
the same object or one that just looks the same).

But I thought that identityHash was not unique??

On 04/02/2011 9:17 AM, Paul Baumann wrote:

> Dennis,
>
> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>
> Paul Baumann
>
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
> Sent: Friday, February 04, 2011 08:44
> To: VWNC,
> Subject: [vwnc] Need unique number for some objects ...
>
> We normally run against gemstone and we use the gemstone "oop" as
> a unique number of objects.  This is fine.
>
> However, during development we don't use gemstone but work with just
> a memory-based system.
>
> We need a "unique number" for our high-level objects (Customer, Order,
> Person, ...).
>
> Anyone have thoughts on how to do this easily?  We current keep a weak array
> and use the index, but we have issues as to when to erase it and start
> over, so before
> I go "fix that" -- I thought I would ask if anyone else has had a
> similar need and how the
> solved it??
>
> --
> Dennis Smith                                     +1 416.798.7948
> Cherniak Software Development Corporation   Fax: +1 416.798.0948
> 509-2001 Sheppard Avenue East        [hidden email]
> Toronto, ON M2J 4Z8              sip:[hidden email]
> Canada                           http://www.CherniakSoftware.com
> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Travis Griggs-4
In reply to this post by davidbuck

On Feb 4, 2011, at 6:08 AM, David Buck wrote:

> <snip> It's possible to allocate the objects in Fixed Space and use their addresses, but that's a pain and won't work across image saves and re-launching.
> <snip>


And Fixed Space is only good for byte type objects anyway:

Behavior>>newInFixedSpace:
"Fail if the class is not bits-indexable...."

--
Travis Griggs
Objologist
Light travels faster than sound. This is why some people appear bright until you hear them speak...





_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Dennis smith-4
In reply to this post by Dennis smith-4
In fact I just proved that identityHash is not unique.
I took all our business objects (2209 right now) and checked, there were
1136 unique identityHash values.
Oh well!

On 04/02/2011 9:49 AM, Dennis Smith wrote:

> We do use the identityHash for non-critical itentification (we modified
> Trippy to show the hash
> as part of every object so we can tell if two trippy windows are showing
> the same object or one that just looks the same).
>
> But I thought that identityHash was not unique??
>
> On 04/02/2011 9:17 AM, Paul Baumann wrote:
>> Dennis,
>>
>> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>>
>> Paul Baumann
>>
>>
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
>> Sent: Friday, February 04, 2011 08:44
>> To: VWNC,
>> Subject: [vwnc] Need unique number for some objects ...
>>
>> We normally run against gemstone and we use the gemstone "oop" as
>> a unique number of objects.  This is fine.
>>
>> However, during development we don't use gemstone but work with just
>> a memory-based system.
>>
>> We need a "unique number" for our high-level objects (Customer, Order,
>> Person, ...).
>>
>> Anyone have thoughts on how to do this easily?  We current keep a weak array
>> and use the index, but we have issues as to when to erase it and start
>> over, so before
>> I go "fix that" -- I thought I would ask if anyone else has had a
>> similar need and how the
>> solved it??
>>
>> --
>> Dennis Smith                                     +1 416.798.7948
>> Cherniak Software Development Corporation   Fax: +1 416.798.0948
>> 509-2001 Sheppard Avenue East        [hidden email]
>> Toronto, ON M2J 4Z8              sip:[hidden email]
>> Canada                           http://www.CherniakSoftware.com
>> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>>

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

davidbuck
In reply to this post by Travis Griggs-4
Ok, so that makes it even more of a pain :-).

Thanks

David Buck

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: Travis Griggs <[hidden email]>
Sender: [hidden email]
Date: Fri, 4 Feb 2011 06:58:33
To: VWNC List<[hidden email]>
Subject: Re: [vwnc] Need unique number for some objects ...


On Feb 4, 2011, at 6:08 AM, David Buck wrote:

> <snip> It's possible to allocate the objects in Fixed Space and use their addresses, but that's a pain and won't work across image saves and re-launching.
> <snip>


And Fixed Space is only good for byte type objects anyway:

Behavior>>newInFixedSpace:
"Fail if the class is not bits-indexable...."

--
Travis Griggs
Objologist
Light travels faster than sound. This is why some people appear bright until you hear them speak...





_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Dennis smith-4
Guess I'm back to my weakArray -- I will find and fix my bug :(

On 04/02/2011 10:19 AM, David Buck wrote:

> Ok, so that makes it even more of a pain :-).
>
> Thanks
>
> David Buck
>
> Sent from my BlackBerry device on the Rogers Wireless Network
>
> -----Original Message-----
> From: Travis Griggs<[hidden email]>
> Sender: [hidden email]
> Date: Fri, 4 Feb 2011 06:58:33
> To: VWNC List<[hidden email]>
> Subject: Re: [vwnc] Need unique number for some objects ...
>
>
> On Feb 4, 2011, at 6:08 AM, David Buck wrote:
>
>> <snip>  It's possible to allocate the objects in Fixed Space and use their addresses, but that's a pain and won't work across image saves and re-launching.
>> <snip>
>
> And Fixed Space is only good for byte type objects anyway:
>
> Behavior>>newInFixedSpace:
> "Fail if the class is not bits-indexable...."
>
> --
> Travis Griggs
> Objologist
> Light travels faster than sound. This is why some people appear bright until you hear them speak...
>
>
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Alan Knight-2
In reply to this post by Dennis smith-4
I guess it depends what you need it for. But I would say add an instance
variable to them for an id and then use a counter to get the next one.
Then you don't need a weak dictionary to keep track of them. But it
depends if what you want to do is find objects from their number, or
find the number given an object.

On 2011-02-04 10:06 AM, Dennis Smith wrote:

> In fact I just proved that identityHash is not unique.
> I took all our business objects (2209 right now) and checked, there were
> 1136 unique identityHash values.
> Oh well!
>
> On 04/02/2011 9:49 AM, Dennis Smith wrote:
>> We do use the identityHash for non-critical itentification (we modified
>> Trippy to show the hash
>> as part of every object so we can tell if two trippy windows are showing
>> the same object or one that just looks the same).
>>
>> But I thought that identityHash was not unique??
>>
>> On 04/02/2011 9:17 AM, Paul Baumann wrote:
>>> Dennis,
>>>
>>> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>>>
>>> Paul Baumann
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
>>> Sent: Friday, February 04, 2011 08:44
>>> To: VWNC,
>>> Subject: [vwnc] Need unique number for some objects ...
>>>
>>> We normally run against gemstone and we use the gemstone "oop" as
>>> a unique number of objects.  This is fine.
>>>
>>> However, during development we don't use gemstone but work with just
>>> a memory-based system.
>>>
>>> We need a "unique number" for our high-level objects (Customer, Order,
>>> Person, ...).
>>>
>>> Anyone have thoughts on how to do this easily?  We current keep a weak array
>>> and use the index, but we have issues as to when to erase it and start
>>> over, so before
>>> I go "fix that" -- I thought I would ask if anyone else has had a
>>> similar need and how the
>>> solved it??
>>>
>>> --
>>> Dennis Smith                                     +1 416.798.7948
>>> Cherniak Software Development Corporation   Fax: +1 416.798.0948
>>> 509-2001 Sheppard Avenue East        [hidden email]
>>> Toronto, ON M2J 4Z8              sip:[hidden email]
>>> Canada                           http://www.CherniakSoftware.com
>>> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>>>
>>> _______________________________________________
>>> vwnc mailing list
>>> [hidden email]
>>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>>
>>>
>>> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>>>

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk
[hidden email]
[hidden email]
http://www.cincomsmalltalk.com

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Anthony Lander-2
In reply to this post by Dennis smith-4
Hi Dennis,

If you can add an ID instvar, you can, of course, just assign them  
increasingly larger integers - then you can get rid of the weak array,  
and not worry about when they disappear.

   -anthony

On 11-Feb-4, at 10:21 AM, Dennis Smith wrote:

> Guess I'm back to my weakArray -- I will find and fix my bug :(
>
> On 04/02/2011 10:19 AM, David Buck wrote:
>> Ok, so that makes it even more of a pain :-).
>>
>> Thanks
>>
>> David Buck
>>
>> Sent from my BlackBerry device on the Rogers Wireless Network
>>
>> -----Original Message-----
>> From: Travis Griggs<[hidden email]>
>> Sender: [hidden email]
>> Date: Fri, 4 Feb 2011 06:58:33
>> To: VWNC List<[hidden email]>
>> Subject: Re: [vwnc] Need unique number for some objects ...
>>
>>
>> On Feb 4, 2011, at 6:08 AM, David Buck wrote:
>>
>>> <snip>  It's possible to allocate the objects in Fixed Space and  
>>> use their addresses, but that's a pain and won't work across image  
>>> saves and re-launching.
>>> <snip>
>>
>> And Fixed Space is only good for byte type objects anyway:
>>
>> Behavior>>newInFixedSpace:
>> "Fail if the class is not bits-indexable...."
>>
>> --
>> Travis Griggs
>> Objologist
>> Light travels faster than sound. This is why some people appear  
>> bright until you hear them speak...
>>
>>
>>
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
> --
> Dennis Smith                         +1 416.798.7948
> Cherniak Software Development Corporation   Fax: +1 416.798.0948
> 509-2001 Sheppard Avenue East        [hidden email]
> Toronto, ON M2J 4Z8              sip:[hidden email]
> Canada         http://www.CherniakSoftware.com
> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Andres Valloud-6
In reply to this post by Dennis smith-4
Why a weak array as opposed to a weak key dictionary, mapped in the
direction you need (object->"oop" or viceversa)?  You could subclass the
dictionary to keep counting "oops" so they are always unique.

On 2/4/2011 5:43 AM, Dennis Smith wrote:

> We normally run against gemstone and we use the gemstone "oop" as
> a unique number of objects.  This is fine.
>
> However, during development we don't use gemstone but work with just
> a memory-based system.
>
> We need a "unique number" for our high-level objects (Customer, Order,
> Person, ...).
>
> Anyone have thoughts on how to do this easily?  We current keep a weak array
> and use the index, but we have issues as to when to erase it and start
> over, so before
> I go "fix that" -- I thought I would ask if anyone else has had a
> similar need and how the
> solved it??
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Paul Baumann
In reply to this post by Dennis smith-4
Dennis,

The identityHash would be reused from a GC event like the number of scavenges. Include something like numScavenges too:

identityHash
        uniqueHash isNil ifTrue: [
                uniqueHash := (Processor activeProcess hash bitShift: 20)
                + ((ObjectMemory current numScavenges bitAnd: 2r111111) bitShift: 14)
                + super identityHash
        ].
        ^uniqueHash

The hash of the active process is a simple (yet not perfect) alternative to an image identifier. One form of image identifier can come from an image start time. Another would be an image identifier that you assign. You decide how many bits for each hash component according to your needs.

Keep in mind that operations like #become: will preserve the hash:

| a aHash b bHash |
aHash := (a := Array new: 1) identityHash.
a at: 1 put: aHash.
bHash := (b := Array new: 1) identityHash.
b at: 1 put: bHash.
(a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
(a identityHash = a first and: [b identityHash = b first]) ifFalse: [self unexpected].
a become: b.
(a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
(a identityHash ~= a first and: [b identityHash ~= b first]) ifFalse: [self unexpected].

Your objects would also need to override #become: to exchange the hash values you've assigned.

Paul Baumann



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
Sent: Friday, February 04, 2011 10:07
To: [hidden email]
Subject: Re: [vwnc] Need unique number for some objects ...

In fact I just proved that identityHash is not unique.
I took all our business objects (2209 right now) and checked, there were
1136 unique identityHash values.
Oh well!

On 04/02/2011 9:49 AM, Dennis Smith wrote:

> We do use the identityHash for non-critical itentification (we modified
> Trippy to show the hash
> as part of every object so we can tell if two trippy windows are showing
> the same object or one that just looks the same).
>
> But I thought that identityHash was not unique??
>
> On 04/02/2011 9:17 AM, Paul Baumann wrote:
>> Dennis,
>>
>> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>>
>> Paul Baumann
>>
>>
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
>> Sent: Friday, February 04, 2011 08:44
>> To: VWNC,
>> Subject: [vwnc] Need unique number for some objects ...
>>
>> We normally run against gemstone and we use the gemstone "oop" as
>> a unique number of objects.  This is fine.
>>
>> However, during development we don't use gemstone but work with just
>> a memory-based system.
>>
>> We need a "unique number" for our high-level objects (Customer, Order,
>> Person, ...).
>>
>> Anyone have thoughts on how to do this easily?  We current keep a weak array
>> and use the index, but we have issues as to when to erase it and start
>> over, so before
>> I go "fix that" -- I thought I would ask if anyone else has had a
>> similar need and how the
>> solved it??
>>
>> --
>> Dennis Smith                                     +1 416.798.7948
>> Cherniak Software Development Corporation   Fax: +1 416.798.0948
>> 509-2001 Sheppard Avenue East        [hidden email]
>> Toronto, ON M2J 4Z8              sip:[hidden email]
>> Canada                           http://www.CherniakSoftware.com
>> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>>

--
Dennis Smith                                     +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada                           http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Paul Baumann
In reply to this post by Dennis smith-4
Oh, I see what you are saying. Yes, there are only 16383 unique identityHash values and obviously more than 16K objects in your image. Sorry. Silly mistake. Use an application incremented value and combine that with an image-specific value.

Paul Baumann

-----Original Message-----
From: Paul Baumann
Sent: Friday, February 04, 2011 15:19
To: 'Dennis Smith'; [hidden email]
Subject: RE: [vwnc] Need unique number for some objects ...

Dennis,

The identityHash would be reused from a GC event like the number of scavenges. Include something like numScavenges too:

identityHash
        uniqueHash isNil ifTrue: [
                uniqueHash := (Processor activeProcess hash bitShift: 20)
                + ((ObjectMemory current numScavenges bitAnd: 2r111111) bitShift: 14)
                + super identityHash
        ].
        ^uniqueHash

The hash of the active process is a simple (yet not perfect) alternative to an image identifier. One form of image identifier can come from an image start time. Another would be an image identifier that you assign. You decide how many bits for each hash component according to your needs.

Keep in mind that operations like #become: will preserve the hash:

| a aHash b bHash |
aHash := (a := Array new: 1) identityHash.
a at: 1 put: aHash.
bHash := (b := Array new: 1) identityHash.
b at: 1 put: bHash.
(a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
(a identityHash = a first and: [b identityHash = b first]) ifFalse: [self unexpected].
a become: b.
(a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
(a identityHash ~= a first and: [b identityHash ~= b first]) ifFalse: [self unexpected].

Your objects would also need to override #become: to exchange the hash values you've assigned.

Paul Baumann



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
Sent: Friday, February 04, 2011 10:07
To: [hidden email]
Subject: Re: [vwnc] Need unique number for some objects ...

In fact I just proved that identityHash is not unique.
I took all our business objects (2209 right now) and checked, there were
1136 unique identityHash values.
Oh well!

On 04/02/2011 9:49 AM, Dennis Smith wrote:

> We do use the identityHash for non-critical itentification (we modified
> Trippy to show the hash
> as part of every object so we can tell if two trippy windows are showing
> the same object or one that just looks the same).
>
> But I thought that identityHash was not unique??
>
> On 04/02/2011 9:17 AM, Paul Baumann wrote:
>> Dennis,
>>
>> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>>
>> Paul Baumann
>>
>>
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
>> Sent: Friday, February 04, 2011 08:44
>> To: VWNC,
>> Subject: [vwnc] Need unique number for some objects ...
>>
>> We normally run against gemstone and we use the gemstone "oop" as
>> a unique number of objects.  This is fine.
>>
>> However, during development we don't use gemstone but work with just
>> a memory-based system.
>>
>> We need a "unique number" for our high-level objects (Customer, Order,
>> Person, ...).
>>
>> Anyone have thoughts on how to do this easily?  We current keep a weak array
>> and use the index, but we have issues as to when to erase it and start
>> over, so before
>> I go "fix that" -- I thought I would ask if anyone else has had a
>> similar need and how the
>> solved it??
>>
>> --
>> Dennis Smith                                     +1 416.798.7948
>> Cherniak Software Development Corporation   Fax: +1 416.798.0948
>> 509-2001 Sheppard Avenue East        [hidden email]
>> Toronto, ON M2J 4Z8              sip:[hidden email]
>> Canada                           http://www.CherniakSoftware.com
>> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>>

--
Dennis Smith                                     +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada                           http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Andres Valloud-6
By the birthday paradox, you only need about 150 random objects to have
a 50% chance of having an identity hash value collision in a 32 bit image.

On 2/4/2011 12:27 PM, Paul Baumann wrote:

> Oh, I see what you are saying. Yes, there are only 16383 unique identityHash values and obviously more than 16K objects in your image. Sorry. Silly mistake. Use an application incremented value and combine that with an image-specific value.
>
> Paul Baumann
>
> -----Original Message-----
> From: Paul Baumann
> Sent: Friday, February 04, 2011 15:19
> To: 'Dennis Smith'; [hidden email]
> Subject: RE: [vwnc] Need unique number for some objects ...
>
> Dennis,
>
> The identityHash would be reused from a GC event like the number of scavenges. Include something like numScavenges too:
>
> identityHash
>          uniqueHash isNil ifTrue: [
>                  uniqueHash := (Processor activeProcess hash bitShift: 20)
>                  + ((ObjectMemory current numScavenges bitAnd: 2r111111) bitShift: 14)
>                  + super identityHash
>          ].
>          ^uniqueHash
>
> The hash of the active process is a simple (yet not perfect) alternative to an image identifier. One form of image identifier can come from an image start time. Another would be an image identifier that you assign. You decide how many bits for each hash component according to your needs.
>
> Keep in mind that operations like #become: will preserve the hash:
>
> | a aHash b bHash |
> aHash := (a := Array new: 1) identityHash.
> a at: 1 put: aHash.
> bHash := (b := Array new: 1) identityHash.
> b at: 1 put: bHash.
> (a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
> (a identityHash = a first and: [b identityHash = b first]) ifFalse: [self unexpected].
> a become: b.
> (a identityHash = aHash and: [b identityHash = bHash]) ifFalse: [self unexpected].
> (a identityHash ~= a first and: [b identityHash ~= b first]) ifFalse: [self unexpected].
>
> Your objects would also need to override #become: to exchange the hash values you've assigned.
>
> Paul Baumann
>
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
> Sent: Friday, February 04, 2011 10:07
> To: [hidden email]
> Subject: Re: [vwnc] Need unique number for some objects ...
>
> In fact I just proved that identityHash is not unique.
> I took all our business objects (2209 right now) and checked, there were
> 1136 unique identityHash values.
> Oh well!
>
> On 04/02/2011 9:49 AM, Dennis Smith wrote:
>> We do use the identityHash for non-critical itentification (we modified
>> Trippy to show the hash
>> as part of every object so we can tell if two trippy windows are showing
>> the same object or one that just looks the same).
>>
>> But I thought that identityHash was not unique??
>>
>> On 04/02/2011 9:17 AM, Paul Baumann wrote:
>>> Dennis,
>>>
>>> Use the #identityHash. If you need it unique between object spaces then bit-join the value with a unique image identifier integer and keep it as an inst var. The first x bits would represent one part and the last x bits would represent the last part. You'd override #identityHash to lazy-initialize the cached value. Once assigned, it would be unique and enduring.
>>>
>>> Paul Baumann
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Smith
>>> Sent: Friday, February 04, 2011 08:44
>>> To: VWNC,
>>> Subject: [vwnc] Need unique number for some objects ...
>>>
>>> We normally run against gemstone and we use the gemstone "oop" as
>>> a unique number of objects.  This is fine.
>>>
>>> However, during development we don't use gemstone but work with just
>>> a memory-based system.
>>>
>>> We need a "unique number" for our high-level objects (Customer, Order,
>>> Person, ...).
>>>
>>> Anyone have thoughts on how to do this easily?  We current keep a weak array
>>> and use the index, but we have issues as to when to erase it and start
>>> over, so before
>>> I go "fix that" -- I thought I would ask if anyone else has had a
>>> similar need and how the
>>> solved it??
>>>
>>> --
>>> Dennis Smith                                     +1 416.798.7948
>>> Cherniak Software Development Corporation   Fax: +1 416.798.0948
>>> 509-2001 Sheppard Avenue East        [hidden email]
>>> Toronto, ON M2J 4Z8              sip:[hidden email]
>>> Canada                           http://www.CherniakSoftware.com
>>> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>>>
>>> _______________________________________________
>>> vwnc mailing list
>>> [hidden email]
>>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>>
>>>
>>> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>>>
>
> --
> Dennis Smith                                     +1 416.798.7948
> Cherniak Software Development Corporation   Fax: +1 416.798.0948
> 509-2001 Sheppard Avenue East        [hidden email]
> Toronto, ON M2J 4Z8              sip:[hidden email]
> Canada                           http://www.CherniakSoftware.com
> Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
> This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Dennis smith-4
In reply to this post by Dennis smith-4
Interesting -- I had never thought of that one -- I will keep it in mind
for the future,
right now my weakarray is working so I will just leave it alone.

On Feb 5/11 1:28 AM, Mark Pirogovsky wrote:

> Try something like :Time microsecondClock on the computer with current
> time.
>
> Dennis Smith wrote:
>> We normally run against gemstone and we use the gemstone "oop" as
>> a unique number of objects.  This is fine.
>>
>> However, during development we don't use gemstone but work with just
>> a memory-based system.
>>
>> We need a "unique number" for our high-level objects (Customer, Order,
>> Person, ...).
>>
>> Anyone have thoughts on how to do this easily?  We current keep a
>> weak array
>> and use the index, but we have issues as to when to erase it and start
>> over, so before
>> I go "fix that" -- I thought I would ask if anyone else has had a
>> similar need and how the
>> solved it??
>>
>

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Need unique number for some objects ...

Mark Pirogovsky-3
In reply to this post by Dennis smith-4
Try something like :Time microsecondClock on the computer with current
time.

Dennis Smith wrote:

> We normally run against gemstone and we use the gemstone "oop" as
> a unique number of objects.  This is fine.
>
> However, during development we don't use gemstone but work with just
> a memory-based system.
>
> We need a "unique number" for our high-level objects (Customer, Order,
> Person, ...).
>
> Anyone have thoughts on how to do this easily?  We current keep a weak array
> and use the index, but we have issues as to when to erase it and start
> over, so before
> I go "fix that" -- I thought I would ask if anyone else has had a
> similar need and how the
> solved it??
>
>    

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc