[m-rev.] for review: allow reporting of statistics to a stream for Java

Julien Fischer jfischer at opturion.com
Tue Mar 23 12:15:58 AEDT 2021


Hi Zoltan,

On Tue, 23 Mar 2021, Zoltan Somogyi wrote:

>
> On Tue, 23 Mar 2021 10:59:38 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
>> - we need to decide how I/O errors that occur when reporting statistics
>> are handled (see XXXs below).
>
> Agreed, though I have no idea how Java programmers
> generally handle such errors.

It's not really a Java issue per se, it boils down to:

    What is the specified behaviour, if any, of the report_stats family of
    predicates when there is an I/O error?

There is (obviously) a wider scope for such errors now that we allow
user supplied file streams.

The obvious choices are:

    1. Ignore it.

    2. Propagate the error back to the Mercury level and throw a Mercury
    exception (e.g. as io.write_string and friends do).

My preference would be for (2).

>> - the C implementation does not update the line number counter
>> associated with the (Mercury) stream.
>
> I am not sure streams *had* line number counters when that code
> was written :-(

They almost certainly didn't.

> Will you fix this, or should I?

I will take a look at it.

> BTW, the C# and Java implementations do not seem to update
> the line counter either.

Correct, the existing implementations do not update it; all of them
just write directly to stderr (or stdout in the case of C#).

The new Java version uses the write() method of the MR_TextOutputFile
class and that does update the line number counter.

>> - it would be nice to have a version of the statistics reporting code
>> that prints a user specified prefix at the beginning of each line.
>
> Agreed.
>
> The names of the predicates that did this would need to be different
> from the current ones, because otherwise we would have e.g.
> two different report_standard_stats/3 predicates: one in which
> the first arg is a stream, and one in which it is this prefix string.
> We could add  "_with_prefix" to the relevant predicate names as a suffix.

"_with_prefix" is fine by me.

Julien.


More information about the reviews mailing list