This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using record cache and booking method

 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Why do you have a seperate map with deleted records Why not just storing null in your record cache for a deleted record?


There you go. I think this is the simplest solution... and it is what I did
 
Colin Duggan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep that was the problem, thanks guys.

Why i used the list in the first place. I thought it would be a good idea to keep the deleted records in a separate list so i wouldn't have to set its String[] to null. I wanted to be able write the record back to the file on shutdown (with is valid flag set to 1). However a simple change to just write the valid flag bit when a record has been deleted solves this.

Roel, i tried the tests you mentioned earlier, running with 2500 iterations and things are looking alot better, only difference being in the second test
with deleting a record with index between 0 and 50: total number of records at the end was 49 (sometimes a delete fails because the record does not exist, so new records are just added)
In my case the number of records at the end is higher. cheers
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Colin Duggan wrote:In my case the number of records at the end is higher.

It's not exact science, so that's possible (you had more deletes of non-existing records than me). But normally you would expect just a few more or less. So when the total number of records is 70 or higher, you might have some other issue with deleting records (or the random number generator is not generating random numbers )
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:It's not exact science, so that's possible (you had more deletes of non-existing records than me). But normally you would expect just a few more or less. So when the total number of records is 70 or higher, you might have some other issue with deleting records (or the random number generator is not generating random numbers )


That's where things like mathematical induction come in!
 
Colin Duggan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya thats it, my deletes of non-existing records is pretty high;

in a run of 2500 iterations

total deleted records (reused and new) = 2249
total records created or reused =2500
total failed deletions = 251

and i end up with 282 records

with always deleting record 1: total number of records at the end was 31 (the 1st record is always reused for the new records)

the total number of records could only be 31 if we could ensure that order in which the delete and create threads execute. so if create executes when no records have been deleted then a new one will end up being created and this could happen alot over the course of 2500 iterations resulting in a large record file
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic