Re: bug in objectId generation?

From: Tomas Jucius (entire..mail.com)
Date: Wed Mar 15 2006 - 10:44:03 EST

  • Next message: Andrus Adamchik: "Re: bug in objectId generation?"

    Thanks,

    would be great to have it fixed in milestone 12..

    TJ

    On 3/15/06, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    > Good catch! I found what the problem is - there can be only 254 ids
    > created *within the same millisecond*. The test below fails with a
    > message "Failed on 254":
    >
    > public void testIdPool() throws Exception {
    > Set idSet = new HashSet();
    > for (int i = 0; i < Integer.MAX_VALUE; i++) {
    > assertTrue("Failed on " + i, idSet.add(new ObjectId
    > ("Artist")));
    > }
    > }
    >
    > While a slightly modified test succeeds (ok I only waited till 100000
    > ids and canceled the test)
    >
    > public void testIdPool() throws Exception {
    > Set idSet = new HashSet();
    > for (int i = 0; i < Integer.MAX_VALUE; i++) {
    > Thread.sleep(1);
    > assertTrue("Failed on " + i, idSet.add(new ObjectId
    > ("Artist")));
    > }
    > }
    >
    > Could you please open a bug report, so that we don't forget about it.
    >
    > Andrus
    >
    > On Mar 15, 2006, at 6:07 PM, Tomas Jucius wrote:
    >
    > > I don't think so:
    > >
    > > -------------------- test1
    > > --------------------------------------------
    > > code:
    > > DataContext ctxt = getDataContext();
    > > for (int i = 0; i<100; i++) {
    > > Test test = (Test)ctxt.createAndRegisterNewObject
    > > ( Test.class);
    > > }
    > > System.out.println(ctxt.newObjects().size());
    > >
    > > output: 100;
    > >
    > > -------------------- test2
    > > --------------------------------------------
    > > code:
    > >
    > > DataContext ctxt = getDataContext();
    > > for (int i = 0; i<300; i++) {
    > > Test test = (Test)ctxt.createAndRegisterNewObject
    > > (Test.class);
    > > }
    > > System.out.println(ctxt.newObjects().size());
    > >
    > > output: 254;
    > >
    > > So??? Why only 254 new objects?
    > >
    > >
    > >
    > > TJ
    > >
    > >
    > > On 3/15/06, Andrus Adamchik <andru..bjectstyle.org > wrote:> So it
    > > is possible to create only 2^8 new objects with
    > > > createAndRegisterNewObject().....
    > >
    > > No - 2^8^8
    > >
    > >
    > >
    > > On Mar 15, 2006, at 5:18 PM, Tomas Jucius wrote:
    > > > Hi,
    > > >
    > > > I have found that ObjectId class constructor uses 8 byte objectId
    > > > generation:
    > > >
    > > > public ObjectId(String entityName) {
    > > > this.entityName = entityName;
    > > > this.key = IDUtil.pseudoUniqueByteSequence8 (); //
    > > > Returns 8 byte key - something strange..
    > > > }
    > > >
    > > >
    > > >
    > > > So it is possible to create only 2^8 new objects with
    > > > createAndRegisterNewObject().....
    > > >
    > > > Shouldn't you change this????
    > > >
    > > >
    > > > I am using Cayenne 1.2M11..
    > > >
    > > >
    > > >
    > > >
    > > > TJ
    > > >
    > > >
    > > >
    > >
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Mar 15 2006 - 10:44:05 EST