JPH06103459B2 - Sorting method and apparatus - Google Patents

Sorting method and apparatus

Info

Publication number
JPH06103459B2
JPH06103459B2 JP17008282A JP17008282A JPH06103459B2 JP H06103459 B2 JPH06103459 B2 JP H06103459B2 JP 17008282 A JP17008282 A JP 17008282A JP 17008282 A JP17008282 A JP 17008282A JP H06103459 B2 JPH06103459 B2 JP H06103459B2
Authority
JP
Japan
Prior art keywords
block
buffer
data
span
sort
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.)
Expired - Lifetime
Application number
JP17008282A
Other languages
Japanese (ja)
Other versions
JPS5960539A (en
Inventor
要 小林
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP17008282A priority Critical patent/JPH06103459B2/en
Publication of JPS5960539A publication Critical patent/JPS5960539A/en
Publication of JPH06103459B2 publication Critical patent/JPH06103459B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/22Arrangements for sorting or merging computer data on continuous record carriers, e.g. tape, drum, disc
    • G06F7/24Sorting, i.e. extracting data from one or more carriers, rearranging the data in numerical or other ordered sequence, and rerecording the sorted data on the original carrier or on a different carrier or set of carriers sorting methods in general

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Description

【発明の詳細な説明】 〔発明の技術分野〕 本発明は、ディスクパック装置などの直接アクセスの外
部記憶に格納されているデータセットの中のレコードを
ソートする方法および装置に関するものである。
Description: TECHNICAL FIELD OF THE INVENTION The present invention relates to a method and apparatus for sorting records in a data set stored in a direct access external storage such as a disk pack device.

〔従来技術と問題点〕[Conventional technology and problems]

外部記憶装置上のデータを与えられた順序関係規約(ソ
ート・ルール)に従って、ソートすることを一般に外部
ソート(external sort)と呼ぶ。外部ソートは、バン
キング・アプリケーションを筆頭に、諸事務計算、デー
タベース・アプリケーション、その他の分野で日常よく
行われる処理である。外部ソートの処理のために、汎用
のソート/マージプログラムが提供されているが、どの
ソート/マージアルゴリズムを採用するにせよ、外部記
憶に記録されたデータは外部記憶制御装置、チャネル装
置を経由して主記憶上に転送され、また送りもどされる
というプロセスが必要になっている。ソートのためのチ
ャネル使用の率は、実行環境により違うが、事務計算や
データベースがらみの処理の分野においては、2割以上
を占めているのではなかろうかといわれている。外部ソ
ートのためのチャネル占有率が減少すれば、相対的に他
の目的のためのチャネル使用効率が高まることになる。
また、外部ソートの性能を左右する主なファクターが、
データの転送回数(アクセス回数)であり、転送回数を
最小にするアルゴリズムが良い外部ソート・アルゴリズ
ムであるとも考えられている。
Sorting data on an external storage device according to a given order relational rule (sorting rule) is generally called an external sort. The external sort is a routine processing routinely performed in banking applications, clerical work, database applications, and other fields. A general-purpose sort / merge program is provided for external sort processing. However, no matter which sort / merge algorithm is adopted, the data recorded in the external storage will pass through the external storage control device and channel device. Need to be transferred to main memory and sent back again. The rate of channel use for sorting varies depending on the execution environment, but it is said that it may account for more than 20% in the field of business calculation and database-related processing. If the channel occupancy rate for external sorts is reduced, the channel utilization efficiency for other purposes is relatively increased.
In addition, the main factors that affect the performance of external sorting are
It is the number of data transfers (the number of accesses), and it is also considered that the algorithm that minimizes the number of transfers is a good external sort algorithm.

しかし、中央演算装置と主記憶装置を用いた外部ソート
方法である限り、チャネル経由のデータ転送回数を減少
させるには限界がある。むしろ、チャネルと外部記憶装
置の中間に外部ソート専用の装置を置いて、チャネルを
使用せずに、外部ソートが達成できれば、(1)専用装
置によるソート処理の高速化、(2)チャネルの外部ソ
ートのための占有率減少の一挙両得になるのではないか
と考えられる。また、仮にもし、そのような専用の装置
ができたとしても、装置が複雑で高価なものになるよう
であれば、ソート処理の高速化と、チャネル占有率の減
少分の努力が実らないことになる。したがって、もしそ
のような装置ができたとしても単純なもので、安価なも
のでなければならない。ましてや、その新しい装置のた
めにさらに巨大なソフトウェア開発が必要になったり、
多大のソフトウェア変更が生じるのではこまる。
However, as long as the external sorting method uses the central processing unit and the main storage device, there is a limit in reducing the number of data transfers via the channel. Rather, if a device dedicated to external sort is placed between the channel and the external storage device and external sort can be achieved without using the channel, (1) speedup of sort processing by the dedicated device, (2) external of the channel It seems that the occupancy rate for sorting will be reduced. Moreover, even if such a dedicated device is made, if the device becomes complicated and expensive, efforts for speeding up sort processing and reducing the channel occupancy rate will not be realized. become. Therefore, if such a device could be made, it should be simple and inexpensive. Even more, it requires a huge amount of software development for the new device,
Don't expect a lot of software changes.

現在の汎用の外部ソート・プログラムは、入力ファイ
ル、作業用ファイル、出力ファイルの3本のファイルを
開設した後に、入力ファイルから作業用ファイルへ、作
業用ファイルから出力ファイルへの読み込み、書き出し
処理を行いながらソート処理を実現している。この処理
内容をそのまゝハードウェア化するというも考えられる
が、しかし、複数のファイルを1つの装置が同時に制御
するという実行環境は、ハードウェア化する場合、ロジ
ックが複雑になるし、スペース不足の場合にどうするか
など、余計な世話もしなくてはならなくなり、単純な装
置として実現するという方針からはずれる。さらに、既
存の汎用ソート・プログラムの設計思想は、データ・ア
クセス回数最小という要請に応えようとするところに力
点があり、単純化しようという思想とは多少ずれてい
る。特に、ファイルのスペース管理という、本来ソフト
ウェアによってサポートされているシステムと情報交換
が必要になることは、ハードウェア化する際のネックに
なる可能性が大きい。したがって、ソートされるべきデ
ータの物理的空間が最初から最後まで、明確に定義され
ているようなソート方法を前提にしたほうがハードウェ
ア化が容易になろう。
The current general-purpose external sort program opens three files, an input file, a work file, and an output file, and then performs read / write processing from the input file to the work file and from the work file to the output file. The sort process is realized while doing it. It is conceivable that the contents of this processing will be converted to hardware as it is, but the execution environment in which one device controls multiple files at the same time makes the logic complicated and lacks space when converted to hardware. In the case of, you have to take extra care of what to do, and you are out of the policy of realizing it as a simple device. Further, the design concept of the existing general-purpose sort program has an emphasis on responding to the request of the minimum number of data access times, and is somewhat different from the concept of simplification. In particular, file space management, which requires information exchange with a system originally supported by software, is likely to be a bottleneck when implementing hardware. Therefore, if the physical space of the data to be sorted is defined from the beginning to the end, it will be easier to implement the hardware on the assumption of a sorting method.

今、仮に、外部記憶装置とチャネルの間にしかるべき、
外部ソート装置を設置したとしよう。その場合の運用状
況としては、『せっかく、外部ソート装置を設置したの
だから』という気持が作用して、その外部ソート装置に
つながるデータセット群は、常にソート済みとして用い
るようなマスターファイル群や、その他のサブファイル
群であろう。すなわち、かような外部ソート装置に連結
されたファイルの多くは、常にソート済みの状況にある
ような運用になろう。とすれば、その外部ソート装置の
特性として、ソート済みの状態にあるファイルへのデー
タの追加、あるいは、ほぼソート済みに近い部分的に未
ソートな状態のもののソートなどが容易に処理できる必
要があろう。
Now, suppose between the external storage device and the channel,
Suppose you have installed an external sorter. The operational situation in that case is that the data set group connected to the external sort device is a master file group that is always used as a sorted file, It may be another subfile group. That is, most of the files connected to such an external sort device will always be in the sorted state. If this is the case, the characteristic of the external sorter is that it is necessary to be able to easily add data to a file in a sorted state, or sort a partially unsorted state that is almost sorted. Ah

〔発明の目的〕[Object of the Invention]

本発明は、上記の考察に基づくものであって、ソートす
べきデータセットの中でソート処理を行い得ること、略
ぼソート済みのデータセットのソートの場合に効果が大
きいこと、使用するメモリ領域の少ないこと及びハード
ウェア化が容易なこと等の特徴を有するソート処理方法
および装置を提供することを目的としている。
The present invention is based on the above consideration, that sort processing can be performed in a data set to be sorted, that the effect is great in the case of sorting a data set that has been substantially sorted, and the memory area used It is an object of the present invention to provide a sort processing method and device having features such as a small number of products and easy hardware implementation.

〔発明の構成〕[Structure of Invention]

そしてそのため、本発明の第1番目の発明のソート処理
方法は、 それぞれがN個のレコードを持つ第1ブロック,第2ブ
ロック,…,第nブロックより構成されたソート済みブ
ロック列に,N個のレコードを持つソート済みの第n+1
ブロックを追加し、第1ブロックから第n+1ブロック
までをソートするソート処理方法であって、 第nブロックを第1バッファに格納し、第n+1ブ
ロックを第2バッファに格納し、 第1バッファの内容と第2バッファの内容をマージ
し、マージ結果をソート・ルールにしたがって第1バッ
ファおよび第2バッファに格納し、 マージ後の第1バッファに格納されているレコード
列において、マージ前の第1バッファに格納されていた
レコード列の先頭レコードより前方に位置するレコード
列が存在するか否かを調べ、 存在しない場合には、ソートを終了し、 存在する場合には、第1バッファの内容を第2バッ
ファに移動し、ソート済みブロック列における1つ前の
ブロックを第1バッファに格納し、再びの処理を行う ことを特徴とするものである。
Therefore, the sorting method according to the first aspect of the present invention is such that N sorted blocks each consisting of a first block, a second block, ... Sorted n + 1 with records
A sort processing method of adding blocks and sorting the first block to the n + 1th block, wherein the nth block is stored in a first buffer, the n + 1th block is stored in a second buffer, and the contents of the first buffer are stored. And the contents of the second buffer are merged, the merged result is stored in the first buffer and the second buffer according to the sorting rule, and in the record string stored in the first buffer after the merge, the first buffer before the merge Check whether or not there is a record string located before the first record of the record string stored in. If it does not exist, the sorting is terminated, and if it exists, the contents of the first buffer are It is characterized by moving to two buffers, storing the previous block in the sorted block sequence in the first buffer, and performing the processing again. Than it is.

本発明の第2番目の発明のソート処理装置は、 それぞれがN個のレコードよりなるM個のブロックを持
つデータセットを格納する外部記憶ユニットと、 バッファ・リードの指令を受取ったとき上記外部記憶ユ
ニットから指定されたブロックを読出して指定されたバ
ッファに格納すると共にライトの指令を受取ったとき指
定されたバッファのデータを指定された外部記憶ユニッ
トのブロックに書込むブロック入出力コントローラと、 内部ソート指令を受取ったとき指定されたバッファの内
容を内部ソートする内部ソータと、 マージを行うと共にスパン長を求めることを支持するス
パン・スライダ指令を受取ったとき指定された第pバッ
ファおよび第qバッファに格納されているソート済デー
タをスパン長に基づいてマージする処理、マージ前とマ
ージ後におけるデータの移動の有無を出力する処理、マ
ージ処理の結果得られるレコード列における,マージ前
の第pバッファに格納されていたレコード列の先頭レコ
ードより前方に位置するレコード列の長さを示すスパン
長を出力する処理を行う2ブロック・スパン・スライダ
と、 制御手段と を具備し、 上記制御手段は、上記データセットの全ブロックのそれ
ぞれを内部ソートする処理を行った後、 ブロック番号iを初期値に設定し、 i+1をiに設定し、 ブロック番号iがMより大であるか否かを調べ、No
の場合には次にの処理に移行し、Yesの場合は終了と
し、 スパン長をNに、ブロック番号iをkに設定すると
共に、第kブロックのデータを第qバッファに格納すべ
きことを上記ブロック入出力コントローラに指令し、 k−1をkに設定し、 kが1より小さいか否かを調べ、Yesの場合には
の処理に戻り、Noの場合には次のの処理を行い、 第kブロックのデータを第qバッファに読込むべき
ことを上記ブロック入出力コントローラに指令すると共
に、第pバッファおよび第qバッファの内容をマージす
べきこと、マージ処理の結果得られるレコード列におけ
るスパンの長さをスパン長格納域にセットすべきこと、
並びにマージ前とマージ後でデータの移動があったか否
かを示す移動有無情報を出力すべきことを上記2ブロッ
ク・スパン・スライダに指令し、 移動有無情報が移動なしを示しているか否かを調
べ、移動なしの場合にはの処理に移行し、移動ありの
場合にはの処理に移行し、 第pバッファのデータを第kブロックに書込むべき
こと及び第qバッファのデータを第k+1ブロックに書
込むべきことを上記ブロック入出力コントローラに指令
し、 スパン長が零であるか否かを調べ、Yesの場合には
の処理に移行し、Noの場合にはの処理に移行し、 第pバッファと第qバッファのデータを交換した
後、上記の処理を行うよう構成されている ことを特徴とするものである。
The sorting apparatus of the second invention of the present invention comprises an external storage unit for storing a data set having M blocks each consisting of N records, and the external storage unit when a buffer read command is received. A block I / O controller that reads the specified block from the unit, stores it in the specified buffer, and writes the data in the specified buffer to the specified external storage unit block when a write command is received, and an internal sort An internal sorter that internally sorts the contents of the specified buffer when a command is received, and a span slider that supports merging and determining the span length. To the p and q buffers specified when a command is received. Process to merge stored sorted data based on span length, before merging And the length of the record string positioned before the first record of the record string stored in the p-th buffer before merging in the record string obtained as a result of the process of outputting the presence or absence of data movement after merging Is provided with a two-block span slider for outputting a span length and a control means, and the control means performs internal sorting processing for all the blocks of the data set, and then the block number. Set i to the initial value, set i + 1 to i, check whether block number i is greater than M, and
In the case of, the process proceeds to the next process, and in the case of Yes, the process is terminated, and the span length is set to N, the block number i is set to k, and the data of the kth block should be stored in the qth buffer. Instruct the above block input / output controller to set k-1 to k, check whether k is less than 1, return to the process in the case of Yes, and execute the next process in the case of No. , Instructing the block input / output controller to read the data of the k-th block into the q-th buffer, merging the contents of the p-th buffer and the q-th buffer, and in the record string obtained as a result of the merging process. The length of the span should be set in the span length storage area,
In addition, the 2 block span slider is instructed to output the movement presence / absence information indicating whether or not the data has been moved before and after the merge, and it is checked whether or not the movement presence / absence information indicates no movement. , If there is no movement, the process shifts to, if there is a shift, shifts to the process, the data in the pth buffer should be written in the kth block, and the data in the qth buffer should be written in the k + 1th block. Instruct the above block I / O controller to write, check whether the span length is zero, move to the process of if it is Yes, move to the process of if it is No, p-th After the data in the buffer and the q-th buffer are exchanged, the above process is performed.

〔発明の実施例〕Example of Invention

以下、本発明を図面を参照しつつ説明する。ファイル
(データセットと同義)Fは、下記のようにレコードr
〔1〕、r〔2〕、…r〔P〕、…r〔K〕の並びとし
て考えることが出来る。
Hereinafter, the present invention will be described with reference to the drawings. File (synonymous with data set) F has record r as shown below.
It can be considered as a sequence of [1], r [2], ... R [P], ... R [K].

また、ファイルFは、下記のようにブロックの並びとし
て考えることも出来る。
Further, the file F can be considered as an array of blocks as described below.

各ブロックは固定長のものであり、ブロックBiは下記の
ようにN個のレコードから構成されている。
Each block has a fixed length, and the block Bi is composed of N records as described below.

ここで、▲Ri j▼は第i番目のブロックの第j番目のレ
コードを意味している。また▲Ri j▼は ▲Ri j▼=r〔N・(i−1)+j〕 である。なお、ブロックとは、入出力の単位である。
Here, ▲ R i j ▼ means the j-th record of the i-th block. Further, ▲ R i j ▼ is ▲ R i j ▼ = r [N · (i-1) + j]. A block is an input / output unit.

次に本明細書で使用する記号の定義について説明する。
r′およびrをレコードとすると、 r′←r は、レコードr′がレコードrの前に位置すべきことを
意味している。また、 r〔p〕r〔q〕 は、レコードr〔p〕からr〔q〕までがソートされた
ことを意味している。ただし、p<qである。
Next, the definition of symbols used in this specification will be described.
Let r'and r be records, r '← r means that record r'should be located before record r. Further, r [p] r [q] means that records r [p] to r [q] are sorted. However, p <q.

同様に、 ▲Ri j▼▲Ri′ j′▼ ただし、N・(i−1)+j<N・(i′−1)+j′
は、レコード▲Ri j▼からレコード▲Ri′ j′▼まで
がソートされたことを意味している。
Similarly, ▲ R i j ▼ ▲ R i ′ j ′ ▼, where N · (i−1) + j <N · (i′−1) + j ′
It is, which means that the record ▲ R i j from ▼ to record ▲ R i 'j' ▼ has been sorted.

次に、本発明のソート処理方式のアルゴリズムについて
説明する。ソート処理は、 given:file F target:▲R1 1▼▲RM N▼ と書くことが出来る。これを問題0という。本発明にお
ける解法レベル1は、 for i=1,M ▲R1 1▼▲Ri N▼ を行うことである。上式は、iを1から1刻みでMまで
変化させながら、 ▲R1 1▼▲Ri N▼ を実行せよ、ということを意味している。第1図は上記
の解法レベル1の処理を説明するものである。即ち、先
ずブロックB1をソートされた状態にする。次に、ブロッ
クB1からB2までをソートされた状態にする。同様な処理
を繰返してブロックB1からBi-1までをソートされた状態
にする。ソートされた状態にあるブロックB1からBi-1
での並びにブロックBiを加え、しかる後にブロックB1
らBiまでをソートされた状態にする。同様な処理を繰返
し、ブロックB1からブロックBMまでをソートされた状態
とする。
Next, the algorithm of the sorting method of the present invention will be described. The sort process can be written as given: file F target: ▲ R 1 1 ▼ ▲ R M N ▼. This is called problem 0. The solution level 1 in the present invention is to perform for i = 1, M ▲ R 11 1 ▼ R i N ▼. The above formula means that while executing i from 1 to M in increments of 1 while performing ▲ R 1 1 ▼ ▲ R i N ▼. FIG. 1 illustrates the processing of the solution level 1 described above. That is, first, the block B 1 is brought into a sorted state. Next, blocks B 1 to B 2 are sorted. The same processing is repeated to bring blocks B 1 to Bi -1 into a sorted state. The blocks B 1 to Bi −1 in the sorted state and the block Bi are added, and then the blocks B 1 to Bi are brought into the sorted state. The same process is repeated to bring blocks B 1 to B M into a sorted state.

上記の処理を行うためには、ソートされた状態にあるブ
ロックB1からBi-1の並びにブロックBiを加える、しかる
後にブロックB1からBiまでをソートされた状態にしなく
てはならない。これを問題1とすると、問題1は given:▲R1 1▼▲Ri-1 N▼,Bi target:▲R1 1▼▲Ri N▼ と書くことが出来る。この問題1の解法を解法レベル2
とすると、解法レベル2は Internal Sort Bi Merge Bi and<B1,B2,………,Bi-1> と書くことが出来る。ここで問題となることは、上記の
マージを如何にして行うかと言うことである。これを問
題2とすると、問題2は、 given:▲R1 1▼▲Ri-1 N▼,▲Ri 1▼▲Ri N▼ target:▲R1 1▼▲Ri N▼ と書くことが出来る。この問題2に対する解法を解法レ
ベル3とすると、解法レベル3は、下記の式で与えられ
る。
In order to perform the above processing, the blocks B 1 to Bi −1 and the block Bi in the sorted state must be added, and then the blocks B 1 to Bi must be put into the sorted state. If this is problem 1, problem 1 can be written as given: ▲ R 1 1 ▼ ▲ R i-1 N ▼, Bi target: ▲ R 1 1 ▼ ▲ R i N ▼. Solution level 2 of this problem 1
Then, the solution level 2 can be written as Internal Sort Bi Merge Bi and <B 1 , B 2 , ....., Bi -1 >. The problem here is how to perform the above merge. If this is problem 2, problem 2 is written as given: ▲ R 1 1 ▼ ▲ R i-1 N ▼, ▲ R i 1 ▼ ▲ R i N ▼ target: ▲ R 1 1 ▼ ▲ R i N ▼ You can Assuming that the solution method for this problem 2 is the solution level 3, the solution level 3 is given by the following equation.

fot u=i,2,−1 ▲Ru-1 1▼▲Ri N▼ 上式は、uをiから−1刻みで2まで変化させながら ▲R1 1▼▲Ri N▼ を実現せよ、ということを意味している。上記の解法レ
ベル3を実行するためには、下記の問題を解く必要があ
る。
fot u = i, 2, -1 ▲ R u-1 1 ▼ ▲ R i N ▼ The above formula realizes ▲ R 1 1 ▼ ▲ R i N ▼ by changing u from i to 2 in steps of -1. It means that. In order to carry out the above solution level 3, it is necessary to solve the following problems.

given:▲Ru-1 1▼▲Ru-1 N▼,▲Ru 1▼▲Ri N▼ target:▲Ru-1 1▼▲Ri N▼ これを問題3とすると、問題3はu−1で示されるブロ
ックBu-1がソートされ、且つブロックBuからBiまでソー
トされた状態の下で、ブロックBu-1からBiまでソートせ
よということを意味している。
given: ▲ R u-1 1 ▼ ▲ R u-1 N ▼, ▲ R u 1 ▼ ▲ R i N ▼ target: ▲ R u-1 1 ▼ ▲ R i N ▼ If this is problem 3, problem 3 Means that the block Bu -1 indicated by u-1 is sorted, and under the condition that the blocks Bu to Bi are sorted, the blocks Bu -1 to Bi are sorted.

最初の状態ではu=iであるので、問題3は、 given:▲Ri-1 1▼▲Ri-1 N▼,▲Ri 1▼▲Ri N▼ target:▲Ri-1 1▼▲Ri N▼ となる。第2図は第1ステップの問題3の解法を説明す
るものである。ブロックBi-1は既にソートされた状態で
あり、その先頭のレコード▲Ri-1 1▼の内容がa、そ
の最後のレコード▲Ri-1 N▼の内容がbであるとす
る。同様に、ブロックBiは既にソートされた状態にあ
り、その先頭レコード▲Ri 1▼の内容はc、最後のレ
コード▲Ri N▼の内容はであるとする。ブロックBi-1
とBiをマージすると、図示のようにCase1ないし4の状
態が生ずる。Case1は、マージ結果とマージ前の状態が
変化しなかった場合を示している。Case2は、マージ結
果においてマージ前のレコード▲Ri 1▼が前方に移され
た場合を示している。Case3は、マージ結果の状態がマ
ージ前のブロックBi-1とBiとを交換した状態になる場合
を示している。Case4は、マージ結果においてマージ前
のレコード▲Ri 1▼が先頭に位置し、マージ前のレコー
ド▲Ri-1 1▼がそれより後方に位置する場合を示してい
る。Case3は、Case4の特別の場合と考えることも出来
る。マージ結果がCase1となる予想される場合には、何
も行わない。即ち、既にブロックB1からBiまでソートが
行われた状態にある。マージ結果がCase2になると予想
される場合には、ブロックBi-1とBiとの2ブロック・マ
ージを行い、その後の処理は行わない。即ち、上記の2
ブロック・マージを行うと、ブロックB1からBiまでがソ
ートされた状態となる。マージ結果がCase3になると予
想される場合は、マージを行いマージ後のBiが完成され
たものとし、次に given:▲R1 1▼▲Ri-2 N▼,▲Ri-1 1▼▲Ri-1 N▼ target:▲R1 1▼▲Ri-1 N▼ なる問題を解く。マージ結果がCase4になると予想され
る場合には、マージを行い、マージ後のBiおよび▲R
i-1 k+1▼▲Ri N▼が完成されたものとし、次に given:▲R1 1▼▲Ri-2 N▼,▲Ri-1 1▼▲Ri-1 k▼ target:▲R1 1▼▲Ri-1 k▼ なる問題を解く。なお、k+1はマージ後において内容
aをもつレコード(マージ前のレコード▲Ri-1 1▼)
のブロックBi-1上の位置を示している。
Since u = i in the initial state, the problem 3 is given: ▲ R i-1 1 ▼ ▲ R i-1 N ▼, ▲ R i 1 ▼ ▲ R i N ▼ target: ▲ R i-1 1 ▼ ▲ R i N ▼. FIG. 2 illustrates the solution of Problem 3 in the first step. It is assumed that the block Bi -1 has already been sorted, and the content of the first record ▲ R i-1 1 ▼ is a and the content of the last record ▲ R i-1 N ▼ is b. Similarly, it is assumed that the block Bi is already sorted, the content of the first record ▲ R i 1 ▼ is c, and the content of the last record ▲ R i N ▼ is. Block Bi -1
When Bi and Bi are merged, Cases 1 to 4 occur as shown in the figure. Case 1 shows a case where the merge result and the state before the merge have not changed. Case 2 shows a case where the record before merge ▲ R i 1 ▼ has been moved forward in the merge result. Case 3 shows a case where the state of the merged result is a state in which the blocks Bi -1 and Bi before the merge are exchanged. Case 4 shows a case where the record before merge ▲ R i 1 ▼ is located at the beginning and the record before merge ▲ R i-1 1 ▼ is located behind it in the merged result. Case3 can be thought of as a special case of Case4. If the merge result is expected to be Case1, do nothing. That is, the blocks B 1 to Bi have already been sorted. When the merged result is expected to be Case 2, the two blocks are merged with the blocks Bi −1 and Bi, and the subsequent processing is not performed. That is, the above 2
When block merging is performed, blocks B 1 to Bi are sorted. If the merged result is expected to be Case 3, it is assumed that the merged Bi has been completed, and then given: ▲ R 1 1 ▼ ▲ R i-2 N ▼, ▲ R i-1 1 ▼ Solve the problem ▲ R i-1 N ▼ target: ▲ R 1 1 ▼ ▲ R i-1 N ▼. If the merge result is expected to be Case 4, perform the merge, and then use Bi and ▲ R after the merge.
It is assumed that i-1 k + 1 ▼ ▲ R i N ▼ has been completed, and then given: ▲ R 1 1 ▼ ▲ R i-2 N ▼, ▲ R i-1 1 ▼ ▲ R i-1 k ▼ target: ▲ R 1 1 ▼ ▲ R i-1 k ▼ solve the problem. Note that k + 1 is a record having the content a after merging (record before merge ▲ R i-1 1 ▼)
The position on the block Bi -1 of is shown.

次に、スパン・スライドなる概念について説明する。第
3図において、レコード▲Ru 1▼ないし▲Ru k▼をスパ
ンという。即ち、スパンとは、前方に位置するレコード
列(▲R1 1▼,…,▲Ru-1 N▼)よりも前方に位置すべ
きレコードを含んでいる可能性のあるレコードのまとま
り(▲Ru 1▼,…,▲Ru k▼)である。これは、第2図
のCase4におけるCからa(たゞしaは含まず)
までに対応する。第3図において、▲R1 1▼▲Ru-2 N
▼,▲Ru-1 1▼▲Ru-1 N▼,▲Ru 1▼▲Ru k▼,▲
u k+1▼▲Ri N▼であり、且つ▲Ru-1 N▼←▲Ru k+1
▼である。ブロックBu-1とブロックBuとをマージする
と、第2図のCase1ないし4の場合が生ずる。Case1、2
の場合にはスパンは消滅し、Case3、4の場合は新たな
スパンが生成される。2個のブロックをマージして、ス
パンを求めることを、スパン・スライドという。Case
3、4の場合には、uの値を−1した後、ブロックBu-1
とブロックBuとのスパン・スライドを行う。ブロックBu
-1とブロックBuとをマージする場合、ブロックBu-1とブ
ロックBuのスパン部分(RuないしRuの部分)とをマージ
する。
Next, the concept of span slide will be described. In FIG. 3, the records ▲ R u 1 ▼ to ▲ R u k ▼ are called spans. That is, the span is a group of records that may include records that should be located ahead of the record sequence (▲ R 1 1 ▼, ..., ▲ R u-1 N ▼) located in front (▲ R u 1 ▼, ..., ▲ R u k ▼). This is from C to a in Case 4 in Figure 2 (not including the a)
Up to. In Fig. 3, ▲ R 1 1 ▼ ▲ R u-2 N
▼, ▲ R u-1 1 ▼ ▲ R u-1 N ▼, ▲ R u 1 ▼ ▲ R u k ▼, ▲
R u k + 1 ▼ ▲ R i N ▼, and ▲ R u-1 N ▼ ← ▲ R u k + 1
▼ When block Bu -1 and block Bu are merged, cases 1 to 4 in FIG. 2 occur. Case1, 2
In the case of, the span disappears, and in Cases 3 and 4, a new span is generated. Merging two blocks and finding the span is called span slide. Case
In the case of 3 and 4, after -1 the value of u, block Bu -1
And slide span with Block Bu. Block Bu
When -1 and the block Bu are merged, the block Bu -1 and the span portion (Ru or Ru portion) of the block Bu are merged.

第4図は本発明の1実施例のブロック図である。第4図
において、1はソート処理装置、2は外部記憶ユニッ
ト、3はスパン・ソート・スーパバイザ、4は2ブロッ
ク・スパン・スライダ、5はブロック内部ソータ、6は
ブロック入出力コントローラ、7はレコード比較器、8
−1ないし8−3はブロック・バッファ、BPはバッファ
・プールをそれぞれ示している。なお、白の太線はブロ
ック・アクセス、黒の太線はレコード・アクセス、実線
は制御信号の流れをそれぞれ示している。ブロック入出
力コントローラ6は、スパン・ソート・スーパバイザ3
から何れのブロックを何れのブロック・バッファに読込
むべきか、或は何れのブロック・バッファの内容を何れ
のブロックに書出すべきかを指示されて、その指示どお
りブロック単位の入出力を行う。ブロック内部ソータ5
は、スパン・ソート・スーパバイザ3から何れのブロッ
ク・バッファの内容を内部ソートすべきかを指示され
て、その指示どおりブロック・バッファ内部のレコード
に関するソーティングを行う。ソーティングに必要なレ
コードとレコードの比較には、レコード比較器7を用い
る。2ブロック・スパン・スライダ4は、スパン・ソー
ト・スーパバイザ3から何れの2個のブロック・バッフ
ァの内容をスパン・スライド(マージ)するかを指示さ
れて、その指示どおりスパン・スライドを行う。レコー
ド比較器7は、2つのレコードが入力されると、それら
の順序を判定し、目的とする順なら真、そうでなければ
偽の値を出力する。スパン・ソート・スーパバイザ3
は、2ブロック・スパン・スライダ4、ブロック内部ソ
ータ5、ブロック入出力コントローラ6に指令を与え
る。このため、スパン・ソート・スーパバイザ3に、外
部記憶ユニット2上のソート対象データセットのブロッ
ク番地の先頭と最後を予め設定しておき、また、スパン
・スライドの制御の初期値を与えておく必要がある。ソ
ート処理装置1をプロセッサで実現する場合には、スパ
ン・ソート・スーパバイザ3、2ブロック・スパン・ス
ライダ4、内部ブロック・ソータ5、ブロック入出力コ
ントローラ6及びレコード比較器7は、ソフトウェアで
実現される。勿論、これらを全て純ハードウェア構成と
することも出来る。
FIG. 4 is a block diagram of one embodiment of the present invention. In FIG. 4, 1 is a sort processor, 2 is an external storage unit, 3 is a span sort supervisor, 4 is a 2 block span slider, 5 is a block internal sorter, 6 is a block input / output controller, and 7 is a record. Comparator, 8
-1 to 8-3 are block buffers, and BP is a buffer pool. The white thick line indicates block access, the black thick line indicates record access, and the solid line indicates the flow of control signals. The block input / output controller 6 is a span sort supervisor 3
Is instructed which block should be read into which block buffer, or the content of which block buffer should be written to which block, and input / output in block units is performed according to the instruction. Block internal sorter 5
Is instructed by the span sort supervisor 3 which block buffer contents should be internally sorted, and sorts records in the block buffer according to the instruction. The record comparator 7 is used to compare the records necessary for sorting. The two-block span slider 4 is instructed by the span sort supervisor 3 as to which of the two block buffer contents should be span-slipped (merged), and the span-slide is performed as instructed. When the two records are input, the record comparator 7 determines their order, and outputs a true value if the target order and a false value otherwise. Span Sort Supervisor 3
Gives a command to the 2-block span slider 4, the block internal sorter 5, and the block input / output controller 6. For this reason, it is necessary to preset the start and end of the block address of the data set to be sorted on the external storage unit 2 in the span sort supervisor 3 and to give the initial value of the span slide control. There is. When the sort processing device 1 is implemented by a processor, the span sort supervisor 3, the two block span slider 4, the internal block sorter 5, the block input / output controller 6, and the record comparator 7 are implemented by software. It Of course, all of these may be pure hardware configurations.

本発明のソート処理は、第1フェーズおよび第2フェー
ズに分けることが出来る。第1フェーズとは、データセ
ットの全ブロックのそれぞれをブロック内部についてソ
ート済みの状態にするためのフェーズである。第5図は
第1フェーズの概要を説明するものである。ブロック入
出力コントローラ6は、スパン・ソート・スーパバイザ
3のリード指令を受けて、外部記憶ユニット2の中のブ
ロックをリードし、これをブロック・バッファ8−1に
書込む。ブロック・バッファ8−1のブロックの書込み
が終了した後、スパン・ソート・スーパバイザ3は、ブ
ロック内部ソータ5に対してブロック・バッファ8−1
の内容を内部ソートすべきことを指令する。この内部ソ
ート指令を受取ると、ブロック内部ソータ5は、レコー
ド比較器7を使用しながらブロック・バッファ8−1の
ブロック・データについての内部ソートを行い、そのソ
ート結果をスパン・ソート・スーパバイザ3に通知す
る。ブロック内部ソータ5によるブロック・データの内
部ソートが完了すると、スパン・ソート・スーパバイザ
3は、必要に応じてブロック・バッファ8−1のブロッ
ク・データを外部記憶ユニット6の元のブロック位置に
ライトすべきことをブロック入出力コントローラ6に指
令する。このライト指令を受取ると、入出力コントロー
ラ6は、ブロック・バッファ8−1の中のブロック・デ
ータを外部記憶ユニット2内の元のブロック位置にライ
トする。以下、同様な処理が繰返される。
The sorting process of the present invention can be divided into a first phase and a second phase. The first phase is a phase for bringing all the blocks of the data set into a sorted state within the blocks. FIG. 5 illustrates the outline of the first phase. The block input / output controller 6 receives a read command from the span sort supervisor 3 to read a block in the external storage unit 2 and write it in the block buffer 8-1. After the writing of the block in the block buffer 8-1 is completed, the span sort supervisor 3 sends the block buffer 8-1 to the block internal sorter 5.
Specifies that the contents of should be sorted internally. Upon receiving this internal sort command, the block internal sorter 5 uses the record comparator 7 to perform an internal sort on the block data in the block buffer 8-1 and sends the sorted result to the span sort supervisor 3. Notice. When the internal sorting of the block data by the block internal sorter 5 is completed, the span sort supervisor 3 writes the block data of the block buffer 8-1 to the original block position of the external storage unit 6 as necessary. The block input / output controller 6 is instructed what to do. When receiving this write command, the input / output controller 6 writes the block data in the block buffer 8-1 to the original block position in the external storage unit 2. Hereinafter, the same process is repeated.

第6図はソート処理の第2フェーズの概要を説明するも
のである。スパン・ソート・スーパバイザ3は、最初に
外部記憶ユニット2内の連続せる2個のブロックをブロ
ック・バッファ8−1、8−2に読込むべきことをブロ
ック入出力コントローラ6に指令する。ブロック入出力
コントローラ6は、このリード指令を受取ると、外部記
憶ユニット2の中の連続せる2個のブロックをブロック
・バッファ8−1、8−2に読込む。このリード指令の
実行が完了した後、スパン・ソート・スーパバイザ3
は、ブロック・バッファ8−1、8−2のブロック・デ
ータについてスパン・スライドすべきことを2ブロック
・スパン・スライダ4に対して指令する。2ブロック・
スパン・スライダ4は、このスパン・スライド指令を受
取ると、ブロック・バッファ8−1、8−2内の2個の
ブロック・データをスパン・スライドし、スパン・スラ
イドの結果をスパン・ソート・スーパバイザ3に対して
通知する。スパン・スライド指令の実行完了後、スパン
・ソート・スーパバイザ3は、必要に応じてブロック・
バッファ8−1、8−2のブロック・データを外部記憶
ユニット2の中の元のブロック位置にライトすると同時
にこれらのブロック・データを外部記憶ユニット2の中
の作業記憶域にライトすべきことをブロック入出力コン
トローラ6に指令する。ブロック入出力コントローラ6
は、このライト指令を受取ると、ブロック・バッファ8
−1、8−2のブロック・データを外部記憶ユニット2
にライトする。以下、同様な処理が繰返される。
FIG. 6 explains the outline of the second phase of the sorting process. The span sort supervisor 3 instructs the block input / output controller 6 to first read two consecutive blocks in the external storage unit 2 into the block buffers 8-1 and 8-2. When the block input / output controller 6 receives this read command, it reads two consecutive blocks in the external storage unit 2 into the block buffers 8-1 and 8-2. After the execution of this read command is completed, the span sort supervisor 3
Instructs the two-block span slider 4 to span-slide the block data in the block buffers 8-1, 8-2. 2 blocks
When the span slider 4 receives this span slide command, it span-slides the two block data in the block buffers 8-1 and 8-2, and the result of the span slide is the span sort supervisor. Notify 3 After completing the execution of the span slide command, the span sort supervisor 3
Write the block data of the buffers 8-1 and 8-2 to the original block position in the external storage unit 2 and at the same time write these block data to the working storage area in the external storage unit 2. The block input / output controller 6 is instructed. Block input / output controller 6
When this write command is received, the block buffer 8
-1 and 8-2 block data to external storage unit 2
Write to. Hereinafter, the same process is repeated.

スパン・ソート・スーパバイザ3からブロック入出力コ
ントローラ6への指令には、下記のようなものがある。
The commands from the span sort supervisor 3 to the block input / output controller 6 are as follows.

BIOC(Read,i,p) BIOC(Write,i,p) ブロック入出力コントローラ6は、前者の指令を受取る
と、第iブロックのデータを第pバッファに読込み、後
者の指令を受取ると、第pバッファのデータを第iブロ
ックに書込む。なお、バッファとはブロック・バッファ
のことである。スパン・ソート・スーパバイザ3からブ
ロック内部ソータ5への指令は、下記のような形式をも
つ。
BIOC (Read, i, p) BIOC (Write, i, p) When the block input / output controller 6 receives the former command, it reads the data of the i-th block into the p-th buffer, and when it receives the latter command, it Write the data in the p buffer to the i-th block. The buffer is a block buffer. The command from the span sort supervisor 3 to the block internal sorter 5 has the following format.

BIS(p,c) ブロック内部ソータ5は、この指令を受取ると、第pバ
ッファのデータを内部ソートし、このときソート前とソ
ート後とでデータの並びが不変であればc=0、変化し
ていればc=1を出力する。スパン・ソート・スーパバ
イザ3から2ブロック・スパン・スライダ4への指令
は、下記のような構成をもつ。
When the BIS (p, c) block internal sorter 5 receives this command, it internally sorts the data in the p-th buffer, and if the data arrangement before and after sorting is unchanged, c = 0, change If so, c = 1 is output. The command from the span sort supervisor 3 to the 2-block span slider 4 has the following configuration.

2BSS(p,q,sp,c) 2ブロック・スパン・スライダ3は、この指令を受取る
と、第pバッファと第qバッファをマージし、終了後の
スパン長を指定領域spに出力し、処理前と処理後とでバ
ッファ内データの移動がなかったならばc=0、移動が
あったならばc=1を出力する。なお、開始直前におい
て第qバッファがスパン長spのスパン・ブロックである
とし、終了後は第pバッファがスパン・ブロックになる
ものとする。
2BSS (p, q, sp, c) When the 2-block span slider 3 receives this command, it merges the p-th buffer and the q-th buffer and outputs the span length after completion to the specified area sp for processing. If there is no movement of data in the buffer between before and after processing, c = 0 is output, and if there is movement, c = 1 is output. It is assumed that the q-th buffer is a span block with a span length sp immediately before the start and the p-th buffer is a span block after the end.

第7図はスパン・ソート・スーパバイザ3の動作ロジッ
クを示すものである。スパン・ソート・スーパバイザ3
は、第1フェーズのための動作ロジックと、第2フェー
ズのための動作ロジックとを有している。先ず、第1フ
ェーズのための動作ロジックについて説明する。
FIG. 7 shows the operation logic of the span sort supervisor 3. Span Sort Supervisor 3
Has operation logic for the first phase and operation logic for the second phase. First, the operation logic for the first phase will be described.

ブロック番号iを0にする。 The block number i is set to 0.

i+1をiとする。 Let i + 1 be i.

iがMより大きいかを調べる。Yesの場合は第2フ
ェーズを開始し、Noの場合にはを行う。
Check if i is greater than M. If Yes, start the second phase, and if No, perform.

BIOC(Read i,1)を発行する。 BIOC (Read i, 1) is issued.

BIC(1,c)を発行する。 Issue BIC (1, c).

cが0であるか、否かを調べる。Yesの場合には
を行い、Noの場合にはを行う。
Check whether c is 0 or not. If yes, perform, and if no, perform.

BIOC(Write,i,1)を行い、に戻る。第2フェー
ズのための動作ロジックは下記のような動作を行う。
Perform BIOC (Write, i, 1) and return to. The operation logic for the second phase operates as follows.

ブロック番号iを1に、バッファ番号pを1に、バ
ッファ番号qを2にする。
The block number i is set to 1, the buffer number p is set to 1, and the buffer number q is set to 2.

i+1をiにする。 Set i + 1 to i.

iがMより大きいか否かを調べる。Yesの場合には
第2フェーズ終了となり、Noの場合にはを行う。
Check if i is greater than M. If Yes, the second phase ends, and if No, go.

Nをスパン長に、iをブロック番号kにし、そして
BIOC(Read,k,q)を発行する。
Let N be the span length, i be the block number k, and
Issue BIOC (Read, k, q).

k−1をkにする。 Let k-1 be k.

kが1より小さいか、否かを調べる。Yesの場合に
はを行い、Noの場合にはを行う。
Check if k is less than 1. If yes, perform, and if no, perform.

BIOC(Read,k,p)および2BSS(p,q,sp,c)を発行す
る。
BIOC (Read, k, p) and 2BSS (p, q, sp, c) are issued.

cが0か、否かを調べる。Yesの場合にはを行
い、Noの場合にはを行う。
Check whether c is 0 or not. If yes, perform, and if no, perform.

BIOC(Write M+1,p),BIOC(Write,M+2,q)、BIO
C(Write,k,p),BIOC(Write,k+1,q)を発行する。
尚、前記2命令は、データ保全性確保のためのデータの
コピーである。
BIOC (Write M + 1, p), BIOC (Write, M + 2, q), BIO
Issues C (Write, k, p) and BIOC (Write, k + 1, q).
The two instructions are data copies for ensuring data integrity.

スパン長が0か、否かを調べる。Yesの場合はを
行い、Noの場合はを行う。
Check whether the span length is 0 or not. If Yes, perform. If No, perform.

第pバッファの内容を第xバッファに移し、第qバ
ッファの内容を第qバッファに移し、第xバッファの内
容を第qバッファに移す。次にを行う。
The contents of the p-th buffer are transferred to the x-th buffer, the contents of the q-th buffer are transferred to the q-th buffer, and the contents of the x-th buffer are transferred to the q-th buffer. Then do the following:

第8図はスパン・ソートの状態遷移の例を示すものであ
る。なお、本発明によるソートをスパン・ソートとい
う。この例は、ブロック数が6の場合である。ステッ
プないしステップは第1フェーズである。ないし
ステップによって、第1ブロックないし第6ブロックが
それぞれ内部ソートされる。ステップにおいては、第
1、第2ブロックがスパン・スライドされ、第1ブロッ
クから第2ブロックまでがソートされた状態とされる。
ステップでは第2、第3ブロックがスパン・スライド
される。ステップの処理でスパンが存続した場合に
は、ステップで第1、第2ブロックのスパン・スライ
ドを行う。ステップが終了すると、第1ブロックから
第3ブロックまでがソートされた状態となる。同様な処
理がこの後も繰返される。
FIG. 8 shows an example of transition of span sort. The sort according to the present invention is called span sort. In this example, the number of blocks is 6. The steps or steps are the first phase. The first block to the sixth block are internally sorted by the steps to. In the step, the first and second blocks are span-slide and the first block to the second block are sorted.
In the step, the second and third blocks are span slid. If the span continues to exist in the processing of the step, the span sliding of the first and second blocks is performed in the step. When the steps are completed, the first block to the third block are sorted. Similar processing is repeated after this.

〔発明の効果〕〔The invention's effect〕

以上の説明から明らかなように、本発明によれば、 (イ) 同一のデータセット内で処理できるので、他の
ファイルを必要としないこと、 (ロ) 必要とするメモリ領域が少なくて済むこと、 (ハ) 線形ソートであるので、ファイルの管理が容易
なこと、 (ニ) 略ぼソート済みのデータセットのソートに効果
が大きいこと、 (ホ) 実行環境が対象データセットのみに限定できる
ので、ハードフェア化が容易なこと 等の顕著な効果を奏することが出来る。
As is apparent from the above description, according to the present invention, (a) the processing can be performed in the same data set, so that another file is not required, and (b) the required memory area is small. , (C) Since it is a linear sort, it is easy to manage files, (D) It is very effective in sorting a roughly sorted data set, and (E) Because the execution environment can be limited to the target data set, In addition, it is possible to achieve remarkable effects such as easy hard fairing.

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

第1図はブロックB1からブロックBMまでをソートするた
めの基本的な手順を説明する図、第2図はソートされた
状態にあるブロックBi-1ソートされた状態にあるブロッ
クBiをマージした後の状態を説明する図、第3図はスパ
ン・スライドを説明するための図、第4図は本発明の1
実施例のブロック図、第5図は実施例におけるソート処
理の第1フェーズの概要を示す図、第6図は実施例にお
けるソート処理の第2フェーズの概要を示す図、第7図
はスパン・ソート・スーパバイザの動作ロジックを示す
図、第8図はスパン・ソートの状態遷移例である。 1……ソート処理装置、2……外部記憶ユニット、3…
…スパン・ソート・スーパバイザ、4……2ブロック・
スパン・スライダ、5……ブロック内部ソータ、6……
ブロック入出力コントローラ、7……レコード比較器、
8−1ないし8−3……ブロック・バッファ、BP……バ
ッファ・プール。
FIG. 1 is a diagram for explaining the basic procedure for sorting blocks B 1 to B M , and FIG. 2 is a block Bi in a sorted state -1 A block Bi in a sorted state is merged. FIG. 3 is a diagram for explaining the state after the step, FIG. 3 is a diagram for explaining the span slide, and FIG.
FIG. 5 is a block diagram of an embodiment, FIG. 5 is a diagram showing an outline of a first phase of sort processing in the embodiment, FIG. 6 is a diagram showing an outline of a second phase of sort processing in the embodiment, and FIG. FIG. 8 is a diagram showing the operation logic of the sort supervisor, and FIG. 8 is a state transition example of span sort. 1 ... Sort processing device, 2 ... External storage unit, 3 ...
… Span sort supervisor, 4 …… 2 blocks ・
Span slider, 5 ... Block internal sorter, 6 ...
Block input / output controller, 7 ... Record comparator,
8-1 to 8-3 ... Block buffer, BP ... Buffer pool.

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】それぞれがN個のレコードを持つ第1ブロ
ック,第2ブロック,…,第nブロックより構成された
ソート済みブロック列に,N個のレコードを持つソート済
みの第n+1ブロックを追加し、第1ブロックから第n
+1ブロックまでをソートするソート処理方法であっ
て、 第nブロックを第1バッファに格納し、第n+1ブ
ロックを第2バッファに格納し、 第1バッファの内容と第2バッファの内容をマージ
し、マージ結果をソート・ルールにしたがって第1バッ
ファおよび第2バッファに格納し、 マージ後の第1バッファに格納されているレコード
列において、マージ前の第1バッファに格納されていた
レコード列の先頭レコードより前方に位置するレコード
列が存在するか否かを調べ、 存在しない場合には、ソートを終了し、 存在する場合には、第1バッファの内容を第2バッ
ファに移動し、ソート済みブロック列における1つ前の
ブロックを第1バッファに格納し、再びの処理を行う ことを特徴とするソート処理方法。
1. A sorted (n + 1) th block having N records is added to a sorted block sequence composed of a first block, a second block, ..., An nth block each having N records. From the 1st block to the nth
A sorting method for sorting up to +1 blocks, wherein the nth block is stored in a first buffer, the n + 1th block is stored in a second buffer, and the contents of the first buffer and the contents of the second buffer are merged. The merged result is stored in the first buffer and the second buffer according to the sort rule, and the first record of the record string stored in the first buffer before the merge in the record string stored in the first buffer after the merge It checks whether or not there is a record string located further ahead, and if it does not exist, sort is terminated, and if it exists, the contents of the first buffer are moved to the second buffer, and the sorted block string The method of sorting is characterized in that the block immediately before in 1 is stored in the first buffer and the processing is performed again.
【請求項2】それぞれがN個のレコードよりなるM個の
ブロックを持つデータセットを格納する外部記憶ユニッ
トと、 バッファ・リードの指令を受取ったとき上記外部記憶ユ
ニットから指定されたブロックを読出して指定されたバ
ッファに格納すると共にライトの指令を受取ったとき指
定されたバッファのデータを指定された外部記憶ユニッ
トのブロックに書込むブロック入出力コントローラと、 内部ソート指令を受取ったとき指定されたバッファの内
容を内部ソートする内部ソータと、 マージを行うと共にスパン長を求めることを支持するス
パン・スライダ指令を受取ったとき指定された第pバッ
ファおよび第qバッファに格納されているソート済デー
タをスパン長に基づいてマージする処理、マージ前とマ
ージ後におけるデータの移動の有無を出力する処理、マ
ージ処理の結果得られるレコード列における,マージ前
の第pバッファに格納されていたレコード列の先頭レコ
ードより前方に位置するレコード列の長さを示すスパン
長を出力する処理を行う2ブロック・スパン・スライダ
と、 制御手段と を具備し、 上記制御手段は、上記データセットの全ブロックのそれ
ぞれを内部ソートする処理を行った後、 ブロック番号iを初期値に設定し、 i+1をiに設定し、 ブロック番号iがMより大であるか否かを調べ、No
の場合には次にの処理に移行し、Yesの場合は終了と
し、 スパン長をNに、ブロック番号iをkに設定すると
共に、第kブロックのデータを第qバッファに格納すべ
きことを上記ブロック入出力コントローラに指令し、 k−1をkに設定し、 kが1より小さいか否かを調べ、Yesの場合には
の処理に戻り、Noの場合には次のの処理を行い、 第kブロックのデータを第pバッファに読込むべき
ことを上記ブロック入出力コントローラに指令すると共
に、第pバッファおよび第qバッファの内容をマージす
べきこと、マージ処理の結果得られるレコード列におけ
るスパンの長さをスパン長格納域にセットすべきこと、
並びにマージ前とマージ後でデータの移動があったか否
かを示す移動有無情報を出力すべきことを上記2ブロッ
ク・スパン・スライダに指令し、 移動有無情報が移動なしを示しているか否かを調
べ、移動なしの場合にはの処理に移行し、移動ありの
場合にはの処理に移行し、 第pバッファのデータを第kブロックに書込むべき
こと及び第qバッファのデータを第k+1ブロックに書
込むべきことを上記ブロック入出力コントローラに指令
し、 スパン長が零であるか否かを調べ、Yesの場合には
の処理に移行し、Noの場合にはの処理に移行し、 第pバッファと第qバッファのデータを交換した
後、上記の処理を行うよう構成されている ことを特徴とするソート処理装置。
2. An external storage unit for storing a data set having M blocks each consisting of N records, and reading a specified block from the external storage unit when a buffer read command is received. A block I / O controller that stores data in the specified buffer and writes the data in the specified buffer to the specified block in the external storage unit when a write command is received, and the buffer specified when the internal sort command is received Of the sorted data stored in the p-th buffer and the q-th buffer specified when the span sorter command is received, which supports merging and determining the span length. Merge based on length, move data before and after merge Processing for outputting the presence / absence, processing for outputting the span length indicating the length of the record string located ahead of the first record of the record string stored in the p-th buffer before the merge in the record string obtained as a result of the merge process And a control means, which performs internal sorting of all blocks of the data set, and then sets a block number i to an initial value, Set i + 1 to i, check whether block number i is greater than M, and
In the case of, the process proceeds to the next process, and in the case of Yes, the process is terminated, and the span length is set to N, the block number i is set to k, and the data of the kth block should be stored in the qth buffer. Instruct the above block input / output controller to set k-1 to k, check whether k is less than 1, return to the process in the case of Yes, and execute the next process in the case of No. , Instructing the block input / output controller to read the data of the k-th block into the p-th buffer, and merging the contents of the p-th buffer and the q-th buffer, in the record string obtained as a result of the merging process. The length of the span should be set in the span length storage area,
In addition, the 2 block span slider is instructed to output the movement presence / absence information indicating whether or not the data has been moved before and after the merge, and it is checked whether or not the movement presence / absence information indicates no movement. , If there is no movement, the process shifts to, if there is a shift, shifts to the process, the data in the pth buffer should be written in the kth block, and the data in the qth buffer should be written in the k + 1th block. Instruct the above block I / O controller to write, check whether the span length is zero, move to the process of if it is Yes, move to the process of if it is No, p-th A sort processing apparatus configured to perform the above processing after exchanging data in a buffer and a qth buffer.
JP17008282A 1982-09-29 1982-09-29 Sorting method and apparatus Expired - Lifetime JPH06103459B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP17008282A JPH06103459B2 (en) 1982-09-29 1982-09-29 Sorting method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP17008282A JPH06103459B2 (en) 1982-09-29 1982-09-29 Sorting method and apparatus

Publications (2)

Publication Number Publication Date
JPS5960539A JPS5960539A (en) 1984-04-06
JPH06103459B2 true JPH06103459B2 (en) 1994-12-14

Family

ID=15898303

Family Applications (1)

Application Number Title Priority Date Filing Date
JP17008282A Expired - Lifetime JPH06103459B2 (en) 1982-09-29 1982-09-29 Sorting method and apparatus

Country Status (1)

Country Link
JP (1) JPH06103459B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6139141A (en) * 1984-07-30 1986-02-25 Noboru Denki Seisakusho:Kk Control system for ram

Also Published As

Publication number Publication date
JPS5960539A (en) 1984-04-06

Similar Documents

Publication Publication Date Title
US4210961A (en) Sorting system
CA2172075A1 (en) Computer method and apparatus for asynchronous ordered operations
JPH0689218A (en) Backup system for multiplex writing volume
JPH06103459B2 (en) Sorting method and apparatus
JP2923952B2 (en) Merge processing method
JPH0581337A (en) Data processor
TWI396975B (en) Adaptable buffer device and method thereof
JPS63196959A (en) Saving and restoring system for file
JPH0581342A (en) Data processor
JP3293544B2 (en) Sorting method using auxiliary storage
JPH01226050A (en) Data sharing control system for different operating systems
CN117251426A (en) Data management device and method based on memory chained descriptive file system
JP3518420B2 (en) Sorting method and apparatus using disk cache
JPH0580977A (en) Data processor
JPH0145648B2 (en)
JP3328849B2 (en) Data writing processor
JPH07101382B2 (en) Margin processing device
JP2895892B2 (en) Data processing device
JPH04353944A (en) Record additional system for index order formation file
JPH0291725A (en) Merging processing system
JPH0310341A (en) Disk space compaction system
JPS634475A (en) File management system for stand alone type work system
JPH02257284A (en) Data processor
JPH07141112A (en) External memory control unit
JPS6190235A (en) High speed classification method for small system