• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calculating the number of records in the data file.

 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have some questions about calculating the number of records in the data file.
I calculate the number in this way:

( [Length of this file] � [header size] � [schema size] ) / [size of one record with a flag]

For length calculation of my file I use length() method from RandomAccessFile. And the return value of length is long. Does it mean that I need to use long?

The problem is that my DB interface has e.g. read Method with int argument. Do I need to use int instead of long? Or can I change my DB interface? When I use int the precision will be lost when the size of the file is bigger than int.
Do you have some idea how to solve this problem?
Thanks for your help!!!

p.s. sorry for my bad English!

[ February 14, 2005: Message edited by: Olena Golub ]
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Olena,

The RandomAccessFile uses a long to indicate positions in the file and its size. It would be nice to honour this.

In your read interface however, you are referring to record indices. You'll probably have a hundred times fewer records in your file than you will have bytes. With int you can address up to 2 billion records, which should be sufficient. Of course unless more than 1/3 of the world population will start their own contractor businesses

So use long when dealing with file size/positions and use int when dealing with record numbers.

Frans.
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frans,

Thanks for your quick answer.

And what about calculation of the record number? Should I use int or long?


or


[ February 14, 2005: Message edited by: Olena Golub ]
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Olena,

I personally would prefer the method that returns an int.

You will convert down to an int somewhere (because the interface forces you) and I think the location where you calculate your record number is the most natural place to do that.

Frans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic