Git Product home page Git Product logo

Comments (13)

SabineMa avatar SabineMa commented on May 27, 2024

I made a copy and paste error, I forgot the asDictionary. But the result is the same. Both cases make hanging image.
RKAPerson selectMany: {('_id' -> (OID value:'75b900000000000000000000'))} asDictionary

from voyage.

SabineMa avatar SabineMa commented on May 27, 2024

According to this thread
http://forum.world.st/voyage-mongo-randomly-wrong-OIDs-td4705396.html#a4705898
I created my own OIDGenerator.
I used Time primUTCMicrosecondsClock .

Now, I want to get an object within pharo by the ObjectId.
Now I found out that both, my OIDGenerator, but also your OID (OID initialize) do not generate OIDs which can be used for lookup.

If I use

db.Persons.find({"_id" : ObjectId("66721700641503420494781612039")})

I get error from mongo:
Fri Aug 14 09:41:37.584 Error: invalid object id: length
(with your and with my generated ids)

Main point: OID>> initialize does not generate ObjectIDs as described here:
http://docs.mongodb.org/manual/reference/object-id/

I wrote a new one like this (not yet cached hostname, this is simplified):

| counter seconds hostname process |  self halt.
seconds := (DateAndTime now asUnixTime hex last: 8) asString.
hostname := ((NetNameResolver localHostName substrings: '.') inject: '' into: [ :str :ele | str , ele ]) last: 6.
process := Processor activeProcess hash asString last: 4.
self increaseOID.
counter := ((self currentOID)  hex last:6) asString.
^ seconds , hostname , process , counter

and I changed BSON>>nextOIDPut: anOID
to stream nextStringPut: anOID value
because it should not be an integer?!

not yet finished, because this leads to hanging image
As soon as I have time I will proceed.

what is your opinion, Esteban? cheers sabine

from voyage.

johnnyzz avatar johnnyzz commented on May 27, 2024

Hi Sabine, why do you need to construct OID from String? I think this is not a bug
Consider this:

OID value: 26555050698940995562836590593. "dec"
OID value: 16r55CDD2B6E9A87A520F000001. "hex"

also take a look at this MongoTalk commit: http://smalltalkhub.com/#!/~MongoTalkTeam/mongotalk/versions/Mongo-BSON-HenrikSperreJohansen.43

from voyage.

SabineMa avatar SabineMa commented on May 27, 2024

Hi John,

you are right. Then there is only the problem with the size of the OID remaining because your example also leads to an database entry which is not searchable by ids id.

db.Persons.find({"_id" : ObjectId("16r55CDD2B6E9A87A520F000001")})
Fri Aug 14 14:07:12.571 Error: invalid object id: length

Can you please check the link to the MongoTalk commit, I can not find it.
added: http://smalltalkhub.com/#!/~MongoTalkTeam/mongotalk/commits
Regards
Sabine

from voyage.

johnnyzz avatar johnnyzz commented on May 27, 2024

Don't know, the link works for me...
The value is Smalltalk code, for Mongo console skip "16r" and the rest is the hex value you need.
In fact you need something like:
In Smalltalk

66721700641503420494781612039 printStringHex
'D796E5AF5F4D5C1EF4000007'

In Mongo

db.Persons.find({"_id" : ObjectId("D796E5AF5F4D5C1EF4000007")})

clear?

from voyage.

SabineMa avatar SabineMa commented on May 27, 2024

Hi John,

yes, now it is. And it works.
Thanks a lot for your help!

Is there a reason why this is not in ConfigurationOfMongoTalk?
Regards
Sabine

from voyage.

johnnyzz avatar johnnyzz commented on May 27, 2024

Sabine, I don't have any commit rights there, but that's good question again for mailing list :-)

from voyage.

estebanlm avatar estebanlm commented on May 27, 2024

Hi,

I do not have too much to say here :)
Just one thing: changing OID write/read to force it an integer is probably not good because an ObjectID, while a number, is a special kind of number: http://docs.mongodb.org/manual/reference/object-id

About adopting packages of Henrik... how backward compatible is it?

from voyage.

SabineMa avatar SabineMa commented on May 27, 2024

Hi Esteban,

it is both a LargePositiveInteger, in original codes case:

value := LargePositiveInteger new: 12.
value := (value bitOr: DateAndTime now asSeconds) bitShift: 24.
value := (value bitOr: self class machineIdentifier) bitShift: 16.
value := (value bitOr: ((Processor activeProcess hash bitShift: -16)
bitAnd: 16rFFFF)) bitShift: 24.
value := (value bitOr: self class counterNext)

and in Henriks code like this:

| processIdentifier |
processIdentifier := Processor activeProcess basicIdentityHash.
value := LargePositiveInteger new: 12.
value
replaceFrom: 9 to: 12 with: Time totalSeconds - 2177452800 startingAt: 1;
replaceFrom: 6 to: 8 with: self class machineIdentifier startingAt: 1;
digitAt: 5 put: (processIdentifier bitAnd: 16rFF);
digitAt: 4 put: ((processIdentifier bitShift: -8) bitAnd: 16rFF);
replaceFrom: 1 to: 3 with: self class counterNext startingAt: 1

So I don't exactly understand what you mean by saying "force it an integer".
Henriks code uses unixtime instead of squeak time, other counter etc and
seems to be faster, see the comment in the commit. It seems to be backward
compatible but here also I don't exactly know what you intend.

I assume, that it will come into the next stable version of MONGO-BSON
package?
Till then I have it in my own configurationOf.

Regards
Sabine

2015-08-17 11:26 GMT+02:00 Esteban Lorenzano [email protected]:

Hi,

I do not have too much to say here :)
Just one thing: changing OID write/read to force it an integer is probably
not good because an ObjectID, while a number, is a special kind of number:
http://docs.mongodb.org/manual/reference/object-id

About adopting packages of Henrik... how backward compatible is it?


Reply to this email directly or view it on GitHub
#6 (comment).

from voyage.

estebanlm avatar estebanlm commented on May 27, 2024

I meant inside MongoDB. There it is not an integer… it is a special type.
You can create an OID with no matter what number inside (as long as is not bigger than 12b)
But I think in the driver it needs to be treated as something different than a number.

Esteban

On 17 Aug 2015, at 13:50, SabineManaa [email protected] wrote:

Hi Esteban,

it is both a LargePositiveInteger, in original codes case:

value := LargePositiveInteger new: 12.
value := (value bitOr: DateAndTime now asSeconds) bitShift: 24.
value := (value bitOr: self class machineIdentifier) bitShift: 16.
value := (value bitOr: ((Processor activeProcess hash bitShift: -16)
bitAnd: 16rFFFF)) bitShift: 24.
value := (value bitOr: self class counterNext)

and in Henriks code like this:

| processIdentifier |
processIdentifier := Processor activeProcess basicIdentityHash.
value := LargePositiveInteger new: 12.
value
replaceFrom: 9 to: 12 with: Time totalSeconds - 2177452800 startingAt: 1;
replaceFrom: 6 to: 8 with: self class machineIdentifier startingAt: 1;
digitAt: 5 put: (processIdentifier bitAnd: 16rFF);
digitAt: 4 put: ((processIdentifier bitShift: -8) bitAnd: 16rFF);
replaceFrom: 1 to: 3 with: self class counterNext startingAt: 1

So I don't exactly understand what you mean by saying "force it an integer".
Henriks code uses unixtime instead of squeak time, other counter etc and
seems to be faster, see the comment in the commit. It seems to be backward
compatible but here also I don't exactly know what you intend.

I assume, that it will come into the next stable version of MONGO-BSON
package?
Till then I have it in my own configurationOf.

Regards
Sabine

2015-08-17 11:26 GMT+02:00 Esteban Lorenzano [email protected]:

Hi,

I do not have too much to say here :)
Just one thing: changing OID write/read to force it an integer is probably
not good because an ObjectID, while a number, is a special kind of number:
http://docs.mongodb.org/manual/reference/object-id

About adopting packages of Henrik... how backward compatible is it?


Reply to this email directly or view it on GitHub
#6 (comment).


Reply to this email directly or view it on GitHub #6 (comment).

from voyage.

SabineMa avatar SabineMa commented on May 27, 2024

Hi Esteban,

I dont understand why you are telling this to me because I don't want to
manipulate something inside mongo, I only wanted to use the implementation
of Henrik now instead of the old one.

Are you sure about the number inside (not larger than 12)? I have OIDs
which are to small:

db.Trips.find({"person.__id" : ObjectId("2E7A4")})

Mon Aug 17 14:20:56.990 Error: invalid object id: length

db.Trips.find({"person.__id" : ObjectId("190372")})

Mon Aug 17 14:21:10.815 Error: invalid object id: length

I think they have to be exactly 12.

Will the implementation of Henrik will come into the next stable version of
MONGO-BSON package?

Regards

Sabine

2015-08-17 14:04 GMT+02:00 Esteban Lorenzano [email protected]:

I meant inside MongoDB. There it is not an integer… it is a special type.
You can create an OID with no matter what number inside (as long as is not
bigger than 12b)
But I think in the driver it needs to be treated as something different
than a number.

Esteban

On 17 Aug 2015, at 13:50, SabineManaa [email protected] wrote:

Hi Esteban,

it is both a LargePositiveInteger, in original codes case:

value := LargePositiveInteger new: 12.
value := (value bitOr: DateAndTime now asSeconds) bitShift: 24.
value := (value bitOr: self class machineIdentifier) bitShift: 16.
value := (value bitOr: ((Processor activeProcess hash bitShift: -16)
bitAnd: 16rFFFF)) bitShift: 24.
value := (value bitOr: self class counterNext)

and in Henriks code like this:

| processIdentifier |
processIdentifier := Processor activeProcess basicIdentityHash.
value := LargePositiveInteger new: 12.
value
replaceFrom: 9 to: 12 with: Time totalSeconds - 2177452800 startingAt:
1;
replaceFrom: 6 to: 8 with: self class machineIdentifier startingAt: 1;
digitAt: 5 put: (processIdentifier bitAnd: 16rFF);
digitAt: 4 put: ((processIdentifier bitShift: -8) bitAnd: 16rFF);
replaceFrom: 1 to: 3 with: self class counterNext startingAt: 1

So I don't exactly understand what you mean by saying "force it an
integer".
Henriks code uses unixtime instead of squeak time, other counter etc and
seems to be faster, see the comment in the commit. It seems to be
backward
compatible but here also I don't exactly know what you intend.

I assume, that it will come into the next stable version of MONGO-BSON
package?
Till then I have it in my own configurationOf.

Regards
Sabine

2015-08-17 11:26 GMT+02:00 Esteban Lorenzano [email protected]:

Hi,

I do not have too much to say here :)
Just one thing: changing OID write/read to force it an integer is
probably
not good because an ObjectID, while a number, is a special kind of
number:
http://docs.mongodb.org/manual/reference/object-id

About adopting packages of Henrik... how backward compatible is it?


Reply to this email directly or view it on GitHub
#6 (comment).


Reply to this email directly or view it on GitHub <
https://github.com/estebanlm/voyage/issues/6#issuecomment-131792943>.


Reply to this email directly or view it on GitHub
#6 (comment).

from voyage.

estebanlm avatar estebanlm commented on May 27, 2024

On 17 Aug 2015, at 14:24, SabineManaa [email protected] wrote:

Hi Esteban,

I dont understand why you are telling this to me because I don't want to
manipulate something inside mongo, I only wanted to use the implementation
of Henrik now instead of the old one.

Are you sure about the number inside (not larger than 12)? I have OIDs
which are to small:

db.Trips.find({"person.__id" : ObjectId("2E7A4")})

Mon Aug 17 14:20:56.990 Error: invalid object id: length

db.Trips.find({"person.__id" : ObjectId("190372")})

Mon Aug 17 14:21:10.815 Error: invalid object id: length

I think they have to be exactly 12.

Will the implementation of Henrik will come into the next stable version of
MONGO-BSON package?

yes it will

Regards

Sabine

2015-08-17 14:04 GMT+02:00 Esteban Lorenzano [email protected]:

I meant inside MongoDB. There it is not an integer… it is a special type.
You can create an OID with no matter what number inside (as long as is not
bigger than 12b)
But I think in the driver it needs to be treated as something different
than a number.

Esteban

On 17 Aug 2015, at 13:50, SabineManaa [email protected] wrote:

Hi Esteban,

it is both a LargePositiveInteger, in original codes case:

value := LargePositiveInteger new: 12.
value := (value bitOr: DateAndTime now asSeconds) bitShift: 24.
value := (value bitOr: self class machineIdentifier) bitShift: 16.
value := (value bitOr: ((Processor activeProcess hash bitShift: -16)
bitAnd: 16rFFFF)) bitShift: 24.
value := (value bitOr: self class counterNext)

and in Henriks code like this:

| processIdentifier |
processIdentifier := Processor activeProcess basicIdentityHash.
value := LargePositiveInteger new: 12.
value
replaceFrom: 9 to: 12 with: Time totalSeconds - 2177452800 startingAt:
1;
replaceFrom: 6 to: 8 with: self class machineIdentifier startingAt: 1;
digitAt: 5 put: (processIdentifier bitAnd: 16rFF);
digitAt: 4 put: ((processIdentifier bitShift: -8) bitAnd: 16rFF);
replaceFrom: 1 to: 3 with: self class counterNext startingAt: 1

So I don't exactly understand what you mean by saying "force it an
integer".
Henriks code uses unixtime instead of squeak time, other counter etc and
seems to be faster, see the comment in the commit. It seems to be
backward
compatible but here also I don't exactly know what you intend.

I assume, that it will come into the next stable version of MONGO-BSON
package?
Till then I have it in my own configurationOf.

Regards
Sabine

2015-08-17 11:26 GMT+02:00 Esteban Lorenzano [email protected]:

Hi,

I do not have too much to say here :)
Just one thing: changing OID write/read to force it an integer is
probably
not good because an ObjectID, while a number, is a special kind of
number:
http://docs.mongodb.org/manual/reference/object-id

About adopting packages of Henrik... how backward compatible is it?


Reply to this email directly or view it on GitHub
#6 (comment).


Reply to this email directly or view it on GitHub <
https://github.com/estebanlm/voyage/issues/6#issuecomment-131792943>.


Reply to this email directly or view it on GitHub
#6 (comment).


Reply to this email directly or view it on GitHub #6 (comment).

from voyage.

estebanlm avatar estebanlm commented on May 27, 2024

oops, this is fixed and I forget to close

from voyage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.