Hi,
I'm trying to test uploading several thousand objects into an OmniBase db and I'm trying to figure out how to commit every 100th object. Can anyone shed some light into this? Every time I try something, it must be surrounded by a transaction, so I can't figure out how to do it.
I have stored a LinkedList to a root element. I have something similar to this:
txn := db newTransaction. 1 to: 1000 do: [:i| base := txn root at: 'linkedlist'. base add: anObject. (i \ 100) = 0 ifTrue: [ txn commit. txn := db newTransaction]]
But this doesn't seem to work. Please help.
Thanks, Daniel
On 4/26/05, Daniel Salama dsalama@user.net wrote:
I'm trying to test uploading several thousand objects into an OmniBase db and I'm trying to figure out how to commit every 100th object. Can anyone shed some light into this? Every time I try something, it must be surrounded by a transaction, so I can't figure out how to do it.
I have stored a LinkedList to a root element. I have something similar to this:
txn := db newTransaction. 1 to: 1000 do: [:i| base := txn root at: 'linkedlist'. base add: anObject. (i \ 100) = 0 ifTrue: [ txn commit. txn := db newTransaction]]
But this doesn't seem to work. Please help.
I would think it would be something like this:
10 timesRepeat: [ [ base := OmniBase root at: 'linkedlist'. 100 timesRepeat: [base add: anObject] ] evaluateAndCommitIn: db newTransaction ]
Avi
Daniel Salama wrote:
I'm trying to test uploading several thousand objects into an OmniBase db and I'm trying to figure out how to commit every 100th object.
txn := db newTransaction. 1 to: 1000 do: [:i| base := txn root at: 'linkedlist'. base add: anObject. (i \ 100) = 0 ifTrue: [ txn commit. txn := db newTransaction]]
How about:
base := txn root at: 'linkedlist'. txn := db newTransaction. 1 to: 1000 do: [:i| base add: anObject. base markDirty. "If you're not using a persistent collection" (i \ 100) = 0 ifTrue: [ txn checkpoint ]]. txn commit
If you look at the implementation of ODBLocalTransaction>>commit it just does a checkpoint and an abort. The abort makes it so that the transaction can't be checkpoint'ed again. So I think your loop would be simpler if you just checkpoint every 100, and do one final commit.
BTW, I've got my framework working with OmniBase, so I'll update the timings I made for your test data.
squeak-dev@lists.squeakfoundation.org