Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Tobias Lund-Melcher

Greenhorn
+ Follow
since Sep 24, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tobias Lund-Melcher

Thanks for your reply Alex,

no it is not necessary, its just that the Data class is becoming a bit large and I would like to delegate some of the things done in the Data class to other classes and hopefully thereby increasing the readability.

BR
-Tobias
Hi Rajesh

I'll try to give you some tips on regarding your code and reading the file.
  • You're using the seek method wrong, seek tells the RandomAccessFile where to start the read operation (not which record to read)
  • You should not hardcode field lengths, you should instead read the field lengths as defined in the schema description.


  • To read a record you could do something like this;

    seek(offset + (recordlenght * recNo))
    readRecord

    You should read the file metadata like this;

    magic = readInt()
    offset = readInt()
    fields = readShort()

    for (fields)
    fieldBytes = new byte[readShort()]
    read(fieldBytes)
    fieldnames[i] = new String(fieldBytes)
    fieldlengths[i] = readShort()
    [ September 26, 2008: Message edited by: Tobias Lund-Melcher ]
    In my assignment it is statet; "Your data access class must be called "Data.java"...". Does this mean that I only may access the data file from this class?

    I would like to create a class wich accesses the data file to retrieve the metadata describing the data file. This would allow me to exchange the reading of metadata with another class if the metadata should change leaving the Data class unchanged.

    Thanks for any help.

    -Tobias
    Are we always required to check the magic cookie? Or, is this dependent on the assignment. My assignment is the B&S ver. 2.2.3, and nowhere in my assignment can I find anything about checking the magic cookie, its existence is only revealed as part of the database file description.

    If I need to check it, how would I know which value I should expect? Is it the value I get when I run it against the file received as part of the assignment?

    Hope anyone can help me on this.