> On March 23, 2016, 1:36 p.m., Zameer Manji wrote: > > I am in favor of making this change. However, it seems this patch could be > > improved because the storage layer has to now check for both `null` and > > empty collection. > > > > I think a better solution would be to change Query.Builder to be a Supplier > > of > > `ITaskQuery` instead of `TaskQuery`. The `I*` classes always return empty > > collections and never null. By doing this the storage layer can be > > simplified to > > only check for empty collections. This is also more future proof because the > > storage/query layer can never be given `null` which means the next time we > > add a > > new field to `TaskQuery` (such as image id?) we don't have to risk > > regressing on > > this behaviour. > > > > I have scanned the code and it doesn't seem to be a lot of work, it seems > > mostly > > places where there are entries like `query.getStatusesSize()` would need to > > be > > replaced with `query.getStatus().size()`. > > > > I don't feel super strong about my suggestion here so if you do object or > > if it > > does seem like a lot of work, I will just ship this change as is. > > John Sirois wrote: > I'll give it a spike and see how it works out. I will note though that > the storage layer (db) - was already doing this for 2/5 collection fields in > the TaskMapper.select. IOW: the scope here is expanding from making things > consistent to also paying down more fundamental existing debt. I'm all for > that, but I also want to call out I tried paying down that debt and then some > by eliminating I* alltogether and using a single consistent immutable model > where no collections were null, but instead empty. So this is make it nice - > but in a middling way.
The `TaskMapper.xml` does of course get cleaner, but the scheduler code gets trickier due to some I* isSet issues (https://issues.apache.org/jira/browse/AURORA-1650 https://issues.apache.org/jira/browse/AURORA-1651). See what you think. - John ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/45193/#review125102 ----------------------------------------------------------- On March 23, 2016, 10:35 a.m., John Sirois wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/45193/ > ----------------------------------------------------------- > > (Updated March 23, 2016, 10:35 a.m.) > > > Review request for Aurora, David Chung, Bill Farner, and Zameer Manji. > > > Repository: aurora > > > Description > ------- > > Previously, `null` was handled differently from an empty collection in > task queries. For the Go thrift bindings, this was problematic since > zero values in Go are useful in almost all cases and in particular in the > case of maps (used to represent sets). In these cases unset `TaskQuery` > collection parameters are serialized as empty collections (empty > maps) instead of `nil` (`null`), leading to the inability to use the > query API in any natural way. > > src/main/java/org/apache/aurora/scheduler/base/JobKeys.java > | 2 +- > src/main/java/org/apache/aurora/scheduler/base/Query.java > | 2 +- > src/main/java/org/apache/aurora/scheduler/storage/TaskStore.java > | 2 +- > src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java > | 6 ++++-- > src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml > | 6 +++--- > src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java > | 20 +++++++++++++++++--- > 6 files changed, 27 insertions(+), 11 deletions(-) > > > Diffs > ----- > > src/main/java/org/apache/aurora/scheduler/base/JobKeys.java > 8f5bf58b963ae5f76aad7dfa34bae5b9e67d6242 > src/main/java/org/apache/aurora/scheduler/base/Query.java > ee01eaa4d0230d6bf0909b6460f27a74f03240db > src/main/java/org/apache/aurora/scheduler/storage/TaskStore.java > ac0bb374842741d7ccb7a83c574a90ac156af0f9 > src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java > 231a55615abfbb483667f5f8ef71d2709fc16a88 > src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml > 684614ffc42dd6778c7675a6c2f81cb72c106c0e > > src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java > e56fed2e6c0cdb47737cf1a9b637c44c5e5b9815 > > Diff: https://reviews.apache.org/r/45193/diff/ > > > Testing > ------- > > NB: This change was broken out of https://reviews.apache.org/r/42756/ > since it stands on its own (although its slightly more awkward in the > mutable thrift world) and the case of the Go Aurora API client forces the > issue. > > Locally green: > ``` > ./build-support/jenkins/build.sh > ./src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh > ``` > > > Thanks, > > John Sirois > >