-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented json_string_cursor and corresponding multilog filters
- Loading branch information
Showing
8 changed files
with
136 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef CONFLUO_CONTAINER_CURSOR_JSON_CURSOR_H_ | ||
#define CONFLUO_CONTAINER_CURSOR_JSON_CURSOR_H_ | ||
|
||
#include <unordered_set> | ||
#include <boost/property_tree/ptree.hpp> | ||
#include <boost/property_tree/json_parser.hpp> | ||
|
||
#include "batched_cursor.h" | ||
#include "offset_cursors.h" | ||
#include "schema/record.h" | ||
#include "parser/expression_compiler.h" | ||
#include "container/data_log.h" | ||
|
||
namespace confluo { | ||
|
||
typedef batched_cursor<std::string> json_cursor; | ||
|
||
/** | ||
* A json cursor that make records into a json formatted string | ||
*/ | ||
class json_string_cursor : public json_cursor { | ||
public: | ||
/** | ||
* Initializes the filter record | ||
* | ||
* @param r_cursor The record cursor | ||
* @param schema The schema | ||
* @param batch_size The number of records in the batch | ||
*/ | ||
json_string_cursor(std::unique_ptr<record_cursor> r_cursor, const schema_t *schema, | ||
size_t batch_size = 64); | ||
|
||
/** | ||
* Loads the next batch from the cursor | ||
* | ||
* @return The size of the batch | ||
*/ | ||
virtual size_t load_next_batch() override; | ||
|
||
private: | ||
std::unique_ptr<record_cursor> r_cursor_; | ||
const schema_t *schema_; | ||
}; | ||
|
||
} | ||
|
||
#endif /* CONFLUO_CONTAINER_CURSOR_JSON_CURSOR_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "container/cursor/json_cursors.h" | ||
|
||
namespace confluo { | ||
|
||
json_string_cursor::json_string_cursor(std::unique_ptr<record_cursor> r_cursor, | ||
const schema_t *schema, | ||
size_t batch_size) | ||
: json_cursor(batch_size), | ||
r_cursor_(std::move(r_cursor)), | ||
schema_(schema) { | ||
init(); | ||
} | ||
|
||
size_t json_string_cursor::load_next_batch() { | ||
namespace pt = boost::property_tree; | ||
pt::ptree root; | ||
|
||
size_t i = 0; | ||
for (; i < current_batch_.size() && r_cursor_->has_more(); | ||
++i, r_cursor_->advance()) { | ||
record_t r = r_cursor_->get(); | ||
std::string json_rec = schema_.data_to_json_string(r.data()); | ||
current_batch_[i] = json_rec; | ||
} | ||
return i; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.