• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calculating OffSet

 
Ixus See
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys, I am confuse about calculating Offset Values.

For the first record.. it should be

the header ... but for the 2nd and next...

do use

1) headersize + (a record size * currentRecordNo) + deleteflag(1)

or

2) headersize + (a record size * (currentRecordNo)) + currentRecordNo;

it seems the 2nd way works.. I don't understand why must i add the current record count and not + 1 for delete flag.
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it is just working because your deleted flag is 1. If it was 2 I guess your 2nd formula would not work at all.

I would expect something like: headerSize + ((record length + deleted flag) * recNo)
 
Ixus See
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same here.. I would also expect that + 1 for delete flag(but it didn't work all the words are jumble up)... BUT the 2nd formula works!!! I don't know why.. can some guru explain to me~??~
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please notice the difference in my formula against your 1st formula! They give complete different results!
 
Ixus See
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Please notice the difference in my formula against your 1st formula! They give complete different results!


oh!! pardon me, I haven't been sleeping much for days.. and still stuck @ database layer..

Thanks once again
 
Sean Keane
Ranch Hand
Posts: 582
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest opening the file with a Hex Editor and starting comparing the schema to the file contents. Then everything will be clear. This thread here should help you to understand the schema and read the data file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic