bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: merge sort temp files


From: Paul Eggert
Subject: Re: merge sort temp files
Date: Fri, 30 Jul 2004 15:43:52 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

address@hidden writes:

> I'm using sort to merge sort two very large inputs, one being from stdin.
> It's working slower than I would like because sort creates a temp file
> when stdin is an input, I think, to keep from possibly clobbering input
> files.

Yes, that's the basic idea.

> Would it be safe to put in a check that says if stdout is the output, that
> it could safely not create temp files?

I don't think so.  Consider the following somewhat-contrived example:

sort -m -o - f1 f2 1<>f1

Here standard output points to the start of the regular file "f1".
If "sort" doesn't copy f1 before writing to standard output, it
will trash its input before reading it.

> I don't understand the current behavior for stat on the output
> file.  Why when it fails does it just return nfiles?

If "sort" can't stat the output file, then it can behave as if the
output file does not exist, so it doesn't need to worry about whether
the output file overlaps one of the inputs, and it can return nfiles
(which means, please merge as much as possible).

Could you please try the following patch instead?  If it solves your
problem, we're done, as it has already been installed in CVS
coreutils.  If not, I'd like to know more about your problem, e.g., a
test case.  Thanks.

http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00076.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]