You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/07/07 06:08:11 UTC

[jira] [Commented] (BEAM-381) OffsetBasedReader should construct sources before updating the range tracker

    [ https://issues.apache.org/jira/browse/BEAM-381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15365666#comment-15365666 ] 

ASF GitHub Bot commented on BEAM-381:
-------------------------------------

GitHub user dhalperi opened a pull request:

    https://github.com/apache/incubator-beam/pull/600

    [BEAM-381] BoundedReader: update the range last of all

    Reorders the code in some splitAtFraction calls so that the rangeTracker update
    is the last thing (besides assignment) in the function. This avoids a potential
    issue if creating the primary or residual sources happens to throw an exception.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dhalperi/incubator-beam offsetbasedreader

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-beam/pull/600.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #600
    
----
commit 489432a3ce31aa3c769834920841c7a1df298720
Author: Dan Halperin <dh...@google.com>
Date:   2016-07-07T06:05:56Z

    [BEAM-381] BoundedReader: update the range last of all
    
    Reorders the code in some splitAtFraction calls so that the rangeTracker update
    is the last thing (besides assignment) in the function. This avoids a potential
    issue if creating the primary or residual sources happens to throw an exception.

----


> OffsetBasedReader should construct sources before updating the range tracker
> ----------------------------------------------------------------------------
>
>                 Key: BEAM-381
>                 URL: https://issues.apache.org/jira/browse/BEAM-381
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>    Affects Versions: 0.1.0-incubating, 0.2.0-incubating
>            Reporter: Daniel Halperin
>            Assignee: Daniel Halperin
>
> OffsetBasedReader has the following code:
> {code}
>       if (!rangeTracker.trySplitAtPosition(splitOffset)) {
>         return null;
>       }
>       long start = source.getStartOffset();
>       long end = source.getEndOffset();
>       OffsetBasedSource<T> primary = source.createSourceForSubrange(start, splitOffset);
>       OffsetBasedSource<T> residual = source.createSourceForSubrange(splitOffset, end);
>       this.source = primary;
>       return residual;
> {code}
> The first line is the line that updates the range of this source. However, subsequent lines might throw (specifically, in source.createSourceForSubrange). We should construct the sources first, and then catch exceptions and return null if they fail. This way, the splitAtFraction call will not throw (so work is not wasted) and the range tracker will not be updated if either the primary or (more likely) the residual could not be created.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)