JPH05334354A - Method for reading-in index organization file - Google Patents

Method for reading-in index organization file

Info

Publication number
JPH05334354A
JPH05334354A JP4142543A JP14254392A JPH05334354A JP H05334354 A JPH05334354 A JP H05334354A JP 4142543 A JP4142543 A JP 4142543A JP 14254392 A JP14254392 A JP 14254392A JP H05334354 A JPH05334354 A JP H05334354A
Authority
JP
Japan
Prior art keywords
key
current
intermediate point
file
read
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP4142543A
Other languages
Japanese (ja)
Inventor
Osamu Shimomura
治 下村
Mayumi Ibe
真由美 伊部
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NIIGATA NIPPON DENKI SOFTWARE KK
NEC Software Niigata Ltd
Original Assignee
NIIGATA NIPPON DENKI SOFTWARE KK
NEC Software Niigata Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NIIGATA NIPPON DENKI SOFTWARE KK, NEC Software Niigata Ltd filed Critical NIIGATA NIPPON DENKI SOFTWARE KK
Priority to JP4142543A priority Critical patent/JPH05334354A/en
Publication of JPH05334354A publication Critical patent/JPH05334354A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PURPOSE:To access a file at a high speed by searching for the key right before a current key by a binary search method and accessing keys in the decreasing order. CONSTITUTION:When the key right before the current key is searched for in a constitution example of a file consisting of a key part 12 and a data part 13, the binary search method is applied to narrow down the range of the search to 1/2, 1/4, 1/8.... Namely, when the current key is larger than the value of HIGH-KEY, the target key right before it is positioned before an intermediate point, so W-KEY (intermediate point) is transferred to HIGH-KEY (upper limit). When the current key is smaller than HIGH-KEY, the target key right before the current key is present between the intermediate point and HIGH-KEY, so the lower limit of the binary search is raised. At this time, the frequency of search for narrowing down the range is made less than that of a normal binary search, so the current key is transferred to not the intermediate point, but LOW-KEY.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、情報処理システムにお
けるファイル読み込み方法に関し、特に索引編成ファイ
ルを利用するための読み込み方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a file reading method in an information processing system, and more particularly to a reading method for using an index organization file.

【0002】[0002]

【従来の技術】従来の索引編成ファイルに対する読み込
み方式は、 1.指定したキーのレコードを直接読む 2.キーの順序(昇順)にレコードを読む 方法が一般的で、JIS COBCLでも命令が用意さ
れている。しかし、あるキーの値から逆の順序(降順)
にレコードを読み込む場合には、現在キーの値から1を
引いた値を次に読み込むキーの値として、キーの値を1
ずつ減算しながら、レコードを発見するまで繰り返し読
み込む方法が行われていた。
2. Description of the Related Art The conventional reading method for indexed files is as follows. Directly read the record of the specified key 1. The method of reading the records in the order of the keys (ascending order) is common, and JIS COBCL also provides instructions. However, from the value of a key to the reverse order (descending order)
When reading a record into, the value of the key is read as the value of the key to be read next by subtracting 1 from the value of the current key.
While subtracting each one, a method of repeatedly reading until a record was found was used.

【0003】[0003]

【発明が解決しようとする課題】上記の方法の場合、現
在キーと直前のキーの差が大きい場合、発見するまでに
読み込む回数が多くなり、処理の時間が長くなるという
欠点がある。
In the above method, when the difference between the current key and the immediately preceding key is large, the number of times of reading is increased until the key is found, and the processing time becomes long.

【0004】[0004]

【課題を解決するための手段】第1の発明は、索引編成
ファイルを利用するシステムにおける索引編成ファイル
の読み込み方法において、二分探索法に基づき現在キー
の直前キーを探索することにより、前記キーを降順にア
クセスすることを特徴とする。
According to a first aspect of the present invention, in a method of reading an index organization file in a system that uses an index organization file, the key immediately before the current key is searched for by the binary search method, and the key is searched. It is characterized by accessing in descending order.

【0005】[0005]

【実施例】本発明について図面を参照して説明する。DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be described with reference to the drawings.

【0006】図1は本発明の一実施例を示すフローチャ
ートである。
FIG. 1 is a flow chart showing an embodiment of the present invention.

【0007】検索したい索引編成ファイル(以下ファイ
ルと呼ぶ)に存在する現在キーが与えられる。この現在
キーの直前のキーを捜し出す手順を以下に説明する。捜
し出す方法は二分探索法の応用で、検索する範囲を2分
の1、4分の1、8分の1・・・に狭めて求める方法で
ある。
The current key existing in the index organization file (hereinafter referred to as a file) to be searched is given. The procedure for finding the key immediately before the current key will be described below. The search method is an application of the binary search method, and is a method of narrowing the search range to ½, ¼, ⅛ ...

【0008】まず、現在キーを作業領域 Wー現在 及
び HIGHーKEY(二分探索の上限)へ格納する
(ステップ1)。現在キーには0を移送する(ステップ
2)。ファイルを現在キーに位置付け、レコードを読み
込む。ここで取得されるキーがこのファイルの最小のキ
ーとなる(ステップ3)。ステップ1で格納しておい
た、 Wー現在とステップ3で取得したファイルの最小
キーを比較し、 Wー現在が最小キーと等しければ現在
キーがブァイルの最小のキーであることになるため、直
前のキーほ存在しないことになり、検索は終了する(ス
テップ4)。等しくない場合のみ、次のステップに進
む。ステップ3で読み込まれた現在キーを LOWーK
EY(二分探索の下限)へ移送する(ステップ5)。L
OWーKEYとHIGHーKEYの中間点を計算して求
め、計算結果を現在キー及びWーKEYへ移送する(ス
テップ6)。LOWーKEY(下限)とWーKEY(中
間点)を比較し、等しい時、この中間点 WーKEY
が直前のキーとなる(ステップ7)。等しくない場合次
のステップ8へ進む。
First, the current key is stored in the work area W-current and HIGH-KEY (upper limit of binary search) (step 1). 0 is transferred to the current key (step 2). Position the file at the current key and read the record. The key obtained here is the minimum key of this file (step 3). Compare the W-current stored in step 1 with the minimum key of the file obtained in step 3, and if W-current is equal to the minimum key, the current key is the minimum key of the file, so Since the previous key does not exist, the search ends (step 4). Only if not equal to the next step. LOW-K the current key read in step 3
Transfer to EY (lower limit of binary search) (step 5). L
The intermediate point between OW-KEY and HIGH-KEY is calculated and obtained, and the calculation result is transferred to the current key and W-KEY (step 6). LOW-KEY (lower limit) and W-KEY (midpoint) are compared, and when they are equal, this midpoint W-KEY
Is the last key (step 7). If not equal, proceed to the next step 8.

【0009】この中間点 WーKEY が目的の直前キ
ーとなる理由を以下に述べる。WーKEYはn桁の整数
項目とする。除算したとき小数点以下は切り捨てられる
ものとする。二分探索はLOWーKEYとHIGHーK
EYの間を狭めていく検索方法であるが、目的のキーを
発見する直前のLOWーKEYの差は1となる。mを目
的のキーと仮定すると (LOWーKEY 十 HIGHーKEY) / 2 = WーKEY = (m十(m十1))/ 2 = m 十 0.5 となる。ここで0.5は切り捨てられるため、WーKE
Yにはmが代入される。よって、LOWーKEY =
WーKEY の時、目的のキーの発見となる。
The reason why the intermediate point W-KEY is the key immediately before the purpose will be described below. W-KEY is an n-digit integer item. When dividing, the numbers after the decimal point shall be truncated. Binary search is LOW-KEY and HIGH-K
This is a search method that narrows the space between EY, but the difference between LOW and KEY immediately before the target key is found is 1. Assuming that m is a target key, (LOW-KEY tens HIGH-KEY) / 2 = W-KEY = (m tens (m tens 1)) / 2 = m tens 0.5. Here, 0.5 is rounded down, so W-KE
M is substituted for Y. Therefore, LOW-KEY =
When W-KEY, it is the discovery of the target key.

【0010】LOWーKEYとWーKEYが等しくない
とき中間点のWーKEYにファイルを位置付け、中間点
の値以上で最も近い(大きい)キーのレコードを読み込
む(ステップ8)。読み込んだキーは現在キーに格納さ
れるので、HIGHーKEYと比較する(ステップ
9)。現在キーがHIGHーKEYの値以上の場合目標
とする直前のキーは中間点より前に位置することになる
ので、WーKEY(中間点)をHIGHーKEY(上
限)に移送する(ステップ10)。現在キーがHIGH
ーKEYよりも小さい場合、中間点とHIGHーKEY
との間に目標とする直前のキーが存在することになるた
め、二分探索の下限を引き上げる。このとき、通常の二
分探索より範囲をしぼり検索回数を少なくするため、中
間点でなく現在キーをLOWーKEYへ移送する(ステ
ップ11)。ステップ7で直前のキーが発見されるま
で、ステップ6からステップ11を繰り返し行う。
When LOW-KEY and W-KEY are not equal, the file is positioned at the intermediate point W-KEY, and the record of the closest (largest) key above the intermediate point value is read (step 8). Since the read key is stored in the current key, it is compared with HIGH-KEY (step 9). When the current key is higher than the value of HIGH-KEY, the key immediately before the target is located before the intermediate point, so W-KEY (intermediate point) is transferred to HIGH-KEY (upper limit) (step 10). ). Currently the key is HIGH
If it is smaller than – KEY, the midpoint and HIGH – KEY
Since the key just before the target exists between and, the lower limit of the binary search is raised. At this time, the current key is moved to LOW-KEY instead of the intermediate point in order to narrow the range and reduce the number of searches compared to the normal binary search (step 11). Steps 6 to 11 are repeated until the previous key is found in step 7.

【0011】図2はキー部12とデータ部13から成る
ファイルの構式例を示す図である。
FIG. 2 is a diagram showing an example of the structure of a file consisting of the key part 12 and the data part 13.

【0012】次に図2に示すようなファイルで現在キ
ー″100″から直前のキー″075″を捜し出す過程
を説明する。 1.ファイル上の最小キーの取得のため、KEY=″0
00″で位置付けをし、READする。KEY=″00
1″が読み込まれるが″100″た等しくないため、″
100″が最小のキーでないことがわかる。
Next, a process of searching the previous key "075" from the current key "100" in the file shown in FIG. 2 will be described. 1. KEY = "0" to get the smallest key on the file
Position with "00" and READ. KEY = "00"
"1" is read, but "100" is not equal, so "
It can be seen that 100 ″ is not the smallest key.

【0013】LOWーKEY=″001″ HIG
HーKEY=″100″ 2.(LOWーKEY 十 HIGHーKEY)= /
2=50.5→50が中間点となるので、KEY=″
050″で位置付け、READすると、″055″が読
み込まれる。
LOW-KEY = "001" HIG
H-KEY = “100” 2. (LOW-KEY 10 HIGH-KEY) = /
Since 2 = 50.5 → 50 is the intermediate point, KEY = ″
When positioned at 050 "and read," 055 "is read.

【0014】″055″ 〈 ″100″ なので、LOWーKEYに″055″を移送する。Since "055" <"100", "055" is transferred to LOW-KEY.

【0015】LOWーKEY=″055″ HIG
HーKEY=″100″ 3.中間点を計算すると77となるので、KEY=″0
77″で位置付けREADすると″100″が読み込ま
れる。現在キーとHIGHーKEYが等しくなるのでH
IGHーKEYに″077″を移送する。
LOW-KEY = "055" HIG
H-KEY = “100” 3. When the intermediate point is calculated, it becomes 77, so KEY = "0.
If you position and read with "77", "100" will be read. Since the current key and HIGH-KEY are equal, H
Transfer "077" to IGH-KEY.

【0016】LOWーKEY=″055″ HIG
HーKEY=″077″ 4.中間点を計算すると66となるので、KEY=″0
66″で位置付けREADすると″075″が読み込ま
れる。 ″075″ 〈 ″077″ なので、LOWーKEYに″075″を移送する。 LOWーKEYに″075″ HIGHーKEY=″
077″ 5.中間点を計算すると76となるので、KEY=″0
76″で位置付けREADすると″100″が読み込ま
れる。 ″100″ ≧ ″077″ なので、HIGHーKEYに中間点″076″を移送す
る。
LOW-KEY = "055" HIG
H-KEY = “077” 4. When the intermediate point is calculated, it becomes 66, so KEY = "0.
"075" is read when positioned at 66 "and read." 075 "<" 077 ", so" 075 "is transferred to LOW-KEY." 075 "HIGH-KEY =" to LOW-KEY.
077 ″ 5. The intermediate point is calculated to be 76, so KEY = ″ 0
When the position is read at 76 "," 100 "is read. Since" 100 "≥" 077 ", the intermediate point" 076 "is transferred to HIGH-KEY.

【0017】LOWーKEY=″075″ HIGH
ーKEY=″076″ 6.中間点を計算すると75となるので、LOWーKE
Yと等しくなり繰り返しを終了する。このときの中間
点″075″が直前のキーである。
LOW-KEY = "075" HIGH
-KEY = "076" 6. The intermediate point is calculated to be 75, so LOW-KE
It becomes equal to Y and the repetition ends. The intermediate point "075" at this time is the immediately preceding key.

【0018】[0018]

【発明の効果】以上説明したように本発明は図2の例で
は直前のキーを5回のREADでキーを発見できるが、
キーを1ずつ減算して読み込む方法で行うと25回RE
ADしなければならない。したがって、降順に次々と読
み込む場合には、より高速にファイルをアクセスするこ
とができるという利点を有する。
As described above, according to the present invention, in the example of FIG. 2, the key immediately before can be found by READ 5 times.
If you read by subtracting the key one by one, it will be 25 times RE
You have to do AD. Therefore, when the files are read one after another in descending order, there is an advantage that the file can be accessed at a higher speed.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の一実施例を示すフローチャートであ
る。
FIG. 1 is a flowchart showing an embodiment of the present invention.

【図2】本実施例におけるファイルの構式例を示す図で
ある。
FIG. 2 is a diagram showing an example of the structure of a file in this embodiment.

【符号の説明】[Explanation of symbols]

12 キー部 13 データ部 12 key part 13 data part

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 索引編成ファイルを利用するシステムに
おける索引編成ファイルの読み込み方法において、二分
探索法に基づき現在キーの直前キーを探索することによ
り、前記キーを降順にアクセスすることを特徴とする索
引編成ファイルの読み込み方法。
1. A method of reading an index organization file in a system using an index organization file, characterized in that a key immediately before a current key is searched based on a binary search method to access the keys in descending order. How to read the organization file.
JP4142543A 1992-06-03 1992-06-03 Method for reading-in index organization file Withdrawn JPH05334354A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4142543A JPH05334354A (en) 1992-06-03 1992-06-03 Method for reading-in index organization file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4142543A JPH05334354A (en) 1992-06-03 1992-06-03 Method for reading-in index organization file

Publications (1)

Publication Number Publication Date
JPH05334354A true JPH05334354A (en) 1993-12-17

Family

ID=15317800

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4142543A Withdrawn JPH05334354A (en) 1992-06-03 1992-06-03 Method for reading-in index organization file

Country Status (1)

Country Link
JP (1) JPH05334354A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100484484B1 (en) * 2002-05-20 2005-04-20 주식회사 케이티 Range search binary method in integer type data structure and apparatus thereof

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100484484B1 (en) * 2002-05-20 2005-04-20 주식회사 케이티 Range search binary method in integer type data structure and apparatus thereof

Similar Documents

Publication Publication Date Title
CN112148738A (en) Hash collision processing method and system
JPH05334354A (en) Method for reading-in index organization file
US5918231A (en) Object-oriented database management system with improved usage efficiency of main memory
JPH06139280A (en) File management system
JP2502262B2 (en) Network database access method
JPH081642B2 (en) Keyword search method
Lin Cat: An execution model for concurrent full text search
JPH05158988A (en) Data base access method
JPS628226A (en) Key retrieving method for file
KR100311233B1 (en) Optimization method of relation size by justification of at tribute order
CN115543993A (en) Data processing method and device, electronic equipment and storage medium
JPS63104134A (en) Index retrieving system
JP2001134598A (en) Structuring method and retrieving method for t-tree index, structuring device and retrieving device for t- tree index, storage medium stored with t-tree index structuring program, and storage medium stored with t-tree index retrieving program
JPH04156624A (en) High speed accessing systme in knowledge base systme
JPH0512739B2 (en)
CN115525650A (en) Method, device, equipment and medium for improving Hash lookup performance
JPH01248233A (en) Data base retrieving device
JPH0668145A (en) Retrieval method
JPH1049545A (en) Associative storage device
JPH04174071A (en) Hash processor
JPH04266146A (en) Computing method
JPS629433A (en) Data base access mechanism
JPS60211542A (en) Data retrieval circuit
JPH04195588A (en) Back coincidence retrieving processing system for data base
JPH10240744A (en) System for processing retrieval of range division chart and method therefor and recording medium for recording retrieval processing program

Legal Events

Date Code Title Description
A300 Application deemed to be withdrawn because no request for examination was validly filed

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 19990803