JPH048815B2 - - Google Patents

Info

Publication number
JPH048815B2
JPH048815B2 JP27277384A JP27277384A JPH048815B2 JP H048815 B2 JPH048815 B2 JP H048815B2 JP 27277384 A JP27277384 A JP 27277384A JP 27277384 A JP27277384 A JP 27277384A JP H048815 B2 JPH048815 B2 JP H048815B2
Authority
JP
Japan
Prior art keywords
record
register
buffer
data
records
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
JP27277384A
Other languages
Japanese (ja)
Other versions
JPS61151737A (en
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 filed Critical
Priority to JP27277384A priority Critical patent/JPS61151737A/en
Publication of JPS61151737A publication Critical patent/JPS61151737A/en
Publication of JPH048815B2 publication Critical patent/JPH048815B2/ja
Granted legal-status Critical Current

Links

Description

【発明の詳細な説明】 〔発明の技術分野〕 この発明は、2ウエイ・マージソート方式を適
用するソート処理装置に好適するソート・セルに
関する。
DETAILED DESCRIPTION OF THE INVENTION [Technical Field of the Invention] The present invention relates to a sort cell suitable for a sort processing device that applies a two-way merge sort method.

〔発明の技術的背景〕[Technical background of the invention]

関係データベースなどのデータベース処理にお
ける主たる処理の1つにソート処理がある。この
ソート処理は、特定のフアイル中の複数のレコー
ドの並びを、レコード中の特定フイールドの値に
従つて所定の順序に並び替えることである。上記
したソート処理は、汎用電子計算機でも実行可能
である。しかし、汎用電子計算機が取扱うデータ
構造と、データベース処理で扱われるデータ構造
とが本質的に異なるため、データベースを構成す
る大量データについて汎用電子計算機を用いて上
記したソート処理を実行しようとすると、膨大な
処理時間を要する。そこで従来より、この種のソ
ート処理を効率よく専用に実行するソート処理装
置が提唱されている。
One of the main processes in database processing such as a relational database is sorting processing. This sorting process involves rearranging a plurality of records in a specific file into a predetermined order according to the value of a specific field in the records. The above sorting process can also be executed by a general-purpose computer. However, since the data structure handled by a general-purpose computer and the data structure handled by database processing are essentially different, if you try to perform the above sorting process on a large amount of data that makes up a database using a general-purpose computer, the amount of data will be enormous. It takes a lot of processing time. Therefore, sorting processing apparatuses have been proposed that efficiently and exclusively perform this type of sorting processing.

この種の専用ソート処理装置の1つに、例え
ば、田中、「データベース処理や文書処理を高速
化するサーチ/ソート・ハードウエアの動向」、
「日経エレクトロニクス」、1983年8月1日号、
pp141−178、に示される(特にpp164−165)の
ようなマージソート方式のソート処理装置が知ら
れている。このソート処理装置は、一般に多段に
縦続接続された複数のソート・セルからなる、n
段目のソート・セルには、2n-1個のレコードを格
納する1対のバツフアが設けられている。n段目
のソート・セルは、前段のソート・セルまででソ
ートされている2n-1個のレコードを2組入力し、
2n個のレコードをソートし、次段に出力する機能
を有している。
One example of this type of dedicated sort processing device is Tanaka, "Trends in search/sort hardware to speed up database processing and document processing,"
"Nikkei Electronics", August 1, 1983 issue,
Merge sort type sorting processing devices such as those shown in pp. 141-178 (particularly pp. 164-165) are known. This sort processing device generally consists of a plurality of sort cells connected in cascade in multiple stages, n
The sort cell in the row is provided with a pair of buffers that store 2 n-1 records. For the n-th sort cell, input two sets of 2 n-1 records that have been sorted up to the previous sort cell, and
2 It has the function of sorting n records and outputting them to the next stage.

〔背景技術の問題点〕[Problems with background technology]

しかし、上記したソート処理装置では、その主
構成要素であるソート・セルについて、ソート処
理の高速化のための具体的構成は示されていなか
つた。
However, in the above-mentioned sorting processing device, no specific configuration for speeding up the sorting processing has been disclosed for the sorting cell, which is the main component thereof.

〔発明の目的〕[Purpose of the invention]

この発明は上記事情に鑑みてなされたものでそ
の目的は、2ウエイ・マージソート方式によるソ
ート処理が高速で行なえるソート・セルを提供す
ることにある。
The present invention has been made in view of the above circumstances, and its object is to provide a sort cell that can perform sorting processing using a two-way merge sort method at high speed.

〔発明の概要〕[Summary of the invention]

この発明では上記した目的を達成するために、
第1の順序列を格納する2n-1個のレコード分の容
量の第1バツフアと、第2の順序列を格納する
2n-1個のレコード分の容量の第2バツフアとが設
けられている。上記第1、第2バツフアに対する
アドレスは、第1、第2アドレスポインタにより
指定される。第1、第2アドレスポインタの内容
は、1レコードの処理開始時に第1、第2バツク
アツプレジスタに保存される。また、この発明で
は、第1バツフアに格納される第1の順序列の総
レコード数を示す情報を保持する第1総レコード
数レジスタと、第2バツフアに格納される第2の
順序列の総レコード数を示す情報を保持する第2
総レコード数レジスタと、第1バツフアから外部
に出力されるレコード数をカウントする第1レコ
ード数カウンタと、上記第2バツフアから外部に
出力されるレコード数をカウントする第2レコー
ド数カウンタと、上記レコードのレコード長を示
す情報を保持するレコード長レジスタと、上記レ
コード内の比較対象となるキーフイールドを指定
する情報を保持するキーフイールドレジスタとが
設けられる。
In order to achieve the above-mentioned purpose, this invention
Stores the first buffer with a capacity of 2 n-1 records, which stores the first sequence, and stores the second sequence.
A second buffer with a capacity for 2 n-1 records is provided. Addresses for the first and second buffers are specified by first and second address pointers. The contents of the first and second address pointers are saved in the first and second backup registers at the start of processing one record. Further, in the present invention, a first total record number register that holds information indicating the total number of records of the first sequence stored in the first buffer and a total number of records of the second sequence stored in the second buffer are provided. A second one that holds information indicating the number of records.
a total record number register, a first record number counter that counts the number of records output from the first buffer to the outside, a second record number counter that counts the number of records output from the second buffer to the outside; A record length register that holds information indicating the record length of a record, and a key field register that holds information that specifies a key field to be compared within the record are provided.

上記第1、第2バツフアからのデータ読出し
は、読出し手段によつて行なわれる。この読出し
手段は、第1、第2アドレスポインタに従つて第
1、第2の順序列を所定バイト単位で読出し、第
1、第2アドレスポインタを進める。また、この
発明では、第1、第2バツフアからの読出しデー
タがキーフイールドレジスタで示されるキーフイ
ールド内のデータであるか否かを検出するキーフ
イールド検出回路と、第1、第2バツフアからの
読出しデータがレコード長レジスタで示されるレ
コード長のレコードの最終データであるか否かを
検出するレコードエンド検出回路と、第1、第2
バツフアからの読出しデータを比較する比較器
と、選択手段とが設けられる。この選択手段は、
比較器の比較結果、キーフイールド検出回路の検
出結果、レコードエンド検出回路の検出結果、お
よび設定されたソート条件に応じ、第1または第
2バツフアからの読出しデータのいずれか一方を
選択出力する。レコードエンド検出回路によつて
レコードエンドが検出された場合、第1または第
2アドレスポインタには、第1または第2バツフ
アレジスタの内容が選択手段の選択結果に応じて
ロードされ、出力が許可されなかつた方のレコー
ドの先頭アドレスが示されるようになつている。
Data reading from the first and second buffers is performed by a reading means. The reading means reads out the first and second sequential sequences in predetermined byte units according to the first and second address pointers, and advances the first and second address pointers. Further, in the present invention, a key field detection circuit that detects whether or not read data from the first and second buffers is data in the key field indicated by the key field register, and a record end detection circuit for detecting whether the read data is the final data of a record having a record length indicated by the record length register;
A comparator for comparing data read from the buffer and selection means are provided. This selection method is
Depending on the comparison result of the comparator, the detection result of the key field detection circuit, the detection result of the record end detection circuit, and the set sorting condition, either one of the read data from the first or second buffer is selectively output. When a record end is detected by the record end detection circuit, the contents of the first or second buffer register are loaded into the first or second address pointer according to the selection result of the selection means, and output is permitted. The start address of the record that was not created is now shown.

更、この発明では、第1、第2順序列出力完了
検出回路が設けられる。第1、第2順序出力完了
検出回路は、第1、第2レコード数カウンタのカ
ウント結果に応じ、第1、第2順序列の出力完了
を検出する。第1または第2順序列出力完了検出
回路によつて、第1、または第2順序列の出力完
了が検出された場合、第2または第1バツフアに
残されている未出力データが吐出される。
Furthermore, in the present invention, first and second sequence output completion detection circuits are provided. The first and second sequential output completion detection circuits detect completion of output of the first and second sequential sequences according to the count results of the first and second record number counters. When the completion of output of the first or second sequence is detected by the first or second sequence output completion detection circuit, the unoutput data remaining in the second or first buffer is discharged. .

〔発明の実施例〕[Embodiments of the invention]

第1図はこの発明の一実施例に係るソート・セ
ル10−n(n=1,……m)の構成を示し、第
2図はソート・セル10−n(n=1)〜ソー
ト・セル10−n(n=m)が縦続接続されてな
るソート処理装置の構成を示す。第1図のソー
ト・セル10−nにおいて、11Uは前段より入
力される第1のソート対象レコードの列(第1の
順序列)を格納するU(Upper)バツフアレジス
タ(以下、UBと称する)、11Lは前段より入
力される第2のソート対象レコードの列(第2の
順序列)を格納するL(Lower)バツフアレジス
タ(以下、LBと称する)である。UB11U,
11Lは、2n-1個のレコード分の容量を有する。
12UはUB11Uに対するアドレスポインタと
してのU側レジスタカウンタ(以下、ADUレジ
スタと称する)、12LはLB11Lに対するアド
レスポインタとしてのL側レジスタカウンタ(以
下、ADLレジスタと称する)である。13Uは
ADUレジスタ2Uの内容を保持するU側バツク
アツプレジスタ(BUUレジスタ)、13Lは
ADLレジスタ12Lの内容を保持するL側バツ
クアツプレジスタ(BULレジスタ)である。1
4はUB11UおよびLB11Lに対するアドレ
ス信号線、15は同じくデータ入力線、16は
UB11UおよびLB11Lからのデータ出力線
である。
FIG. 1 shows the configuration of a sort cell 10-n (n=1, . . . m) according to an embodiment of the present invention, and FIG. The configuration of a sort processing device in which cells 10-n (n=m) are connected in cascade is shown. In the sorting cell 10-n in FIG. 1, 11U is a U (Upper) buffer register (hereinafter referred to as UB) that stores the column of records to be sorted (first sequence) input from the previous stage. ), 11L is an L (lower) buffer register (hereinafter referred to as LB) that stores a second sequence of records to be sorted (second sequence) input from the previous stage. UB11U,
11L has a capacity for 2 n-1 records.
12U is a U-side register counter (hereinafter referred to as ADU register) as an address pointer for UB11U, and 12L is an L-side register counter (hereinafter referred to as ADL register) as an address pointer for LB11L. 13U is
The U-side backup register (BUU register), 13L, holds the contents of ADU register 2U.
This is an L-side backup register (BUL register) that holds the contents of the ADL register 12L. 1
4 is an address signal line for UB11U and LB11L, 15 is also a data input line, and 16 is an address signal line for UB11U and LB11L.
This is a data output line from UB11U and LB11L.

17UはUB11Uからの読出しデータを保持
するU側データレジスタ(DUレジスタ)、17
LはLB11Lからの読出しデータを保持するL
側データレジスタ(DLレジスタ)である。18
はDUレジスタ17UおよびDLレジスタ17L
の各内容を比較する比較器(CMP)、19はDU
レジスタ17UまたはDLレジスタ17Lの内容
のいずれか一方を選択するマルチプレクサ
(MUX)、20はMUX19からの選択出力デー
タを次段に伝達するデータ出力線である。
17U is a U-side data register (DU register) that holds read data from UB11U, 17
L is L that holds read data from LB11L
This is the side data register (DL register). 18
are DU register 17U and DL register 17L
A comparator (CMP) that compares each content of , 19 is DU
A multiplexer (MUX) 20 that selects either the contents of the register 17U or the DL register 17L is a data output line that transmits selected output data from the MUX 19 to the next stage.

21はソート対象となるレコードのレコード長
RL(具体的には1レコードの構成バイト数)RL
を示すレコード長レジスタ(RLレジスタ)、22
はソート処理において比較対象となるキーフイー
ルドのキーフイールド長KL(単位はバイト)を示
すキーフイールド長レジスタ(KLレジスタ)で
ある。23はレコード長およびキーフイールド長
をカウントするカウンタ(RL/KLカウンタ)、
24はRLレジスタ21およびRL/KLカウンタ
23の各内容を比較する比較器(CMP)、25は
KLレジスタ22およびRL/KLカウンタ23の
各内容を比較する比較器(CMP)である。26
UはUB11Uに格納される第1のソート対象レ
コード列の総レコード数TRNを示すトータルレ
コード数レジスタ(TRNUレジスタ)、26Lは
LB11Lに格納される第2のソート対象レコー
ド列の総レコード数TRNを示すトータルレコー
ド数レジスタ(TRNLレジスタ)である。27
Uは上記第1のソート対象レコード列のレコード
数をカウントするU側レコード数カウンタ
(RNUカウンタ)、27Lは上記第2のソート対
象レコード列のレコード数をカウントするL側レ
コード数カウンタ(RNLカウンタ)である。2
8UはTRNUレジスタ26UおよびRNUカウン
タ27Uの各内容を比較する比較器(CMP)、2
8LはTRNLレジスタ26LおよびRNLカウン
タ27Lの各内容を比較する比較器(CMP)、2
9はソート・セル10−n全体を制御する制御部
である。
21 is the record length of the record to be sorted
RL (specifically the number of bytes that make up one record) RL
Record length register (RL register) indicating 22
is a key field length register (KL register) indicating the key field length KL (in bytes) of the key field to be compared in the sorting process. 23 is a counter (RL/KL counter) that counts the record length and key field length;
24 is a comparator (CMP) that compares the contents of the RL register 21 and the RL/KL counter 23; 25 is a comparator (CMP) that compares the contents of the RL register 21 and the RL/KL counter 23;
This is a comparator (CMP) that compares the contents of the KL register 22 and the RL/KL counter 23. 26
U is the total record number register (TRNU register) indicating the total number of records TRN of the first sort target record string stored in UB11U, and 26L is the total record number register (TRNU register).
This is a total record number register (TRNL register) that indicates the total number of records TRN of the second sort target record string stored in LB11L. 27
U is a U-side record number counter (RNU counter) that counts the number of records in the first sorting target record string, and 27L is an L-side record number counter (RNL counter) that counts the number of records in the second sorting target record string. ). 2
8U is a comparator (CMP) that compares the contents of the TRNU register 26U and the RNU counter 27U, 2
8L is a comparator (CMP) that compares the contents of the TRNL register 26L and the RNL counter 27L;
9 is a control unit that controls the entire sorting cell 10-n.

次に上記した構成の動作を説明する。ソート・
セル10−nでのソート処理に際し、UB11U
の0番地から始まる領域には、前段からの第1の
ソート対象レコード列がその順序を保つて例えば
1バイト単で格納される。また、LB11Lの0
番地から始まる領域には、前段からの第2のソー
ト対象レコード列がその順序を保つて1バイト単
位で格納される。第1のソート対象レコード列
は、前段のソート・セルまででソートされている
2n-1個のレコードA,C,E,……Xからなり、
第2のソート対象レコード列は、前段のソート・
セルまででソートされている2n-1個のレコード
B,D,F,……Yからなる。これら、レコード
A〜Yは、第3図のフオーマツトに示すように、
比較対象部であるキーフイールドと、比較非対象
部とからなる。この例において、キーフイールド
は、レコードの先頭に位置するように、予め移動
処理が施されているものとする(第3図参照)。
なお、レコードA〜Yのレコード長RLは等しい。
また、レコードA〜Yのキーフイールド長KLも
等しい。ここで、レコードAのキーフイールド
が、第4図aに示すように1バイトデータa,
b,c,……gからなり、レコードBのキーフイ
ールドが、第4図bに示すように1バイトデータ
a′,b′,c′,……g′からなるものとする。また、
レコードAの比較非対象部がA′、レコードBの
比較非対象部がB′であるものとする。
Next, the operation of the above configuration will be explained. sort·
When sorting in cell 10-n, UB11U
In the area starting from address 0, the first sort target record string from the previous stage is stored in, for example, 1 byte while maintaining its order. Also, 0 of LB11L
In the area starting from the address, the second sort target record string from the previous stage is stored in one byte unit while maintaining its order. The first sorted record column is sorted up to the previous sort cell.
2 Consists of n-1 records A, C, E, ...X,
The second sort target record column is
It consists of 2n -1 records B, D, F, ...Y sorted by cell. These records A to Y are, as shown in the format of Figure 3,
It consists of a key field, which is a comparison target part, and a non-comparison target part. In this example, it is assumed that the key field has been moved in advance so that it is positioned at the beginning of the record (see FIG. 3).
Note that the record lengths RL of records A to Y are equal.
Furthermore, the key field lengths KL of records A to Y are also equal. Here, the key field of record A is 1-byte data a, as shown in Figure 4a.
b, c, ...g, and the key field of record B is 1-byte data as shown in Figure 4b.
It is assumed that it consists of a′, b′, c′, ...g′. Also,
Assume that the non-comparison part of record A is A', and the non-comparison part of record B is B'.

さて、ソート処理開始時においては、ADUレ
ジスタ12U、ADLレジスタ12L、RL/KL
カウンタ23、RNUカウンタ27U、および
RNLカウンタ27Lには、“0”がロードされて
いる。また、RLレジスタ21にはソート対象レ
コードのレコード長RLを示す情報が、KLレジス
タ22には同じくキーフイールド長KLを示す情
報がそれぞれ格納されている。更に、TRNUレ
ジスタ26UおよびTRNLレジスタ26Lには、
ソート対象レコード列の総レコード数TRNを示
す情報がロードされている。
Now, when starting the sorting process, ADU register 12U, ADL register 12L, RL/KL
Counter 23, RNU counter 27U, and
“0” is loaded into the RNL counter 27L. Further, the RL register 21 stores information indicating the record length RL of the record to be sorted, and the KL register 22 stores information indicating the key field length KL. Furthermore, the TRNU register 26U and TRNL register 26L have
Information indicating the total number of records TRN of the record column to be sorted is loaded.

しかして、UB11UおよびLB11L内の1
レコードに対するソート処理が開始されると、そ
の開始タイミングでADUレジスタ12Uの内容
(この例では“0”)がBUUレジスタ13Uに保
存され、ADLレジスタ12Lの内容(この例で
は“0”)がBULレジスタ13Lに保存される。
この状態で、まずADUレジスタ12Uの内容が
UB11Uに対するアドレスを指定するように、
制御部29により制御される。これにより、UB
11UからレコードA(内のキーフイールド)の
先頭データaが読出される。このデータaはデー
タ出力線16を介してDUレジスタ17Uに導か
れ、同レジスタ17Uに保持される。このとき、
ADUレジスタ12Uの内容は+1され、次に読
出すべきデータ(この例ではb)の格納アドレス
を示す。次に、ADLレジスタ12Lの内容がLB
11Lに対するアドレスを指定するように、制御
部29により制御される。これにより、LB11
LからレコードB(内のキーフイールド)の先頭
データa′が読出される。このデータa′はデータ出
力線16を介してDLレジスタ17Lに導かれ、
同レジスタ17Lに保持される。このとき、
ADLレジスタ12Lの内容は+1され、次に読
出すべきデータ(この例ではb′)の格納アドレス
を示す。
Therefore, 1 in UB11U and LB11L
When sorting processing for records starts, at the start timing, the contents of the ADU register 12U (“0” in this example) are saved in the BUU register 13U, and the contents of the ADL register 12L (“0” in this example) are saved in the BUL register. Saved in register 13L.
In this state, first the contents of ADU register 12U are
To specify the address for UB11U,
It is controlled by the control section 29. This allows UB
Starting data a of record A (key field therein) is read from 11U. This data a is led to the DU register 17U via the data output line 16 and held in the same register 17U. At this time,
The contents of the ADU register 12U are incremented by 1, indicating the storage address of the data to be read next (b in this example). Next, the contents of ADL register 12L are LB
It is controlled by the control unit 29 to specify the address for 11L. As a result, LB11
Starting data a' of record B (the key field therein) is read from L. This data a' is led to the DL register 17L via the data output line 16,
It is held in the same register 17L. At this time,
The contents of the ADL register 12L are incremented by 1, indicating the storage address of the data to be read next (b' in this example).

DUレジスタ17UおよびDLレジスタ17L
の保持内容(この例では、a,a′)は、CMP1
8に導かれる。CMP18はa,a′を比較する。
CMP18の比較結果は制御部29に導かれる。
このとき、RL/KLカウンタ23は+1される。
制御部29には、CMP24,25,28U,2
8Lの比較結果も導かれる。
DU register 17U and DL register 17L
The retained contents (a, a′ in this example) are CMP1
Guided by 8. CMP18 compares a and a'.
The comparison result of the CMP 18 is led to the control section 29.
At this time, the RL/KL counter 23 is incremented by one.
The control unit 29 includes CMPs 24, 25, 28U, 2
Comparison results for 8L are also derived.

制御部29は、予め設定されているソート条
件、およびCMP18,24,25の比較結果に
応じ、DUレジスタ17UおよびDLレジスタ1
7Lに内容に対する出力制御を行なう。今、UB
11Uからの読出しデータをU,LB11Lから
の読出しデータをLとすると、制御部29は、
CMP18の比較結果がU>LまたはU<Lの場
合は、その時点でU側レコード(UB11U内の
1レコード)とL側レコード(LB11L内の1
レコード)との指定キーフイールド間での比較結
果を確定する。即ち、制御部29は、U>Lまた
はU<Lの場合、そのときのCMP18の比較結
果を、指定キーフイールドの比較結果として採用
する。この場合、制御部29は、上記比較確定結
果およびソート条件に従つて、MUX19を制御
する。例えばソート条件として昇順ソートが指定
されている場合に、U>Lが確定すれば、制御部
29は、該当レコードの最終データまで、U側デ
ータ即ちDLレジスタ17Lの内容が出力される
ようにMUX19を制御する。これに対し、U=
Lの場合には、比較結果を確定することはできな
い。この場合、その時点のU側データまたはL側
データのいずれを出力しても同じ結果となるが、
この例ではU側データ即ちDUレジスタ17Uの
内容が選択されるように、MUX19が制御され
る。但し、RL/KLカウンタ23の内容がKLレ
ジスタ22に一致したことがCMP25によつて
検出された場合、即ちキーフイールドの最終デー
タの比較であることが検出された場合には、制御
部29はU=Lを確定する。この場合、制御部2
9は、該当レコードの最終データまで、U側レコ
ードが選択されるようにMUX19を制御する。
一旦、比較結果が確定すると、以後の比較処理は
不要となる。したがつて、ソート処理の高速化が
可能となる。
The control unit 29 controls the DU register 17U and the DL register 1 according to preset sorting conditions and the comparison results of the CMPs 18, 24, and 25.
7L performs output control for the contents. Now, U.B.
Assuming that the read data from LB11U is U and the read data from LB11L is L, the control unit 29
If the comparison result of CMP18 is U>L or U<L, at that point the U side record (1 record in UB11U) and the L side record (1 record in LB11L)
record) and the specified key field. That is, in the case of U>L or U<L, the control unit 29 adopts the comparison result of the CMP 18 at that time as the comparison result of the designated key field. In this case, the control unit 29 controls the MUX 19 according to the above-described comparison result and sorting conditions. For example, when ascending order sorting is specified as a sorting condition, if U>L is established, the control unit 29 controls the MUX 19 so that the U side data, that is, the contents of the DL register 17L, is output up to the final data of the corresponding record. control. On the other hand, U=
In the case of L, the comparison result cannot be determined. In this case, the same result will be obtained regardless of whether the U-side data or L-side data at that time is output.
In this example, the MUX 19 is controlled so that the U-side data, ie, the contents of the DU register 17U, is selected. However, when the CMP 25 detects that the contents of the RL/KL counter 23 match the KL register 22, that is, when it is detected that the final data of the key fields are compared, the control unit 29 Confirm U=L. In this case, the control unit 2
9 controls the MUX 19 so that U-side records are selected up to the final data of the corresponding record.
Once the comparison result is determined, subsequent comparison processing is unnecessary. Therefore, it is possible to speed up the sorting process.

上記した論理によれば、例えばa=a′であれ
ば、ソート条件に無関係にaが選択される。ま
た、a>a′であれば、昇順ソートのときには
a′が、降順ソートのときにはaが選択される。a
<a′の場合には、上記したa>a′の場合の逆にな
る。
According to the above logic, if a=a', for example, a is selected regardless of the sorting conditions. Also, if a>a′, when sorting in ascending order,
When a' is sorted in descending order, a is selected. a
In the case of <a', the situation is the opposite of the above-mentioned case of a>a'.

aとa′の比較処理が終了すると、a,a′の場合
と同様にして、次のbとb′の比較処理、cとc′の
比較処理……が順に行なわれ、対応するデータが
選択出力される。但し、a>a′またはa<a′であ
れば、その時点でキーフイールドの比較が確定す
るので、以降の出力データは、U側またはL側の
いずれか一方に固定される。
When the comparison process of a and a' is completed, the next comparison process of b and b', the comparison process of c and c', etc. is performed in the same way as in the case of a and a', and the corresponding data is Selectively output. However, if a>a' or a<a', the key field comparison is determined at that point, and the subsequent output data is fixed to either the U side or the L side.

上記した動作が繰返され、やがてUB11Uか
らgが、LB11Lからg′が読出されたものとす
る。UB11UからのgはDUレジスタ17Uに、
LB11Lからのg′はDLレジスタ17Lに保持さ
れる。しかして、CMP18によりgとg′との比
較が行なわれる。このとき、RL/KLカウンタ2
3は+1され、その内容はKLレジスタ22の内
容に一致するようになる。この結果、CMP25
から一致検出信号が制御部29に出力される。制
御部29は、CMP25が一致を検出すると、即
ちキーフイールドが全て比較されると、それまで
のCMP18の比較結果が全てU=Lであつた場
合には、初めて比較確定を行ない、以後該当レコ
ードの最終データまで無条件でU側データを選択
せしめる。一方、すでに比較確定が行なわれてい
る場合には、その比較確定により決定されたU側
またはL側のデータが該当レコードの最終データ
まで選択される。
It is assumed that the above-described operation is repeated and eventually g is read from the UB 11U and g' is read from the LB 11L. g from UB11U goes to DU register 17U,
g' from LB11L is held in DL register 17L. The CMP 18 then compares g and g'. At this time, RL/KL counter 2
3 is incremented by 1, and its contents match the contents of the KL register 22. As a result, CMP25
A coincidence detection signal is outputted to the control section 29 from. When the CMP 25 detects a match, that is, when all the key fields are compared, and if all the comparison results of the CMP 18 up to that point are U=L, the control unit 29 confirms the comparison for the first time, and thereafter uses the corresponding record. U-side data is unconditionally selected up to the final data. On the other hand, if the comparison has already been confirmed, the data on the U side or the L side determined by the comparison is selected up to the final data of the corresponding record.

このようにして、レコードA(内の比較非対象
部A′)またはレコードB(内の比較非対象部B′)
の最終データ、例えばレコードAの最終データが
MUX19からデータ出力線20に選択出力され
たものとする。このとき、ADUレジスタ12U
は、次のレコードであるレコードCの先頭アドレ
スを示す。またRL/KLカウンタ23は、レコー
ド長RLを示す。このため、レコードAの最終デ
ータの出力時において、RL/KLカウンタ23の
内容とRLレジスタ21の内容を比較している
CMP24は、一致を検出し、一致検出信号を出
力する。
In this way, record A (non-comparison part A' within) or record B (non-comparison part B' within)
For example, the final data of record A is
It is assumed that the MUX 19 selectively outputs the data to the data output line 20. At this time, ADU register 12U
indicates the start address of record C, which is the next record. Further, the RL/KL counter 23 indicates the record length RL. Therefore, when outputting the final data of record A, the contents of the RL/KL counter 23 and the contents of the RL register 21 are compared.
The CMP 24 detects a match and outputs a match detection signal.

CMP24からの一致検出信号は制御部29に
導かれる。これにより、制御部29は1レコード
の出力終了を判断し、次のレコード処理のために
以下の処理を行なう。即ち、制御部29は、例え
ばこの例のようにレコードA(即ちU側レコード)
が選択出力された場合、BULレジスタ13Lに
保持されていたL側の現レコードのアドレス(こ
の例ではレコードBの先頭アドレス)をADLレ
ジスタ12Lにロードせしめる。次に、制御部2
9は、ADUレジスタ12Uの内容(この例では
U側の次のレコードであるレコードCの先頭アド
レス)をBUUレジスタ13Uに、ADLレジスタ
12Lの内容をBULレジスタ13Lに保存する。
なお、この例のようにU側レジスタが選択出力さ
れた場合には、ADLレジスタ12Lの内容を
BULレジスタ13Lに保存する処理が必ずしも
必要でない。また、制御部29は、RL/KLカウ
ンタ23に“0”をロードし(RL/KLカウンタ
23を“0”クリアし)、RNUカウンタ27Uの
内容を+1する。なお、L側レコードが選択出力
された場合には、今度はRNLカウンタ27Lの
内容が+1されることは言うまでもない。以上の
動作が終了すると、次のU側およびL側レコード
(この例ではレコードCとレコードB)について、
前記したレコードAとレコードBの場合と同様の
処理が行なわれる。
The coincidence detection signal from the CMP 24 is guided to the control section 29. Thereby, the control unit 29 determines that output of one record has ended, and performs the following processing for processing the next record. That is, the control unit 29 controls record A (i.e., U-side record), for example, as in this example.
is selected and output, the address of the current record on the L side held in the BUL register 13L (in this example, the start address of record B) is loaded into the ADL register 12L. Next, the control section 2
9 stores the contents of the ADU register 12U (in this example, the start address of record C, which is the next record on the U side) in the BUU register 13U, and the contents of the ADL register 12L in the BUL register 13L.
In addition, when the U side register is selectively output as in this example, the contents of ADL register 12L are
The process of saving in the BUL register 13L is not necessarily necessary. Further, the control unit 29 loads "0" into the RL/KL counter 23 (clears the RL/KL counter 23 to "0"), and increments the contents of the RNU counter 27U by 1. It goes without saying that when the L-side record is selected and output, the contents of the RNL counter 27L are incremented by 1. When the above operations are completed, for the next U-side and L-side records (record C and record B in this example),
The same processing as in the case of record A and record B described above is performed.

このようにして、UB11Uに格納された第1
のソート対象レコード列、またはLB11Lに格
納された第2のソート対象レコード列のいずれか
一方、例えば第1のソート対象レコード列が先に
選択出力されたものとする。このとき、RNUカ
ウンタ27Uは総レコード数TRNを示す。この
ため、RNUカウンタ27Uの内容とTRNUレジ
スタ26Uの内容とを比較しているCMP28U
は、第1のソート対象レコード列の最終レコード
Xの最終データの出力時において、一致を検出
し、一致検出信号を出力する。CMP28Uから
の一致検出信号は制御部29に導かれる。これに
より、制御部29は、UB11Uに格納された第
1のソート対象レコード列の出力終了を判断し、
LB11Lに残されている未出力データ(第2の
ソート対象レコード列の残りデータ)の吐出し制
御を行なう。この吐出しに際しては、BULレジ
スタ13Lに保持されていた現レコード(レコー
ドXとの比較処理において選択出力されなかつた
L側レコード)の先頭アドレスがADLレジスタ
12Lにロードされ、以後1バイト読出し出力毎
に、ADLレジスタ12Lの内容が+1される。
このようにしてレコードYの最終データが出力さ
れると、RNLカウンタ27Lの内容がTRNLレ
ジスタ26Lの内容に一致し、CMP28Lから
一致検出信号が出力される。これにより、制御部
29は第2のソート対象レコード列の残りデータ
(LB11Lに残されていた未出力データ)の出力
終了、即ちこの例では、第1および第2のソート
対象レコード列に対する全てのソート処理の終了
を判断し、ソート動作を停止する。
In this way, the first
It is assumed that one of the sort target record column or the second sort target record column stored in LB11L, for example, the first sort target record column, is selected and output first. At this time, the RNU counter 27U indicates the total number of records TRN. Therefore, the CMP 28U which is comparing the contents of the RNU counter 27U and the contents of the TRNU register 26U
detects a match and outputs a match detection signal when outputting the final data of the final record X of the first record string to be sorted. The coincidence detection signal from the CMP 28U is guided to the control section 29. As a result, the control unit 29 determines that the output of the first sort target record string stored in the UB 11U has ended;
Control is performed to eject unoutput data (remaining data of the second sort target record column) remaining in the LB11L. At this time, the start address of the current record held in the BUL register 13L (the L-side record that was not selected and output in the comparison process with record Then, the contents of the ADL register 12L are incremented by 1.
When the final data of record Y is output in this manner, the contents of the RNL counter 27L match the contents of the TRNL register 26L, and a coincidence detection signal is output from the CMP 28L. As a result, the control unit 29 finishes outputting the remaining data of the second sort target record string (unoutput data left in LB11L), that is, in this example, all the data for the first and second sort target record strings are output. Determine the end of the sorting process and stop the sorting operation.

なお、前記実施例では、比較対象部である指定
キーフイールドがレコードの先頭に移動されてい
るものとして説明したが、これに限るものではな
い。但し、指定キーフイールドがレコードの先頭
に位置していない場合には、レコード内における
キーフイールドの開始位置と終了位置を指定する
情報が必要となる。また、この場合、少なくとも
レコードの先頭データからキーフイールドの直前
データまではU側またはL側いずれのデータを選
択出力するか判定不可能となるため、これらU側
およびL側データを一時格納しておくバツフアが
必要となる。前記実施例は、キーフイールドの開
始位置がレコードの開始位置に一致する場合とい
える。
In the above embodiment, the specified key field, which is the comparison target section, is moved to the beginning of the record, but the present invention is not limited to this. However, if the specified key field is not located at the beginning of the record, information specifying the start and end positions of the key field within the record is required. In addition, in this case, it is impossible to determine whether to selectively output U-side or L-side data, at least from the first data of the record to the data immediately before the key field, so these U-side and L-side data are temporarily stored. A buffer is required. The above embodiment can be said to be a case where the start position of the key field matches the start position of the record.

〔発明の効果〕〔Effect of the invention〕

以上詳述したようにこの発明によれば、指定キ
ーフイールド間の比較が効率よく行なえ、しかも
少なくとも指定キーフイールドの最終データまで
には比較結果確定できるので、以後の比較処理が
不要となる。したがつて2ウエイ・マージソート
方式によるソート処理が高速で行なえる。
As described in detail above, according to the present invention, comparison between specified key fields can be performed efficiently, and the comparison result can be determined at least by the final data of the specified key field, so that subsequent comparison processing is not necessary. Therefore, sort processing using the two-way merge sort method can be performed at high speed.

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

第1図はこの発明の一実施例に係るソート・セ
ルのブロツク構成図、第2図は第1図のソート・
セルを適用してなるソート処理装置の全体構成
図、第3図はレコードのフオーマツトを示す図、
第4図はレコード内容の一例を示す図である。 11U……UB(Uバツフア)、11L……LB
(Lバツフア)、12U……ADUレジスタ、12
L……ADLレジスタ、13U……BUUレジス
タ、13L……BULレジスタ、18,24,2
5,28U,28L……CMP(比較器)、19…
…MUX(マルチプレクサ)、21……RLレジス
タ、22……KLレジスタ、23……RL/KLカ
ウンタ、26U……TRNUレジスタ、26L…
…TRNLレジスタ、27U……RNUカウンタ、
27L……RNLカウンタ。
FIG. 1 is a block diagram of a sort cell according to an embodiment of the present invention, and FIG. 2 is a block diagram of a sort cell according to an embodiment of the present invention.
An overall configuration diagram of a sort processing device using cells; FIG. 3 is a diagram showing the record format;
FIG. 4 is a diagram showing an example of record contents. 11U...UB (U Batsuhua), 11L...LB
(L buffer), 12U...ADU register, 12
L...ADL register, 13U...BUU register, 13L...BUL register, 18, 24, 2
5, 28U, 28L...CMP (comparator), 19...
...MUX (multiplexer), 21...RL register, 22...KL register, 23...RL/KL counter, 26U...TRNU register, 26L...
...TRNL register, 27U...RNU counter,
27L...RNL counter.

Claims (1)

【特許請求の範囲】[Claims] 1 順序列を構成する2n-1個のレコードを前段よ
り2組入力し、2nのレコードをソートして次段に
出力するソート・セルn(n=1,……m)をm
(mは1以上の整数)段縦続接続してなる2ウエ
イ・マージソート方式のソート処理装置におい
て、第1の順序列を格納する2n-1個のレコード分
の容量の第1バツフアと、第2の順序列を格納す
る2n-1個のレコード分の容量の第2バツフアと、
上記第1バツフアに対するアドレスを指定する第
1アドレスポインタと、上記第2バツフアに対す
るアドレスを指定する第2アドレスポインタと、
1レコードの処理開始時の上記第1アドレスポイ
ンタの内容を保存する第1バツクアツプレジスタ
と、1レコードの処理開始時の上記第2アドレス
ポインタの内容を保存する第2バツクアツプレジ
スタと、上記第1バツフアに格納される上記第1
の順序列の総レコード数を示す情報を保持する第
1総レコード数レジスタと、上記第2バツフアに
格納される上記第2の順序列の総レコード数を示
す情報を保持する第2総レコード数レジスタと、
上記第1バツフアから外部に出力されるレコード
数をカウントする第1レコード数カウンタと、上
記第2バツフアから外部に出力されるレコード数
をカウントする第2レコード数カウンタと、上記
レコードのレコード長を示す情報を保持するレコ
ード長レジスタと、上記レコード内の比較対象と
なるキーフイールドを指定する情報を保持するキ
ーフイールドレジスタと、上記第1、第2バツフ
アから上記第1、第2アドレスポインタに従つて
上記第1、第2の順序列を所定バイト単位で読出
し、上記第1、第2アドレスポインタを進める読
出し手段と、上記第1、第2バツフアからの読出
しデータが上記キーフイールドレジスタで示され
るキーフイールド内のデータであるか否かを検出
するキーフイールド検出回路と、上記第1、第2
バツフアからの読出しデータが上記レコード長レ
ジスタで示されるレコード長のレコードの最終デ
ータであるか否かを検出するレコードエンド検出
回路と、上記第1、第2バツフアからの読出しデ
ータを比較する比較器と、この比較器の比較結
果、上記キーフイールド検出回路の検出結果、上
記レコードエンド検出回路の検出結果、および設
定されたソート条件に応じ、上記第1または第2
バツフアからの読出しデータのいずれか一方を選
択出力する選択手段と、上記レコードエンド検出
回路によるレコードエンド検出時に、上記選択手
段の選択に応じて上記第1または第2アドレスポ
インタのいずれか一方に、上記第1または第2バ
ツクアツプレジスタの内容をロードする手段と、
上記レコードエンド検出回路によるレコードエン
ド検出時に、上記選択手段の選択に応じて上記第
1レコード数カウンタまたは上記第2レコード数
カウンタのいずれか一方を更新する手段と、上記
第1レコード数カウンタのカウント結果に応じ、
上記第1の順序列の外部出力完了を検出する第1
順序列出力完了検出回路と、上記第2レコード数
カウンタのカウント結果に応じ、上記第2の順序
列の外部出力完了を検出する第2順序列出力完了
検出回路と、上記第1または第2順序列出力完了
検出回路による出力完了検出結果に応じ、上記第
2はたは第1バツフアに残されている未出力デー
タを吐出す手段とを具備することを特徴とするソ
ート・セル。
1 Input two sets of 2n -1 records that form a sequence from the previous stage, and set a sort cell n (n=1,...m) to sort the 2n records and output them to the next stage.
(m is an integer greater than or equal to 1) In a two-way merge sort type sort processing device formed by cascading stages, a first buffer having a capacity of 2 n-1 records for storing a first sequence; a second buffer having a capacity of 2 n-1 records for storing a second sequence;
a first address pointer that specifies an address for the first buffer; a second address pointer that specifies an address for the second buffer;
a first backup register for storing the contents of the first address pointer at the start of processing of one record; a second backup register for storing the contents of the second address pointer at the start of processing for one record; The above first data stored in one buffer
a first total record number register that holds information indicating the total number of records of the ordered sequence; and a second total record number register that holds information indicating the total number of records of the second sequence stored in the second buffer. register and
A first record number counter that counts the number of records output from the first buffer to the outside, a second record number counter that counts the number of records output from the second buffer, and a record length of the record. a record length register that holds information that specifies a key field to be compared in the record, a key field register that holds information that specifies a key field to be compared in the record, and a record length register that holds information that specifies a key field to be compared in the record, and a read means for reading out the first and second sequences in predetermined byte units and advancing the first and second address pointers, and the read data from the first and second buffers being indicated by the key field register. a key field detection circuit that detects whether or not the data is in the key field;
a record end detection circuit that detects whether the data read from the buffer is the final data of a record with the record length indicated by the record length register; and a comparator that compares the data read from the first and second buffers. and the first or second one according to the comparison result of this comparator, the detection result of the key field detection circuit, the detection result of the record end detection circuit, and the set sorting condition.
a selection means for selectively outputting either one of the read data from the buffer; and when the record end detection circuit detects the end of the record, according to the selection of the selection means, one of the first or second address pointer; means for loading the contents of the first or second backup register;
means for updating either the first record number counter or the second record number counter according to the selection of the selection means when the record end detection circuit detects a record end; and a count of the first record number counter. Depending on the results,
A first device that detects the completion of external output of the first ordered sequence.
a sequence output completion detection circuit; a second sequence output completion detection circuit for detecting completion of external output of the second sequence according to the count result of the second record counter; A sort cell characterized by comprising means for discharging unoutput data remaining in the second or first buffer according to the output completion detection result by the column output completion detection circuit.
JP27277384A 1984-12-26 1984-12-26 Sort cell Granted JPS61151737A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP27277384A JPS61151737A (en) 1984-12-26 1984-12-26 Sort cell

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP27277384A JPS61151737A (en) 1984-12-26 1984-12-26 Sort cell

Publications (2)

Publication Number Publication Date
JPS61151737A JPS61151737A (en) 1986-07-10
JPH048815B2 true JPH048815B2 (en) 1992-02-18

Family

ID=17518539

Family Applications (1)

Application Number Title Priority Date Filing Date
JP27277384A Granted JPS61151737A (en) 1984-12-26 1984-12-26 Sort cell

Country Status (1)

Country Link
JP (1) JPS61151737A (en)

Also Published As

Publication number Publication date
JPS61151737A (en) 1986-07-10

Similar Documents

Publication Publication Date Title
US4053871A (en) Method and system for the iterative and simultaneous comparison of data with a group of reference data items
CA1069217A (en) Multistage sorter with concurrent access to interstage buffer memories
US5247665A (en) Data base processing apparatus using relational operation processing
US2735082A (en) Goldberg ett al
GB1563482A (en) Multipass sorter for arranging an input list into numerical order
US5115490A (en) Variable length data processing apparatus with delimiter location-based address table
JPS6142031A (en) Sorting processor
JPH048815B2 (en)
JP2880199B2 (en) Symbol string search method and search device
JPH0833812B2 (en) Sorting device
JPH01173230A (en) Merge processing system
JP2535655B2 (en) Dictionary search method
JPH07101382B2 (en) Margin processing device
JPS61278933A (en) Data sorting out system
JPH01201722A (en) Sort processor
JPS6266326A (en) Array processing system for japanese data
JPS61162898A (en) Associative memory
JPH0642248B2 (en) Information retrieval device
JPS6373422A (en) Information retrieving device
JPH01288920A (en) Data sorting device
JPH03290730A (en) System for sorting data classification
JPH05298070A (en) Sort processor
JPS6162134A (en) Sort preprocessor
JPH0312736A (en) Method and device for processing merge
JPH0774988B2 (en) Processing equipment

Legal Events

Date Code Title Description
EXPY Cancellation because of completion of term