mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Park" <mp...@apache.org>
Subject Re: Review Request 41593: Added `jsonify` function to stout.
Date Fri, 08 Jan 2016 04:50:44 GMT


> On Jan. 7, 2016, 10:25 a.m., Alexander Rukletsov wrote:
> > 3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp, lines 97-99
> > <https://reviews.apache.org/r/41593/diff/14/?file=1181766#file1181766line97>
> >
> >     Why this behaviour? I would expect if `set()` is not called, nothing is printed.
If a field is optional, I can imagine some cases treating the absence of a value differently
to `false`, effectively implementing tribool logic.
> >     
> >     Or am I understanding the workflow wrong?

This behavior is consistent with other writers such as `ArrayWriter` where not calling `append`
results in `[]`. The provided expectation is that a writer will always write something. If
a field is optional and therefore we want to omit writing under certain conditions, the pattern
is to not invoke the `write` at all.

For exmaple,
```cpp
 190   // Omit pid for http frameworks.
 191   if (framework.pid.isSome()) {
 192     writer->field("pid", string(framework.pid.get()));
 193   }
```

Does this seem reasonable?


- Michael


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/41593/#review113230
-----------------------------------------------------------


On Jan. 8, 2016, 4:47 a.m., Michael Park wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/41593/
> -----------------------------------------------------------
> 
> (Updated Jan. 8, 2016, 4:47 a.m.)
> 
> 
> Review request for mesos and Benjamin Hindman.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/Makefile.am 5ab7bc4966fe32eaddd573a4dbfd997f98b5d481

>   3rdparty/libprocess/3rdparty/stout/README.md a2a3dc6120b10c8fe82088b9f0ebecfa5642f945

>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am b2dea9b93adfa3ea0415a0b5c81a369dd29b6cfe

>   3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp 98ea47794b3a7c99b3cbd2418ba6e36eb5951259

>   3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt 62ad461eb228b688f1ceac16cfb003561ed5a806

>   3rdparty/libprocess/3rdparty/stout/tests/jsonify_tests.cpp PRE-CREATION 
>   3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp bf2a2b8a9f67c6a4cf66b156b9c14fae015a8af0

> 
> Diff: https://reviews.apache.org/r/41593/diff/
> 
> 
> Testing
> -------
> 
> Added tests to `<stout/jsonify_tests.cpp>`
> 
> 
> Thanks,
> 
> Michael Park
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message