[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16488425#comment-16488425 ] Raghu Angadi commented on BEAM-2980: Is there a pointer to rationale for existence of {{isEmpty()}}? > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16487985#comment-16487985 ] Kenneth Knowles commented on BEAM-2980: --- I can dig that perspective, too. The issue hitting users is probably that "current" isn't as obvious to them. Unfortunately I don't see a good transcript anywhere of the conversation between the options of "XYZState is always a changing view of an underlying ref cell" versus having a future-like API. It does see that the utility of readLater() is tied to a particular implementation strategy wherein local changes are buffered separately from whatever is read because of the hint. TBH I just think futures are simpler. But I see that you'd need to refactor bits of the API, for prefetching hint methods to cause futures to be delivered elsewhere, versus imperative readLater() calls in the prefetch methods. > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16487964#comment-16487964 ] Ben Chambers commented on BEAM-2980: I think `StateFuture` was considered, but intentionally not used because it would generally suggest we snapshot the value from the time the future is created. The intuition behind `ReadableState` should be it is like a ref-cell. As a reference, when you `read` it you get the current value stored in the location it references. > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16484501#comment-16484501 ] Kenneth Knowles commented on BEAM-2980: --- Hmm, yes it is subtle. I think that we have a minor problem because we don't clearly distinguish between handles to mutable locations and the immutable (future) values therein. I would annotate like so: {code:java} BagState myBag = // a handle to a mutable bag ReadableState isMyBagEmpty = myBag.isEmpty(); // a future value of isEmpty as of this program location readResultBefore = myBag.read(); // the contents of the bag at this program location (empty) myBag.add(bizzle); // the bag now contains bizzle readResultAfter = myBag.read(); // the contents of the bag at this program location (bizzle) bool createBeforeReadAfter = isMyBagEmpty.read() // the future value from above {code} But I don't actually like my answer. I really don't like that BagState implements ReadableState! We made this terminology up to make it "easier" but it means that there is no explicit future value for the contents of the bag. Here is what it would be if we just abandoned ReadableState and went with StateFuture (deliberately avoiding JDK class names) {code:java} BagState myBag = // a handle to a mutable bag StateFuture isMyBagEmpty = myBag.isEmpty(); // a future value of isEmpty as of this program location StateFuture> contentsFuture = myBag.conents(); // an immutable future value as of this program location myBag.add(bizzle); // the bag now contains bizzle readResultBefore = contentsFuture.read(); // the resolved future value (empty) readResultAfter = myBag.contents().read(); // the actual contents of the bag at this program location (bizzle) bool createBeforeReadAfter = isMyBagEmpty.read() // the future value from above (true, it is empty) {code} > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16484480#comment-16484480 ] Robert Bradshaw commented on BEAM-2980: --- This seems a bit more subtle. Given BagState myBag = // empty ReadableState isMyBagEmpty = myBag.isEmpty(); readResultBefore = myBag.read(); myBag.add(bizzle); readResultAfter = myBag.read(); bool createBeforeReadAfter = isMyBagEmpty.read() I think it makes a lot of sense for readResultAfter to contain bizzle, but the question is whether createBeforeReadAfter is True or False. > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16387298#comment-16387298 ] Kenneth Knowles commented on BEAM-2980: --- Since you also have BEAM-2975, are these resolved adequately [~mil...@google.com]? > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Daniel Mills >Priority: Major > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16176570#comment-16176570 ] Kenneth Knowles commented on BEAM-2980: --- Yea, it actually came up because the tests added for BEAM-2975 enforce that {{isEmpty()}} does *not* take a snapshot. https://github.com/apache/beam/blob/master/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java#L1991 > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Kenneth Knowles > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (BEAM-2980) BagState.isEmpty needs a tighter spec
[ https://issues.apache.org/jira/browse/BEAM-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16176119#comment-16176119 ] Aljoscha Krettek commented on BEAM-2980: I think this is a more specific version of BEAM-2975. > BagState.isEmpty needs a tighter spec > - > > Key: BEAM-2980 > URL: https://issues.apache.org/jira/browse/BEAM-2980 > Project: Beam > Issue Type: Bug > Components: beam-model >Reporter: Kenneth Knowles >Assignee: Kenneth Knowles > > Consider the following: > {code} > BagState myBag = // empty > ReadableState isMyBagEmpty = myBag.isEmpty(); > myBag.add(bizzle); > bool empty = isMyBagEmpty.read(); > {code} > Should {{empty}} be true or false? We need a consistent answer, across all > kinds of state, when snapshots are required. -- This message was sent by Atlassian JIRA (v6.4.14#64029)