× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: finding the right place in a RRN file
  • From: "James W. Kilgore" <qappdsn@xxxxxxx>
  • Date: Tue, 15 Apr 1997 21:29:08 -0700
  • Organization: Progressive Data Systems, Inc.

boothm@earth.goddard.edu wrote:
> 
> I'm thinking there's gotta be an easy way to do this.
> 
> I have a sequential file, sorted into alphabetical order on a field called
> "LastName".  I want to process it as a subfile by Relative Record Number.
> 
> But a user needs to be able  set the file at a particular "LastName",
> based on a keyed-in field called "GetName".
> 
> Is there an easy way to do that?
Basically you have two workable solutions: binary halving or building a
logical.

Halving routines are text book cases and easily obtained.  If you are
new to the process:
  1) obtain the value contained in record #1 of file (call this low
value/record#).
  2) obtain the value of the last record in the file (call this high
value/record#)
  3) once user enters value,
        3a) compare if less than low value, set exception
        3b) compare if greater than high value, set exception
  4) begin halving process: 
        4a) subtract low value record# from high record# then div by 2 and get
middle of                       remaining file value.  ((high#-low#)/2)+low# 
ie:((100-1)/2)+1=50
        4b) compare value requested to middle of file value,
        4c) If value requested is higher than middle
                then replace low record#/value with middle record#/value: goto 
4a
        4d) if value requested is lower than middle
                then replace high record#/value with middle record#/value: goto 
4a 
In the middle of all of this, determine a reasonable value to drop out
of halving and just do reads.  

Depending upon application, one lookup then exit, vs multiple lookups,
you can reduce disk access by building an array of value/record#
combinations and set low value to nearest low.  Pick any size array that
works for you.  We had a code generator on a S/3 that a 128 element
array against a 50,000 record file with approx 100 lookups per execution
ran 8 times faster than starting from scratch with each search.

In either case, the selected records RRN can be obtained from the file
feedback data structure.
Careful with logicals though..record #6 of the logical is not always
record #6 in the physical.

(We didn't even think of it when our logical excluded records marked for
deletion...duhhhh)

Apply RRN process to whichever file (physical or logical) you derived
the number from.
Place the number into your subfile as a hidden field so when the user
points and shoots 
you get the right entry.
-- 
===================================================
James W. Kilgore   | Progressive Data Systems, Inc.
President          | 311 31st Ave SE
(206) 848-2567     | Puyallup, Washington 98374 USA
qappdsn@ibm.net    | http://www.ultimate.org/PDS
===================================================
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the Midrange System Mailing List!  To submit a new message,   *
* send your mail to "MIDRANGE-L@midrange.com".  To unsubscribe from     *
* this list send email to MAJORDOMO@midrange.com and specify            *
* 'unsubscribe MIDRANGE-L' in the body of your message.  Questions      *
* should be directed to the list owner / operator: david@midrange.com   *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.