Roel De Nijs wrote:Hi Roman,
Welcome to the ranch!
Let me ask you some questions:
a) "the total size of all records", i guess you mean "the total size of all fields in a record"
b) does your recordNumber start at 0 or 1?
c) in my db-schema i have first a delete flag (indicating if that record is a deleted or a valid record) and then i have the actual record. did you add that byte (or bytes) to your sizeRecords?
your formula you use looks fine to me (if of course recNo starts at 1): dataOffset + (recNo - 1) * recordLength
Roel De Nijs wrote:random behavior is idd a big problem to debug I had also a problem with reading/writing the file but i was lucky: problem appeared with each run, so the bug was found easily.
don't forget to start each run with a brand new copy of your data file so you are completely sure the data isn't already corrupted
a) what's the length of all your fields?
b) what's the size of the "deleted" flag (according to your instruction)
c) what is getSizeRecord() returning? the length of all your fields? or the length of all your fields + the size of the deleted flag?
d) if you create your record don't forget to write the "deleted"-flag also
if you create your record don't forget to write the "deleted"-flag also
my calculation is correct?
I ask this because when I create a record with the method create () an error is occurring:
getSizeRecord() returning == 183 and the length of all my fields (not include delete flag)
Roel De Nijs wrote:
my calculation is correct?
I ask this because when I create a record with the method create () an error is occurring:
you don't use the calculateSeekPoint-method in your create-method, because you use seek(getFile().length());
getSizeRecord() returning == 183 and the length of all my fields (not include delete flag)
if it returns the length of all my fields, your calculate method is wrong, it should be
because the length of a record = length of all your fields + the deleted/valid flag
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record
SCJP 1.4 100%
SCJD 99.5%
returning == 183 and the length of all my fields (not include delete flag)