aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Using record cache and booking method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Using record cache and booking method" Watch "Using record cache and booking method" New topic
Author

Using record cache and booking method

Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

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


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Colin Duggan
Ranch Hand

Joined: Feb 23, 2008
Posts: 41
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
Bartender

Joined: Jul 19, 2004
Posts: 5596
    
  15

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 )


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

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

Joined: Feb 23, 2008
Posts: 41
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using record cache and booking method