Forums Register Login

NX: Help with storing DB size

+Pie Number of slices to send: Send
Hi all,
I have run into a problem that you may be able to help me with.
I have the class Data which is reading the DB with a RAF. This class uses a class called DBMeataData which contains the header info within the DB. The DBMetaData uses a DataInputStream to read the header info. I want add a method to the DBMetaData classes that will return the number of records in the DB. I plan to work out the number of records from the size of the file. This is where I have my problem the, I can not get the size of the file from the DataInputStream. However I can get the size of the file from the RAF within the Data class. The number of records in the DB is metadata not the data.
I hope you understand my problem,
thanks
Chris
+Pie Number of slices to send: Send
Well I'd consider that maybe the number of records should not be considered part of the metadata. My own DBMetaData is an immutable class; it's initialized by reading the header info, and the data it represents cannot be changed. (Which is useful to know for thread safety.) The number of records cannot be betermined from the header, and is mutable (thanks to create() and deleted()). Assuming you need this method at all, couldn't you put it in the Data class rather than DBMetaData? What benefit is there to putting the method in DBMetaData?
+Pie Number of slices to send: Send
Hi Jim,
The reason I wanted to put the getNumRecords methods within DBMeataData was beacuse I wanted the Data classes to ONLY have public methods which have been defined within the DB interface. Which is not really a strong reason.
I was planned to use the getNumRecords was within a DBAdapter class that has a method called getContractors(). This methods returns all the contractors within this database. The getContractors method calls the read method within Data with reocrd numbers 0 to numOfRecords.
Another way of doing this would be to added a method called read() to Data which reads all the records within the database. Again I was not up for this idea as the read() method was not defined within the DB interface.
DO you think it would be ok to define public methods within the Data that are not defined within the DB interface?
Thanks
Chris
+Pie Number of slices to send: Send
DO you think it would be ok to define public methods within the Data that are not defined within the DB interface?
Yup. In fact my own Data class has a getMetaData() method which is how clients get the metadata. (I use thick clients; all validation is client-side, none on server-side, because that was the simplest way to implement my requirements as I understood them, even though ut's probably not what I'd do in the "real world".)
One other alternative is your DBAdapter could use find([all nulls]) to get a list of all possible record numbers, then read(recNo) for each one individually. However calling find() for this rather inefficient. It's your call if that's good enough reason to add a getMaxRecNo() method, but I did it.
[ October 09, 2003: Message edited by: Jim Yingst ]
+Pie Number of slices to send: Send
Jim,
Thanks I forgot all about find(null).
It may be inefficient but the requirments do not mention anything about performace.
I am looking for a nice and simple solution. (What I end up with may be something very diffrent).
Chris
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 566 times.
Similar Threads
Header from network packet
calculating the number of records in the data file.
Suggested Locking Solution
End of file indication
URLyBird db format
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:50:52.