JSON interface for RPC Client [Issue #14]#109
JSON interface for RPC Client [Issue #14]#109attaluris wants to merge 6 commits intoucbrise:single-machinefrom
Conversation
|
Test FAILed. |
|
Test PASSed. |
| TEST_F(AtomicMultilogTest, AppendAndGetJSONRecordTest1) { | ||
| atomic_multilog mlog("my_table", s, "/tmp", storage::IN_MEMORY, archival_mode::OFF, MGMT_POOL); | ||
|
|
||
| std::string rec1 = "{'a':'false', 'b':'0', 'c':'0', 'd':'0', 'e':'0', 'f':'0.000000', 'g':'0.010000', 'h':'abc'}"; |
There was a problem hiding this comment.
We should also test if this syntax works -- this would be the main use-case, I don't expect users to convert it to JSON and then back to string as the test now does.
libconfluo/confluo/atomic_multilog.h
Outdated
| * @param json_data The json-formatted data to be stored | ||
| * @return The offset of where the data is located | ||
| */ | ||
| size_t append_json(std::string json_data); |
There was a problem hiding this comment.
| size_t append_json(std::string json_data); | |
| size_t append_json(const std::string &json_data); |
libconfluo/confluo/schema/schema.h
Outdated
| * | ||
| * @return A pointer to the record data | ||
| */ | ||
| void *json_string_to_data(const std::string json_record) const; |
There was a problem hiding this comment.
| void *json_string_to_data(const std::string json_record) const; | |
| void *json_string_to_data(const std::string &json_record) const; |
libconfluo/confluo/schema/schema.h
Outdated
| * | ||
| * @param record The records used for conversion | ||
| * | ||
| * @return A pointer to the record data |
There was a problem hiding this comment.
This does not return anything..
libconfluo/src/atomic_multilog.cc
Outdated
| return offset; | ||
| } | ||
|
|
||
| size_t atomic_multilog::append_json(std::string json_record) { |
There was a problem hiding this comment.
| size_t atomic_multilog::append_json(std::string json_record) { | |
| size_t atomic_multilog::append_json(const std::string &json_record) { |
libconfluo/src/schema/schema.cc
Outdated
| return str; | ||
| } | ||
|
|
||
| void *schema_t::json_string_to_data(const std::string json_record) const { |
There was a problem hiding this comment.
| void *schema_t::json_string_to_data(const std::string json_record) const { | |
| void *schema_t::json_string_to_data(const std::string &json_record) const { |
|
|
||
| std::stringstream ss; | ||
| pt::write_json(ss, root); | ||
| std::string ret = ss.str(); |
There was a problem hiding this comment.
Maybe try printing this out and use the printed string as your test input? Tests are also useful as sample usage for users.
librpc/src/rpc_server.cc
Outdated
| void rpc_service_handler::read_json(std::string &_return, int64_t id, const int64_t offset, const int64_t nrecords) { | ||
| atomic_multilog *mlog = store_->get_atomic_multilog(id); | ||
| _return = mlog->read_json((uint64_t) offset); | ||
| // TODO: put in functionality for nrecords to be read |
There was a problem hiding this comment.
Throw unsupported exception instead of incorrect functionality...
|
|
||
| std::stringstream ss; | ||
| pt::write_json(ss, root); | ||
| std::string ret = ss.str(); |
There was a problem hiding this comment.
Same thing here -- need to figure out what correct JSON string format is. We need to document it somewhere too.
|
|
||
| std::stringstream ss; | ||
| pt::write_json(ss, root); | ||
| std::string ret = ss.str(); |
| @@ -0,0 +1,299 @@ | |||
| #!/usr/bin/env python | |||
There was a problem hiding this comment.
This file should not be checked in.
There was a problem hiding this comment.
running genall.sh resulted in this; were there supposed to be no changes?
There was a problem hiding this comment.
Yes I know it generates this file, but we don't want to check it in. Ideally the genall.sh file should delete it explicitly -- I can add that change, but can you add a commit to remove the file?
There was a problem hiding this comment.
sounds good; are there any other files that shouldn't be checked in?
|
Test PASSed. |
| /** | ||
| * A json cursor that make records into a json formatted string | ||
| */ | ||
| class aggregated_json_cursor : public json_cursor { |
There was a problem hiding this comment.
Don't need any aggregation
| * @param cexpr The filter expression | ||
| * @param batch_size The number of records in the batch | ||
| */ | ||
| aggregated_json_cursor(std::unique_ptr<offset_cursor> o_cursor, |
There was a problem hiding this comment.
This should take std::unique_ptr<record_cursor> as first argument, const schema_t *as second argument (for converting record to json) and size_t batch_size as the third and last argument.
| size_t i = 0; | ||
| for (; i < current_batch_.size() && o_cursor_->has_more(); | ||
| ++i, o_cursor_->advance()) { | ||
| uint64_t o = o_cursor_->get(); |
There was a problem hiding this comment.
None of this logic will be needed; only need to convert each record in record_cursor to JSON.
fc7ecd1 to
0cce8a8
Compare
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
No description provided.