-
Notifications
You must be signed in to change notification settings - Fork 5
Serializer new model #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gshigin
wants to merge
22
commits into
pp
Choose a base branch
from
serializer-new-model
base: pp
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Serializer new model #164
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
10cf1b2
init
gshigin 1da3536
new model initial
gshigin 2a9a543
new model bench
gshigin 5a85f53
SerializedData separate class
gshigin 02619ba
update benchmark
gshigin c6f562d
interface
gshigin 74c7eac
entrypoint
gshigin 68f7513
includes fix
gshigin ea75b2e
Merge branch 'pp' into serializer-new-model
gshigin 9c5056f
entrypoint fix
gshigin ac23507
tidy fix
gshigin 110df4c
new recoder
gshigin 8346a7b
serializer new model tests update
gshigin 95585ec
Merge branch 'pp' into serializer-new-model
gshigin c7b8216
review fixes
gshigin 4930677
tests fix + coverage
gshigin 5e005fc
Merge branch 'pp' into serializer-new-model
gshigin 1e18c7c
fix
gshigin 06796b2
review fixes
gshigin 1724587
benchmark fix
gshigin a85ba25
Merge branch 'pp' into serializer-new-model
gshigin af8f150
naming fix
gshigin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,29 @@ | ||
#pragma once | ||
|
||
#include "series_data/serialization/serialized_data.h" | ||
|
||
namespace entrypoint::head { | ||
|
||
class SerializedDataGo { | ||
public: | ||
explicit SerializedDataGo(const series_data::DataStorage& storage, const series_data::querier::QueriedChunkList& queried_chunks) | ||
: data_{series_data::serialization::DataSerializer{storage}.serialize(queried_chunks)} {} | ||
|
||
[[nodiscard]] PROMPP_ALWAYS_INLINE auto get_buffer_view() const noexcept { return data_view_.get_buffer_view(); } | ||
[[nodiscard]] PROMPP_ALWAYS_INLINE auto get_chunks_view() const noexcept { return data_view_.get_chunks_view(); } | ||
|
||
[[nodiscard]] PROMPP_ALWAYS_INLINE uint32_t next() noexcept { return data_view_.next_series(); } | ||
[[nodiscard]] PROMPP_ALWAYS_INLINE auto iterator() const noexcept { return data_view_.create_current_series_iterator(); } | ||
|
||
private: | ||
series_data::serialization::SerializedData data_; | ||
series_data::serialization::SerializedDataView data_view_{data_}; | ||
}; | ||
|
||
using SerializedDataPtr = std::unique_ptr<SerializedDataGo>; | ||
using SerializedDataIteratorPtr = std::unique_ptr<series_data::serialization::SerializedDataView::SeriesIterator>; | ||
|
||
static_assert(sizeof(SerializedDataPtr) == sizeof(void*)); | ||
static_assert(sizeof(SerializedDataIteratorPtr) == sizeof(void*)); | ||
|
||
} // namespace entrypoint::head |
This file contains hidden or 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 hidden or 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 hidden or 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
68 changes: 68 additions & 0 deletions
68
pp/entrypoint/series_data_serialization_serialized_data.cpp
This file contains hidden or 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,68 @@ | ||
#include "series_data_serialization_serialized_data.h" | ||
|
||
#include "head/serialization.h" | ||
|
||
extern "C" void prompp_series_data_serialization_serialized_data_next(void* args, void* res) { | ||
struct Arguments { | ||
entrypoint::head::SerializedDataPtr serialized_data; | ||
}; | ||
|
||
using Result = struct { | ||
uint32_t series_id; | ||
}; | ||
|
||
new (res) Result{.series_id = static_cast<Arguments*>(args)->serialized_data->next()}; | ||
} | ||
|
||
extern "C" void prompp_series_data_serialization_serialized_data_iterator(void* args, void* res) { | ||
struct Arguments { | ||
entrypoint::head::SerializedDataPtr serialized_data; | ||
}; | ||
|
||
using Result = struct { | ||
entrypoint::head::SerializedDataIteratorPtr iterator; | ||
}; | ||
|
||
new (res) Result{ | ||
.iterator = std::make_unique<series_data::serialization::SerializedDataView::SeriesIterator>(static_cast<Arguments*>(args)->serialized_data->iterator())}; | ||
} | ||
|
||
extern "C" void prompp_series_data_serialization_serialized_data_iterator_next(void* args, void* res) { | ||
using series_data::decoder::DecodeIteratorSentinel; | ||
|
||
struct Arguments { | ||
entrypoint::head::SerializedDataIteratorPtr iterator; | ||
}; | ||
|
||
struct Result { | ||
int64_t timestamp{}; | ||
double value{}; | ||
bool has_value; | ||
}; | ||
|
||
const Arguments* in = static_cast<Arguments*>(args); | ||
|
||
if (*in->iterator == DecodeIteratorSentinel{}) { | ||
new (res) Result{.has_value = false}; | ||
} else { | ||
const auto sample = **(in->iterator); | ||
new (res) Result{.timestamp = sample.timestamp, .value = sample.value, .has_value = true}; | ||
++(*in->iterator); | ||
} | ||
} | ||
|
||
extern "C" void prompp_series_data_serialization_serialized_data_iterator_dtor(void* args) { | ||
struct Arguments { | ||
entrypoint::head::SerializedDataIteratorPtr iterator; | ||
}; | ||
|
||
static_cast<Arguments*>(args)->~Arguments(); | ||
} | ||
|
||
extern "C" void prompp_series_data_serialization_serialized_data_dtor(void* args) { | ||
struct Arguments { | ||
entrypoint::head::SerializedDataPtr serialized_data; | ||
}; | ||
|
||
static_cast<Arguments*>(args)->~Arguments(); | ||
} |
This file contains hidden or 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,68 @@ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Get next series_id in serialized data. | ||
* | ||
* @param args { | ||
* serializedData uintptr // pointer to serialized data. | ||
* } | ||
* | ||
* @param res { | ||
* series_id uint32 // series id (UINT32_MAX if no more series). | ||
* } | ||
*/ | ||
void prompp_series_data_serialization_serialized_data_next(void* args, void* res); | ||
|
||
/** | ||
* @brief Create a decode iterator for current series_id (returned by the last call of _next()) | ||
* | ||
* @param args { | ||
* serializedData uintptr // pointer to serialized data. | ||
* } | ||
* | ||
* @param res { | ||
* iterator uintptr // pointer to constructed decode iterator. | ||
* } | ||
*/ | ||
void prompp_series_data_serialization_serialized_data_iterator(void* args, void* res); | ||
|
||
/** | ||
* @brief Advance decode iterator. | ||
* | ||
* @param args { | ||
* iterator uintptr // pointer to decode iterator | ||
* } | ||
* | ||
* @param res { | ||
* has_data bool // is iterator has more data to decode. | ||
* timestamp int64 // sample timestamp | ||
* value float64 // sample value | ||
* } | ||
*/ | ||
void prompp_series_data_serialization_serialized_data_iterator_next(void* args, void* res); | ||
|
||
/** | ||
* @brief Destroy decode iterator. | ||
* | ||
* @param args { | ||
* iterator uintptr // pointer to decode iterator | ||
* } | ||
* | ||
*/ | ||
void prompp_series_data_serialization_serialized_data_iterator_dtor(void* args); | ||
|
||
/** | ||
* @brief Destroy serialized data object. | ||
* | ||
* @param args { | ||
* serializedData uintptr // pointer to serialized data. | ||
* } | ||
* | ||
*/ | ||
void prompp_series_data_serialization_serialized_data_dtor(void* args); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.