Skip to main content

JoinEncodedWithMeta.h File

Stage executor to join encoded payload with metadata into a Bundle. More...

Included Headers

#include "graph/StageExecutor.h" #include "graph/nodes/StageNode.h" #include <cstddef> #include <cstdint> #include <deque> #include <memory> #include <string> #include <unordered_map> #include <utility> #include <vector>

Namespaces Index

namespacesimaai
namespaceneat
namespacegraph
namespacenodes

Classes Index

structJoinEncodedWithMetaOptions
classJoinEncodedWithMeta

Description

Stage executor to join encoded payload with metadata into a Bundle.

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
10
11#include <cstddef>
12#include <cstdint>
13#include <deque>
14#include <memory>
15#include <string>
16#include <unordered_map>
17#include <utility>
18#include <vector>
19
21
23 // Optional: explicitly mark which input port carries encoded data.
24 PortId encoded_port = kInvalidPort;
25 // Optional: PortId -> name map for bundle field names.
26 std::unordered_map<PortId, std::string> port_names;
27 // Fallback name when encoded detection is implicit.
28 std::string encoded_name = "encoded";
29 // Max number of pending keys to hold before eviction.
30 std::size_t max_pending = 1024;
31 // Emit a bundle even if some meta inputs are missing.
32 bool emit_partial = true;
33};
34
36public:
38
39 void set_ports(const StagePorts& ports) override;
40 void on_input(StageMsg&& msg, std::vector<StageOutMsg>& out) override;
41 void on_tick(std::int64_t now_ns, std::vector<StageOutMsg>& out) override;
42
43private:
44 std::string make_key_(const Sample& sample) const;
45 bool is_encoded_(PortId port, const Sample& sample) const;
46 std::string field_name_(PortId port, const Sample& sample, bool encoded) const;
47 void evict_if_needed_();
48
50 std::unordered_map<std::string, std::unordered_map<PortId, Sample>> pending_;
51 std::deque<std::string> order_;
52 PortId out_port_ = kInvalidPort;
53};
54
55// Convenience: wrap JoinEncodedWithMeta in a StageNode.
56std::shared_ptr<simaai::neat::graph::Node> JoinEncodedWithMetaNode(std::vector<std::string> inputs,
57 std::string label = {},
58 std::string output = "bundle");
59
60} // namespace simaai::neat::graph::nodes

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.