Why do we need an index for fixed-length records

If a record is fixed length, then surely the record offset is easily calculated ?

If the node record is 32 bytes long, and the node data set starts at 1000 bytes, then record n is at position 1000 + 32 * (n - 1). Why do we need an index of node records pointing to a node record ?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
john's picture

Re: Why do we need an index for fixed-length records

Consider an Object hierarchy where Object A has a field that references Object B, B references Object C, etc.

When the record for Object A is written to the stream, the reference for B is found, and B is added to the queue of objects to be written. When the queue is processed, and B's record is written out, the reference from B to C is found. Etc.

When each object *reference* is found, it is tracked and given an index number. When it is *written*, its offset in the byte stream is associated with its index number.

That's why we need the index. :-)


Sorry for being thick .. but

Sorry for being thick .. but ..
If A (node 1) has a child of B (node 25), if you are writing the objects to the stream in node order (1,2,3,4 etc) then even if you haven't written node 25 yet, you know that the offset will be StartOfNodes + (25 - 1) * NodeRecordLength, so you just need to store (25) as the node reference to B.

IOW you do not need to store a pointer to an index, if the index number is the number of the node itself, you can just store the node number.


john's picture

Re: Sorry for being thick .. but

We're not just dealing with Node objects. :) There are 40 different Xferable object classes in Proparse. A Node might reference a Symbol might reference a Scope... etc.

We aren't even dealing with a homogeneous set of node Objects. There are a few different classes of node objects, each with potentially different record size.


Well, why didn't you say so

Well, why didn't you say so ? :) Sorry for wasting the bandwidth


john's picture

Not a waste of bandwidth at

Not a waste of bandwidth at all. Good questions that keep us all thinking.


no takers on this ?

no takers on this ?


jurjen's picture

I think you are right, and

I think you are right, and that you don't need to read the index.