From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,29f36805b9a20fe8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-02 07:02:19 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!news-out.nuthinbutnews.com!news-in-austin.nuthinbutnews.com!feed2.newsfeeds.com!newsfeeds.com!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: <3AC64324.A79AE084@worldnet.att.net> Subject: Re: Streams in Ada Message-ID: Date: Mon, 02 Apr 2001 14:00:21 GMT NNTP-Posting-Host: 209.208.22.130 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 986220021 209.208.22.130 (Mon, 02 Apr 2001 10:00:21 EDT) NNTP-Posting-Date: Mon, 02 Apr 2001 10:00:21 EDT Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:6339 Date: 2001-04-02T14:00:21+00:00 List-Id: In article <3AC64324.A79AE084@worldnet.att.net>, James Rogers says... > >I assume from your use of the term "streams" that you want to be able >to directly address file elements. "Streams" is the C term for such >capability. Ada uses streams for a somewhat different capability. > >I believe what you want is handled by the package Ada.Direct_Io. Actually, this sounds like the exact issue we've talked about twice in the last couple of months already. You generally don't want to use Direct_IO instantiated for byte-sized objects, as there will be a call for each and every byte read, which is going to be really slow (and make your Ada code look bad). If there is only a couple of sizes to read, you might be able to get away with a separate Direct_IO instantiation for each, but there will still be a bit of waste closing one instantiation's view of the file so the other can open it and reposition to the right place. The best way to solve the problem of reading an unstructured array of bytes from a file in Ada is to use Ada.Streams.Stream_IO, along with a direct call to Ada.Streams.Read with a properly-sized array of stream elements. Didn't someone volunteer to put some example sources for doing this on AdaPower? I can post some code I have that does this, if needed. (hmmm, assuming I didn't delete it last week...) The speedup I observed in doing it this way vs. Sequential_IO was nothing less than amazing. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com