Todd Lipcon has posted comments on this change. Change subject: Add json builder utility ......................................................................
Patch Set 3: (8 comments) http://gerrit.cloudera.org:8080/#/c/7387/3/src/kudu/util/easy_json-test.cc File src/kudu/util/easy_json-test.cc: PS3, Line 92: : child["child_attr"] = 1; : ASSERT_EQ(child.value()["child_attr"].GetInt(), 1); weird, I thought the point of the allocator thing was so that all descendents shared an allocator owned by the root? or I guess you're defeating that by refcounting. Is that necessary, given the use case? http://gerrit.cloudera.org:8080/#/c/7387/3/src/kudu/util/easy_json.h File src/kudu/util/easy_json.h: PS3, Line 31: : // rapidjson::Document d; : // rapidjson::Value v; : // v.SetObject(); : // rapidjson::Value list; : // list.SetArray(); : // v.AddMember("list", list, d.GetAllocator()); : // v["list"].PushBack(rapidjson::Value().SetString("element"), d.GetAllocator()); style nit: can you indent these code examples by a couple spaces, like: // Example: // // Foo bar; // bar.baz(); // // ... so that it's a bit offset from the text? Line 41: nit: get rid of this extra space, or put a // on it Line 43: // ej["list"][0] = "element"; is this usage dangerous? eg I'm afraid it ends up resulting in code like: EasyJson d; for (const auto& tablet : tablets_) { d["tablet_ids"].PushBack(tablet->id()); } or whatever. This will work great when we test it with a non-empty list of tablets, but then when tablets_ is empty, we'll end up with a missing field going into the template instead of an empty array, whereas I would have expected an empty array to indicate no data. So, I think we're better off forcing people to do an explicit 'SetArray' or 'SetObject'. Line 62: EasyJson& SetObject(); not quite sure how to use these PS3, Line 53: EasyJson Get(const std::string& key); : EasyJson Get(int index); : : EasyJson operator[](const std::string& key); : EasyJson operator[](int index); : : template<typename T> : EasyJson& operator=(T val); : : EasyJson& SetObject(); : EasyJson& SetArray(); : template<typename T> : EasyJson Set(const std::string& key, T val); : template<typename T> : EasyJson Set(int index, T val); : template<typename T> : EasyJson PushBack(T val); : : rapidjson::Value& value() const; need docs on all these methods PS3, Line 74: amongst "among" Line 86: rapidjson::Value value_; hm, what's this top-level value for? isn't that already stored in the top-level EasyJson object? -- To view, visit http://gerrit.cloudera.org:8080/7387 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie195b06c5ba67af3043d2032c56b90c1a85f641a Gerrit-PatchSet: 3 Gerrit-Project: kudu Gerrit-Branch: master Gerrit-Owner: Sam Okrent <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Dan Burkert <[email protected]> Gerrit-Reviewer: Kudu Jenkins Gerrit-Reviewer: Sam Okrent <[email protected]> Gerrit-Reviewer: Tidy Bot Gerrit-Reviewer: Todd Lipcon <[email protected]> Gerrit-HasComments: Yes
