comp.lang.ada
 help / color / mirror / Atom feed
From: kilgallen@eisner.decus.org (Larry Kilgallen)
Subject: Re: Efficient io of arbitrary binary data.
Date: 1996/09/14
Date: 1996-09-14T00:00:00+00:00	[thread overview]
Message-ID: <1996Sep14.112929.1@eisner> (raw)
In-Reply-To: 3239B3B2.1AE4@cray.com


In article <3239B3B2.1AE4@cray.com>, "Brian R. Hanson" <brh@cray.com> writes:
> I recently had to replace a merge/sort program written in terible
> fortran with a new implimentation written in c.
> 
> The data being sorted is variable length binary records.  The 
> sort reads as many records as fit into some large buffer sorts them
> and writes the sorted data to a file in large blocks.  THe blocks
> are generated so that no record spans a block and the size of the block
> is chosen to be efficiently read and written by the os.

Given that many constraints, you are bound to do some individualized
fiddling, which is the basic operational mode for C.  Such activities
are possible in Ada, but not using the higher level constructs which
make the language popular with its adherents.

> I considering how this program could be written in Ada (part of 
> an attempt to become Ada literate in an Ada hostile environment)
> I a puzzled.  The approaches which Ada seems to allow all require 
> much more copying of data as I am not allowed to return a reference
> to a slice of an array I can only return the slice itself.

Given that your input is performed in some os-specific fashion anyway
(your approach seems to indicate you would not want extra os buffering),
you could return an access to the input buffer (array) and indices for the
start and ending bytes of a particular record.  Copy the data when you
are ready to ship the record out.  Given a high-quality optimizing
compiler, a tight loop to move the bytes should not be any less efficient
than having it done by a run-time-library.

Larry Kilgallen




  reply	other threads:[~1996-09-14  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-13  0:00 Efficient io of arbitrary binary data Brian R. Hanson
1996-09-14  0:00 ` Larry Kilgallen [this message]
1996-09-14  0:00   ` Robert Dewar
1996-09-16  0:00   ` Brian Hanson
1996-09-17  0:00   ` Ted Dennison
1996-09-14  0:00 ` Larry Kilgallen
1996-09-16  0:00   ` Brian Hanson
1996-09-16  0:00     ` Stephen Leake
1996-09-16  0:00     ` Larry Kilgallen
1996-09-16  0:00     ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox