Dear Dr. Wang:
Xiaogang Wang wrote:
>Hi,
>
> Thanks to all who replied. They are very timely and helpful.
>
>The reason I did not use direct access file is that I prefer to put a few
>'header' records at the beginning of the binary file such as number of records,
>length of each record. This way the file itself is self-contained.
>(the example I gave was a oversimplified one)
>
It looks like you are combining two very different kinds of
information into one file:
1. The data itself
2. Information about how the file is structured.
These are really two very different concepts and kinds of
information. You may wish to place each kind of information into
separate files, the data file and a configuration file about the data
file. This makes conceptual sense and is usually considered to be good
practice.
Of course, ordinary, generic files are not database tables, so you
don't have to implement this idea. However, putting the configuration
information about your data file into a separate configuration file
would most likely allow you to restructure your data file as a direct
access file. This would allow you to take advantages of the execution
efficiencies of direct access files, if this is important to you, which
seems to be the case, according to your previous message.
> Another reason is that once I choose to use sequential access, I never come
>back to think about the direct access option.
>
It's usually helpful to re-visit your assumptions and design
decisions from time to time, to see if you overlooked anything, to
adjust to changes in circumstances, and to see if there are any ways to
improve your system.
> Thanks to Malcolm Cohen who suggested to use a read with a blank I/O list.
>Malcolm believe that this will also skip the record ( the data is not actually
>read from the disk). This sounds very likely to be true. If so, this
>would be the ideal solution to my problem with a very big record size (million).
>
>Xiaogang
>
As Richard Maine pointed out in a separate answer, the I/O library
may not necessarily skip disk sectors on sequential I/O. There is a
much better chance of execution efficiencies using direct I/O, since all
records in direct-access files must have the same length. It's the use
of fixed-length records that makes it possible to easily and accurately
compute the position of any arbitrary record within the file.
>Malcolm Cohen said:
>
>
>>Clive Page said:
>> > Doesn't a read with nothing in it's I/O list perform a skip of one record?
>>
>> Indeed so, that's why I suggested it!
>>
>> > If so, this would be better, as there's no possibility of a data type
>> > incompatibility.
>>
>> There is also no possibility of the record being too big or too small
>> (for the requested data); READ with no list skips one record whatever size.
>>
>>
>
>------------------------------------------------
>Dr Xiaogang Wang
>Departement de chimie
>Universite de Montreal
>C.P. 6128, succursale Centre-ville
>Montreal (Quebec) H3C 3J7
>
>Tel. (514) 3436111 ext 3947 (office)
>FAX (514) 3437586 (office)
>e-mail: [log in to unmask]
>homepage: http://www.esi.umontreal.ca/~wangx
>------------------------------------------------
>
>
--
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place E-mail: [log in to unmask]
Brookfield, WI 53005-2759 Voice Phone: (262) 783-5869
USA Fax Phone: (262) 783-5928
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." -- Benjamin Franklin
(1759)
|