[Pharo-users] how to duplicate document with Voyage
Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? Best regards Olivier ;-)
Re: [Pharo-users] how to duplicate document with Voyage
Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save should do. Norbert
Re: [Pharo-users] how to duplicate document with Voyage
On 17 Apr 2014, at 10:17, Norbert Hartl norb...@hartl.name wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save +1 should do. Norbert
Re: [Pharo-users] how to duplicate document with Voyage
simply ? Thanks ;-) 2014-04-17 10:42 GMT+02:00 Esteban Lorenzano esteba...@gmail.com: On 17 Apr 2014, at 10:17, Norbert Hartl norb...@hartl.name wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save +1 should do. Norbert
Re: [Pharo-users] RDBMS Atomic Counter?
I think this is simply a case of optimistic locking - there is a general way and very often db specific ways first you get the current active value ... (one row) currentValue from select counterfield from tablename then you update the table (single row) update tablename set counterfield = currentValue + 1 where counterfield = currentValue commit then you look how many rows have been changed (=1) and assume, that commit was successful and then you know if you were successful ... otherwise you must retry ... this is a simple, with worst performance but portale approach ... Marten Am 16.04.2014 21:52, schrieb Esteban A. Maringolo: Hi, A few weeks ago Sven was asking for a lock-free in-image atomic counter. Today I'm in need of implementing a DB backed (PGSQL) counter for business forms numbering, and maybe there are some toughts you're willing to share :) I can't find any other way than a row lock for each counter, but maybe there is something better (I avoid locks as much as possible). Any thoughts to share here? Regards! -- Marten Feldtmann
[Pharo-users] Voyage: how to delete references to objects.
Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? Best regards Olivier ;-)
Re: [Pharo-users] Voyage: how to delete references to objects.
Am 17.04.2014 um 13:53 schrieb olivier olivier.auver...@gmail.com: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert
Re: [Pharo-users] Voyage: how to delete references to objects.
Am 17.04.2014 um 15:05 schrieb olivier auverlot olivier.auver...@gmail.com: thanks Robert for the explications. It’s Norbert btw. :) I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? You need to explicitly save it as we don’t have something like write barriers in the image. So aComicCollection removeBook: aBook; save is needed. Norbert Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl norb...@hartl.name: Am 17.04.2014 um 13:53 schrieb olivier olivier.auver...@gmail.com: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert
Re: [Pharo-users] Voyage: how to delete references to objects.
Norbert, Sorry for my mistake ;-) 2014-04-17 15:18 GMT+02:00 Norbert Hartl norb...@hartl.name: Am 17.04.2014 um 15:05 schrieb olivier auverlot olivier.auver...@gmail.com: thanks Robert for the explications. It’s Norbert btw. :) I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? You need to explicitly save it as we don’t have something like write barriers in the image. So aComicCollection removeBook: aBook; save is needed. Norbert Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl norb...@hartl.name: Am 17.04.2014 um 13:53 schrieb olivier olivier.auver...@gmail.com: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert
Re: [Pharo-users] Voyage: how to delete references to objects.
Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] ml-node+s1294792n4755092...@n4.nabble.com wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl [hidden email]http://user/SendEmail.jtp?type=nodenode=4755092i=0 : Am 17.04.2014 um 13:53 schrieb olivier [hidden email]http://user/SendEmail.jtp?type=nodenode=4755092i=1 : Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert -- If you reply to this email, your message will be added to the discussion below: http://forum.world.st/Voyage-how-to-delete-references-to-objects-tp4755088p4755092.html To start a new topic under Pharo Smalltalk Users, email ml-node+s1294792n1310670...@n4.nabble.com To unsubscribe from Pharo Smalltalk Users, click herehttp://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=1310670code=c2FiaW5lLmtub2VmZWxAZ21haWwuY29tfDEzMTA2NzB8MTA0OTM5MTYx . NAMLhttp://forum.world.st/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://forum.world.st/Voyage-how-to-delete-references-to-objects-tp4755088p4755097.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Re: [Pharo-users] Voyage: how to delete references to objects.
Sabine, I read the case now the first time. Just one note. Having references in both directions is probably not the best idea if using a non-object store. For navigating the graph it might be good but for persisting it is not. The serialization is a lot more complex if you do and the gain is nothing. For most databases with proper indexes you can request both directions easily and fast. So having one reference pointing from A to B you get the opposite direction for free. Norbert Am 17.04.2014 um 15:22 schrieb Sabine Knöfel sabine.knoe...@gmail.com: Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] [hidden email] wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl [hidden email]: Am 17.04.2014 um 13:53 schrieb olivier [hidden email]: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert If you reply to this email, your message will be added to the discussion below: http://forum.world.st/Voyage-how-to-delete-references-to-objects-tp4755088p4755092.html To start a new topic under Pharo Smalltalk Users, email [hidden email] To unsubscribe from Pharo Smalltalk Users, click here. NAML View this message in context: Re: Voyage: how to delete references to objects. Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Re: [Pharo-users] Voyage: how to delete references to objects.
Hi Norbert, for me the gain within smalltalk is huge because I want to navigate from person to trip and from trip to person by the attributes without asking mongo for the correspondent object via indexes. Don't you think that this is a question of design of the object model and should not be decided by database arguments? Regards Sabine On Thu, Apr 17, 2014 at 3:40 PM, NorbertHartl [via Smalltalk] ml-node+s1294792n4755102...@n4.nabble.com wrote: Sabine, I read the case now the first time. Just one note. Having references in both directions is probably not the best idea if using a non-object store. For navigating the graph it might be good but for persisting it is not. The serialization is a lot more complex if you do and the gain is nothing. For most databases with proper indexes you can request both directions easily and fast. So having one reference pointing from A to B you get the opposite direction for free. Norbert Am 17.04.2014 um 15:22 schrieb Sabine Knöfel [hidden email]http://user/SendEmail.jtp?type=nodenode=4755102i=0 : Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] a href=x-msg://56/user/SendEmail.jtp?type=nodeamp;node=4755097amp;i=0 target=_top rel=nofollow link=external[hidden email] wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl [hidden email]http://user/SendEmail.jtp?type=nodenode=4755092i=0 : Am 17.04.2014 um 13:53 schrieb olivier [hidden email]http://user/SendEmail.jtp?type=nodenode=4755092i=1 : Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert -- If you reply to this email, your message will be added to the discussion below: http://forum.world.st/Voyage-how-to-delete-references-to-objects-tp4755088p4755092.html To start a new topic under Pharo Smalltalk Users, email a href=x-msg://56/user/SendEmail.jtp?type=nodeamp;node=4755097amp;i=1 target=_top rel=nofollow link=external[hidden email] To unsubscribe from Pharo Smalltalk Users, click here. NAMLhttp://forum.world.st/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: Re: Voyage: how to delete references to objects.http://forum.world.st/Voyage-how-to-delete-references-to-objects-tp4755088p4755097.html Sent from the Pharo Smalltalk Users mailing list
Re: [Pharo-users] Voyage: how to delete references to objects.
Am 17.04.2014 um 15:52 schrieb Sabine Knöfel sabine.knoe...@gmail.com: Hi Norbert, for me the gain within smalltalk is huge because I want to navigate from person to trip and from trip to person by the attributes without asking mongo for the correspondent object via indexes. Don't you think that this is a question of design of the object model and should not be decided by database arguments? I think there isn’t only one _or_ the other. Of course it is a lot more beautiful to have set up proper objects and collections and do everything in a smalltalkish way. That does only count as long as you stay on the island (smalltalk image). As soon as you start to play with the outer world you have to change your rules. If you agree it isn’t perfectly beautiful if you have a proper object model that freezes your image, right? :) IMHO the beauty comes from a mixture of both that fit them together without restricting one or the other. So I would try to avoid storing both directions. But which one to skip? If I assume that a person can have a lot of trips than I would skip the collection inside Person. The more trips a Person has the bigger the serialized document becomes. This makes it first slower to operate on the database and will fail if you reach a document size of 16MB because that is the maximum Mongo supports. Most of the time this will be a non-issue but for now I take it into account. So the data model will have a class Trip with an instVar pointing to Person. And Person will have an instVar trips that is transient (see VOMongoTransientDescription). The implementation for Person then goes Person#trips ^ trips ifNil: [ trips := self fetchTrips ] Person#fetchTrips ^ Trips selectMany: [: each| … ] Person#addTrip: aTrip aTrip person: self. aTrip save So the Trip will have a reference to Person in the database but Person will have no reference to Trip. Person will retrieve its trips as soon as they are used in a really smalltalkish way :). Person acts as a smalltalk object and as a database object cache at the same time. So this an implementation of Person that on the inside takes the database nature in regard but on the outside the interface is pure smalltalk. Still not good? Norbert Regards Sabine On Thu, Apr 17, 2014 at 3:40 PM, NorbertHartl [via Smalltalk] [hidden email] wrote: Sabine, I read the case now the first time. Just one note. Having references in both directions is probably not the best idea if using a non-object store. For navigating the graph it might be good but for persisting it is not. The serialization is a lot more complex if you do and the gain is nothing. For most databases with proper indexes you can request both directions easily and fast. So having one reference pointing from A to B you get the opposite direction for free. Norbert Am 17.04.2014 um 15:22 schrieb Sabine Knöfel [hidden email]: Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] a href=x-msg://56/user/SendEmail.jtp?type=nodeamp;node=4755097amp;i=0 target=_top rel=nofollow link=external[hidden email] wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl [hidden email]: Am 17.04.2014 um 13:53 schrieb olivier [hidden email]: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the
Re: [Pharo-users] Voyage: how to delete references to objects.
On 17 Apr 2014, at 15:18, Norbert Hartl norb...@hartl.name wrote: Am 17.04.2014 um 15:05 schrieb olivier auverlot olivier.auver...@gmail.com: thanks Robert for the explications. It’s Norbert btw. :) I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? You need to explicitly save it as we don’t have something like write barriers in the image. So aComicCollection removeBook: aBook; save is needed. yes, and also (if you want to be clean): aBook remove. (assuming aBook is also persistent). But as Sabina points: #enableMissingContent in CommicCollection will help you to simplify things, then you just need: aBook remove, and next time you read aComicCollection it will “clean” the invalid reference. I call that “eventual integrity” :P but beware of it… is considered “power voyage programming” :) Esteban Norbert Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl norb...@hartl.name: Am 17.04.2014 um 13:53 schrieb olivier olivier.auver...@gmail.com: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert
Re: [Pharo-users] Voyage: how to delete references to objects.
On 17 Apr 2014, at 16:26, Norbert Hartl norb...@hartl.name wrote: Am 17.04.2014 um 15:52 schrieb Sabine Knöfel sabine.knoe...@gmail.com: Hi Norbert, for me the gain within smalltalk is huge because I want to navigate from person to trip and from trip to person by the attributes without asking mongo for the correspondent object via indexes. Don't you think that this is a question of design of the object model and should not be decided by database arguments? I think there isn’t only one _or_ the other. Of course it is a lot more beautiful to have set up proper objects and collections and do everything in a smalltalkish way. That does only count as long as you stay on the island (smalltalk image). As soon as you start to play with the outer world you have to change your rules. If you agree it isn’t perfectly beautiful if you have a proper object model that freezes your image, right? :) IMHO the beauty comes from a mixture of both that fit them together without restricting one or the other. So I would try to avoid storing both directions. But which one to skip? If I assume that a person can have a lot of trips than I would skip the collection inside Person. The more trips a Person has the bigger the serialized document becomes. This makes it first slower to operate on the database and will fail if you reach a document size of 16MB because that is the maximum Mongo supports. Most of the time this will be a non-issue but for now I take it into account. So the data model will have a class Trip with an instVar pointing to Person. And Person will have an instVar trips that is transient (see VOMongoTransientDescription). The implementation for Person then goes Person#trips ^ trips ifNil: [ trips := self fetchTrips ] Person#fetchTrips ^ Trips selectMany: [: each| … ] Person#addTrip: aTrip aTrip person: self. aTrip save So the Trip will have a reference to Person in the database but Person will have no reference to Trip. Person will retrieve its trips as soon as they are used in a really smalltalkish way :). Person acts as a smalltalk object and as a database object cache at the same time. So this an implementation of Person that on the inside takes the database nature in regard but on the outside the interface is pure smalltalk. Still not good? yes, no good :) I mean: I understand there are times when you need it, but I would prefer a framework to solve that for me (then I can think just in my objects). And if the framework does not do a good job, then is a bad framework (even if made by me :P) and it needs to be improved. having to think in persistence is a cancer that needs to be removed :P Esteban Norbert Regards Sabine On Thu, Apr 17, 2014 at 3:40 PM, NorbertHartl [via Smalltalk] [hidden email] wrote: Sabine, I read the case now the first time. Just one note. Having references in both directions is probably not the best idea if using a non-object store. For navigating the graph it might be good but for persisting it is not. The serialization is a lot more complex if you do and the gain is nothing. For most databases with proper indexes you can request both directions easily and fast. So having one reference pointing from A to B you get the opposite direction for free. Norbert Am 17.04.2014 um 15:22 schrieb Sabine Knöfel [hidden email]: Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] a href=x-msg://56/user/SendEmail.jtp?type=nodeamp;node=4755097amp;i=0 target=_top rel=nofollow link=external[hidden email] wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl [hidden email]: Am 17.04.2014 um 13:53 schrieb olivier [hidden email]: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image
Re: [Pharo-users] Voyage: how to delete references to objects.
Am 17.04.2014 um 18:05 schrieb Esteban Lorenzano esteba...@gmail.com: On 17 Apr 2014, at 16:26, Norbert Hartl norb...@hartl.name wrote: Am 17.04.2014 um 15:52 schrieb Sabine Knöfel sabine.knoe...@gmail.com: Hi Norbert, for me the gain within smalltalk is huge because I want to navigate from person to trip and from trip to person by the attributes without asking mongo for the correspondent object via indexes. Don't you think that this is a question of design of the object model and should not be decided by database arguments? I think there isn’t only one _or_ the other. Of course it is a lot more beautiful to have set up proper objects and collections and do everything in a smalltalkish way. That does only count as long as you stay on the island (smalltalk image). As soon as you start to play with the outer world you have to change your rules. If you agree it isn’t perfectly beautiful if you have a proper object model that freezes your image, right? :) IMHO the beauty comes from a mixture of both that fit them together without restricting one or the other. So I would try to avoid storing both directions. But which one to skip? If I assume that a person can have a lot of trips than I would skip the collection inside Person. The more trips a Person has the bigger the serialized document becomes. This makes it first slower to operate on the database and will fail if you reach a document size of 16MB because that is the maximum Mongo supports. Most of the time this will be a non-issue but for now I take it into account. So the data model will have a class Trip with an instVar pointing to Person. And Person will have an instVar trips that is transient (see VOMongoTransientDescription). The implementation for Person then goes Person#trips ^ trips ifNil: [ trips := self fetchTrips ] Person#fetchTrips ^ Trips selectMany: [: each| … ] Person#addTrip: aTrip aTrip person: self. aTrip save So the Trip will have a reference to Person in the database but Person will have no reference to Trip. Person will retrieve its trips as soon as they are used in a really smalltalkish way :). Person acts as a smalltalk object and as a database object cache at the same time. So this an implementation of Person that on the inside takes the database nature in regard but on the outside the interface is pure smalltalk. Still not good? yes, no good :) I mean: I understand there are times when you need it, but I would prefer a framework to solve that for me (then I can think just in my objects). And if the framework does not do a good job, then is a bad framework (even if made by me :P) and it needs to be improved. Sure. I was talking about _real_ stuff you can do _now_. I like to think just in objects, too. But we have a separation in hard disc and memory so we need to take care about persistence. I would also prefer to think just in programming and not have to use a stupid device like a keyboard and a mouse just in order to type silly characters that when interpreted probably come close to what I meant. But for the time being I need to stick to it, I guess. having to think in persistence is a cancer that needs to be removed :P Yep, we just need a common memory space where we can waste Zetabytes of memory to do little programs. Ah, and did I mention it needs to be infinitely fast because I have a certain use case and I don’t like to optimize it because I think that is cancer, too? Very academic view, well done! :) Norbert Esteban Norbert Regards Sabine On Thu, Apr 17, 2014 at 3:40 PM, NorbertHartl [via Smalltalk] [hidden email] wrote: Sabine, I read the case now the first time. Just one note. Having references in both directions is probably not the best idea if using a non-object store. For navigating the graph it might be good but for persisting it is not. The serialization is a lot more complex if you do and the gain is nothing. For most databases with proper indexes you can request both directions easily and fast. So having one reference pointing from A to B you get the opposite direction for free. Norbert Am 17.04.2014 um 15:22 schrieb Sabine Knöfel [hidden email]: Hi Olivier, possibly the option VOMongoContainerenableMissingContent; is useful to avoid http://forum.world.st/Voyage-image-freeze-VOMongoError-Lazy-reference-not-found-td4703739.html Here is an example: http://esug.org/data/ESUG2013/4-Thu/03-ESUG2013%20-%20VoyageTutorial.pdf Regards Sabine On Thu, Apr 17, 2014 at 3:07 PM, Olivier Auverlot [via Smalltalk] a href=x-msg://56/user/SendEmail.jtp?type=nodeamp;node=4755097amp;i=0 target=_top rel=nofollow link=external[hidden email] wrote: thanks Robert for the explications. I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply
Re: [Pharo-users] We need *you* for the upcoming Pharo's website
Hi Kilon, On Wed, Apr 16, 2014 at 6:44 PM, kilon alios kilon.al...@gmail.com wrote: I was thinking of creating a screencast to explain in a few minutes why I like Pharo, emphasizing on live coding , the image and the development environment. By coincidence I recorded a test tutorial yesterday (before noticing this announcement) for the very basics of pharo, just 15 minutes. So its definitely something I am willing to do. Its just that will like to do several tries and possible edit it to make it as efficient and as simple as possible. So If you are not in a hurry I can offer something. that would be really great. We want to release the new website in the coming 2/3 weeks, do you think you could make it? Maybe you could do short ones that show a specific feature or two each? That would make integration into the website easier. As an example, the ones of babymock are great: http://www.youtube.com/watch?v=cPbItfNc5WY Thanks -- Damien Cassou http://damiencassou.seasidehosting.st Success is the ability to go from one failure to another without losing enthusiasm. Winston Churchill
Re: [Pharo-users] We need *you* for the upcoming Pharo's website
please use nice looking font and large ones and go ahead :) On 16/4/14 18:44, kilon alios wrote: I was thinking of creating a screencast to explain in a few minutes why I like Pharo, emphasizing on live coding , the image and the development environment. By coincidence I recorded a test tutorial yesterday (before noticing this announcement) for the very basics of pharo, just 15 minutes. So its definitely something I am willing to do. Its just that will like to do several tries and possible edit it to make it as efficient and as simple as possible. So If you are not in a hurry I can offer something. On Wed, Apr 16, 2014 at 12:16 PM, Esteban Lorenzano esteba...@gmail.com mailto:esteba...@gmail.com wrote: please do not answer all at once! (subtle irony) anyway, I have to add that screencast has to be Pharo3 based. cheers, Esteban On 15 Apr 2014, at 13:03, Damien Cassou damien.cas...@gmail.com mailto:damien.cas...@gmail.com wrote: Hi everyone, we are working on a new website for Pharo! We need your help. If you have some time, please create and send us one of the following items: - An up-to-date screenshot of Pharo 3.0 that shows some cool features. It should be 800px wide ; - A screencast ; - A paragraph (around 40 words) that presents a nice topic about Pharo and a corresponding screenshot. We will select 1 large screenshot, 3 screencasts and 4 topic paragraphs. This could be a very nice way for you to contribute to Pharo! Best, -- Damien Cassou http://damiencassou.seasidehosting.st Success is the ability to go from one failure to another without losing enthusiasm. Winston Churchill
Re: [Pharo-users] how to duplicate document with Voyage
Hi norbert Olivier was doing a copy but it did not work and we thought that Voyage should offer a clone or something like that that does not mess up with the id. Because we already corrupted nicely a mongoDB. Stef On 17/4/14 10:17, Norbert Hartl wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save should do. Norbert
Re: [Pharo-users] how to duplicate document with Voyage
Ok so what I said was wrong :) On 17/4/14 10:48, olivier auverlot wrote: simply ? Thanks ;-) 2014-04-17 10:42 GMT+02:00 Esteban Lorenzano esteba...@gmail.com mailto:esteba...@gmail.com: On 17 Apr 2014, at 10:17, Norbert Hartl norb...@hartl.name mailto:norb...@hartl.name wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com mailto:olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save +1 should do. Norbert
Re: [Pharo-users] how to duplicate document with Voyage
Hi, copy should not mess with the id (unless your objects redefines = and hash). I can take a look if Olivier is around tomorrow. Esteban On 17 Apr 2014, at 21:41, pharo4s...@free.fr wrote: Hi norbert Olivier was doing a copy but it did not work and we thought that Voyage should offer a clone or something like that that does not mess up with the id. Because we already corrupted nicely a mongoDB. Stef On 17/4/14 10:17, Norbert Hartl wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save should do. Norbert
Re: [Pharo-users] Voyage: how to delete references to objects.
esteban you should do a pass on the voyage documentation chapter and add this kind of infomration. We can pair write if you want. stef On 17/4/14 17:56, Esteban Lorenzano wrote: On 17 Apr 2014, at 15:18, Norbert Hartl norb...@hartl.name mailto:norb...@hartl.name wrote: Am 17.04.2014 um 15:05 schrieb olivier auverlot olivier.auver...@gmail.com mailto:olivier.auver...@gmail.com: thanks Robert for the explications. It’s Norbert btw. :) I agree with you that's the best way to remove a book is to delete the reference in ComicsCollection. But how to do that ? Must I simply remove the reference in the ordered collection ? Voyage will syncronize automatically the data in memory with the content of the database ? Must I force the save of the data after removing the reference ? You need to explicitly save it as we don’t have something like write barriers in the image. So aComicCollection removeBook: aBook; save is needed. yes, and also (if you want to be clean): aBook remove. (assuming aBook is also persistent). But as Sabina points: #enableMissingContent in CommicCollection will help you to simplify things, then you just need: aBook remove, and next time you read aComicCollection it will “clean” the invalid reference. I call that “eventual integrity” :P but beware of it… is considered “power voyage programming” :) Esteban Norbert Olivier ;-) 2014-04-17 14:10 GMT+02:00 Norbert Hartl norb...@hartl.name mailto:norb...@hartl.name: Am 17.04.2014 um 13:53 schrieb olivier olivier.auver...@gmail.com mailto:olivier.auver...@gmail.com: Hi, I'm using Voyage in a Pharo application. I have two MongoDB collections which are ComicsCollection and ComicsBook. Each book is attached to a instance of ComicsCollection. The reference of each book is stored in an ordered collection (in the instance of ComicsCollection). The problem is that if I remove a book, the reference to the book is not deleted from ComicsCollection. How can I remove properly a book and the reference to the book ? From the smalltalk image view the problem is usually exactly the opposite: You don’t delete objects but you remove references to them. As voyage maps objects it is a good idea to stay in the object realm. So you should rather remove the book from the collection. This way you won’t get errors just garbage. The „real“ problem that arises then is that the book would still be in the database. Just like it is in the image but there is no garbage collector for mongo. To decide that from the image is not possible. You load only a sub graph from the database into image memory. So you don’t know if there are other objects referencing the book. If your records fit all in memory you could load all collections and books and build the difference between all referenced books in the collections and the total amount of books. The difference will be the set of objects not being referenced by a collection and those can be deleted. If the records do not fit in memory an alternative strategy would be needed. I started to research if it is possible to build a map/reduce based garbage collector for common cases but got distracted. But I have the same problem so I will need to pick it up some time. hope that helps, Norbert
Re: [Pharo-users] how to duplicate document with Voyage
On 17/4/14 21:45, Esteban Lorenzano wrote: Hi, copy should not mess with the id (unless your objects redefines = and hash). I can take a look if Olivier is around tomorrow. Thanks. I told him to talk to you but this is a really shy guy :) He is pushing Pharo to build other application in the lab :) Esteban On 17 Apr 2014, at 21:41, pharo4s...@free.fr wrote: Hi norbert Olivier was doing a copy but it did not work and we thought that Voyage should offer a clone or something like that that does not mess up with the id. Because we already corrupted nicely a mongoDB. Stef On 17/4/14 10:17, Norbert Hartl wrote: Am 17.04.2014 um 10:08 schrieb Olivier Auverlot olivier.auver...@gmail.com: Hi, I'm using Voyage and I need to duplicate an existing document in a Mongo database. I suppose that the id must be changed before saving. What is the best way to do that ? If you need a shallow copy then you better just copy the object and store it. Changing the id is asking for trouble I guess. That would probably work if you implement #= on those objects but I think it is a hack. anObject copy save should do. Norbert