JPH03216729A - Elctronic computer - Google Patents
Elctronic computerInfo
- Publication number
- JPH03216729A JPH03216729A JP1210690A JP1210690A JPH03216729A JP H03216729 A JPH03216729 A JP H03216729A JP 1210690 A JP1210690 A JP 1210690A JP 1210690 A JP1210690 A JP 1210690A JP H03216729 A JPH03216729 A JP H03216729A
- Authority
- JP
- Japan
- Prior art keywords
- key
- data
- sorting
- record
- keys
- 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
Links
- 238000013500 data storage Methods 0.000 claims abstract description 5
- 238000000034 method Methods 0.000 claims description 11
- 230000001174 ascending effect Effects 0.000 description 11
- 238000010586 diagram Methods 0.000 description 4
- 238000007726 management method Methods 0.000 description 2
- 238000007796 conventional method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012804 iterative process Methods 0.000 description 1
Landscapes
- Input From Keyboards Or The Like (AREA)
Abstract
Description
【発明の詳細な説明】
〔産業上の利用分野〕
本発明は、電子計算機において、データの効率的なソー
トを行なうためのソート条件(以降、キーと呼ぶ)の構
造に関する。DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to the structure of sort conditions (hereinafter referred to as keys) for efficiently sorting data in an electronic computer.
[従来の技術]
第6図は、従来のソート方法を示すフローチャートであ
る。まず最初に、データ入力装置からデータを入力する
61。入力されたデータを固定長または可変長の1レコ
ード毎に分割するβ2。最も優先順位の高いキー情報を
キー作成のためのキー情報とする63。そのキー情報に
基づいて、全てのデータレコードに対してキーを作成す
る64。[Prior Art] FIG. 6 is a flowchart showing a conventional sorting method. First, data is input 61 from a data input device. β2 divides the input data into fixed or variable length records. The key information with the highest priority is set as the key information for key creation 63. A key is created 64 for all data records based on the key information.
昇順ソート、降順ソートの2種類のソート処理を用意し
、昇順または降順の指定により実行するソート処理を選
択し、ソートを行う65。ソート終了後、次に優先順位
の高いキーを、キー作成のためのキー情報とする66。Two types of sort processing, ascending order sorting and descending order sorting, are prepared, and the sorting processing to be executed is selected by specifying ascending order or descending order, and the sorting is performed 65. After sorting is completed, the key with the next highest priority is set as key information for key creation 66.
そして、そのキー情報に基づいて、再び、キーを作成し
、これまでのソートによって順番.が確定していない部
分のデータレコードのソートを行う。また、ソニトされ
た結果、キーが全く同一であった場合に、同一なデータ
レコードはデータ入力順に並べたいという要求があった
場合、ソートした結果を元の順番も含めて見直すか、ソ
ートの時に、キーの値が同じであった場合には順番が入
れ替わらないようにする。Then, based on that key information, keys are created again, and the order is sorted according to the previous sorting. Sorts the data records for which the data has not yet been determined. Also, if the keys are exactly the same as a result of sorting, and there is a request to arrange the same data records in the order of data input, either review the sorted results including the original order, or , the order will not be swapped if the key values are the same.
指定されたキー情報すべてが参照されるか、データが完
全にソートされるまでキーの作成とソートを繰り返し、
終了した時点で、ソートした結果を出力装置へ出力する
67。Repeat creating and sorting keys until all of the specified key information is referenced or the data is completely sorted.
Upon completion, the sorted results are output to the output device 67.
[発明が解決しようとする課題コ
しかし、前記の従来技術では、複数個のキー情報が指定
されていれば、キー情報のそれぞれに対して、その都度
キー作成とソートを行うため、キー情報の指定が多けれ
ば多いほど、キー作成とソートのための繰り返し処理が
多くなってしまう。[Problems to be Solved by the Invention] However, in the above-mentioned prior art, if multiple pieces of key information are specified, keys are created and sorted for each piece of key information. The more specifications there are, the more iterative processes will be required for key creation and sorting.
さらに、2番目以降のキーでソートを行う場合、それ以
前のキー情報によるソートで順番が確定したデータに関
しては、ソートを行う必要がない。Furthermore, when sorting is performed using the second or subsequent keys, there is no need to perform sorting on data whose order has been determined by sorting using previous key information.
そのため、確定されていないデータかどうかの区別を行
うために、データレコードそれぞれにフラグを設ける、
または、確定していないデータ範囲を記憶する等の、な
んらかの処理を行わなければならない。また、データレ
コードのキー情報に対応するキーをキー情報の数だけ最
初に作成しておく方法の場合、最も優先順位の高いキー
情報によるキーで比較し、大小関係が決まれば昇順降順
の指定に従ってソートする。比較したキーが同じであれ
ば、次に優先順位の高いキーを取り出して、昇順または
降順に分けてソートする。このようにして、キーが同じ
であった場合は、順次、次の優先順位のキーを比較対象
として比較していく。しかし、この方法では、キー毎に
異なるソート方向を指定されていた場合には、次のキー
の比較に移る度に、ソート方向の判定をし、ソート処理
を選択しなければならない。このような点から、従来の
方法でソートを行う場合、キー情報の数とそのキ一部分
に位置するデータの性質によっては、繰り返し処理が非
常に多くなり、処理時間が長くなると同時に、ソートが
終了していない範囲を特定しておかなければならない、
といった煩雑な処理が必要になるという問題があった。Therefore, in order to distinguish whether the data is unconfirmed or not, a flag is set for each data record.
Alternatively, some processing must be performed, such as storing an undefined data range. In addition, if you first create keys corresponding to the key information of a data record as many keys as the number of key information, compare the keys based on the key information with the highest priority, and once the size relationship is determined, follow the specified ascending or descending order. Sort. If the compared keys are the same, the key with the next highest priority is extracted and sorted in ascending or descending order. In this way, if the keys are the same, the keys with the next priority are compared in sequence. However, with this method, if a different sorting direction is specified for each key, the sorting direction must be determined and the sorting process must be selected each time the next key is compared. From this point of view, when sorting using the conventional method, depending on the number of key information and the nature of the data located in that key part, there is a large number of repeated processes, which increases the processing time and at the same time the sorting is completed. It is necessary to identify the areas where
There is a problem in that such complicated processing is required.
また、複数のキーが指定されていた場合、キー毎にソー
ト方向の判定と、ソート処理の選択を行わなければなら
ず、非効率的であるという欠点があった。このような問
題に鑑み、高速かつ効率的なソートを実現するための手
段を提供することを目的とする。Furthermore, when a plurality of keys are specified, it is necessary to determine the sorting direction and select the sorting process for each key, which is inefficient. In view of these problems, it is an object of the present invention to provide a means for realizing high-speed and efficient sorting.
[課題を解決するための手段コ
本発明は、データ入力装置と、データ出力装置と、入力
データを1レコード毎に分割する手段と、データ記憶装
置と、ソートのためのキーをデータから作成する手順と
、入力された前記データの順番を特定する手段と、同一
のデータレコードに対するキーを1′)のキーレコード
としてまとめる手段と、ソートのために作成された前記
キーの記憶装置と、前記キーに基づいてソートを行う手
段とを備えたことを特徴とする。[Means for Solving the Problems] The present invention includes a data input device, a data output device, means for dividing input data into records, a data storage device, and a method for creating keys for sorting from data. a procedure, a means for specifying the order of the input data, a means for grouping keys for the same data record as a key record of 1'), a storage device for the keys created for sorting, and a storage device for the keys created for sorting; and means for sorting based on.
[作用コ
本発明においては、複数個のキーが指定された場合、1
つのデータレコードに対して、指定された複数個のキー
情報全てに対応するキーを最初に作成し、それらのキー
を図3のように1つのキーレコードにまとめる.さらに
、各キー毎にそのソート方向を考慮して昇順用にキーを
作成した後、降順が指定されているキーについては、大
小関係を逆にするために、そのキーの全てのビットを反
転させた値をキーレコードに登録する。データレコード
と、複数のキーからなるキーレコードを1対1に対応さ
せることによって、キーレコード全体を比較することに
より、複数のキーでの比較を繰り返し行ったものと同じ
結果が得られるようになる。また、指定されたソートの
ためのキーが全く同じデータレコードが存在した場合に
、キーが同一のデータを元のデータ順番で並べることが
必要な場合がある。この場合、優先順位の最も低いキー
として、元のデータレコードの順番をキーレコード内に
設定する。この方法により、キー作成とソートを繰り返
し行うことなくソートをすることができ、処理時間を減
らすことができ、さらに、繰り返しによる煩雑さをなく
すことができる。また、ソート実行時、比較するキー全
てを1つのキーレコードとしてまとめてしまうことによ
り、ソートのためのキーがデータエリア内に散在せず、
一カ所で管理できるという利点がある。[Operation] In the present invention, when multiple keys are specified, 1
For one data record, first create keys that correspond to all of the specified multiple key information, and then combine those keys into one key record as shown in Figure 3. Furthermore, after creating a key for ascending order by considering the sorting direction for each key, for keys that are specified for descending order, all bits of that key are reversed to reverse the magnitude relationship. Register the value in the key record. By creating a one-to-one correspondence between a data record and a key record consisting of multiple keys, comparing the entire key record allows you to obtain the same result as repeatedly comparing multiple keys. . Furthermore, if there are data records with exactly the same specified sorting key, it may be necessary to arrange the data with the same keys in the original data order. In this case, the order of the original data record is set in the key record as the key with the lowest priority. With this method, it is possible to perform sorting without repeating key creation and sorting, reduce processing time, and eliminate the complexity caused by repetition. Also, when performing sorting, all the keys to be compared are grouped together as one key record, so the keys for sorting are not scattered in the data area.
It has the advantage of being able to be managed in one place.
[実施例]
以下に、本発明の実施例を図面に基づいて説明する.
(実施例1)
第1図は本発明のブロック図であり、データ記憶装置1
3と、ソートのために作成されたキーの記憶装置14と
、データを入力する装置11と、ソートされたデータを
出力する装置12から構成され、さらに、入力されたデ
ータ全体から1つ1つのデータレコードへ分割する手段
15と、データからキーを作成する手段16と、複数個
のキーをまとめて1つのキーレコードを作成する手段1
7と、データの入力された順番を特定する手段18と、
ソートを実行する手段19を備えている。[Examples] Examples of the present invention will be described below based on the drawings. (Embodiment 1) FIG. 1 is a block diagram of the present invention, in which a data storage device 1
3, a storage device 14 for keys created for sorting, a device 11 for inputting data, and a device 12 for outputting sorted data. A means 15 for dividing into data records, a means 16 for creating a key from data, and a means 1 for creating one key record by combining a plurality of keys.
7, and means 18 for specifying the input order of data;
Means 19 for performing sorting are provided.
第5図は、本発明のフローチャートである。2種類のキ
ー情報が指定されたものとじ、優先順位の高い方からキ
ー情報1、キー情報2とする。また、データは、ある一
定の長さで区切られる固定長のレコードの集まりとする
。最初に、入力装置からデータを読み込む51。続いて
、固定長のデータの集まりなので、一定の長さ毎にデー
タを分け、データレコードに分割する52。データレコ
ードへの分割が終了した後、それぞれのデータレコード
に対してキーレコードを作成する53。データレコード
とキーレコードの関係は第2図のようになる.管理情報
は必要に応じて使用し、また、なくても構わない。まず
、優先順位の高いキー情報1に基づいてデータからキー
に変換してキー1を得、キー1をキーレコードエリアに
登録する.この時、昇順か降順かを判断し、昇順ソート
が指定されていれば、そのまま登録する.降順ソートの
場合は、キーが大きい値のデータを前に、小さい値のデ
ータを後に並べる必要があるので、キーの値を全て大小
、逆にする必要がある。そのため、全ビットを反転させ
ることによって大小を反転させ、昇順ソートと同じ手順
で比較処理し、降順にソートされるようにする。続いて
、キー情報2に基づいてデータからキー2を作成する。FIG. 5 is a flow chart of the present invention. Assuming that two types of key information are specified, the one with the highest priority is designated as key information 1 and key information 2. Furthermore, the data is a collection of fixed-length records separated by a certain length. First, data is read 51 from the input device. Next, since the data is a collection of fixed length data, the data is divided into data records of a certain length 52. After the division into data records is completed, a key record is created 53 for each data record. The relationship between data records and key records is shown in Figure 2. Management information can be used as needed, or can be omitted. First, data is converted into a key based on key information 1, which has a high priority, to obtain key 1, and key 1 is registered in the key record area. At this time, it is determined whether the order is ascending or descending, and if ascending sort is specified, it is registered as is. In the case of descending sorting, it is necessary to arrange data with large values in the front and data with small values in the rear, so it is necessary to reverse the magnitude of all key values. Therefore, by inverting all bits, the magnitude is inverted, comparison processing is performed in the same procedure as ascending order sorting, and sorting is performed in descending order. Next, a key 2 is created from data based on the key information 2.
キー2についてもキー1と同様に昇順、降順のための処
理を行う。得られたキー2をキーレコード内のキー1の
後ろに続けて設定する。キーレコードは、図3のように
なり、キーl、キー2をまとめた形で1つのキーレコー
ドとする。全てのデータレコードに対して、図3のよう
なキーレコードを作成し、データレコードとキーレコー
ドを1対1に対応させる。キーレコードをすべて作成し
終わったところで、このキーレコードを比較して昇順に
ソートする54.ソートの方法はクィックソート、バブ
ルソート等どの様なソート方法を用いてもよい。For key 2, processing for ascending and descending order is performed in the same way as for key 1. The obtained key 2 is set consecutively after key 1 in the key record. The key record is as shown in FIG. 3, and key 1 and key 2 are combined into one key record. A key record as shown in FIG. 3 is created for every data record, and data records and key records are made to correspond one-to-one. Once all key records have been created, compare the key records and sort them in ascending order54. Any sorting method may be used, such as quick sort or bubble sort.
キーレコードがソートできれば、キーレコードとデータ
レコードは1対1に対応するので、データレコードのソ
ートも完了したことになる。最後に、データレコードを
ソートされた順番で出力装置へ出力すれば終了である5
5。If the key records can be sorted, the key records and data records have a one-to-one correspondence, so sorting of the data records has also been completed. Finally, output the data records to the output device in the sorted order and you are done.5
5.
(実施例2)
キー情報が3種類指定されたものとし、優先順位の高い
順にキー情報l、キー情報2、キー情報3とし、キー情
報1は昇順、2、3は降順が指定されたものとする。さ
らに、キーが全く同じであった場合には、入力された順
番が先のデータレコードが前になるようにソートを行う
。データは、ある区切り記号で区切られる可変長のデー
タレコードの集まりとする。まず、入力装置からソート
するデータを読み込み、区切り記号によって7’ −タ
をデータレコードに分割する。その後、それぞれのデー
タレコードに対応するキーレコードを作成する.キー情
報1、キー情報2、キー情報3に従って得られたキーを
それぞれ、キー1、キー2、キー3とする。キー情報2
、3が降順であるので、キー2、3の値の大小関係が逆
になるようにキー2、3の値を、全ビットを反転する。(Example 2) Three types of key information are specified, and key information 1, key information 2, and key information 3 are specified in descending order of priority, and key information 1 is specified in ascending order, and keys 2 and 3 are specified in descending order. shall be. Further, if the keys are exactly the same, the data records are sorted so that the data record inputted first comes first. The data is a collection of variable length data records separated by a certain delimiter. First, the data to be sorted is read from the input device, and the 7'-data is divided into data records using delimiters. Then, create a key record corresponding to each data record. Let keys obtained according to key information 1, key information 2, and key information 3 be key 1, key 2, and key 3, respectively. Key information 2
, 3 are in descending order, all bits of the values of keys 2 and 3 are inverted so that the magnitude relationship between the values of keys 2 and 3 is reversed.
得られたキーを、優先順位の高いキーから順番に並べて
キーレコードを作成する。ここで、入力データ内でのデ
ータレコードの位置または順番を示すデータを、優先順
位の最も低いキーとして、キー3に続けてキーレコード
に登録し、第4図のようなキーレコードを作成する。こ
の時に登録する値は、順番が前方にあるデータレコード
の方が、後に入力されたデータレコードよりも小さい値
になるようなデータであれば、どのような値でも構わな
い。このようにして、各データレコードに対応するキー
レコードをすべて作成した後で、キーレコードを比較す
ることによってデータレコード間の大小関係を決め、ソ
ートを行う。ソート終了後、結果を出力装置へ出力する
。A key record is created by arranging the obtained keys in order of priority. Here, data indicating the position or order of data records within the input data is registered in the key record following key 3 as the key with the lowest priority to create a key record as shown in FIG. The value to be registered at this time may be any value as long as the data record located earlier in the order has a smaller value than the data record input later. After all key records corresponding to each data record are created in this way, the size relationship between the data records is determined by comparing the key records, and sorting is performed. After sorting is complete, output the results to the output device.
キーレコードには、データ長等の管理情報を含んでいて
も良い。ただし、ソート実行時の比較キーには含まない
ようにする。また、キーレコード1つ1つは、可変長で
も固定長でもよいが、複数のキーが指定されている場合
には、キーレコード内で、それぞれのキー情報に対応す
るキーの長さがわかるようにする。また、複数のキー情
報が指定された場合、それぞれのキー情報が、元のデー
タのどの位置のキーとして指定されていても構わない。The key record may include management information such as data length. However, it should not be included in the comparison key when performing sorting. Also, each key record may be of variable length or fixed length, but if multiple keys are specified, the length of the key corresponding to each key information can be found in the key record. Make it. Further, when a plurality of pieces of key information are specified, it does not matter where each piece of key information is specified as a key in the original data.
また、キー位置が元のデータ上で重なっていても構わな
い。Further, the key positions may overlap on the original data.
[発明の効果]
以上、説明した本発明によれば、複数のキー情報に基づ
いてソートする場合も、キー情報の数の分だけキーを作
成してソートを行うことを繰り返す必要がなくなり、処
理時間の効率化を図ることができる。さらに、1回目の
ソートの後、順番が確定していない部分だけを抜き出し
て2回目以降のソートを行うという煩雑さをなくすこと
ができるという効果がある。また、データが入力された
順番もキーの一部として扱う。このように、ソートする
ときに比較するデータは、全てキーの一部にしてしまう
ことにより、データを内部に散在させることなく一カ所
で管理でき、データ構造がわかりやすくなるという効果
がある。[Effects of the Invention] According to the present invention described above, even when sorting is performed based on a plurality of pieces of key information, it is no longer necessary to repeatedly create keys for each number of key information and perform sorting, and the processing is simplified. It is possible to improve time efficiency. Furthermore, after the first sorting, it is possible to eliminate the complication of extracting only the portions whose order has not been determined and performing the second and subsequent sorting. The order in which data is input is also treated as part of the key. In this way, by making all the data to be compared when sorting part of the key, the data can be managed in one place without being scattered internally, and the data structure becomes easier to understand.
第1図は、本発明の電子計算機の構成を示すためのブロ
ック図である.第2図は、データレコードとキーレコー
ドの関係を示す図である。第3図、第4図は、キーレコ
ードの構造を示す図である。
第5図は、本発明の一実施例を示すフローチャートであ
る。第6図は、従来のソートを行う手段を示すフローチ
ャートである。
l1 ・・・・・・ データ入力装置
1 2
1 3
1 4
1 5
データ出力装置
データ記憶装置
キー記憶装置
入力データをレコードに
分割する手段
キー作成手段
キーレコード作成手段
データ順番特定手段
ソート手段
以上FIG. 1 is a block diagram showing the configuration of an electronic computer according to the present invention. FIG. 2 is a diagram showing the relationship between data records and key records. FIGS. 3 and 4 are diagrams showing the structure of a key record. FIG. 5 is a flowchart showing one embodiment of the present invention. FIG. 6 is a flowchart showing conventional sorting means. l1 ...... Data input device 1 2 1 3 1 4 1 5 Data output device Data storage device Key storage device Means for dividing input data into records Key creation means Key record creation means Data order specifying means Sorting means and above
Claims (1)
レコード毎に分割する手段と、データ記憶装置と、ソー
トのためのソート条件をデータから作成する手順と、入
力された前記データの順番を特定する手段と、同一のデ
ータレコードに対するソート条件を1つのソート条件レ
コードとしてまとめる手段と、ソートのために作成され
た前記ソート条件の記憶装置と、前記ソート条件に基づ
いてソートを行なう手段とを備えたことを特徴とする電
子計算機。Data input device, data output device, input data 1
means for dividing each record, a data storage device, a procedure for creating sort conditions for sorting from data, a means for specifying the order of the input data, and a means for dividing sort conditions for the same data record into one 1. An electronic computer comprising: means for organizing a sort condition record; a storage device for the sort conditions created for sorting; and means for sorting based on the sort conditions.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1210690A JPH03216729A (en) | 1990-01-22 | 1990-01-22 | Elctronic computer |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1210690A JPH03216729A (en) | 1990-01-22 | 1990-01-22 | Elctronic computer |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH03216729A true JPH03216729A (en) | 1991-09-24 |
Family
ID=11796317
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP1210690A Pending JPH03216729A (en) | 1990-01-22 | 1990-01-22 | Elctronic computer |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH03216729A (en) |
-
1990
- 1990-01-22 JP JP1210690A patent/JPH03216729A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10733508B2 (en) | Methods and systems for data analysis in a state machine | |
| US6678687B2 (en) | Method for creating an index and method for searching an index | |
| US4959785A (en) | Character processing system with spelling check function that utilizes condensed word storage and indexed retrieval | |
| KR100467638B1 (en) | Method for fast searching and analyzing inter-relations between patents from a patent database | |
| JP2003044267A (en) | Data sort method, data sort device, and data sort program | |
| Thorup | Faster deterministic sorting and priority queues in linear space | |
| JP2888188B2 (en) | Information retrieval device | |
| US20070239663A1 (en) | Parallel processing of count distinct values | |
| JPH03216729A (en) | Elctronic computer | |
| JPS59121436A (en) | Sorting method of data group | |
| WO2009147794A1 (en) | Finite automaton generating system | |
| JPH07191827A (en) | Method and apparatus for stable sorting or merging of sequential list by means of space adaptive system | |
| JPH0782429B2 (en) | How to merge multiple files | |
| JP3061486B2 (en) | Data sort processing system | |
| JPH0452967A (en) | And operation processing system for set file | |
| JPS6227836A (en) | Storing system for document data | |
| JP2926803B2 (en) | Sorting method | |
| JPH0518148B2 (en) | ||
| JPS6266326A (en) | Array processing system for japanese data | |
| EP4500355A1 (en) | Methods and systems for performing a vectorized delete in a distributed database system | |
| JPS63149728A (en) | Index forming device | |
| JPH03259329A (en) | Key relative address classifying system for bulk data | |
| CN120429426A (en) | Method, device, medium, and terminal for generating domain knowledge response results | |
| JPH0240772A (en) | Index generating system | |
| JPH06195414A (en) | Logical design supporting system |