G
Guest
Hi All,
I am a bit stuck with a project: Specifically, when making a database like
engine in 'the old days', I would have wrapped a record class with a stream
class, so I could have a file of records on disc, such that I could always
jump straight to the record number I wanted. Simple random file access.
Maybe they were fixed length records and I knew the n'th record was
(n*length of record) into the file. I could therefore jump straight to the
(n*length of record)th byte and read out the record, since I knew how long
each fixed length record was. Then by using a b-tree algorithm I could have
myself a mini-database engine.
The question is how do I implement the record management class in C#, using
serialization, so that I can jump straight to a specific record? Since
everything is wrapped up nicely in classes and objects. we don't use pointers
much nowadays, nor know how 'big' classes/structs are in terms of bytes, how
do I jump straight to the record I want in a file of records on disc? (or in
memory, etc).
It may be that I have not thought this through enough, but I don't see an
easy way to do this.
If anybody could point me in the right direction I would be very grateful.
If I have described the problem badly give me a shout and I will do my best
to clarify,
Thanks,
Gary.
I am a bit stuck with a project: Specifically, when making a database like
engine in 'the old days', I would have wrapped a record class with a stream
class, so I could have a file of records on disc, such that I could always
jump straight to the record number I wanted. Simple random file access.
Maybe they were fixed length records and I knew the n'th record was
(n*length of record) into the file. I could therefore jump straight to the
(n*length of record)th byte and read out the record, since I knew how long
each fixed length record was. Then by using a b-tree algorithm I could have
myself a mini-database engine.
The question is how do I implement the record management class in C#, using
serialization, so that I can jump straight to a specific record? Since
everything is wrapped up nicely in classes and objects. we don't use pointers
much nowadays, nor know how 'big' classes/structs are in terms of bytes, how
do I jump straight to the record I want in a file of records on disc? (or in
memory, etc).
It may be that I have not thought this through enough, but I don't see an
easy way to do this.
If anybody could point me in the right direction I would be very grateful.
If I have described the problem badly give me a shout and I will do my best
to clarify,
Thanks,
Gary.