[Info-vax] Indexed RMS file question
Hein, Nashua NH
heinvandenheuvel at gmail.com
Sat Oct 3 08:50:43 EDT 2009
On Oct 2, 2:34 pm, "J Xenu" <j_x... at hotmail.com> wrote:
> Thanks, Hein.
>
> So, I take it that I would have to create a key which is String1+String2
> appended to do the second kind of read (read a record which matches both strings)?
Yes. And that's called a segmented key. There is no reason to have a
seperate key with the first segments. Just use the key size on read
(RAB$B_KSZ) to indcates how many bytes should match.
> My real question was actually, if I restrict the range to all records matching
> the first key, give me a record which (also) matches the second key.
Sorry, no can do. That has been one of my wishes as well.
As an interim/helper solution, I would have been happy with a special
flavor of (alternate) key get to return an array (up to RAB$W_USZ ) of
matching RFA's. The program can then use those to do an set based AND,
OR, XOR... without having to do a full IO to the bucket holding the
data record itself (which need not be colse to any other records
already fetched, and may need an RRV read as well).
> Assuming that two records match my key, if I do an indexed read followed by a
> sequential read, will I get both records in the same order?
Yes. If there are more segments, then they come in the order of those
extra segments.
If the entire key is equal then they come in order of arrival: FIFO
> I realize I will have to check the results of the second read to see if the key actually does still match, if there was only one matching record it wouldn't.
Actually, the RMS option RAV$V_LIM can be used to have RMS do the
compare.
So start with $FIND. On success set _LIM and start a loop with $GET.
Doing this no exception for the first or last record needs to be
coded..
> Sorry for my poor explanation, but in my example, key3 was a range.
> I want a call to read with a
> key of "Beta 0042" to match the record "Beta 33-50 This is the data I want",
> key of "Beta 0033" to also match that record,
> key of "Beta 0047" to also match that record,
> key of "Beta 0055" to NOT match (and return a RMS-E-RNF type error) and
> key of "Beta 0020" to NOT match (but match the record "Beta 12-32 even more data").
You did not answer my questions earlier.
RMS can not and will not intepret: 33-50
For RMS that is a piece of string sorting between "33-49" and "33-51".
I thing you would need to "Beta 0000" first and work your way up.
Maybe a LIM on Beta 9999.
Or start at Beta 9999 and work your way down.
> Maybe we should look at some Oracle-type product, but that seems overblown
> for this.
Yes. Or MySQL or .. any other proper database.
Mind you, there are tools on OpenVMS to do this for you: DATATRIEVE.
> I can arrange the order of the data and make the numbers strings, however.
Ok. That will halp some, if you decide to go RMS.
How many records are we talking about?
Sounds like thousands, not millions.
Just stick to a primary key and large buckets and read the whole lot
of potential matches into main memory. Doing so you'll get dozens of
records per IO and may well be faster than doing a few alternate key
IOs.
Hein.
More information about the Info-vax
mailing list