• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using record cache and booking method

 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic