JPH0689186A - Sort processing method - Google Patents

Sort processing method

Info

Publication number
JPH0689186A
JPH0689186A JP23914892A JP23914892A JPH0689186A JP H0689186 A JPH0689186 A JP H0689186A JP 23914892 A JP23914892 A JP 23914892A JP 23914892 A JP23914892 A JP 23914892A JP H0689186 A JPH0689186 A JP H0689186A
Authority
JP
Japan
Prior art keywords
sort
processing
record
routine
program
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.)
Granted
Application number
JP23914892A
Other languages
Japanese (ja)
Other versions
JP3305767B2 (en
Inventor
Wataru Takagi
渉 高木
Hiroyoshi Imaoka
弘良 今岡
Tatsunori Miyake
立記 三宅
Ryoichi Watanabe
良一 渡辺
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.)
Hitachi Software Engineering Co Ltd
Hitachi Ltd
Original Assignee
Hitachi Software Engineering Co Ltd
Hitachi 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 Hitachi Software Engineering Co Ltd, Hitachi Ltd filed Critical Hitachi Software Engineering Co Ltd
Priority to JP23914892A priority Critical patent/JP3305767B2/en
Publication of JPH0689186A publication Critical patent/JPH0689186A/en
Application granted granted Critical
Publication of JP3305767B2 publication Critical patent/JP3305767B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To shorten the processing time of the sort function in the programming language processing system. CONSTITUTION:A copmpiler 101 reads in a sort statement from a source program 100 and generates a comparison function 117 only for this sort statement in an object program 111. A sort processing part 124 of a sort routine 121 receives the address of the comparison function 117 when being called, and it is called (125) to realize the sort function. The time to the start of the actual sort processing is shortened by omission of sort key information analysis processing in the initial processing of the sort routine, and the processing speed is increased by omission of key information reference and analysis in the comparison processing of the sort processing, and the sort processing time is shortened as the whole.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、ユーザが指定した順序
関係の決定方法に従ってデータのソートを効率的に行な
うためのソート処理方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a sorting method for efficiently sorting data according to a method of determining an order relation designated by a user.

【0002】[0002]

【従来の技術】プログラミング言語が用意したソート機
能を使用する場合、ユーザはデータの順序関係をソート
キーやキーを揃える向き(昇順・降順の別)などでソー
スプログラム中に指定する。従来のコンパイラは、これ
を読んでソートキーの情報をパラメタとしてソートルー
チンを呼び出すオブジェクトを生成するように構成され
ていた。また、コンパイルしたオブジェクトプログラム
の実行時において、従来のソートルーチンは、オブジェ
クトプログラムよりパラメタとして渡されたキー情報を
解析し、ソート処理中に、内部に蓄えたソートキー情報
を参照しながらデータを比較することによってソートを
行なうように構成されていた。
2. Description of the Related Art When a sort function provided by a programming language is used, a user specifies the order relation of data in a source program by a sort key and a direction in which the keys are aligned (ascending order / descending order). A conventional compiler is configured to read this and generate an object that calls a sort routine by using the information of the sort key as a parameter. Further, when the compiled object program is executed, the conventional sort routine analyzes the key information passed as a parameter from the object program, and compares the data while referring to the sort key information stored inside during the sort process. It was configured to sort by.

【0003】公知文献に関して述べれば、「HITAC
プログラムプロダクト VOS3COBOL85 使用
の手引」(マニュアル番号 8090-3-855-30、(株)日立製
作所)の第197頁から第205頁によれば、COBOLコン
パイラはソースプログラムのSORT文から「拡張ソー
トマージXSORT」(ソートマージプログラム)に渡
すパラメタを生成する。このパラメタは、キーの位置、
長さ、データ形式、向きの4項目の組をキーの数だけ繰
り返したものである。
As for publicly known documents, "HITAC
According to pages 197 to 205 of "Program Product VOS3 COBOL85 User's Guide" (manual number 8090-3-855-30, Hitachi, Ltd.), the COBOL compiler uses the SORT statement of the source program as "extended sort merge XSORT.""(Sort merge program) to generate the parameters to be passed. This parameter is the key position,
A set of four items of length, data format, and orientation is repeated by the number of keys.

【0004】そして「プログラムプロダクト VOS3
拡張ソートマージ XSORT E2解説・文法書」(マ
ニュアル番号 6180-3-470、(株)日立製作所)の第7頁
に記述してあるように、「拡張ソートマージXSOR
T」は、それらパラメタ(文献中では「拡張ソートマー
ジ制御文」)を解析してからソート処理を実行する。
Then, "program product VOS3
As described on page 7 of "Extended Sort Merge XSORT E2 Explanation / Grammar Manual" (manual number 6180-3-470, Hitachi, Ltd.), "Extended Sort Merge XSOR"
"T" analyzes those parameters ("extended sort merge control statement" in the literature) and then executes sort processing.

【0005】[0005]

【発明が解決しようとする課題】ソースプログラム上の
ソートキー情報をパラメタにしてソートルーチンを実行
させる方式では、ソートルーチン側でソートキー情報パ
ラメタを解析しなければならず、また、ソート機能の実
行時に、キーを比較しようとするたびにキー情報を参照
しながら比較を行なわなければならず、これらのことが
ソート処理全体の時間を増加させる要因となっていた。
In the method of executing the sort routine by using the sort key information on the source program as a parameter, the sort key information parameter must be analyzed on the sort routine side, and when the sort function is executed, Each time a key is compared, the key information must be referenced to perform the comparison, which has been a factor in increasing the time of the entire sort process.

【0006】本発明の目的は、前記のような処理時間増
加要因を排除することによって、ソート処理全体の時間
を短縮できるソート処理方法を提供することにある。
An object of the present invention is to provide a sort processing method capable of shortening the time of the whole sort processing by eliminating the above factors for increasing the processing time.

【0007】より具体的にいえば、本発明の一つの目的
は、ソートルーチンにソートキー情報のパラメタを渡さ
ないようにして、ソートルーチンにおけるパラメタ解析
フェーズを不要とすることにより、実際のソート処理が
始まるまでの時間の短縮を図ることである。本発明のも
うひとつの目的は、ソートルーチンにおいて比較のたび
にキー情報を参照する必要をなくすことによって、デー
タ比較の処理速度を上げることである。
More specifically, one object of the present invention is to prevent the sort key information from being passed to the sort routine and to eliminate the parameter analysis phase in the sort routine, so that the actual sort processing can be performed. The goal is to reduce the time it takes to get started. Another object of the present invention is to speed up data comparison processing by eliminating the need to refer to key information in each sort routine during each comparison.

【0008】[0008]

【課題を解決するための手段】本発明は、ソースプログ
ラムのコンパイル時にコンパイラにおいて、プログラミ
ング言語固有の方法でソースプログラムに書かれたソー
ト順序の決定方法から、ソートに必要なデータ比較処理
ルーチンをオブジェクトプログラム中に生成し、オブジ
ェクトプログラムの実行時にソートプログラムにおい
て、オブジェクトプログラム中に生成されたデータ比較
処理ルーチンを使用してデータのソートを実行すること
を特徴としたものである。
According to the present invention, when a source program is compiled, a compiler compares a data comparison processing routine required for sorting from a sort order determination method written in the source program by a method specific to a programming language. It is characterized in that it is generated in a program, and when the object program is executed, a sort program is used to sort data by using a data comparison processing routine generated in the object program.

【0009】[0009]

【作用】ソートルーチンの初期処理でソートキー情報の
解析処理が不要になるため、この分だけ実際のソート処
理が始まるまでの時間が短くなる。またソートルーチン
のソート処理中の比較処理でキー情報を参照して解釈す
る処理が不要になるため、この分だけ処理速度が向上す
る。このような二つの時間の短縮の結果として、ソート
処理全体の時間短縮を達成できる。また、コンパイラに
最適化機能がある場合、ソート処理専用のデータ比較処
理ルーチンの最適化による高速化も期待できる。
Since the analysis processing of the sort key information is unnecessary in the initial processing of the sorting routine, the time until the actual sorting processing starts is shortened by this amount. Further, since the process of referring to and interpreting the key information in the comparison process during the sort process of the sort routine becomes unnecessary, the processing speed is improved accordingly. As a result of such two time reductions, it is possible to reduce the time of the entire sorting process. In addition, if the compiler has an optimization function, it can be expected to speed up by optimizing the data comparison processing routine dedicated to the sort processing.

【0010】[0010]

【実施例】以下、COBOL言語処理系での本発明の一
実施例について、図面を用いて説明する。なお、説明に
おいて、処理の流れ等を表現するためにJIS X0128
のPAD図を使用する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention in a COBOL language processing system will be described below with reference to the drawings. In the description, JIS X0128 is used to express the flow of processing.
The PAD diagram of is used.

【0011】図1は、本発明の一実施例におけるコンパ
イラ及びソートルーチンの構造、並びにコンパイルされ
たオブジェクトプログラムとソートルーチンとの呼び出
し関係を示している。1と2は計算機の中央処理装置
(CPU)と記憶装置である。ここでは、ソースプログ
ラム100、コンパイラ101、オブジェクトプログラ
ム111、ソートルーチン121はすべて記憶装置2上
にあるものとして示されている。また、図示されていな
いがソートすべきデータファイルと、ソート後のデータ
ファイルなども記憶装置2上にあるものとする。
FIG. 1 shows the structures of a compiler and a sorting routine according to an embodiment of the present invention, and a calling relationship between the compiled object program and the sorting routine. Reference numerals 1 and 2 are a central processing unit (CPU) and a storage device of the computer. Here, the source program 100, the compiler 101, the object program 111, and the sort routine 121 are all shown on the storage device 2. Further, although not shown, a data file to be sorted, a data file after sorting, and the like are also stored in the storage device 2.

【0012】コンパイラ101の全体的構成は従来と同
様であって、ソースプログラム100を解析して中間言
語表現のプログラムを生成するフロント部102と、そ
れを入力してオブジェクトプログラム111を生成する
バック部104とからなる。フロント部102はソート
文展開処理部103を含むが、これはソースプログラム
上のソート文を解析し、データ整列機能を実現する中間
言語を生成する部分である。
The overall structure of the compiler 101 is similar to the conventional one, and a front part 102 for analyzing the source program 100 to generate a program of an intermediate language expression, and a back part for inputting the front part 102 to generate an object program 111. And 104. The front section 102 includes a sort statement expansion processing section 103, which is a section that analyzes a sort statement on a source program and generates an intermediate language that realizes a data sorting function.

【0013】従来、このソート文展開処理部103で、
ソートキー情報を解析して、それを引数としてソートル
ーチンを呼び出す中間言語プログラムを生成していた。
しかし本発明によれば、このソート文展開部分103
は、ソートに必要なデータ比較を行う中間言語関数を生
成し、さらにオブジェクトプログラム実行時にソートル
ーチンを呼び出すときの引数を、その関数のアドレスと
するように機能が変更される。
Conventionally, in this sort statement expansion processing unit 103,
An intermediate language program that analyzes sort key information and calls a sort routine by using it as an argument is generated.
However, according to the present invention, this sort sentence expansion portion 103
Changes the function so that an intermediate language function that performs data comparison necessary for sorting is generated, and the argument when calling the sort routine when the object program is executed is the address of the function.

【0014】ソートルーチン121の全体的構成は従来
と同様であって、初期化処理部122、レコード受け取
り(データ入力)処理部123、ソート処理部124、
レコード引渡し(データ出力)処理部126、終了処理
部127のルーチン群からなる。しかし、本発明によれ
ば、初期化処理部122に従来含まれていたソートキー
情報パラメタ解釈処理は取り除かれる。また本発明によ
れば、ソート処理部124のデータ比較処理の内容は、
ソートキー情報を解釈しながら比較する従来の方式から
変更され、コンパイラ101が生成したデータ比較関数
に比較対象の2つのデータを渡し、その戻り値を判定す
る方式とされる。なお、レコード受け取り処理部12
3、レコード引渡処理部126及び終了処理部127は
従来と変わらない。
The overall structure of the sort routine 121 is the same as that of the conventional one and includes an initialization processing section 122, a record receiving (data input) processing section 123, a sorting processing section 124,
The routine includes a record passing (data output) processing unit 126 and an end processing unit 127. However, according to the present invention, the sort key information parameter interpretation processing conventionally included in the initialization processing unit 122 is eliminated. Further, according to the present invention, the contents of the data comparison process of the sort processing unit 124 are:
The method is different from the conventional method of comparing sort key information while interpreting it, and is a method of passing two pieces of data to be compared to a data comparison function generated by the compiler 101 and determining a return value thereof. The record receiving processing unit 12
3, the record delivery processing unit 126 and the end processing unit 127 are the same as the conventional ones.

【0015】111はコンパイラ101により出力され
たオブジェクトプログラムである。このオブジェクトプ
ログラム111において、112〜116がソースプロ
グラム100上のSORT文を展開した部分であり、ソ
ートルーチン121の対応する部分を呼び出す。117
は、コンパイラ101がSORT文から生成した比較関
数(ソートのためのデータ比較処理ルーチン)である。
Reference numeral 111 is an object program output by the compiler 101. In this object program 111, 112 to 116 are the expanded parts of the SORT statement on the source program 100, and call the corresponding parts of the sort routine 121. 117
Is a comparison function (data comparison processing routine for sorting) generated from the SORT statement by the compiler 101.

【0016】次に、オブジェクトプログラム111とソ
ートルーチン121との呼び出し関係について説明す
る。
Next, the call relationship between the object program 111 and the sort routine 121 will be described.

【0017】オブジェクトプログラム111の初期処理
呼び出し112では、ソートするデータのレコード長と
最大レコード件数を引数にして、ソートルーチン121
の初期処理部122を呼び出し、初期処理部122は必
要な作業領域を確保する。
In the initial process call 112 of the object program 111, the record length of the data to be sorted and the maximum number of records are used as arguments, and the sort routine 121
The initial processing unit 122 is called, and the initial processing unit 122 secures a necessary work area.

【0018】オブジェクトプログラム111のレコード
受け取り処理呼び出し113では、ソート(整列)作業
用のレコードにSORT文で指定された方法でソート対
象のデータを設定し、そのレコード領域のアドレスを引
数にしてレコード受け取り処理部123を呼び出す。レ
コード受け取り処理部123は、レコードを一つ受け取
って初期処理部122で確保した作業領域に格納する。
ソート対象のデータがなくなるまでこの呼び出しを繰り
返す。
In the record receiving processing call 113 of the object program 111, the sort target data is set in the record for sorting (sorting) by the method specified by the SORT statement, and the record area address is used as an argument to receive the record. The processing unit 123 is called. The record reception processing unit 123 receives one record and stores it in the work area secured by the initial processing unit 122.
Repeat this call until there are no more data to sort.

【0019】オブジェクトプログラム111のソート処
理呼び出し114では、ソート処理部124を呼び出
す。ソート処理部124では、レコード受け取り処理部
123で蓄えたレコードの中から比較すべき二つのレコ
ードをソートアルゴリズムに従って選択し、このレコー
ドのアドレスを引数にして比較関数117を呼び出す
(比較関数呼び出し125)。比較関数117では、S
ORT文のソートキー情報に従って二つのレコードを比
較し、レコードの順番を入れ替える必要があるかどうか
を判定して、必要があれば "入れ替える" を、なければ
"入れ替えない"を、リタン値として返す。ソート処理
部124は、制御が戻ると、リタン値が "入れ替える"
ならレコードの順番を入れ替え、そうでなければ入れ替
えない。このようにして、データを全てソートする。
The sort processing call 114 of the object program 111 calls the sort processing unit 124. The sort processing unit 124 selects two records to be compared from the records stored by the record reception processing unit 123 according to the sorting algorithm, and calls the comparison function 117 using the address of this record as an argument (comparison function call 125). . In the comparison function 117, S
The two records are compared according to the sort key information of the ORT statement, it is determined whether the order of the records needs to be changed, and if necessary, "Swap" is selected.
"Replace" is returned as the return value. When the control returns, the sort processing unit 124 "replaces" the return value.
Then swap the order of the records, otherwise don't. In this way, all the data are sorted.

【0020】オブジェクトプログラム111のレコード
引渡し処理呼び出し115では、受け取りになるソート
用のレコード領域のアドレスを引数にしてレコード引渡
し処理部126を繰返し呼び出し、ソートされた順番に
レコードを受け取ってSORT文に指定された方法で処
理する。レコード引渡し処理部126では、ソート済み
のデータを、呼ばれるたびに1レコードずつ引数のレコ
ード領域に格納する。終了処理呼び出し116では、終
了処理部127を呼び出す。終了処理部127では、ソ
ートルーチン121で使用した作業領域を解放する。
In the record delivery processing call 115 of the object program 111, the record delivery processing unit 126 is repeatedly called with the address of the record area for sorting to be received as an argument, and the records are received in the sorted order and specified in the SORT statement. Process as described. The record delivery processing unit 126 stores the sorted data in the record area of the argument one record each time it is called. In the end processing call 116, the end processing unit 127 is called. The end processing unit 127 releases the work area used in the sort routine 121.

【0021】次に、このようなプログラム実行時の呼び
出し関係を実現するために、コンパイラ101がSOR
T文を展開する処理を説明する。
Next, in order to realize such a calling relationship during program execution, the compiler 101 uses the SOR.
The process of expanding the T sentence will be described.

【0022】図2は、コンパイラ101のSORT文展
開処理部103の処理の流れを示すPAD図である。こ
の図の中で、「展開する」とは、中間言語表現の処理を
展開することを意味する。
FIG. 2 is a PAD diagram showing the flow of processing of the SORT sentence expansion processing unit 103 of the compiler 101. In this figure, "expanding" means expanding the processing of the intermediate language expression.

【0023】まずSORT文のソートキー情報から比較
関数117を展開し(ステップ201)、次にソートル
ーチンの初期処理呼び出し112を展開する(ステップ
202)。次に、ソートルーチンへデータを引き渡すた
めのレコード受取処理呼び出し113を展開する(ステ
ップ203)。次にソートルーチンのソート処理呼び出
し114を展開する(ステップ204)。次にソートル
ーチンから整列順にデータを受け取るためのレコード引
渡し処理呼び出し205を展開する(ステップ20
5)。最後にソートルーチンの終了処理の呼び出し11
6を展開する(ステップ206)。
First, the comparison function 117 is expanded from the sort key information of the SORT statement (step 201), and then the initial process call 112 of the sort routine is expanded (step 202). Next, the record receiving processing call 113 for passing data to the sort routine is expanded (step 203). Next, the sort process call 114 of the sort routine is expanded (step 204). Next, the record transfer processing call 205 for receiving data from the sort routine is expanded (step 20).
5). Finally, call the end processing of the sort routine 11
6 is expanded (step 206).

【0024】図3は、図2の比較関数展開処理ステップ
201を詳細に説明したPAD図である。図4は、図3
の処理で組み立てていく処理の部品をPAD図で表した
ものである。組み立てる比較関数の仕様は、レコード1
とレコード2を引数として受け取り、レコード1の方が
順序が前にあるとして入れ替える必要があると判定した
ら "入れ替える" を、そうでなければ "入れ替えない"
を、リタン値として返すというものである。ここではP
AD図の組み立て方で関数の生成方法を説明するが、実
際には組み立てられたPAD図に相当する中間言語表現
の処理を展開する。
FIG. 3 is a PAD diagram showing in detail the comparison function expansion processing step 201 of FIG. FIG. 4 shows FIG.
It is a PAD diagram showing the parts of the process to be assembled by the process of. The specification of the comparison function to be assembled is record 1
And record 2 as arguments, and if record 1 is in the previous order and it is determined that it needs to be swapped, then "swap", otherwise "do not swap"
Is returned as a Ritan value. Here P
Although a method of generating a function will be described by a method of assembling an AD diagram, the process of the intermediate language expression corresponding to the assembled PAD diagram is actually developed.

【0025】図4において、401は比較関数の入り口
部分で、レコード1とレコード2を受け取る。402は
比較関数の出口部分で、設定されたリタン値を呼び出し
元に返す。403〜406はn番目のソートキー(以
後、キーnと表す)に対する処理である。
In FIG. 4, reference numeral 401 denotes an entry portion of the comparison function, which receives record 1 and record 2. An exit portion 402 of the comparison function returns the set return value to the calling source. 403 to 406 are processes for the n-th sort key (hereinafter referred to as key n).

【0026】403と404は指定されたキーのうち最
後でないもの対する処理である。403はキーが昇順の
ときの処理で、レコード1のキーnがレコード2のキー
nより大きいときは "入れ替える" を、小さければ "入
れ替えない" をリタン値に設定する。どちらでもないと
きの処理は、他の処理部品をつなげられるように空けて
ある。404はキーが降順のときの処理で、判定条件が
403と逆になるが、どちらでもないときの処理は40
3と同様に空けてある。
Reference numerals 403 and 404 denote processes for the designated key which is not the last one. Reference numeral 403 denotes a process when the keys are in ascending order. When the key n of the record 1 is larger than the key n of the record 2, "replace" is set, and when it is smaller, "do not replace" is set as the return value. The processing when neither is done is open so that other processing components can be connected. 404 is a process when the keys are in descending order, and the determination condition is the opposite of 403, but the process when neither is 40
It is vacant as in 3.

【0027】405と406は最後に指定されたキーに
対する処理である。405はキーが昇順のときの処理
で、レコード1のキーnがレコード2のキーnより大き
いときは "入れ替える" を、そうでなければ、 "入れ替
えない" を、リタン値に設定する。406はキーが降順
のときの処理で、判定条件が403と逆になる。
Reference numerals 405 and 406 are processes for the last designated key. 405 is a process when the keys are in ascending order. When the key n of the record 1 is larger than the key n of the record 2, "replace" is set, and otherwise, "do not replace" is set as the return value. 406 is a process when the keys are in descending order, and the determination condition is the reverse of 403.

【0028】次に、図3に従って比較関数の展開方法を
説明する。まず、部分401を展開し関数の入り口を作
る(ステップ301)。そして、(SORT文に指定さ
れたキーの数 − 1)回だけ、変数nに回数を設定しな
がら次の処理行う(ステップ302)。
Next, a method of expanding the comparison function will be described with reference to FIG. First, the part 401 is expanded to create a function entrance (step 301). Then, the next process is performed while setting the number of times in the variable n only (the number of keys specified in the SORT sentence-1) times (step 302).

【0029】即ち、もしキーnが昇順指定のものなら
(ステップ303)、PAD図の最も右下に部分403
を接続し(ステップ304)、そうでなければPAD図
の最も右下に部分404を接続する(ステップ30
5)。もしキーが一つしか指定されなかった場合は、3
02〜305の処理は1回も行われない。
That is, if the key n has an ascending order designation (step 303), the portion 403 at the bottom right of the PAD diagram.
(Step 304), otherwise connect the portion 404 at the bottom right of the PAD diagram (step 30).
5). 3 if only one key is specified
The processing of 02 to 305 is not performed even once.

【0030】次に、変数nに、SORT文に指定された
キーの数を設定して(ステップ306)、もしキーn
(つまり最後のキー)が昇順指定のものならば(ステッ
プ307)、PAD図の最も右下に部分405を接続し
(ステップ308)、そうでなければPAD図の最も右
下に部分406を接続する(ステップ309)。そして
最後に、最も左下に部分402を展開して、この関数の
出口を作る(ステップ310)。
Next, the variable n is set to the number of keys specified in the SORT statement (step 306).
If the last key is the ascending order designation (step 307), the part 405 is connected to the lower rightmost part of the PAD diagram (step 308), and the part 406 is connected to the lowermost right part of the PAD diagram otherwise. (Step 309). And finally, the part 402 is expanded to the lower left and the exit of this function is made (step 310).

【0031】具体的な比較の演算方法は、データ属性
(文字、2進形式、ゾーン形式、パック形式など)によ
って異なるが、ソースプログラムの他の部分の比較演算
と同様に、コンパイラ101のバック部104で異なる
オブジェクトを生成することで解決する。このようにし
て、特定のSORT文に専用の比較関数117を生成す
る。
The specific comparison operation method differs depending on the data attribute (character, binary format, zone format, pack format, etc.), but like the comparison operation of other parts of the source program, the back part of the compiler 101 is used. This is solved by generating different objects in 104. In this way, the comparison function 117 dedicated to the specific SORT sentence is generated.

【0032】次に、実際のCOBOLプログラムのSO
RT文から、図3及び図4で説明した方法で展開される
比較関数の例を、図5及び図6で説明する。
Next, the SO of the actual COBOL program
An example of the comparison function expanded from the RT statement by the method described with reference to FIGS. 3 and 4 will be described with reference to FIGS. 5 and 6.

【0033】図5は、SORT文を含んだCOBOLプ
ログラムの例である。501はソート(整列)用ファイ
ルのレコードの構造を指定している部分である。502
と503はそれぞれ入力ファイルと出力ファイルのレコ
ードの構造を指定している部分である。504はSOR
T文である。SOR文504において、505は最初の
キーである S-URIAGE-KOSU について降順に並べること
を指定し、506は2番目のキーの S-CODE について昇
順に並べることを指定し、507と508はそれぞれ入
力ファイルと出力ファイルを指定している。
FIG. 5 shows an example of a COBOL program including a SORT statement. Reference numeral 501 is a portion that specifies the structure of records in a sort file. 502
And 503 are portions that specify the record structures of the input file and the output file, respectively. 504 is SOR
It is a T sentence. In the SOR statement 504, 505 specifies that the first key S-URIAGE-KOSU should be arranged in descending order, 506 specifies that the S-CODE of the second key should be arranged in ascending order, and 507 and 508 respectively. Input file and output file are specified.

【0034】図6は、このCOBOLプログラムのSO
RT文504から生成される比較関数の内容を示すPA
D図である。601は図4の401を展開したもので、
レコード1(C1-RECORD)とレコード2(C2-RECORD)を
受け取る。レコード1とレコード2は、それぞれ図中の
610と611により示されるレコード構造を持つよう
にコンパイラの内部で設定する。なお、これらのレコー
ド構造は、図5のCOBOLプログラムの部分91で指
定されたソート(整列)用ファイルのレコード構造と同
じである。602は、ソースプログラムのSORT文5
04において最初のキー S-URIAGE-KOSU が降順指定な
ので、図4の404を展開している。レコード1の C1-
URIAGE-KOSU が レコード2の C2-URIAGE-KOSU より小
さければリタン値を "入れ替える" に設定し、大きけれ
ば "入れ替えない" に設定する。どちらでもないときの
処理には603を展開する。これは、SORT文504
の次のキー S-CODE が昇順指定であり、しかもこのキー
が最後のキーなので、図4の405を展開したものであ
る。レコード1のC1-CODE が レコード2のC2-CODEより
大きければ、リタン値を "入れ替える" に設定し、そう
でなければ "入れ替えない" に設定する。この関数の最
後は、図4の82を展開した604であり、ここでは、
リタン値を呼び出し元に返す。
FIG. 6 shows the SO of this COBOL program.
PA showing the contents of the comparison function generated from the RT statement 504
FIG. 601 is an expanded version of 401 in FIG.
Receive record 1 (C1-RECORD) and record 2 (C2-RECORD). Record 1 and record 2 are set inside the compiler so as to have the record structures indicated by 610 and 611 in the figure, respectively. Note that these record structures are the same as the record structure of the sort file specified in the portion 91 of the COBOL program in FIG. 602 is a SORT statement 5 of the source program
Since the first key S-URIAGE-KOSU is designated in descending order in 04, 404 in FIG. 4 is expanded. Record 1 C1-
If URIAGE-KOSU is smaller than C2-URIAGE-KOSU of record 2, set the return value to "swap", and if it is larger, set it to "not swap". 603 is expanded to the processing when neither is. This is a SORT statement 504
The key S-CODE next to is an ascending order designation, and since this key is the last key, it is an expanded version of 405 in FIG. If the C1-CODE of record 1 is greater than the C2-CODE of record 2, set the return value to "swap", otherwise set to "not swap". The end of this function is the expanded 604 of 82 in FIG. 4, where
Returns the return value to the caller.

【0035】以上のように、コンパイル段階で、コンパ
イラはフロント部でソート文を解析してデータを比較す
る中間言語表現の関数を生成することにより、ユーザが
指定したデータ順序の決定方法に特化したソート処理用
比較関数(ソート専用データ比較処理ルーチン)を、オ
ブジェクトプログラム中に生成する。そして、オブジェ
クトプログラムの実行時に、ソートルーチンの初期処理
部においてソートキーパラメタ解析処理を不要にし、実
際のソート処理を始めるまでの時間を短縮することがで
きる。また、ソートルーチンのソート処理部において、
ソートキー情報を解釈しながら比較する替わりに、コン
パイラが生成した比較関数を呼び出してその戻り値を判
定する方式とすることで、解釈する処理がない分だけ、
比較処理を高速化することができる。さらに、コンパイ
ラに最適化機能があれば、この比較関数も最適化処理さ
れて高速になることが期待できる。
As described above, at the compile stage, the compiler analyzes the sort statement in the front part and generates the function of the intermediate language expression for comparing the data, thereby specializing in the method of determining the data order specified by the user. The sorted comparison function (sort-only data comparison routine) is generated in the object program. Then, when the object program is executed, the sort key parameter analysis process is not required in the initial processing unit of the sort routine, and the time until the actual sort process is started can be shortened. Also, in the sort processing section of the sort routine,
Instead of comparing the sort key information while comparing it, by calling the comparison function generated by the compiler and judging the return value, there is no processing to interpret,
The comparison process can be speeded up. Furthermore, if the compiler has an optimization function, it can be expected that this comparison function will also be optimized and become faster.

【0036】[0036]

【発明の効果】本発明によれば、ソートルーチンの初期
処理の中のソートキー情報の解析処理がなくなる分だけ
実際のソート処理が始まるまでの時間が短くなり、さら
に、ソート処理中の比較処理で、キー情報を参照して解
釈しなくなる分だけ処理速度が向上し、結果としてソー
ト全体処理時間を短縮できる。
According to the present invention, the time until the actual sort processing is started is shortened by the amount of the analysis processing of the sort key information in the initial processing of the sort routine being shortened, and the comparison processing during the sort processing is further reduced. , The processing speed is increased by the amount of time when the key information is not referred to and interpreted, and as a result, the entire sort processing time can be shortened.

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

【図1】本発明の一実施例におけるコンパイラ及びソー
トルーチンの一般的構造、並びにコンパイルされたオブ
ジェクトプログラムとソートルーチンとの呼び出し関係
を示す図である。
FIG. 1 is a diagram showing a general structure of a compiler and a sort routine in one embodiment of the present invention, and a calling relationship between a compiled object program and a sort routine.

【図2】SORT文を展開する処理を表したPAD図で
ある。
FIG. 2 is a PAD diagram showing a process of developing a SORT sentence.

【図3】比較関数を展開する処理を表したPAD図であ
る。
FIG. 3 is a PAD diagram showing a process of expanding a comparison function.

【図4】比較関数展開処理で使用する処理部品を表した
PAD図である。
FIG. 4 is a PAD diagram showing processing components used in comparison function expansion processing.

【図5】SORT文を含んだCOBOLプログラムの例
を示す図である。
FIG. 5 is a diagram showing an example of a COBOL program including a SORT statement.

【図6】COBOLプログラム例から生成する比較関数
の内容を表したPAD図である。
FIG. 6 is a PAD diagram showing the contents of a comparison function generated from a COBOL program example.

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

100 ソースプログラム 101 コンパイラ 102 フロント部 103 ソート文展開処理部 104 バック部 111 オブジェクトプログラム 112 初期処理呼び出し 113 レコード受け取り処理呼び出し 114 ソート処理呼び出し 115 レコード引渡し処理呼び出し 116 終了処理呼び出し 117 比較関数 121 ソートルーチン 122 初期処理部 123 レコード受け取り処理部 124 ソート処理部 125 比較関数呼び出し 126 レコード引渡し処理部 127 終了処理部 501 ソート用ファイルのレコード構造指定部 502 入力ファイルのレコード構造指定部 503 出力ファイルのレコード構造指定部 504 SORT文 610 レコード1の構造 611 レコード2の構造 100 Source Program 101 Compiler 102 Front Section 103 Sort Statement Expansion Processing Section 104 Back Section 111 Object Program 112 Initial Processing Call 113 Record Reception Processing Call 114 Sort Processing Call 115 Record Passing Processing Call 116 End Processing Call 117 Comparison Function 121 Sort Routine 122 Initial Processing unit 123 Record receiving processing unit 124 Sort processing unit 125 Comparison function call 126 Record passing processing unit 127 End processing unit 501 Record structure specifying unit for sorting file 502 Record structure specifying unit for input file 503 Record structure specifying unit for output file 504 SORT sentence 610 Structure of record 1 611 Structure of record 2

───────────────────────────────────────────────────── フロントページの続き (72)発明者 今岡 弘良 神奈川県横浜市戸塚区戸塚町5030番地 株 式会社日立製作所ソフトウェア開発本部内 (72)発明者 三宅 立記 神奈川県横浜市中区尾上町6丁目81番地 日立ソフトウェアエンジニアリング株式会 社内 (72)発明者 渡辺 良一 神奈川県横浜市中区尾上町6丁目81番地 日立ソフトウェアエンジニアリング株式会 社内 ─────────────────────────────────────────────────── ─── Continuation of the front page (72) Inventor Hiroyoshi Imaoka 5030 Totsuka-cho, Totsuka-ku, Yokohama City, Kanagawa Prefecture Software Development Division, Hitachi Ltd. 81-chome Hitachi Software Engineering Co., Ltd. (72) Inventor Ryoichi Watanabe 6-81 Onoue-cho, Naka-ku, Yokohama-shi Kanagawa Hitachi Software Engineering Co., Ltd. In-house

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムのコンパイル時にコン
パイラにおいて、プログラミング言語固有の方法でソー
スプログラムに書かれたソート順序の決定方法からソー
トに必要なデータ比較処理ルーチンをオブジェクトプロ
グラム中に生成し、オブジェクトプログラムの実行時に
ソートプログラムにおいて、オブジェクトプログラム中
に生成されたデータ比較処理ルーチンを使用してデータ
のソートを実行することを特徴とするソート処理方法。
1. When compiling a source program, the compiler generates a data comparison processing routine required for sorting in the object program from the method of determining the sort order written in the source program by a method specific to the programming language, A sort processing method characterized in that a sort program is executed at the time of execution to sort data by using a data comparison processing routine generated in an object program.
JP23914892A 1992-09-08 1992-09-08 Sort processing method and compilation method Expired - Fee Related JP3305767B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP23914892A JP3305767B2 (en) 1992-09-08 1992-09-08 Sort processing method and compilation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP23914892A JP3305767B2 (en) 1992-09-08 1992-09-08 Sort processing method and compilation method

Publications (2)

Publication Number Publication Date
JPH0689186A true JPH0689186A (en) 1994-03-29
JP3305767B2 JP3305767B2 (en) 2002-07-24

Family

ID=17040471

Family Applications (1)

Application Number Title Priority Date Filing Date
JP23914892A Expired - Fee Related JP3305767B2 (en) 1992-09-08 1992-09-08 Sort processing method and compilation method

Country Status (1)

Country Link
JP (1) JP3305767B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010198070A (en) * 2009-02-23 2010-09-09 Nec Corp Sort key comparison code generation device, sort processor, and sort key comparison code generation method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010198070A (en) * 2009-02-23 2010-09-09 Nec Corp Sort key comparison code generation device, sort processor, and sort key comparison code generation method

Also Published As

Publication number Publication date
JP3305767B2 (en) 2002-07-24

Similar Documents

Publication Publication Date Title
US5586328A (en) Module dependency based incremental compiler and method
JPH06250846A (en) Compiling device
US5790760A (en) Program generating apparatus and method thereof
US5375242A (en) Compiler architecture for cross-module optimization
KR100624248B1 (en) Method and system for performing static initialization
JPH06103463B2 (en) Code generation method
US6851106B1 (en) Object oriented optimizing code generator with user selection of use or do not use for dynamic generation of functions
JPH10161884A (en) Improved code optimizer for pipeline computer
JP2708405B2 (en) Loop unrolling method in compiler
JP3802058B2 (en) System, method and compiler preprocessor for conditionally compiling software compilation units
JPH04215133A (en) Compiler optimizing method
US5781777A (en) Optimization method for computation partitioning oriented to a distributed memory
US5241678A (en) Program translation based on generalized partial computation
JP2000207221A (en) Method and device for code generation for array range check and method and device for versioning
US7926044B2 (en) Method, apparatus and computer program for executing a program
JPH0689186A (en) Sort processing method
JPH09128246A (en) Compiler device
Weiskamp Advanced turbo C programming
JPH0689187A (en) Inline expansion optimizing method
JP3044953B2 (en) Symbol processing method of language processing system
JPH06290159A (en) Process assigning method for parallel computers
JP2002140198A (en) Inline development method
JPH09231087A (en) Compiling device and method
Ku et al. Behavioral Transformations
JPH0713963A (en) Method for processing scheduling of vector instruction

Legal Events

Date Code Title Description
FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080510

Year of fee payment: 6

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090510

Year of fee payment: 7

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100510

Year of fee payment: 8

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110510

Year of fee payment: 9

LAPS Cancellation because of no payment of annual fees