Re: Robert...EDS - questions/comments
Jonas Temple writes:
> 1. Say I have a table with a key structure of : {atom, atom}.
> I insert 3 records with the following key values:
> {1 , 1} {1, 2} {1, 3}.
> I add another 10,00 entries with other key values.
> I then add {1, 4} {1, 5}.
> Now I want to get all records with the first key value of 1.
> Assuming I use db_find_key and find and read the
> first three records, would I have to read through the
> next 10,000 to get the last two records?
No. As Matt Lewis pointed out, the records are always organized
in order of key value. That allows a fast binary search to be used
to find any key. Sequences are sorted in the usual "alphabetic"
way, with the first element being the most significant.
> 2. Somewhat relating to question 1, if I used db_find_key
> with a key value of {1, 0} (assuming there will never be
> a record with a second key value of 0) I would get
> a negative result.
Yes.
> If I am reading the docs right, the negative number
> would be the record number if it were inserted into the file.
Yes.
> For example, if the db_find_key returned -4, would this mean
> that if I were to retrieve record 4, would it have a key
> value of {1, 1} (assuming key value {1, 1} is in the file)?
Yes, the -4 tells you that if {1,0} were inserted right now,
it would be the 4th record. Since you haven't actually inserted
it yet, the current 4th record would be the record that
comes after {1,0}. {1,1} in your case.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
|
Not Categorized, Please Help
|
|