• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assignment Comments relating use of Caching and RandomAccessFile

 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have some doubts relation the use of Caching for my assignment (URLyBird 1.1.3). The following comment in my interface delivered by Sun:

// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;

This read-method gets the record according to the recNo from a file? Do they mean a physical database file? So is it then impossible for me to use caching?
Am I too pedantic?

And here comes my doubts or gap in my knowledge relating the use of the RandomAccessFile class:

... All numeric values are stored in the header information use the format of the DataInputStream and DataOutputStream. ...

This tells me, that the db file was created by using the above streams. The RandomAccessFile implements superclasses of the above Streams (DataInput and DataOutput).
Are these informations enough to allow the use of the RandomAccessFile to access our database file?

Thanks for your help.
cheers Bob
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bob,

I used the RAF and I passed, and I think every scjd'er used that class

I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method.



Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

Roel De Nijs wrote:
I used the RAF and I passed, and I think every scjd'er used that class

Seems I was a little bit pedantic here I will enter the RAF club.
Roel De Nijs wrote:
I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method. ...
Kind regards,
Roel


I really think I have a big problem. I'm not CREATIVE enough. That has to be changed
From now on I will interpret the comment "Reads a record from the file" as "Reads a record from the file via the RecordCache". I will write that down in the choices and everyone is happy.
To modify one method (read(int recNo)) does not justify creating a new interface, I think.

Thanks for opening my eyes, Roel. I feel like a new man
cheers
Bob
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bob,

Bob and Roel together in my thread. I feel honoured. The white knights in the night

Roberto Perillo wrote:Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.

I already used your database file reader. Works like hell (meant positive )
But I was to lazy to try it with RAF. I will try it, later.

Thanks and cheers
Bob


 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob Wheeler wrote:
Bob and Roel together in my thread. I feel honoured.

You certainly should be
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night


Haha indeed they are "white knights".

Well I'm not going to say much since my good buddies Roel and Roberto did the job already.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured.


Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night


Yeah - they are really great! Thanks guys!

Roberto Perillo wrote:Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!

More football commentary.

(I've got my sister & her family over from Ireland at the moment - one Man-U, one Chelsea, & one Liverpool supporter. Sigh. )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic