I currently have this method implemented such that it writes " " for the length of the record to be deleted. However, I am contemplating truncating it instead so I am hoping to gather a few opinions as to whether or not just over-writing the record with " " satisfies what the interface calls for: "Deletes a record, making the record number and associated disk storage available for reuse." I could make an argument for and against using " " to just over-write. Thoughts?
Roberto Perillo wrote:I myself used a record cache (Map<Long, Room>), so when a record is deleted, I first replace its entry in the map with null. When the application finishes and the records are written back to the file, for each entry whose values are null, I just write the deleted flag for each particular record.
Is the key in the record cache the record number? If it is, then this seems strange that a Long would be used as the key.
All of the assignments use Integer (or more precisely int) as the record number - see list of unlock methods here. For example:
Based on this, shouldn't your record cache instead be an Integer as the key i.e. Map<Integer, Room>?
Sean Keane wrote:All of the assignments use Integer (or more precisely int) as the record number - see list of unlock methods here.
I think you definitely need a pair of glasses (or maybe you just have to go and put the assignment aside for a bit )
Of course this was my error. The full list of unlock methods listed on the FAQ page is:
Version Signature of Unlock method
1.1.1 public void unlock(int recNo, long cookie) throws RecordNotFoundException, SecurityException;
1.2.1 public void unlock(long recNo, long cookie) throws SecurityException;
1.2.2 public void unlock(long recNo, long cookie) throws SecurityException;
1.3.1 public void unlock(int recNo) throws RecordNotFoundException;
1.3.3 public void unlock(int recNo) throws RecordNotFoundException;
As can be seen, when I wake up , two of the methods actually take long as the record number.