COBOL 数据缓冲,无需逐个字符移动

发布于 2024-11-09 15:12:32 字数 273 浏览 0 评论 0原文

我正在读取一个可变长度输入文件,并想要创建一个不会逐个字符移动的输出缓冲区(索引表)。

例如:我的第一个输入记录是 79 个字符,然后我可以将其移动到表的组级别。我的第二个输入记录是 101 个字符 - 我如何获取这 101 个字符并将它们放入我的表中,从位置 80 开始,长度为 101 ?下一个输入记录从位置 180 开始......等等。我们目前执行的是 1 乘 1 变化,但与块移动到起始地址相比,这是令人难以置信的 CPU 密集型。

我们每天都会这样做数百万次,找到一个解决方案将非常有用。

I am reading a variable length input file and wanting to create an output buffer (indexed table) that will not utilize a character by character move.

For example: my first input record is 79 characters, I can then move this to my group level of the table. My second input record is 101 characters -- how can I take these 101 characters and place them in my table beginning at position 80 for a length of 101 ? And the next input record beginning at position 180.....etc. We currently Perform Varying 1 by 1 but this is incredibly CPU intensive compared to a block move to a beginning address.

We do this millions of times a day and a solution would be quite useful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

城歌 2024-11-16 15:12:33

使用记录中长度的参考修改。考虑一下:

01 Record
  05 Rec-LL  Pic S9(4) Binary.
  05 Rec-Data Pic X(32767).
01 Tgt-Area Pic X(10000000).
01 Curr-Ptr   Pic S9(8) Binary.

一旦您阅读了记录,您就可以根据长度移动,如下所示:

   Move 1 to Curr-Ptr
   Perform Get-Next-Record
   Perform until no-more-data
      Move Rec-Data (1:Rec-LL) to Tgt-Area (curr-ptr:rec-LL)
      Compute Curr-Ptr = Curr-Ptr + Rec-LL
      Perform Get-Next-Record
   End-Perform

Use reference modification with the length from your record. Consider:

01 Record
  05 Rec-LL  Pic S9(4) Binary.
  05 Rec-Data Pic X(32767).
01 Tgt-Area Pic X(10000000).
01 Curr-Ptr   Pic S9(8) Binary.

Once you read your record, you can move based on the length like so:

   Move 1 to Curr-Ptr
   Perform Get-Next-Record
   Perform until no-more-data
      Move Rec-Data (1:Rec-LL) to Tgt-Area (curr-ptr:rec-LL)
      Compute Curr-Ptr = Curr-Ptr + Rec-LL
      Perform Get-Next-Record
   End-Perform
硬不硬你别怂 2024-11-16 15:12:33

或者老式的(我们在这里谈论 COBOL 所以老式 = 侏罗纪)方式:-

    01 Record.
       05 REC-LL           PIC S9(4) Binary.
       05 REC-DATA.
          10  REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.

    01 TARGET-AREA.
       05 TARGET-HEADER       PIC X(79).
       05 TARGET-REC          PIC X(101) OCCURS 50 TIMES.

    01 TGT-INDEX              PIC S9(8) BINARY VALUE 1.

   *  Length calculation happens by magic!

       Perform Read-Record.
       move REC-DATA TO TARGET-HEADER.
       perform until no-more-data 
           Perform Read-Record
           move REC-DATA to TARGET-RED(TGT-INDEX)
           add +1 to TGT-INDEX
       end-perform

或者如果记录确实在 1 到 101 字节之间变化:

    01 Record.
       05 REC-LL           PIC S9(4) Binary.
       05 REC-DATA.
          10  REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.

    01 TARGET-AREA.
       05 TGT-LL              PIC s9(8) BINARY.
       05 TGT-REC.
          10  TGX-BYTE        OCCURS 3175 depending on TGT-LL.
       05 TGT-EXTRA           PIC X(101). 




       Perform Read-Record.
       Move +0 to tgt-LL.
       perform until no-more-data
           MOVE REC-DATE to TGT-EXTRA
           ADD REC-LL TO TGT-LL
           Perform Read-Record
           add +1 to TGT-INDEX
       end-perform

Or the old fashioned ( we are talking COBOL here so old fashioned = Jurassic) way:-

    01 Record.
       05 REC-LL           PIC S9(4) Binary.
       05 REC-DATA.
          10  REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.

    01 TARGET-AREA.
       05 TARGET-HEADER       PIC X(79).
       05 TARGET-REC          PIC X(101) OCCURS 50 TIMES.

    01 TGT-INDEX              PIC S9(8) BINARY VALUE 1.

   *  Length calculation happens by magic!

       Perform Read-Record.
       move REC-DATA TO TARGET-HEADER.
       perform until no-more-data 
           Perform Read-Record
           move REC-DATA to TARGET-RED(TGT-INDEX)
           add +1 to TGT-INDEX
       end-perform

Or if records really vary between 1 and 101 bytes:

    01 Record.
       05 REC-LL           PIC S9(4) Binary.
       05 REC-DATA.
          10  REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.

    01 TARGET-AREA.
       05 TGT-LL              PIC s9(8) BINARY.
       05 TGT-REC.
          10  TGX-BYTE        OCCURS 3175 depending on TGT-LL.
       05 TGT-EXTRA           PIC X(101). 




       Perform Read-Record.
       Move +0 to tgt-LL.
       perform until no-more-data
           MOVE REC-DATE to TGT-EXTRA
           ADD REC-LL TO TGT-LL
           Perform Read-Record
           add +1 to TGT-INDEX
       end-perform
来世叙缘 2024-11-16 15:12:33

看一下 STRING INTO 动词,特别是 WITH POINTER 子句。像这样将事情串在一起时,不要忘记 ON OVERFLOW 命令。

有关详细信息,请获取 Gary Cutler 的 OpenCOBOL 程序员指南的副本。

http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf

这是一本世界级的 COBOL 手册,并且是一个开放且免费的文档 (GNU FDL)。

Take a look at the STRING INTO verb, in particular the WITH POINTER clause. Don't forget the ON OVERFLOW imperative when stringing things together like this.

For details, grab a copy of Gary Cutler's OpenCOBOL Programmer's Guide.

http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf

This is a world class COBOL manual, and it's an open and free document (GNU FDL).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文