-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started json_cursor functionality; some fixes to json-parser function…
…ality
- Loading branch information
Showing
8 changed files
with
171 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,51 @@ | ||
#ifndef CONFLUO_CONTAINER_CURSOR_JSON_CURSOR_H_ | ||
#define CONFLUO_CONTAINER_CURSOR_JSON_CURSOR_H_ | ||
|
||
#include <unordered_set> | ||
|
||
#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 aggregated_json_cursor : public json_cursor { | ||
public: | ||
/** | ||
* Initializes the filter record | ||
* | ||
* @param o_cursor The offset cursor | ||
* @param dlog The data log pointer | ||
* @param schema The schema | ||
* @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, | ||
const data_log *dlog, const schema_t *schema, | ||
const parser::compiled_expression &cexpr, | ||
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<offset_cursor> o_cursor_; | ||
const data_log *dlog_; | ||
const schema_t *schema_; | ||
const parser::compiled_expression &cexpr_; | ||
}; | ||
|
||
} | ||
|
||
#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,33 @@ | ||
#include "container/cursor/json_cursors.h" | ||
|
||
namespace confluo { | ||
|
||
aggregated_json_cursor::aggregated_json_cursor(std::unique_ptr<offset_cursor> o_cursor, | ||
const data_log *dlog, | ||
const schema_t *schema, | ||
const parser::compiled_expression &cexpr, | ||
size_t batch_size) | ||
: json_cursor(batch_size), | ||
o_cursor_(std::move(o_cursor)), | ||
dlog_(dlog), | ||
schema_(schema), | ||
cexpr_(cexpr) { | ||
init(); | ||
} | ||
|
||
size_t aggregated_json_cursor::load_next_batch() { | ||
// TODO add functionality to make into a json_string | ||
size_t i = 0; | ||
for (; i < current_batch_.size() && o_cursor_->has_more(); | ||
++i, o_cursor_->advance()) { | ||
uint64_t o = o_cursor_->get(); | ||
read_only_data_log_ptr ptr; | ||
dlog_->cptr(o, ptr); | ||
if (!cexpr_.test(current_batch_[i] = schema_->apply(o, ptr))) { | ||
i--; | ||
} | ||
} | ||
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.