-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a303e9
commit 473e849
Showing
4 changed files
with
226 additions
and
77 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
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,80 @@ | ||
--- | ||
layout: center | ||
--- | ||
|
||
Appendix | ||
|
||
--- | ||
section: Data Serialization | ||
slide: Serializing User-Defined Types - Implementation | ||
--- | ||
|
||
```cpp {1-3,14-17|5-10} {lines:true} | ||
class object final { | ||
public: | ||
explicit object(std::string arg_name) : name(std::move(arg_name)), _v() {} | ||
|
||
template <typename T> | ||
object& add(std::string&& key, T&& value) { | ||
using type = typename std::remove_cv<typename std::remove_reference<T>::type>::type; | ||
_v.emplace(std::move(key), serializer<type>().serialize(std::forward<T>(value))); | ||
return *this; | ||
} | ||
|
||
/** ... */ | ||
|
||
private: | ||
std::string name; | ||
std::map<std::string, data_point> _v; | ||
} | ||
``` | ||
--- | ||
section: Data Submission | ||
slide: Serializing Test Cases | ||
--- | ||
```cpp {|4-7} | ||
std::vector<uint8_t> Testcase::serialize(const std::vector<Testcase>& testcases) { | ||
flatbuffers::FlatBufferBuilder builder; | ||
std::vector<flatbuffers::Offset<fbs::MessageBuffer>> messageBuffers; | ||
for (const auto& tc : testcases) { | ||
const auto& out = tc.flatbuffers(); | ||
messageBuffers.push_back(fbs::CreateMessageBufferDirect(builder, &out)); | ||
} | ||
const auto& messages = fbs::CreateMessagesDirect(builder, &messageBuffers); | ||
builder.Finish(messages); | ||
const auto& ptr = builder.GetBufferPointer(); | ||
return {ptr, ptr + builder.GetSize()}; | ||
} | ||
``` | ||
|
||
--- | ||
section: Data Submission | ||
slide: Serializing Data Points | ||
--- | ||
|
||
<div class="space-y-2 wsl-code-text-sm wsl-code-p-sm"> | ||
|
||
```cpp {|6} | ||
std::vector<uint8_t> Testcase::flatbuffers() const { | ||
/** ... */ | ||
std::vector<flatbuffers::Offset<fbs::Result>> fbsResultEntries; | ||
for (const auto& result : _resultsMap) { | ||
const auto& key = result.first.c_str(); | ||
const auto& value = result.second.val.serialize(builder); | ||
fbsResultEntries.push_back(fbs::CreateResultDirect(builder, key, value)); | ||
} | ||
/** ... */ | ||
} | ||
``` | ||
|
||
```cpp {|3} | ||
flatbuffers::Offset<fbs::TypeWrapper> data_point::serialize( | ||
flatbuffers::FlatBufferBuilder& builder) const { | ||
return touca::detail::visit(data_point_serializer_visitor(builder), _value); | ||
} | ||
) | ||
``` | ||
|
||
</div> |
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 |
---|---|---|
|
@@ -89,3 +89,8 @@ layout: center | |
</div> | ||
</div> | ||
</div> | ||
|
||
--- | ||
src: ./pages/07_appendix.md | ||
sectionDefault: '' | ||
--- |