JPH02165325A - Sorting system for random access file - Google Patents

Sorting system for random access file

Info

Publication number
JPH02165325A
JPH02165325A JP32143788A JP32143788A JPH02165325A JP H02165325 A JPH02165325 A JP H02165325A JP 32143788 A JP32143788 A JP 32143788A JP 32143788 A JP32143788 A JP 32143788A JP H02165325 A JPH02165325 A JP H02165325A
Authority
JP
Japan
Prior art keywords
input
sort
sorting
file
output
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.)
Pending
Application number
JP32143788A
Other languages
Japanese (ja)
Inventor
Yoichi Ueda
洋一 上田
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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP32143788A priority Critical patent/JPH02165325A/en
Publication of JPH02165325A publication Critical patent/JPH02165325A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

PURPOSE:To save a file space in an auxiliary storage device which is used for sorting by executing sorting while using a sorting input file also as a sorting work file for storing a sorting intermediate result. CONSTITUTION:The sorting input file 1 is constituted of plural blocks having the same size, and in this case the file 1 is constituted of four blocks 11 to 14. Sorting is executed while using the sorting input file 1 also as a sorting work file for storing a sorting intermediate result. Consequently, the file space in the auxiliary storage device which is used for sorting can be saved.

Description

【発明の詳細な説明】 (産業上の利用分野) 本発明は、補助記憶装置上のランダムアクセス可能なフ
ァイル内に格納されたレコードをソートするソート処理
に関する。
DETAILED DESCRIPTION OF THE INVENTION (Field of Industrial Application) The present invention relates to a sorting process for sorting records stored in a randomly accessible file on an auxiliary storage device.

(従来の技術) 従来、補助記憶装置上のランダムアクセス可能なファイ
ル内に格納されたレコードをソートするソート処理にお
いては、ソート用のワークファイルと、ソートすべきレ
コードの格納されたソート入力ファイルとは、補助記憶
装置内で別々のファイル領域に収られていた。
(Prior Art) Conventionally, in a sorting process for sorting records stored in a randomly accessible file on an auxiliary storage device, a work file for sorting, a sorting input file storing records to be sorted, and were stored in separate file areas within auxiliary storage.

(発明が解決しようとする課題) 上述したように、従来補助記憶装置上のランダムアクセ
ス可能なファイル内に格納されたレコードをソートする
ソート処理においては、ソー1〜用のワークファイルと
、ソー1〜すべきレコードの格納されたソート入力ファ
イルとは、補助記憶装置内で別々のファイル領域に取ら
れていたから、特にソー1への対象となるレコードの件
数が多く、ソート入力ファイルのサイズが大きいような
場合には、ソートワークファイルとしてソート入力ファ
イルと同じ大きさのファイルVJ、域が必要となり、補
助記憶装置内のファイル領域を多く使用してしまうとい
う欠点があった。
(Problems to be Solved by the Invention) As described above, in the conventional sorting process for sorting records stored in randomly accessible files on an auxiliary storage device, work files for source 1 to The sort input file containing the records to be processed was stored in a separate file area in the auxiliary storage device, so it is likely that there are many records to be sorted and the size of the sort input file is large. In this case, a file VJ area of the same size as the sort input file is required as the sort work file, which has the drawback of using a large amount of file area in the auxiliary storage device.

(課題を解決するための手段) 本発明は、補助記憶装置上のランダムアクセス可能なフ
ァイル内に格納されたコードをソートするソート処理に
おいて、 ツー1−すべきレコードが格納され、ソートのワークフ
ァイルとしても兼用されるソート入力ファイルと、 前記ソート入力ファイル内のレコードをソートするソー
ト処理手段と、 前記ソート入力ファイル内のレコードをプロ・ンク単位
で入力するだめの入出力処理手段と、前記ソート処理手
段が前記入出力処理手段にノ(ラメータとして渡すため
の入出力パラメータテーブルと、 前記ソー1〜処理手段が前記入出力処理手段を用いて前
記ソー1〜人カフアイルからレコードを入力する際にバ
ンファとして用いる主記憶装置内の入力バッファと、 前記ソート処理手段が前記入出力処理手段を用いて前記
ソート入力ファイルへレコードを出力する際にバッファ
として用いる主記憶装置内の出力バッファと、 前記ソート処理手段が前記ソート入力ファイル内の空き
ブロックを管理するための空きブロック管理テーブルと
、 ソート結果を書き込むためのソート出力ファイルと、 前記ソート処理手段がソートを行うためのワークエリア
として用いる主記憶装置内のソートワーク領域と を備え、 前記ソート入力ファイルは一定の大きさを持つブロック
から構成され、 前記入力バッファ及び前記出力バッファは前記ソート入
力ファイルのブロックサイズと同一の大きさをそれぞれ
持ち、 前記ソート処理手段は、前記入出力処理手段を呼び出す
ことにより前記ソート入力ファイルのブロックを先頭ブ
ロックから順に前記入力バッファに入力していき、前記
入力バッファ内に入力されたブロックからレコードを一
件ずつ取り出し、取り出したレコードを前記ソートワー
ク領域内でソートしていき、ソートの中間結果としての
ストリングと呼ぶ順付けられたレコード列を生成し、生
成したストリングを前記出力バッファをバッファとして
用いながら前記ソート入力ファイル内へ前記入出力処理
手段を用いてブロック単位で書き出して行き、前記ソー
ト入力ファイルからのレコード入力修了後、生成したス
トリングをマージして行き、新しいストリングを作成し
ていき、一回のマージで全ストリングをマージできるま
でストリングの本数を減らすと、最後に全ストリングを
マージし、一本のストリングにまとめ、ソート結果とし
て前記ソート出力ファイルに出力していくことによりソ
ート処理を行うが、 前記ソート処理手段は、ソートす、べきレコードを入力
する処理において、前記ソート入力ファイルから、前記
入出力処理手段を用いて、プロ・ツクをm個前記入カバ
・yファ内に読み込む毎に、読み込んだブロックの先頭
の前記ソート入力ファイル内相対アドレスを前記空きブ
ロック管理テーブルに登録しておき、ストリングのブロ
ックを、ソート中間結果として前記ソート入力ファイル
へ出力する際には、前記空きブロック管理テーブルから
、1エントリ取り出し、ストリングのブロックを出力す
べき前記ソート入力ファイル内位置を得て、前記入出力
パラメータテーブルにブロック出力位置として設定し、
前記入出力処理手段を呼び出してストリングを出力して
いく ことを!tly徴とする。
(Means for Solving the Problems) The present invention provides a sorting process for sorting codes stored in a randomly accessible file on an auxiliary storage device, in which records to be processed are stored and a work file for sorting is performed. a sort input file which is also used as a sort input file; a sort processing means for sorting records in the sort input file; an input/output processing means for inputting records in the sort input file in units of procs; An input/output parameter table for the processing means to pass as a parameter to the input/output processing means; an input buffer in the main memory used as a buffer; an output buffer in the main memory used as a buffer when the sort processing means outputs records to the sort input file using the input/output processing means; A free block management table for the processing means to manage free blocks in the sort input file, a sort output file for writing the sort results, and a main storage device used as a work area for the sort processing means to perform sorting. a sort work area within the sort input file, the sort input file is composed of blocks having a certain size, the input buffer and the output buffer each have the same size as the block size of the sort input file, The sort processing means inputs blocks of the sort input file into the input buffer in order from the first block by calling the input/output processing means, and extracts records one by one from the blocks input into the input buffer. , sort the retrieved records in the sort work area, generate an ordered record sequence called a string as an intermediate result of sorting, and input the generated string to the sort input using the output buffer as a buffer. Write out blocks into a file using the input/output processing means, and after inputting records from the sort input file, merge the generated strings to create a new string, and perform one merge. When the number of strings is reduced until all strings can be merged, the sorting process is performed by finally merging all strings, combining them into one string, and outputting the sort results to the sort output file. In the process of inputting records to be sorted, the sort processing means reads m programs from the sort input file into the input cover y file using the input/output processing means. The relative address in the sort input file of the beginning of the block is registered in the free block management table, and when outputting a block of strings to the sort input file as an intermediate sort result, the address from the free block management table is registered. , retrieve one entry, obtain the position in the sort input file at which the block of strings should be output, and set it as the block output position in the input/output parameter table;
Call the input/output processing means and output the string! It is considered as a tly symptom.

(作用) 本発明のソート方式では、上述の手段により、ソート入
力ファイルをソーl〜の中間結果をたくわえておくため
のソートワークファイルとしても兼用しながらソートを
行って行く、そこで、本発明の方式ではソートで使用す
る補助記憶装置上のファイルスペースを節減することが
できる。
(Function) In the sorting method of the present invention, sorting is performed by using the above-mentioned means while also using the sort input file as a sort work file for storing intermediate results of sorts. This method can save file space on auxiliary storage used for sorting.

(実施例) 次に本発明について、図面を参照して詳細に説明する。(Example) Next, the present invention will be explained in detail with reference to the drawings.

第1図は、本発明の一実施例を示すプロ・ンク図である
FIG. 1 is a diagram showing one embodiment of the present invention.

第1図において、1はソートすべきレコードが格納され
、ソートのワークファイルとしても兼用されるソート入
力ファイル、2はソート入力ファイル1内のレコードを
ソートするソート処理手段、3はソート入力ファイル1
内のレコードをブロック単位で入出力するための入出力
処理手段、4はソート処理手段2が入出力処理手段3に
パラメータとして渡すための入出力パラメータテーブル
、5はソー1−処理手段2が入出力処理手段3を用いて
ソート入力ファイル1からレコードを入力する際にバッ
ファとして用いる主記憶装置内の入力バッファ、6はソ
ート処理手段2が入出力処理手段3を用いてソート入力
ファイル1ヘレコードを出力する際にバッファとして用
いる主記憶装置内の出力バッファ、7はソート処理手段
2がソート入力ファイル1内の空きブロックを管理する
ための空きブロック管理テーブル、8はソート結果を書
き込むためのソート出力ファイル、9はソート処理手段
2がソートを行うためのワークエリアとして用いる主記
憶装置内のソートワーク領域である。
In FIG. 1, 1 is a sort input file in which records to be sorted are stored and is also used as a work file for sorting, 2 is a sort processing means for sorting records in the sort input file 1, and 3 is a sort input file 1
4 is an input/output parameter table for the sort processing means 2 to pass as a parameter to the input/output processing means 3; 5 is an input/output parameter table for the sort processing means 2 to input and output records in block units; An input buffer 6 in the main storage device is used as a buffer when inputting records from the sort input file 1 using the output processing means 3; An output buffer in the main storage device used as a buffer when outputting, 7 an empty block management table for the sort processing means 2 to manage empty blocks in the sort input file 1, 8 a sort output for writing sort results. File 9 is a sort work area in the main storage device used as a work area for sorting by the sort processing means 2.

ソート入力ファイル1は、同一の大きさを、もつブロッ
クから構成されており、本例では4個のブロック11,
12,13.14から構成されている。
The sort input file 1 is composed of blocks having the same size, and in this example, four blocks 11,
It is composed of 12, 13, and 14.

また本例では、ソート処理手段2は、ソート主処理21
、ソートレコード入力処理22、ストリング出力処理2
3の3つの部分に分けられているものとする。
Further, in this example, the sorting processing means 2 includes the sorting main processing 21
, sort record input processing 22, string output processing 2
It is assumed that it is divided into three parts.

第2図は、ソート主処理21の処理ステップを示す流れ
図である。
FIG. 2 is a flowchart showing the processing steps of the main sorting process 21.

ソート主処理21は、まずステップ201で、ソート入
力ファイル1のファイルサイズ、ブロックサイズをそれ
ぞれ、F、Bに設定する。
In step 201, the sort main processing 21 first sets the file size and block size of the sort input file 1 to F and B, respectively.

次にステップ202でソート実行に必要な準備をした後
ステップ203へ移行する。
Next, in step 202, necessary preparations for sorting are made, and then the process moves to step 203.

ステップ203では、ソートレコード入力処理22を呼
び出しソート入力ファイル1からレコードを1件ソート
ワーク領域9へ入力する。
In step 203, the sort record input process 22 is called and one record is input from the sort input file 1 into the sort work area 9.

ステップ204では、入力レコードが尽きた旨ソートレ
コード入力処理22から通知されたか否か判断する。
In step 204, it is determined whether or not the sort record input processing 22 has notified that the input records have run out.

人力レコードが尽きていなければ、ステップ205にお
いて、ステップ203で読み込んだレコードをソートワ
ーク領域9内でソートしストリンクとして出力すべきレ
コードを決定し、ステップ206で出力すべきレコード
が決定したか判定し、まだ決定していない場合は、ステ
ップ203に戻り、出力するレコードが決定するまでレ
コードの入力を続け、ストリングとして出力すべきレコ
ードが決定すると、ステップ207において、ストリン
グ出力処理23を呼び出すことによりストリングのレコ
ードをソート入力ファイル1へ書き込みステップ203
へ戻る。
If the human records have not been exhausted, in step 205, the records read in step 203 are sorted in the sort work area 9, records to be output as strings are determined, and in step 206 it is determined whether records to be output have been determined. However, if it has not been determined yet, return to step 203 and continue inputting records until the record to be output is determined. When the record to be output as a string is determined, in step 207, by calling the string output processing 23, Write string records to sort input file 1 Step 203
Return to

入力レコードが尽きた旨ソートレコード入力処理22か
ら通知されると、ステップ208へ移行し、ステップ2
08では、ソートワーク領域9内に残っているレコード
をソートしてソート入力ファイル1ヘストリング出力処
理23を用いて出力し、ステップ209において、ステ
ップ208以下で生成したストリングをマージし、新た
なストリングを作成、再びソート入力ファイルに書き込
んでいき、マージ処理をくりかえして実行し、ストリン
グを最終的に一本のストリングにまとめソート出力ファ
イル8に出力してソート処理を終了する。
When the sort record input processing 22 notifies that the input records are exhausted, the process moves to step 208, and step 2
In step 08, the records remaining in the sort work area 9 are sorted and output to the sort input file 1 using string output processing 23, and in step 209, the strings generated in steps 208 and below are merged to create a new string. is created and written to the sort input file again, the merging process is repeated and executed, and the strings are finally combined into one string and output to the sort output file 8 to complete the sort process.

第3図は、ソートレコード入力処理22の処理ステップ
を示す流れ図である。
FIG. 3 is a flowchart showing the processing steps of the sort record input processing 22.

ソートレコード入力処理22は、ソート主処理21から
制御を渡されると、まずステップ301で最初のレコー
ド入力か否か判定する。
When the sort record input process 22 receives control from the sort main process 21, it first determines in step 301 whether or not it is the first record input.

最初のレコード入力でなければ、ステップ302で入力
バッファ5内に読み込まれているブロックからルコード
を取り出し、ステップ゛303において、まだソートワ
ーク領域9に読み込んでいないレコードが、入力バッフ
アラ内に残っていなかったか否か判定し、残っていたな
らば、ステップ304において、ステップ302で取り
出したレコードをソート主処理21へ渡し処理を終了し
、ソート主処理21へ制御を戻し、まだソートワーク領
域9に読み込んでいないレコードが人力バノファ5内に
は既になかったならば、ステップ305において、D 
十BとFとを比較、D−1−BかFより大であるなら、
読み込むべきブロックはもうないのでステップ306で
入力レコードが尽きた旨ソート主処理21に通知し処理
を終了しソート主処理21に制御を戻し、D+BがF以
下なら次のブロックを読み込むためにステップ309へ
分岐する。
If it is not the first record input, the code is extracted from the block read into the input buffer 5 in step 302, and in step 303, the input buffer is checked to see if there are any records that have not been read into the sort work area 9 yet. If there are any records left, in step 304, the record retrieved in step 302 is passed to the sort main processing 21, the processing is ended, control is returned to the sort main processing 21, and the record is still read into the sort work area 9. If there is already no record in the manual banofer 5, in step 305,
Compare 10B and F, if D-1-B is greater than F,
Since there are no more blocks to read, the main sorting process 21 is notified that the input records have run out in step 306, the process is terminated, and control is returned to the main sorting process 21. If D+B is less than or equal to F, the next block is read in step 309. Branch to.

最初のレコード入力である場合は、ステップ307で、
空きブロック管理テーブル7の作成エントリを示すため
の制御変数′Fの初期値としてOを設定、ステップ30
8では、ソート入力ファイル1からブロックを入力すべ
き位置を示すための制御変数りに初期値として0を設定
し、ステップ309へ移行する。
If it is the first record input, in step 307,
Set O as the initial value of the control variable 'F to indicate the creation entry of the free block management table 7, step 30
In step 8, a control variable for indicating the position at which a block is to be input from the sort input file 1 is set to 0 as an initial value, and the process moves to step 309.

ステップ309以下は、ソート入力ファイル1から1ブ
ロック読み込むための処理ステップである。
Step 309 and subsequent steps are processing steps for reading one block from the sort input file 1.

ステップ309では、入出力パラメータテーブル4に、
読み込むべきブロックの位置としてDを設定し、ステッ
プ310で入出力処理手段3を呼び出しソート入力ファ
イル1がら、入力バッフアラへブロックを1個読み込む
In step 309, in the input/output parameter table 4,
D is set as the position of the block to be read, and in step 310 the input/output processing means 3 is called to read one block from the sort input file 1 into the input buffer array.

次にステップ311で、読み込みを完了したブロックの
ソート入力ファイル1内アドレス(D)を空きブロック
管理テーブル7のT番目のエントリに設定し、ステップ
312で、DをD+Bに設定、ステップ313でTをT
+1に設定した後ステップ302へ移行し入力バッフア
ラからレコードを取り出す。
Next, in step 311, the address (D) in the sort input file 1 of the block that has been read is set to the T-th entry in the free block management table 7, in step 312, D is set to D+B, and in step 313, T T
After setting it to +1, the process moves to step 302 and a record is taken out from the input buffer.

第4図は、ストリング出力処理23の処理ステップを示
す流れ図である。
FIG. 4 is a flowchart showing the processing steps of the string output processing 23.

ストリング出力処理23は、ソート主処理21から制御
を渡されると、まずステ・ツブ401で、最初のレコー
ド出力であるが否か判定し、最初のレコード出力であれ
ば、ステップ402で空きプD ツク管理テーブル7の
エントリを示すための制御変数Sの初期値として0を設
定する。
When the string output processing 23 is given control from the sort main processing 21, it first determines in step 401 whether or not it is the first record output, and if it is the first record output, in step 402 it outputs an empty program. 0 is set as the initial value of the control variable S to indicate the entry in the block management table 7.

次にステップ403において、出力しようとしているレ
コードを書き込めるだけのスペースが出力バッファ6内
に残っているが否が判定する。
Next, in step 403, it is determined whether there is enough space left in the output buffer 6 to write the record to be output.

出力しようとしているレコードを書き込めるだけのスペ
ースが出力バッファ6内に残っていれば、ステップ40
4で、出力レコードを出力バッファ6へ転送し処理を終
了、ソート主処理21へ制御を戻す。
If there is enough space left in the output buffer 6 to write the record to be output, step 40
At step 4, the output record is transferred to the output buffer 6, the process is terminated, and control is returned to the sort main process 21.

出力しようとしているレコードを書き込めるだけのスペ
ースが出力バッファ6内に残っていなければ、ステップ
405からステップ408で出力バッファ6内のレコー
ドをストリングの1ブロツクとしてソート入力ファイル
lへ出力して行く。
If there is not enough space left in the output buffer 6 to write the record to be output, then in steps 405 to 408 the record in the output buffer 6 is output as one block of string to the sort input file l.

ステップ405では、空きブロック管理テーブル7のS
番目のエントリから、ブロックを書き込むべきソート入
力ファイル内位置Aを得る。
In step 405, S of the free block management table 7 is
The position A in the sort input file where the block should be written is obtained from the th entry.

次にステップ406において、入出力パラメータテーブ
ル4に、ブロック書き込み位置として、Aを設定し、ス
テップ407で、入出力処理手段3を呼び出し出力バッ
ファ6内のレコードをストリングの1ブロツクとしてソ
ート入力ファイルに書き込み、ステップ408において
SをS+1に設定しステップ404へ分岐し、出力レコ
ードを出力バッファ6へ転送する。
Next, in step 406, A is set as the block write position in the input/output parameter table 4, and in step 407, the input/output processing means 3 is called to sort the records in the output buffer 6 as one block of strings into the input file. In step 408, S is set to S+1, and the process branches to step 404, where the output record is transferred to the output buffer 6.

(発明の効果) 上述したように本発明は、補助記憶装置上のランダムア
クセス可能なファイル内に格納されたレコードをソート
するソート処理において、ソート入力ファイルを、ソー
ト中間結果をたくわえておくためのソートワークファイ
ルとしても兼用しながらソートを行うようにすることに
より、ソートで使用する補助記憶装置上のファイルスペ
ースを節減することができるという効果がある。
(Effects of the Invention) As described above, the present invention provides a sort input file for storing intermediate sort results in a sorting process for sorting records stored in a randomly accessible file on an auxiliary storage device. By performing sorting while also serving as a sort work file, there is an effect that the file space on the auxiliary storage device used for sorting can be saved.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の一実施例を示すソート処理のブロック
図、第2図は第1図実施例におけるソー1へ主処理の処
理ステップを示す流れ図、第3図は第1図実施例におけ
るソートレコード入力処理の処理ステップを示す流れ図
、第4図は第1図実施例におけるストリング出力処理の
処理ステップを示す流れ図である。 1・・・ソートすべきレコードが格納され、ソートのワ
ークファイルとしても兼用されるソート入力ファイル、
2・・・ソート入力ファイル内のレコードをソートする
ソート処理手段、3・・・ソート入力ファイル内のレコ
ードをブロック単位で入出力するための入出力処理手段
、4・・・ソート処理手段が前記入出力処理手段にパラ
メータとして渡すための入出力パラメータテーブル、5
・・・ソート処理手段が入出力処理手段を用いてソート
入力ファイルからレコードを入力する際にバッファとし
て用いる主記憶装置内の入力バッファ、6・・・ソート
処理手段が入出力処理手段を用いてソート入力ファイル
へレコードを出力する際にバッファとして用いる主記憶
装置内の出力バッファ、7・・・ソート処理手段がソー
ト入力ファイル内の空きブロックを管理するだめの空き
ブロック管理テーブル、8・・・ソート結果を書き込む
ためのソート出力ファイル、9・・・ソート処理手段が
ソートを行うためのワークエリアとして用いる主記憶装
置内のソートワーク領域、11,12.13.14・・
・ソート入力ファイルを構成するブロック、21・・・
ソート主処理、22・・・ソートレコード入力処理、2
3・・・ストリング出力処理。
FIG. 1 is a block diagram of sorting processing showing an embodiment of the present invention, FIG. 2 is a flowchart showing processing steps of main processing for saw 1 in the embodiment of FIG. 1, and FIG. FIG. 4 is a flowchart showing the processing steps of the sort record input processing. FIG. 4 is a flowchart showing the processing steps of the string output processing in the embodiment of FIG. 1... A sort input file in which records to be sorted are stored and also used as a work file for sorting;
2... Sort processing means for sorting records in the sort input file, 3... I/O processing means for inputting and outputting records in the sort input file in block units, 4... Sorting processing means is the front an input/output parameter table for passing as a parameter to the input/output processing means, 5
... an input buffer in the main storage device used as a buffer when the sort processing means inputs records from the sort input file using the input/output processing means; 6... the sort processing means uses the input/output processing means; an output buffer in the main storage device used as a buffer when outputting records to the sort input file, 7... an empty block management table for the sort processing means to manage empty blocks in the sort input file, 8... Sort output file for writing sort results, 9... Sort work area in the main storage device used as a work area for sorting by the sort processing means, 11, 12.13.14...
・Blocks that constitute the sort input file, 21...
Sort main processing, 22... Sort record input processing, 2
3... String output processing.

Claims (1)

【特許請求の範囲】 補助記憶装置上のランダムアクセス可能なファイル内に
格納されたレコードをソートするソート処理において、 ソートすべきレコードが格納され、ソートのワークファ
イルとしても兼用されるソート入力ファイルと、 前記ソート入力ファイル内のレコードをソートするソー
ト処理手段と、 前記ソート入力ファイル内のレコードをブロック単位で
入力する入出力処理手段と、 前記ソート処理手段が前記入出力処理手段にパラメータ
として渡す入出力パラメータテーブルと、前記ソート処
理手段が前記入出力処理手段を用いて前記ソート入力フ
ァイルからレコードを入力する際にバッファとして用い
る主記憶装置内の入力バッファと、 前記ソート処理手段が前記入出力処理手段を用いて前記
ソート入力ファイルへレコードを出力する際にバッファ
として用いる主記憶装置内の出力バッファと、 前記ソート処理手段が前記ソート入力ファイル内の空き
ブロックを管理するための空きブロック管理テーブルと
、 ソート結果を書き込むためのソート出力ファイルと、 前記ソート処理手段がソートを行うためのワークエリア
として用いる主記憶装置内のソートワーク領域と を備え、 前記ソート入力ファイルは一定の大きさを持つブロック
から構成され、 前記入力バッファ及び前記出力バッファは前記ソート入
力ファイルのブロックサイズと同一の大きさをそれぞれ
持ち、 前記ソート処理手段は、前記入出力処理手段を呼び出す
ことにより前記ソート入力ファイルのブロックを先頭ブ
ロックから順に前記入力バッファに入力していき、前記
入力バッファ内に入力されたブロックからレコードを一
件ずつ取り出し、取り出したレコードを前記ソートワー
ク領域内でソートしていき、ソートの中間結果としての
ストリングと呼ぶ順付けられたレコード列を生成し、生
成したストリングを前記出力バッファをバッファとして
用いながら前記ソート入力ファイル内へ前記入出力処理
手段を用いてブロック単位で書き出して行き、前記ソー
ト入力ファイルからのレコード入力修了後、生成したス
トリングをマージして行き、新しいストリングを作成し
ていき、一回のマージで全ストリングをマージできるま
でストリングの本数を減らすと、最後に全ストリングを
マージし、一本のストリングにまとめ、ソート結果とし
て前記ソート出力ファイルに出力していくことによりソ
ート処理を行うが、 前記ソート処理手段は、ソートすべきレコードを入力す
る処理において、前記ソート入力ファイルから、前記入
出力処理手段を用いて、ブロックを一個前記入力バッフ
ァ内に読み込む毎に、読み込んだブロックの先頭の前記
ソート入力ファイル内相対アドレスを前記空きブロック
管理テーブルに登録しておき、ストリングのブロックを
、ソート中間結果として前記ソート入力ファイルへ出力
する際には、前記空きブロック管理テーブルから、1エ
ントリ取り出し、ストリングのブロックを出力すべき前
記ソート入力ファイル内位置を得て、前記入出力パラメ
ータテーブルにブロック出力位置として設定し、前記入
出力処理手段を呼び出してストリングを出力していく ことを特徴とするランダムアクセス可能なファイルのソ
ート方式。
[Claims] In a sorting process for sorting records stored in a randomly accessible file on an auxiliary storage device, there is provided a sorting input file in which records to be sorted are stored and also used as a sorting work file. , a sort processing means for sorting the records in the sort input file, an input/output processing means for inputting records in the sort input file in units of blocks, and an input that the sort processing means passes as a parameter to the input/output processing means. an output parameter table; an input buffer in a main storage device used as a buffer when the sorting processing means inputs records from the sorting input file using the input/output processing means; and the sorting processing means performs the input/output processing. an output buffer in a main storage device used as a buffer when outputting records to the sort input file using the means; and a free block management table for the sort processing means to manage free blocks in the sort input file. , a sort output file for writing sort results, and a sort work area in a main storage device used as a work area for sorting by the sort processing means, and the sort input file is a block having a certain size. The input buffer and the output buffer each have the same size as the block size of the sort input file, and the sort processing means reads the blocks of the sort input file by calling the input/output processing means. The first block is sequentially input to the input buffer, records are retrieved one by one from the blocks input to the input buffer, the retrieved records are sorted within the sort work area, and the intermediate results of sorting are generates an ordered record string called a string, writes the generated string in blocks to the sort input file using the input/output processing means using the output buffer as a buffer, and writes the generated string in blocks by using the input/output processing means, After inputting records from the file, merge the generated strings, create new strings, reduce the number of strings until you can merge all strings in one merge, and finally merge all strings. , the sorting process is performed by combining the records into one string and outputting them to the sorting output file as the sorting result. In the process of inputting records to be sorted, the sorting processing means inputs the following information from the sorting input file: Each time a block is read into the input buffer using the input/output processing means, the relative address in the sort input file of the head of the read block is registered in the free block management table, and the block of strings is , when outputting to the sort input file as an intermediate sort result, extract one entry from the free block management table, obtain the position in the sort input file where the block of strings should be output, and write it to the input/output parameter table. A randomly accessible file sorting method characterized in that a string is set as a block output position, and a string is output by calling the input/output processing means.
JP32143788A 1988-12-20 1988-12-20 Sorting system for random access file Pending JPH02165325A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP32143788A JPH02165325A (en) 1988-12-20 1988-12-20 Sorting system for random access file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP32143788A JPH02165325A (en) 1988-12-20 1988-12-20 Sorting system for random access file

Publications (1)

Publication Number Publication Date
JPH02165325A true JPH02165325A (en) 1990-06-26

Family

ID=18132547

Family Applications (1)

Application Number Title Priority Date Filing Date
JP32143788A Pending JPH02165325A (en) 1988-12-20 1988-12-20 Sorting system for random access file

Country Status (1)

Country Link
JP (1) JPH02165325A (en)

Similar Documents

Publication Publication Date Title
US4785400A (en) Method for processing a data base
JPH02178730A (en) Internal sorting system using dividing method
JPH02165325A (en) Sorting system for random access file
JP2586610B2 (en) File creation method
JPS63276629A (en) Sorting system for record in file
JPH0145648B2 (en)
JPS6381526A (en) Sort input/output buffer management system
JPH02116936A (en) Reorganizing system
JPH04353944A (en) Record additional system for index order formation file
JPS6266326A (en) Array processing system for japanese data
JPH01228022A (en) Tow-dimensional data storing system
JPH03202934A (en) Data processor
JPH03226829A (en) Information processor
JPH04102918A (en) Sorting processing system
JP2926803B2 (en) Sorting method
JPS59214948A (en) Sorting method of data
JPH01258071A (en) System for creating file of logic coincident point
JPH04238532A (en) Sort processing system
JPH02216554A (en) System for reforming index order forming file
JPH04213111A (en) Data sort system
JPS62251923A (en) Sort processing method
JPH02294729A (en) Sort processing system
JPS6476339A (en) Processing system for restoration of editing data
JPS5829046A (en) Memory sorting system
JPS6326411B2 (en)