You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Sean Owen (JIRA)" <ji...@apache.org> on 2009/09/09 11:37:58 UTC

[jira] Created: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Use IOUtils, FileLineIterable/Iterator across the project
---------------------------------------------------------

                 Key: MAHOUT-175
                 URL: https://issues.apache.org/jira/browse/MAHOUT-175
             Project: Mahout
          Issue Type: Improvement
    Affects Versions: 0.2
            Reporter: Sean Owen
            Assignee: Sean Owen
            Priority: Minor
             Fix For: 0.2
         Attachments: MAHOUT-175.patch

The patch I will attach does a couple things:

Uses FileLineIterable/Iterator for iterating over lines of a file. This is slightly tidier, but also addresses a few subtle issues across the code base, where reading of files did not always end by closing the stream, or, relied on platform default character encoding.

Uses IOUtils consistently to close Closeables, swallowing and logging exceptions in cases where they are not to be treated as errors.

Finally, fixes some issues in ARFFIterator while I'm at it -- hasNext() changes state, when next() should, and next() did not throw NoSuchElementException

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Sean Owen <sr...@gmail.com>.
Not sure I really highlighted the punchline, reason it might ever
matter -- if you have more than one Closeable to close() in a block,
you probably need to do something like this. If the first one fails to
close, you miss closing the second. Unless you write some funky nested
finally blocks and such.

On Wed, Sep 9, 2009 at 5:37 PM, Sean Owen<sr...@gmail.com> wrote:
> That's 7 lines I don't need to repeat all over the place. It came in
> very handy to convert 3x7 = 21 such lines into 1 since a JDBC call
> involves 3 closeable things -- Connection, Statement, ResultSet. This
> is for the common case that some failure on closing something you're
> done reading is... noteworthy but probably not a reason to just stop
> immediately with an exception.
>

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Ted Dunning <te...@gmail.com>.
Cool.  It just suddenly sounded like finalizers were creeping in with the
assumption that they would handle closing files.

On Wed, Sep 9, 2009 at 9:37 AM, Sean Owen <sr...@gmail.com> wrote:

> It just packs up this...
> ...
> That's 7 lines I don't need to repeat all over the place.
>



-- 
Ted Dunning, CTO
DeepDyve

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Sean Owen <sr...@gmail.com>.
It just packs up this...

if (closeable != null) {
  try {
    closeable.close();
  } catch (IOException ioe) {
    log.warning(ioe);
  }
}

That's 7 lines I don't need to repeat all over the place. It came in
very handy to convert 3x7 = 21 such lines into 1 since a JDBC call
involves 3 closeable things -- Connection, Statement, ResultSet. This
is for the common case that some failure on closing something you're
done reading is... noteworthy but probably not a reason to just stop
immediately with an exception.

I didn't change any such calls where it seemed plausible that one
would definitely want to stop. Like unit tests.

On Wed, Sep 9, 2009 at 5:33 PM, Ted Dunning<te...@gmail.com> wrote:
> How does IOUtils do this?
>
> On Wed, Sep 9, 2009 at 2:37 AM, Sean Owen (JIRA) <ji...@apache.org> wrote:
>
>> > Uses IOUtils consistently to close Closeables,
>>
>
>
>
> --
> Ted Dunning, CTO
> DeepDyve
>

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Ted Dunning <te...@gmail.com>.
How does IOUtils do this?

On Wed, Sep 9, 2009 at 2:37 AM, Sean Owen (JIRA) <ji...@apache.org> wrote:

> > Uses IOUtils consistently to close Closeables,
>



-- 
Ted Dunning, CTO
DeepDyve

[jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Owen updated MAHOUT-175:
-----------------------------

    Attachment: MAHOUT-175.patch

> Use IOUtils, FileLineIterable/Iterator across the project
> ---------------------------------------------------------
>
>                 Key: MAHOUT-175
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-175
>             Project: Mahout
>          Issue Type: Improvement
>    Affects Versions: 0.2
>            Reporter: Sean Owen
>            Assignee: Sean Owen
>            Priority: Minor
>             Fix For: 0.2
>
>         Attachments: MAHOUT-175.patch
>
>
> The patch I will attach does a couple things:
> Uses FileLineIterable/Iterator for iterating over lines of a file. This is slightly tidier, but also addresses a few subtle issues across the code base, where reading of files did not always end by closing the stream, or, relied on platform default character encoding.
> Uses IOUtils consistently to close Closeables, swallowing and logging exceptions in cases where they are not to be treated as errors.
> Finally, fixes some issues in ARFFIterator while I'm at it -- hasNext() changes state, when next() should, and next() did not throw NoSuchElementException

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Owen resolved MAHOUT-175.
------------------------------

    Resolution: Fixed

> Use IOUtils, FileLineIterable/Iterator across the project
> ---------------------------------------------------------
>
>                 Key: MAHOUT-175
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-175
>             Project: Mahout
>          Issue Type: Improvement
>    Affects Versions: 0.2
>            Reporter: Sean Owen
>            Assignee: Sean Owen
>            Priority: Minor
>             Fix For: 0.2
>
>         Attachments: MAHOUT-175.patch
>
>
> The patch I will attach does a couple things:
> Uses FileLineIterable/Iterator for iterating over lines of a file. This is slightly tidier, but also addresses a few subtle issues across the code base, where reading of files did not always end by closing the stream, or, relied on platform default character encoding.
> Uses IOUtils consistently to close Closeables, swallowing and logging exceptions in cases where they are not to be treated as errors.
> Finally, fixes some issues in ARFFIterator while I'm at it -- hasNext() changes state, when next() should, and next() did not throw NoSuchElementException

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.