[Mongo] Creating MongoTimeStamp

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

[Mongo] Creating MongoTimeStamp

tinchodias
Hi,

This email is related to Mongo project [1].

As MongoDb documentation [2] states: 

"BSON has a special timestamp type for internal MongoDB use and is not associated with the regular Datetype. Timestamp values are a 64 bit value where:
- the first 32 bits are a time_t value (seconds since the Unix epoch)
- the second 32 bits are an incrementing ordinal for operations within a given second."

Now, our Mongo bindings [1] convert this MongoDb's internal type to Pharo's TimeStamp (i.e. the subclass of DateAndTime) with two problems: 
- it's a wrong: the 2 parts of 32 bits are converted as 64 bits of milliseconds
- it produces a warning in latest Pharo [3]: TimeStamp has been removed so extension methods cannot be installed.


That's why I'm creating MongoTimeStamp, and changing BSON marshaling from:

BSON>>nextTimestamp
^self nextDateAndTime asTimeStamp

to:

BSON>>nextTimestamp
^MongoTimeStamp value: self nextInt64

(similar for writing).


This solution was idea of Esteban and Norbert, and discussed in the issue tracker of Voyage [3]. Mongo talk team, please tell me if you don't agree.


Regards,
Martin

1. http://smalltalkhub.com/#!/~MongoTalkTeam/mongotalk
2: https://docs.mongodb.org/manual/reference/bson-types/#timestamps


Reply | Threaded
Open this post in threaded view
|

Re: [Mongo] Creating MongoTimeStamp

tinchodias
Hi,

Voyage's build is green: 
https://travis-ci.org/tinchodias/voyage/jobs/116040942
(for the build I temporarily updated BaselineOfVoyage to load #development version of Mongo).

I will release 1.9.2 as stable if nobody disagrees.

Martin


Reply | Threaded
Open this post in threaded view
|

Re: [Mongo] Creating MongoTimeStamp

EstebanLM
+1

On 15 Mar 2016, at 20:53, Martin Dias <[hidden email]> wrote:

Hi,

Voyage's build is green: 
https://travis-ci.org/tinchodias/voyage/jobs/116040942
(for the build I temporarily updated BaselineOfVoyage to load #development version of Mongo).

I will release 1.9.2 as stable if nobody disagrees.

Martin



Reply | Threaded
Open this post in threaded view
|

Re: [Mongo] Creating MongoTimeStamp

tinchodias
Done: released 1.9.2.

However, I discovered a problem to run Voyage tests in the Test Runner (and in Nautilus). The problem comes from 1.9.1. This is weird because Travis builds are green... but in ui tools tests have this weird problem.


Martin

On Tue, Mar 15, 2016 at 5:07 PM, Esteban Lorenzano <[hidden email]> wrote:
+1

On 15 Mar 2016, at 20:53, Martin Dias <[hidden email]> wrote:

Hi,

Voyage's build is green: 
https://travis-ci.org/tinchodias/voyage/jobs/116040942
(for the build I temporarily updated BaselineOfVoyage to load #development version of Mongo).

I will release 1.9.2 as stable if nobody disagrees.

Martin




Reply | Threaded
Open this post in threaded view
|

Re: [Mongo] Creating MongoTimeStamp

tinchodias
Hi, new commit:

Name: Mongo-Core-MartinDias.49
Author: MartinDias
Time: 17 March 2016, 12:41:15.956567 am
UUID: 6597b821-e01e-48b0-85b5-14a60733363d
Ancestors: Mongo-Core-HolgerHansPeterFreyther.48
Make MongoDatabase>>addCollection:capped:size:max: tolerate error 48, i.e. collection already exists. This was the behavior for adding a collection before version  44 of this package.

This is the change:

addCollection: aString capped: aCapped size: aSize max: aMax
| command reply |
command := SmallDictionary new.
command at: 'create' put: aString.
aCapped ifTrue: [
command at: 'capped' put: true.
aSize ifNotNil: [command at: 'size' put: aSize].
aMax ifNotNil: [command at: 'max' put: aMax]].
reply := self command: command.
(reply at: 'ok' ifAbsent: [self halt]) = 1.0 ifFalse: [
+++ "Tolerate error 48: collection already exists"
+++ ((reply at: 'code') = 48) ifFalse: [ ^self error: 'Command failed' ]
--- ^self error: 'Command failed'.
].
^MongoCollection database: self name: aString



If no problem, I'll release 1.9.3 with this small change.

Cheers,
Martin

On Wed, Mar 16, 2016 at 2:36 AM, Martin Dias <[hidden email]> wrote:
Done: released 1.9.2.

However, I discovered a problem to run Voyage tests in the Test Runner (and in Nautilus). The problem comes from 1.9.1. This is weird because Travis builds are green... but in ui tools tests have this weird problem.


Martin

On Tue, Mar 15, 2016 at 5:07 PM, Esteban Lorenzano <[hidden email]> wrote:
+1

On 15 Mar 2016, at 20:53, Martin Dias <[hidden email]> wrote:

Hi,

Voyage's build is green: 
https://travis-ci.org/tinchodias/voyage/jobs/116040942
(for the build I temporarily updated BaselineOfVoyage to load #development version of Mongo).

I will release 1.9.2 as stable if nobody disagrees.

Martin