-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it easy to log custom arrow data in C++ (#8880)
Co-authored-by: Clement Rey <[email protected]>
- Loading branch information
Showing
135 changed files
with
693 additions
and
960 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,56 @@ | ||
// Use `send_column` to send an entire column of custom data to Rerun. | ||
|
||
#include <rerun.hpp> | ||
|
||
#include <arrow/array/builder_primitive.h> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <numeric> | ||
|
||
arrow::Status run_main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_any_batch_value_send_columns"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
constexpr int64_t STEPS = 64; | ||
|
||
std::vector<int64_t> times(STEPS); | ||
std::iota(times.begin(), times.end(), 0); | ||
|
||
std::shared_ptr<arrow::Array> arrow_array; | ||
|
||
arrow::DoubleBuilder one_per_timestamp_builder; | ||
for (int64_t i = 0; i < STEPS; i++) { | ||
ARROW_RETURN_NOT_OK(one_per_timestamp_builder.Append(sin(static_cast<double>(i) / 10.0))); | ||
} | ||
ARROW_RETURN_NOT_OK(one_per_timestamp_builder.Finish(&arrow_array)); | ||
auto one_per_timestamp = | ||
rerun::ComponentBatch::from_arrow_array(std::move(arrow_array), "custom_component_single") | ||
.value_or_throw(); | ||
|
||
arrow::DoubleBuilder ten_per_timestamp_builder; | ||
for (int64_t i = 0; i < STEPS * 10; i++) { | ||
ARROW_RETURN_NOT_OK(ten_per_timestamp_builder.Append(cos(static_cast<double>(i) / 100.0))); | ||
} | ||
ARROW_RETURN_NOT_OK(ten_per_timestamp_builder.Finish(&arrow_array)); | ||
auto ten_per_timestamp = | ||
rerun::ComponentBatch::from_arrow_array(std::move(arrow_array), "custom_component_multi") | ||
.value_or_throw(); | ||
|
||
rec.send_columns( | ||
"/", | ||
rerun::TimeColumn::from_sequence_points("step", std::move(times)), | ||
one_per_timestamp.partitioned().value_or_throw(), | ||
ten_per_timestamp.partitioned(std::vector<uint32_t>(STEPS, 10)).value_or_throw() | ||
); | ||
|
||
return arrow::Status::OK(); | ||
} | ||
|
||
int main() { | ||
arrow::Status status = run_main(); | ||
if (!status.ok()) { | ||
printf("%s\n", status.ToString().c_str()); | ||
return 1; | ||
} | ||
return 0; | ||
} |
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,54 @@ | ||
// Use `send_column` to send entire columns of custom data to Rerun. | ||
|
||
#include <rerun.hpp> | ||
|
||
#include <arrow/array/builder_primitive.h> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <numeric> | ||
|
||
arrow::Status run_main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_any_values_send_columns"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
constexpr int64_t STEPS = 64; | ||
|
||
std::vector<int64_t> times(STEPS); | ||
std::iota(times.begin(), times.end(), 0); | ||
|
||
std::shared_ptr<arrow::Array> arrow_array; | ||
|
||
arrow::DoubleBuilder sin_builder; | ||
for (int64_t i = 0; i < STEPS; i++) { | ||
ARROW_RETURN_NOT_OK(sin_builder.Append(sin(static_cast<double>(i) / 10.0))); | ||
} | ||
ARROW_RETURN_NOT_OK(sin_builder.Finish(&arrow_array)); | ||
auto sin = | ||
rerun::ComponentBatch::from_arrow_array(std::move(arrow_array), "sin").value_or_throw(); | ||
|
||
arrow::DoubleBuilder cos_builder; | ||
for (int64_t i = 0; i < STEPS; i++) { | ||
ARROW_RETURN_NOT_OK(cos_builder.Append(cos(static_cast<double>(i) / 10.0))); | ||
} | ||
ARROW_RETURN_NOT_OK(cos_builder.Finish(&arrow_array)); | ||
auto cos = | ||
rerun::ComponentBatch::from_arrow_array(std::move(arrow_array), "cos").value_or_throw(); | ||
|
||
rec.send_columns( | ||
"/", | ||
rerun::TimeColumn::from_sequence_points("step", std::move(times)), | ||
sin.partitioned().value_or_throw(), | ||
cos.partitioned().value_or_throw() | ||
); | ||
|
||
return arrow::Status::OK(); | ||
} | ||
|
||
int main() { | ||
arrow::Status status = run_main(); | ||
if (!status.ok()) { | ||
printf("%s\n", status.ToString().c_str()); | ||
return 1; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.