JP3516365B2 - Method and apparatus for storing records in memory - Google Patents

Method and apparatus for storing records in memory

Info

Publication number
JP3516365B2
JP3516365B2 JP13692495A JP13692495A JP3516365B2 JP 3516365 B2 JP3516365 B2 JP 3516365B2 JP 13692495 A JP13692495 A JP 13692495A JP 13692495 A JP13692495 A JP 13692495A JP 3516365 B2 JP3516365 B2 JP 3516365B2
Authority
JP
Japan
Prior art keywords
record
input
storage area
length
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 - Fee Related
Application number
JP13692495A
Other languages
Japanese (ja)
Other versions
JPH08328826A (en
Inventor
清充 日吉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP13692495A priority Critical patent/JP3516365B2/en
Publication of JPH08328826A publication Critical patent/JPH08328826A/en
Application granted granted Critical
Publication of JP3516365B2 publication Critical patent/JP3516365B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

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

【0001】[0001]

【産業上の利用分野】本発明は情報処理の分野に係り、
入力された複数のレコードをメモリ内に読み込む方法と
その装置に関する。
The present invention relates to the field of information processing,
The present invention relates to a method and apparatus for reading a plurality of input records into a memory.

【0002】[0002]

【従来の技術】今日の情報処理においては、ソートマー
ジプログラムを始めとして、入力ファイル内の複数のレ
コードをメモリに読み込んで処理を行うプログラムが多
く用いられている。例えばソートマージプログラムによ
るソートマージ処理は、入力ファイル内のレコードを一
定の条件のもとでソートするために行われる。従来のソ
ートマージ処理等において、可変長レコードまたは不定
長レコードをメモリ内に読み込む時は、ユーザが入力フ
ァイル内のレコードの長さの上限(最大レコード長)を
指定し、処理装置は指定された値をもとに複数のレコー
ド格納領域(BIN)を割り当てている。
2. Description of the Related Art In today's information processing, many programs including a sort-merge program are used to read a plurality of records in an input file into a memory for processing. For example, sort merge processing by a sort merge program is performed in order to sort the records in the input file under a certain condition. When reading variable length records or indefinite length records into memory in conventional sort merge processing, etc., the user specifies the upper limit (maximum record length) of the record length in the input file, and the processing device is specified. A plurality of record storage areas (BIN) are allocated based on the value.

【0003】図13は、従来のソートマージプログラム
によるソートマージ処理を示している。図13におい
て、まずユーザは入力ファイル2の最大レコード長1を
指定し、それをソートマージプログラム3に通知する。
もし、明確な最大レコード長が分からなければ、例えば
少し余裕のある大きめの値を最大レコード長1として指
定しておく。ソートマージプログラム3は、指定された
最大レコード長1の大きさのBINをメモリ4内にn個
割り当て、それらをレコード用領域として確保する。次
に、入力ファイル2の入力レコードを先頭から順に入力
バッファに読み込み、入力バッファからBINに入力レ
コードを移動して、ソートマージ処理を行う。
FIG. 13 shows sort merge processing by a conventional sort merge program. In FIG. 13, the user first specifies the maximum record length 1 of the input file 2 and notifies the sort merge program 3 of it.
If the clear maximum record length is not known, for example, a large value with a little margin is designated as the maximum record length 1. The sort merge program 3 allocates n BINs each having the specified maximum record length 1 in the memory 4 and secures them as a record area. Next, the input records of the input file 2 are sequentially read into the input buffer from the beginning, the input records are moved from the input buffer to BIN, and the sort merge processing is performed.

【0004】[0004]

【発明が解決しようとする課題】しかしながら上述のよ
うな従来のソートマージ処理には次のような問題があ
る。
However, the conventional sort merge processing as described above has the following problems.

【0005】複数のBINをメモリ4内で効率よく割り
当てるためには、ユーザはソートマージプログラム3を
実行する前に、入力ファイル2内の最大レコード長を知
っている必要がある。もし、実際の最大レコード長より
著しく大きな値を指定した場合は、メモリ4内の割り当
て可能なBINの数が減少し、処理効率が低下する。逆
に、ユーザの指定した最大レコード長1より大きな入力
レコードが入力されると、ソートマージプログラム3は
処理を中断しなければならなくなる。
In order to efficiently allocate a plurality of BINs in the memory 4, the user needs to know the maximum record length in the input file 2 before executing the sort merge program 3. If a value that is significantly larger than the actual maximum record length is specified, the number of allocable BINs in the memory 4 decreases and the processing efficiency decreases. On the contrary, when an input record larger than the maximum record length 1 specified by the user is input, the sort merge program 3 has to interrupt the processing.

【0006】本発明は、ユーザが最大レコード長を指定
することなく、可変長レコードまたは不定長レコードを
効率良くメモリに格納するレコード格納方法およびその
装置を提供することを目的とする。
It is an object of the present invention to provide a record storage method and apparatus for efficiently storing variable length records or indefinite length records in a memory without the user designating a maximum record length.

【0007】[0007]

【課題を解決するための手段】図1は、本発明のレコー
ド格納方法の原理図である。図1において処理が開始さ
れると、まず1つの入力レコードを格納するための空き
のレコード格納領域がメモリ内にあるかどうかを調べ
(ステップS1)、そのような空きのレコード格納領域
がメモリ内にあれば、そこに上記入力レコードを格納す
る(ステップS3)。空きのレコード格納領域がメモリ
内になければ、現在のレコード格納領域をこれまでに入
力された最大のレコードの長さ以上の複数の領域に分割
して、空きのレコード格納領域を生成する(ステップS
2)。そして、生成された空きのレコード格納領域に上
記入力レコードを格納する(ステップS3)。次に、既
に格納された、上記入力レコードを含む複数の入力レコ
ードのうち、最大のレコードの長さを記憶して(ステッ
プS4)、処理を終了する。
FIG. 1 is a principle diagram of a record storing method of the present invention. When the process is started in FIG. 1, it is first checked whether or not there is an empty record storage area for storing one input record in the memory (step S1), and such an empty record storage area is found in the memory. If so, the input record is stored there (step S3). If there is no free record storage area in the memory, the current record storage area is divided into a plurality of areas that are equal to or longer than the maximum record length input so far, and a free record storage area is generated (step S
2). Then, the input record is stored in the generated empty record storage area (step S3). Next, of the plurality of input records including the above-mentioned input record, which has already been stored, the maximum record length is stored (step S4), and the process ends.

【0008】[0008]

【作用】入力ファイルの入力レコードを格納するための
レコード格納領域(BIN)は、情報処理装置のメモリ
内に設けられ、これまでに入力された最大のレコードの
長さは最大入力レコード長として記憶されている。ま
ず、現在メモリ内に設定されているレコード格納領域が
空いているかどうかを調べ(ステップS1)、空きのレ
コード格納領域があれば、そこに新しい入力レコードを
格納する(ステップS3)。
The record storage area (BIN) for storing the input record of the input file is provided in the memory of the information processing device, and the maximum record length input so far is stored as the maximum input record length. Has been done. First, it is checked whether or not the record storage area currently set in the memory is free (step S1), and if there is a free record storage area, a new input record is stored (step S3).

【0009】もし、空きのレコード格納領域がメモリ内
になければ、既に入力レコードが格納されている現在の
レコード格納領域を、記憶されている最大入力レコード
長以上の長さの複数の領域に分割する(ステップS
2)。分割により生成される新しいレコード格納領域は
元のレコード格納領域よりも小さくなるが、これまでに
入力されたレコードの長さ以上であることは保証され
る。したがって、既存の入力レコードはすべて格納され
たままで、新たな空きのレコード格納領域が生成され、
新しい入力レコードを格納することができるようになる
(ステップS3)。こうして空きのレコード格納領域に
格納された新しい入力レコードを含む複数の入力レコー
ドのうち、最大のレコードの長さを改めて最大入力レコ
ード長として記憶する(ステップS4) このようなレコード格納方法によれば、メモリ内のレコ
ード格納領域の数と大きさを入力レコードに応じて変更
することができ、メモリの利用効率が高まる。また、最
大入力レコード長は自動的に決められるので、ユーザは
入力ファイル内のレコード長の上限を指定する必要がな
くなる。
If there is no empty record storage area in the memory, the current record storage area in which the input record is already stored is divided into a plurality of areas having a length equal to or longer than the maximum input record length stored. Yes (Step S
2). The new record storage area generated by the division is smaller than the original record storage area, but it is guaranteed that it is longer than the length of the record input so far. Therefore, all existing input records are still stored and new empty record storage area is created.
A new input record can be stored (step S3). Of the plurality of input records including the new input record thus stored in the empty record storage area, the maximum record length is stored again as the maximum input record length (step S4). The number and size of the record storage areas in the memory can be changed according to the input record, and the memory utilization efficiency is improved. Further, since the maximum input record length is automatically determined, the user does not need to specify the upper limit of the record length in the input file.

【0010】[0010]

【実施例】以下、図面を参照しながら、本発明の実施例
を詳細に説明する。図2は、実施例における情報処理装
置の構成図である。図2の情報処理装置は、入出力端末
11、CPU(中央処理装置)12、外部記憶装置1
3、メモリ14、およびこれらを結合するバス15を備
える。入出力端末11は、例えばキーボードやマウス等
の入力機器とディスプレイ装置等の出力装置を備えたユ
ーザ端末であり、レコードを処理するプログラムの起動
や処理結果の出力等に用いられる。外部記憶装置13
は、例えば磁気ディスク装置や光ディスク装置等の記憶
装置であり、入力ファイルや出力ファイル等を格納す
る。メモリ14は、CPU12により作業領域として使
用され、ここにレコード用領域等が設定される。
Embodiments of the present invention will now be described in detail with reference to the drawings. FIG. 2 is a configuration diagram of the information processing apparatus in the embodiment. The information processing apparatus of FIG. 2 includes an input / output terminal 11, a CPU (central processing unit) 12, and an external storage device 1.
3, a memory 14, and a bus 15 coupling these. The input / output terminal 11 is a user terminal provided with an input device such as a keyboard and a mouse and an output device such as a display device, and is used for starting a program for processing a record and outputting a processing result. External storage device 13
Is a storage device such as a magnetic disk device or an optical disk device, and stores input files and output files. The memory 14 is used as a work area by the CPU 12, and a record area and the like are set therein.

【0011】図3は、実施例におけるメモリ14の内部
構成を示している。図3(a)はソート処理を行うとき
のメモリ14を示しており、図3(b)はマージ処理を
行うときのメモリ14を示している。
FIG. 3 shows the internal structure of the memory 14 in the embodiment. FIG. 3A shows the memory 14 when performing sort processing, and FIG. 3B shows the memory 14 when performing merge processing.

【0012】図3(a)のメモリ14内には、入力バッ
ファ16、レコード用領域17、作業バッファ18、お
よびレコード長格納域19が設けられる。入力バッファ
16は入力ファイル21のレコードをメモリ14内に読
み込むためのバッファであり、作業バッファ18は処理
の終わったレコードを作業ファイル22へ出力するため
のバッファである。
An input buffer 16, a record area 17, a work buffer 18, and a record length storage area 19 are provided in the memory 14 of FIG. 3A. The input buffer 16 is a buffer for reading the records of the input file 21 into the memory 14, and the work buffer 18 is a buffer for outputting the processed records to the work file 22.

【0013】CPU12はプログラムを実行することに
より、外部記憶装置13の入力ファイル21に含まれる
入力レコードを入力バッファ16に読み込み、複数のB
IN等から成るレコード用領域17に移動してソート処
理を行う。そして、処理の中間結果を作業バッファ18
に移し、一時的に作業ファイル22として出力する。。
The CPU 12 reads the input record contained in the input file 21 of the external storage device 13 into the input buffer 16 by executing the program, and a plurality of B's are read.
Sorting processing is performed by moving to the record area 17 composed of IN or the like. Then, the intermediate result of the processing is stored in the work buffer
And the work file 22 is temporarily output. .

【0014】このとき、レコード長格納域19には、レ
コード用領域17内の最も大きなレコードのレコード長
(最大レコード長)が格納される。CPU12は、レコ
ード長格納域19に格納された最大レコード長を参照し
て、現在のBINの長さ(BIN長)を適当な整数nで
n等分し、最大レコード長以上のn個の領域に分割す
る。そして、分割処理により生成されたn個の領域の各
々を改めてBINとして使用する。
At this time, the record length storage area 19 stores the record length (maximum record length) of the largest record in the record area 17. The CPU 12 refers to the maximum record length stored in the record length storage area 19, divides the current BIN length (BIN length) into n equal parts by an appropriate integer n, and divides into n areas equal to or larger than the maximum record length. Split into. Then, each of the n areas generated by the division processing is used again as BIN.

【0015】図3(b)のメモリ14内には、作業バッ
ファ18、レコード用領域17、および出力バッファ2
4が設けられる。作業バッファ18は作業ファイル22
をメモリ14内に読み込むために使用され、出力バッフ
ァ24はマージされたレコードを出力ファイル23へ出
力するために使用される。入力ファイル21に含まれる
入力レコードをすべて読み込むと、CPU12はメモリ
14内でいくつかの作業ファイル22のマージ処理等を
行い、出力ファイル23として外部記憶装置13に出力
する。
In the memory 14 of FIG. 3B, a work buffer 18, a record area 17 and an output buffer 2 are provided.
4 are provided. The work buffer 18 is a work file 22.
Are read into the memory 14 and the output buffer 24 is used to output the merged records to the output file 23. When all the input records included in the input file 21 are read, the CPU 12 performs merge processing of some work files 22 in the memory 14 and outputs the work file 22 as an output file 23 to the external storage device 13.

【0016】このように、本実施例では、プログラムが
レコード用領域17内の最大レコード長をもとにして動
的にBIN長を変更するので、処理の進行状況に応じて
適当なBIN長が自動的に設定される。したがって、ユ
ーザはあらかじめ最大レコード長を入力する必要がな
い。
As described above, in this embodiment, the program dynamically changes the BIN length based on the maximum record length in the record area 17, so that an appropriate BIN length can be set according to the progress of processing. It is set automatically. Therefore, the user does not need to input the maximum record length in advance.

【0017】次に、図4から図12までを参照しなが
ら、本発明のレコード格納方法を用いたソートマージ処
理について説明する。図4は、ソートマージ処理のフロ
ーチャートであり、図5から図9までは、処理の途中に
おけるメモリ14内のレコード用領域17の例を示して
いる。図4のソートマージ処理は、CPU12がソート
マージプログラムを実行することにより開始される。
Next, the sort merge processing using the record storing method of the present invention will be described with reference to FIGS. FIG. 4 is a flowchart of the sort merge processing, and FIGS. 5 to 9 show an example of the record area 17 in the memory 14 during the processing. The sort merge processing of FIG. 4 is started by the CPU 12 executing the sort merge program.

【0018】図4において処理が開始されると、CPU
12はまずメモリ14内にレコード用領域17を確保し
(ステップS11)、BIN長の初期設定を行う(ステ
ップS12)。この初期設定により、BIN長はレコー
ド用領域17の領域長に設定される。このときのレコー
ド用領域17内のBINの数(BIN数)は1であり、
レコード用領域17は図5のようになる。
When the processing is started in FIG. 4, the CPU
First, the area 12 secures the record area 17 in the memory 14 (step S11) and initializes the BIN length (step S12). By this initial setting, the BIN length is set to the area length of the record area 17. At this time, the number of BINs (BIN number) in the record area 17 is 1,
The record area 17 is as shown in FIG.

【0019】次に、入力ファイル21からレコードを入
力バッファ16に読み込み(ステップS13)、入力フ
ァイル21の最後(EOF)かどうか、および処理対象
のレコードが入力バッファ16内の最終のレコードかど
うかを判定する(ステップS14、S15)。EOFで
あればステップS26以降の処理を行い、入力バッファ
16の最終であればステップS14以降の処理を繰り返
す。EOFでなく、入力バッファ16の最終でもなけれ
ば、入力バッファ16からレコード用領域17に移動す
るレコードの長さを調べる(ステップS16)。
Next, a record is read from the input file 21 into the input buffer 16 (step S13), and it is determined whether the record at the end (EOF) of the input file 21 and whether the record to be processed is the last record in the input buffer 16. The determination is made (steps S14 and S15). If it is EOF, the processing from step S26 is performed, and if it is the last input buffer 16, the processing from step S14 is repeated. If it is neither the EOF nor the end of the input buffer 16, the length of the record moved from the input buffer 16 to the record area 17 is checked (step S16).

【0020】移動するレコードの長さが現在のBIN長
よりも長ければソート処理を行い(ステップS24)、
現在のBIN長以下であれば、そのレコードを入力バッ
ファ16からレコード用領域17内のBINに移動する
(ステップS18)。そして、レコード用領域17に格
納されたレコードの内で、最も大きなもののレコード長
をレコード長格納域19に記憶する(ステップS1
9)。もし、直前に移動したレコードの長さが、既にレ
コード長格納域19に記憶されていた最大入力レコード
長よりも長ければ、そのレコードのレコード長が新しく
最大入力レコード長として記憶される。逆に、移動した
レコードの長さの方が短ければ、レコード長格納域19
内の最大入力レコード長は更新されない。
If the length of the record to be moved is longer than the current BIN length, sort processing is performed (step S24),
If it is not more than the current BIN length, the record is moved from the input buffer 16 to the BIN in the record area 17 (step S18). Then, the record length of the largest record among the records stored in the record area 17 is stored in the record length storage area 19 (step S1).
9). If the length of the record moved immediately before is longer than the maximum input record length already stored in the record length storage area 19, the record length of the record is newly stored as the maximum input record length. On the contrary, if the length of the moved record is shorter, the record length storage area 19
The maximum input record length in is not updated.

【0021】図5の状態で入力バッファ16からレコー
ドを移動した場合は、図6に示すように、そのレコード
はレコード用領域17の先頭に先頭レコードとして格納
され(ステップS18)、そのレコード長が最大入力レ
コード長として、レコード長格納域19に格納される
(ステップS19)。
When a record is moved from the input buffer 16 in the state of FIG. 5, the record is stored as the first record at the beginning of the record area 17 as shown in FIG. 6 (step S18), and the record length is changed. The maximum input record length is stored in the record length storage area 19 (step S19).

【0022】次に、レコード用領域17内に空きのBI
Nがあるかどうかを調べ(ステップS20)、空きのB
INがあればステップS14以降の処理を繰り返す。も
し、空きのBINがなければ、レコード長格納域19内
の最大入力レコード長のn倍の長さと現在のBIN長と
を比較する(ステップS21)。現在のBIN長が最大
入力レコード長のn倍よりも小さければ、ステップS2
4以降の処理を行う。また、現在のBIN長が最大入力
レコード長のn倍以上であれば、現在のBIN長をn等
分して(ステップS22)、空きのBINを確保し(ス
テップS23)、ステップS14以降の処理を繰り返
す。ここで、nは適当な分割数であり、あらかじめプロ
グラムに記述されている。
Next, an empty BI in the record area 17
It is checked whether or not N is present (step S20), and empty B
If IN is present, the processing from step S14 is repeated. If there is no empty BIN, the length n times the maximum input record length in the record length storage area 19 is compared with the current BIN length (step S21). If the current BIN length is smaller than n times the maximum input record length, step S2
The processing after 4 is performed. If the current BIN length is n times the maximum input record length or more, the current BIN length is divided into n equal parts (step S22), a free BIN is secured (step S23), and the processes after step S14. repeat. Here, n is an appropriate number of divisions and is described in the program in advance.

【0023】例えば、図6においては空きのBINがな
いので(ステップS20、NO)、最大入力レコード長
の2倍(n=2)とBIN長とを比較する。現在のBI
N長はレコード用領域17の領域長に等しく、最大入力
レコード長の2倍より大きいので(ステップS21、Y
ES)、BINを2等分する(ステップS22)。この
結果、レコード用領域17は図7のようになり、空きの
BINが生成される(ステップS23)。このときのB
IN数は2であり、BIN長はレコード用領域17の領
域長の1/2である。
For example, in FIG. 6, since there is no empty BIN (step S20, NO), twice the maximum input record length (n = 2) is compared with the BIN length. Current BI
Since the N length is equal to the area length of the record area 17 and is larger than twice the maximum input record length (step S21, Y
ES) and BIN are equally divided into two (step S22). As a result, the record area 17 becomes as shown in FIG. 7, and an empty BIN is generated (step S23). B at this time
The number of INs is 2, and the BIN length is 1/2 of the area length of the record area 17.

【0024】そして、先頭レコードに続く次のレコード
は、図8に示すように、生成された空きのBINに格納
される(ステップS18)。このとき、最大入力レコー
ド長は、先頭レコードと次のレコードのうち長い方のレ
コード長となる(ステップS19)。この後も同様にし
て、2つのBINはさらに2等分され、図9に示すよう
に、2つの新しい空きのBINが生成される。このとき
のBIN数は4になり、BIN長はレコード用領域17
の領域長の1/4になる。
Then, the next record following the first record is stored in the generated empty BIN as shown in FIG. 8 (step S18). At this time, the maximum input record length is the longer record length of the first record and the next record (step S19). After this, similarly, the two BINs are further divided into two, and two new empty BINs are generated as shown in FIG. At this time, the number of BIN is 4, and the BIN length is the record area 17
It becomes 1/4 of the area length.

【0025】このような処理は、ステップS17でBI
N長がレコードの長さよりも短くなるまで、あるいは、
ステップS21でBIN長が最大入力レコード長の2倍
よりも小さくなるまで続けられる。ここでは、BIN長
の分割数をn=2として処理を行っているが、一般には
任意の分割数を用いることができ、nの値を処理の途中
で変更することもできる。
Such processing is performed in step S17 in BI.
Until the N length is shorter than the record length, or
This is continued until the BIN length becomes smaller than twice the maximum input record length in step S21. Here, the processing is performed with the number of divisions of the BIN length set to n = 2, but generally any number of divisions can be used, and the value of n can be changed during the processing.

【0026】次に、ステップS24で行う処理について
説明する。ステップS24では、レコード用領域17内
の複数のレコードについて一旦ソートを行い、作業バッ
ファ18に移動させる。ここでは、ソート方法として、
トーナメント法によるソート処理方式(特願平2−27
9953、特開平4−153826)またはQUICK
(クイック)ソートを用いる。
Next, the processing performed in step S24 will be described. In step S24, the plurality of records in the record area 17 are once sorted and moved to the work buffer 18. Here, as a sorting method,
Sorting method by tournament method (Japanese Patent Application No. 2-27)
9953, JP-A-4-153826) or QUICK
Use (quick) sort.

【0027】図10は、トーナメント法によるソート処
理のフローチャートである。トーナメント法とは、2つ
のレコードを1組にした勝ち抜き戦を繰り返し、最も強
いレコードを選出する方法である。図10において処理
が開始されると、CPU12はまずレコード用領域17
内の複数のレコードについて初期トーナメントを行い、
優勝レコードを決定する(ステップS31)。そして、
その優勝レコードを作業バッファ18へ移動する(ステ
ップS32)。
FIG. 10 is a flowchart of the sorting process by the tournament method. The tournament method is a method of selecting the strongest record by repeating winning battles in which two records form a set. When the process is started in FIG. 10, the CPU 12 first determines the record area 17
Initial tournaments for multiple records in
The winning record is determined (step S31). And
The winning record is moved to the work buffer 18 (step S32).

【0028】次に、入力バッファ16に次の入力レコー
ドがあるかどうかを調べ(ステップS33)、次の入力
レコードがあれば、そのレコード長とBIN長を比較す
る(ステップS34)。ここで、次の入力レコードのレ
コード長がBIN長以下であれば、それが作業バッファ
18へ移された優勝レコードより弱いかどうかを判定す
る(ステップS35)。次の入力レコードが優勝レコー
ドより弱ければ、それを優勝レコードの格納されていた
BINに格納し、再びトーナメントを行って次の優勝レ
コードを選出する(ステップS36)。そして、ステッ
プS32以降の処理を繰り返す。
Next, it is checked whether or not there is a next input record in the input buffer 16 (step S33), and if there is a next input record, the record length is compared with the BIN length (step S34). If the record length of the next input record is equal to or less than the BIN length, it is determined whether or not it is weaker than the winning record transferred to the work buffer 18 (step S35). If the next input record is weaker than the winning record, it is stored in the BIN where the winning record was stored, the tournament is performed again, and the next winning record is selected (step S36). Then, the processing from step S32 is repeated.

【0029】図11は、レコード用領域17内の4つの
レコードに対するトーナメントソートの例を示してい
る。例えば、図9に示す4つのBINにそれぞれレコー
ドA、B、C、Dが格納された後に、図10の処理が開
始されたとする。このとき、レコードBよりレコードA
が強く、レコードDよりレコードCが強く、またレコー
ドCよりレコードAが強いものとすると、初期トーナメ
ントによりレコードAが優勝する(ステップS31)。
そこで、レコードAは作業バッファ18に移され(ステ
ップS32)、次の入力レコードEがレコードAの格納
されていたBINに移されて、レコードE、B、C、D
の間でトーナメントが行われる(ステップS36)。
FIG. 11 shows an example of tournament sort for four records in the record area 17. For example, it is assumed that the process of FIG. 10 is started after the records A, B, C, and D are stored in the four BINs shown in FIG. 9, respectively. At this time, from record B to record A
, Record C is stronger than record D, and record A is stronger than record C, record A wins the initial tournament (step S31).
Therefore, the record A is moved to the work buffer 18 (step S32), the next input record E is moved to the BIN in which the record A was stored, and the records E, B, C, D are stored.
A tournament is held between (step S36).

【0030】このような処理が繰り返され、ステップS
33で次の入力レコードがなくなった時、またはステッ
プS34でレコード長がBIN長を超えた時、あるいは
ステップS35で次の入力レコードが優勝レコードより
強い時、レコード用領域17内の残りのレコードをソー
トして作業バッファ18へ出力し(ステップS37)、
処理を終了する。
Such processing is repeated, and step S
When the next input record disappears in 33, or the record length exceeds the BIN length in step S34, or when the next input record is stronger than the winning record in step S35, the remaining records in the record area 17 are deleted. Sort and output to the work buffer 18 (step S37),
The process ends.

【0031】例えば、図11において、次の入力レコー
ドEがなかったときは(ステップS33、NO)、残り
のレコードB、C、Dがソートされて、作業バッファ1
8へ移される(ステップS37)。
For example, in FIG. 11, when there is no next input record E (step S33, NO), the remaining records B, C and D are sorted and the work buffer 1
8 (step S37).

【0032】トーナメント法は、メモリ14内のレコー
ドから1件の優勝レコードを選出した後、次の入力レコ
ードを優勝レコードがあったBINに格納することで、
初期入力時に格納したレコード数以上のレコードを1つ
のストリングとして出力できる点で、他のソート技法よ
り優れている。
In the tournament method, one winning record is selected from the records in the memory 14, and the next input record is stored in the BIN where the winning record existed.
It is superior to other sorting techniques in that records more than the number of records stored at initial input can be output as one string.

【0033】図12は、もう一つのソート方法であるQ
UICK法によるソート処理のフローチャートである。
図12において処理が開始されると、CPU12はまず
QUICKソートにより、レコード用領域17内のレコ
ードをすべて並べ替える(ステップS41)。次に、ソ
ートされた全レコードを作業バッファ18へ移動させて
(ステップS42)、処理を終了する。
FIG. 12 shows another sorting method Q.
It is a flowchart of the sorting process by the UICK method.
When the process is started in FIG. 12, the CPU 12 first sorts all the records in the record area 17 by QUICK sort (step S41). Next, all the sorted records are moved to the work buffer 18 (step S42), and the process ends.

【0034】QUICK法では、処理中に入力レコード
を追加することがないため、一つのストリングに格納で
きるレコード数はトーナメントソートより少なくなる
が、ストリングの構造は簡単になる。
In the QUICK method, since no input record is added during processing, the number of records that can be stored in one string is smaller than that in tournament sort, but the string structure is simple.

【0035】こうしてステップS24のソート処理が終
わると、CPU12は作業バッファ18の内容を作業フ
ァイル22に出力し(ステップS25)、再び初期設定
を行って(ステップS26)、ステップS14以降の処
理を繰り返す。そして、ステップS27でEOFになる
と、次に作業ファイル22を使用しているかどうかを調
べる(ステップS27)。
When the sort process of step S24 is completed in this way, the CPU 12 outputs the contents of the work buffer 18 to the work file 22 (step S25), initializes again (step S26), and repeats the processes of step S14 and thereafter. . When the EOF is reached in step S27, it is checked whether or not the work file 22 is used next (step S27).

【0036】もし、一度もステップS24の処理を行っ
ておらず、作業ファイル22を使用していなければ、そ
のままレコード用領域17内のレコードをソートして
(ステップS28)、出力ファイル23に出力し(ステ
ップS30)、処理を終了する。しかし、作業ファイル
22を使用している場合は、レコード用領域17内のレ
コードと作業ファイル22内のレコードのソートマージ
を行う(ステップS29)。そして、マージ結果を出力
ファイル23に出力し(ステップS30)、処理を終了
する。
If the processing of step S24 has never been performed and the work file 22 is not used, the records in the record area 17 are sorted (step S28) and output to the output file 23. (Step S30), the process ends. However, when the work file 22 is used, the records in the record area 17 and the records in the work file 22 are sorted and merged (step S29). Then, the merged result is output to the output file 23 (step S30), and the process ends.

【0037】例えば、従来のレコード格納方法では、レ
コード用領域17が1MB(メガバイト)であった場
合、ユーザが指定した最大レコード長が1KB(キロバ
イト)なら、レコード用領域17に格納できるレコード
件数は常に1000件(1MB/1KB)である。
For example, in the conventional record storage method, when the record area 17 is 1 MB (megabytes) and the maximum record length specified by the user is 1 KB (kilobytes), the number of records that can be stored in the record area 17 is It is always 1000 (1MB / 1KB).

【0038】しかし、本実施例では、実際の入力レコー
ドのレコード長の平均値により入力できる件数は異なっ
てくる。つまり、入力レコードの長さにばらつきがある
場合には、比較的小さなレコードは一度に多数入力し、
著しく大きなレコードについてのみ入力数が減少する。
例えば、平均的なレコード長が0.1KBなら1000
0件、0.5KBなら2000件のレコードを格納する
ことができ、最も効率の悪い1KBの場合でも1000
件のレコードが格納されることになる。この結果、メモ
リ14内に読み込める入力レコード数が増加し、一度に
ソートできるデータ量が各段に増える。したがって、ソ
ートマージ処理の処理時間が短縮される。
However, in this embodiment, the number of records that can be input differs depending on the average value of the record lengths of the actual input records. In other words, if there are variations in the length of the input records, enter a relatively small number of records at once,
The number of inputs is reduced only for records that are significantly larger.
For example, if the average record length is 0.1 KB, 1000
2000 records can be stored for 0 or 0.5 KB, and 1000 records can be stored even for the worst 1 KB.
Records will be stored. As a result, the number of input records that can be read in the memory 14 increases and the amount of data that can be sorted at one time increases. Therefore, the processing time of the sort merge processing is shortened.

【0039】[0039]

【発明の効果】本発明によれば、可変長レコードまたは
不定長レコードを情報処理装置のメモリ内に読み込む処
理において、ユーザが入力レコードの最大値を指定する
必要がなくなる。また、メモリの利用効率が高まり、読
み込んだレコードの処理速度が向上する。
According to the present invention, it is not necessary for the user to specify the maximum value of the input record in the process of reading the variable length record or the indefinite length record into the memory of the information processing apparatus. In addition, the memory utilization efficiency is improved, and the processing speed of the read record is improved.

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

【図1】本発明の原理図である。FIG. 1 is a principle diagram of the present invention.

【図2】実施例の情報処理装置の構成図である。FIG. 2 is a configuration diagram of an information processing apparatus according to an embodiment.

【図3】実施例におけるメモリの内部構成を示す図であ
る。
FIG. 3 is a diagram showing an internal configuration of a memory in the example.

【図4】実施例におけるソートマージ処理のフローチャ
ートである。
FIG. 4 is a flowchart of sort merge processing according to the embodiment.

【図5】BIN数1のレコード用領域を示す図である。FIG. 5 is a diagram showing a record area with a BIN number of 1;

【図6】先頭レコード格納後のレコード用領域を示す図
である。
FIG. 6 is a diagram showing a record area after the first record is stored.

【図7】BIN数2のレコード用領域を示す図である。FIG. 7 is a diagram showing a record area with a BIN number of 2;

【図8】次のレコード格納後のレコード用領域を示す図
である。
FIG. 8 is a diagram showing a record area after the next record is stored.

【図9】BIN数4のレコード用領域を示す図である。FIG. 9 is a diagram showing a record area with a BIN number of 4;

【図10】実施例におけるトーナメント処理のフローチ
ャートである。
FIG. 10 is a flowchart of tournament processing according to the embodiment.

【図11】トーナメントソートの例を示す図である。FIG. 11 is a diagram showing an example of tournament sort.

【図12】実施例におけるクイック処理のフローチャー
トである。
FIG. 12 is a flowchart of a quick process according to the embodiment.

【図13】従来のソートマージ処理を示す図である。FIG. 13 is a diagram showing a conventional sort merge process.

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

1 最大レコード長 2、21 入力ファイル 3 ソートマージプログラム 4、14 メモリ 11 入出力端末 12 CPU 13 外部記憶装置 16 入力バッファ 17 レコード用領域 18 作業バッファ 19 レコード長格納域 22 作業ファイル 23 出力ファイル 24 出力バッファ 1 maximum record length 2,21 Input file 3 sort merge program 4,14 memory 11 Input / output terminals 12 CPU 13 External storage device 16 input buffers 17 record area 18 working buffer 19 record length storage area 22 working files 23 Output file 24 output buffer

Claims (11)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 レコードをメモリ内に読み込んで処理を
行う情報処理装置において、 1つの入力レコードを格納するための空きのレコード格
納領域がメモリ内にあるかどうかを調べ、 該空きのレコード格納領域がメモリ内にあれば、該空き
のレコード格納領域に前記入力レコードを格納し、 該空きのレコード格納領域がメモリ内になければ、現在
のレコード格納領域をこれまでに入力された最大のレコ
ードの長さ以上の複数の領域に分割し、生成された空き
のレコード格納領域に前記入力レコードを格納し、 格納された複数の入力レコードのうち、最大のレコード
の長さを記憶することを特徴とするレコード格納方法。
1. An information processing apparatus for reading a record into a memory for processing, checks whether or not a free record storage area for storing one input record exists in the memory, and determines the empty record storage area. If it is in the memory, the input record is stored in the empty record storage area, and if the empty record storage area is not in the memory, the current record storage area is stored as the largest record input so far. It is characterized in that the input record is divided into a plurality of areas having a length equal to or larger than the length, the input record is stored in a generated empty record storage area, and the maximum record length among the plurality of stored input records is stored. How to store records.
【請求項2】 前記生成された空きのレコード格納領域
が1つ以上ある時、1つ以上の空きのレコード格納領域
に前記入力レコードを含む1つ以上の入力レコードを格
納し、該1つ以上の空きのレコード格納領域の全てに入
力レコードが格納されると、各レコード格納領域をさら
に複数の領域に分割することを繰り返して、さらに空き
のレコード格納領域を生成することを特徴とする請求項
1記載のレコード格納方法。
2. When there is one or more generated empty record storage areas, one or more input records including the input record are stored in one or more empty record storage areas, and the one or more When the input records are stored in all of the empty record storage areas, the record storage area is further divided into a plurality of areas to generate an empty record storage area. The record storage method described in 1.
【請求項3】 請求項1記載のレコード格納方法により
複数のレコード格納領域にそれぞれ格納された複数の入
力レコードをソートして、ファイルに出力することを特
徴とするソート方法。
3. A sorting method comprising: sorting a plurality of input records respectively stored in a plurality of record storage areas by the record storing method according to claim 1 and outputting the sorted records to a file.
【請求項4】 前記複数の入力レコードをトーナメント
ソートによりソートして、決定した優勝レコードを前記
ファイルに出力し、該優勝レコードが格納されていたレ
コード格納領域に次の入力レコードを格納してトーナメ
ントソートを繰り返すことを特徴とする請求項3記載の
ソート方法。
4. A tournament in which the plurality of input records are sorted by tournament sort, the determined winning record is output to the file, and the next input record is stored in the record storage area where the winning record was stored. The sorting method according to claim 3, wherein the sorting is repeated.
【請求項5】 前記入力レコードの長さが前記空きのレ
コード格納領域の長さを超える時、これまでに入力され
た複数のレコードをトーナメントソートによりソートし
て作業ファイルに出力し、新しく入力される入力レコー
ドがなくなると、レコード格納領域の内容と作業ファイ
ルの内容をマージして出力ファイルに出力することを特
徴とする請求項3記載のソート方法。
5. When the length of the input record exceeds the length of the empty record storage area, a plurality of records input so far are sorted by tournament sort, output to a work file, and newly input. 4. The sorting method according to claim 3, wherein when there are no more input records, the contents of the record storage area and the contents of the work file are merged and output to the output file.
【請求項6】 前記現在のレコード格納領域をこれまで
に入力された最大のレコードの長さ以上の複数の領域に
分割できない時、これまでに入力された複数のレコード
をトーナメントソートによりソートして作業ファイルに
出力し、新しく入力される入力レコードがなくなると、
レコード格納領域の内容と作業ファイルの内容をマージ
して出力ファイルに出力することを特徴とする請求項3
記載のソート方法。
6. When the current record storage area cannot be divided into a plurality of areas that are longer than the maximum record length that has been input so far, the plurality of records that have been input so far are sorted by tournament sort. If you output to a work file and there are no new input records,
4. The contents of the record storage area and the contents of the work file are merged and output to an output file.
The sort method described.
【請求項7】 前記複数の入力レコードをクイックソー
トによりソートして、前記ファイルに出力することを特
徴とする請求項3記載のソート方法。
7. The sorting method according to claim 3, wherein the plurality of input records are sorted by quick sort and output to the file.
【請求項8】 前記入力レコードの長さが前記空きのレ
コード格納領域の長さを超える時、これまでに入力され
た複数のレコードをクイックソートによりソートして作
業ファイルに出力し、新しく入力される入力レコードが
なくなると、レコード格納領域の内容と作業ファイルの
内容をマージして出力ファイルに出力することを特徴と
する請求項3記載のソート方法。
8. When the length of the input record exceeds the length of the empty record storage area, a plurality of records input so far are sorted by a quick sort, output to a work file, and newly input. 4. The sorting method according to claim 3, wherein when there are no more input records, the contents of the record storage area and the contents of the work file are merged and output to the output file.
【請求項9】 前記現在のレコード格納領域をこれまで
に入力された最大のレコードの長さ以上の複数の領域に
分割できない時、これまでに入力された複数のレコード
をクイックソートによりソートして作業ファイルに出力
し、新しく入力される入力レコードがなくなると、レコ
ード格納領域の内容と作業ファイルの内容をマージして
出力ファイルに出力することを特徴とする請求項3記載
のソート方法。
9. When the current record storage area cannot be divided into a plurality of areas that are longer than the maximum record length that has been input so far, the plurality of records that have been input so far are sorted by a quick sort. 4. The sorting method according to claim 3, wherein when a new input record is output to the work file, the contents of the record storage area and the work file are merged and output to the output file.
【請求項10】 レコードをメモリ内に読み込んで処理
を行う情報処理装置において、 これまでに入力された最大のレコードの長さを、最大入
力レコード長として記憶する手段と、 1つの入力レコードを格納するための空きのレコード格
納領域がメモリ内にあるかどうかを調べる手段と、 該空きのレコード格納領域がメモリ内になければ、現在
のレコード格納領域を前記最大入力レコード長以上の長
さの複数の領域に分割して、空きのレコード格納領域を
生成する手段と、 前記空きのレコード格納領域に前記入力レコードを格納
する手段とを備えることを特徴とするレコード格納装
置。
10. An information processing apparatus for reading a record into a memory for processing, a means for storing the maximum record length input so far as the maximum input record length, and one input record Means for checking whether or not there is a free record storage area in the memory, and if the free record storage area is not in the memory, the current record storage area is divided into a plurality of records having a length equal to or larger than the maximum input record length. And a means for generating an empty record storage area and a means for storing the input record in the empty record storage area.
【請求項11】 複数のレコード格納領域にそれぞれ格
納された複数の入力レコードをソートして、ファイルに
出力する手段をさらに備えることを特徴とする請求項1
0記載のレコード格納装置。
11. The apparatus according to claim 1, further comprising means for sorting a plurality of input records respectively stored in the plurality of record storage areas and outputting the sorted records to a file.
0 record storage device.
JP13692495A 1995-06-02 1995-06-02 Method and apparatus for storing records in memory Expired - Fee Related JP3516365B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP13692495A JP3516365B2 (en) 1995-06-02 1995-06-02 Method and apparatus for storing records in memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP13692495A JP3516365B2 (en) 1995-06-02 1995-06-02 Method and apparatus for storing records in memory

Publications (2)

Publication Number Publication Date
JPH08328826A JPH08328826A (en) 1996-12-13
JP3516365B2 true JP3516365B2 (en) 2004-04-05

Family

ID=15186762

Family Applications (1)

Application Number Title Priority Date Filing Date
JP13692495A Expired - Fee Related JP3516365B2 (en) 1995-06-02 1995-06-02 Method and apparatus for storing records in memory

Country Status (1)

Country Link
JP (1) JP3516365B2 (en)

Also Published As

Publication number Publication date
JPH08328826A (en) 1996-12-13

Similar Documents

Publication Publication Date Title
US5487164A (en) Distribution-based replacement selection sorting system
US5548751A (en) Dynamic data storage system allowing variable size records and fields by using linked record segments
US6618728B1 (en) Multi-process compression
JP4053115B2 (en) Storage control method for document image data
US5375233A (en) File system
US5021946A (en) Mostly contiguous file allocation technique involving file extension
US5421007A (en) Key space analysis method for improved record sorting and file merging
EP0127753A2 (en) Method for executing a distribution sort
US6604170B1 (en) Information processing apparatus and method, and computer readable memory
US5367677A (en) System for iterated generation from an array of records of a posting file with row segments based on column entry value ranges
CN110134650B (en) File loading method, device, equipment and storage medium
US5081608A (en) Apparatus for processing record-structured data by inserting replacement data of arbitrary length into selected data fields
US7496572B2 (en) Reorganizing database objects using variable length keys
JP3251138B2 (en) Hash method
JPH05265708A (en) Computer operating method
US20030037049A1 (en) Dynamic buffer allocation
US5524214A (en) System for modification of dynamic buffer allocation by comparing modification request with current allocation and updating allocation based upon comparison discrepancy
JP3516365B2 (en) Method and apparatus for storing records in memory
JPH02116936A (en) Reorganizing system
JPS61256442A (en) Method for increasing record retrieving speed
US6032206A (en) Method of reducing access when passing data from external memory through buffer to data processor by allocating buffer portion for receiving external memory's identification data
KR100261177B1 (en) Message handling routine
JP2669241B2 (en) Migration processing method
JP3578501B2 (en) Document search method and apparatus
JP3785766B2 (en) Merge processing device

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20040113

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040116

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

Free format text: PAYMENT UNTIL: 20080130

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20090130

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20100130

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20110130

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20110130

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20120130

Year of fee payment: 8

LAPS Cancellation because of no payment of annual fees