15#include <jaffarCommon/exceptions.hpp>
16#include <jaffarCommon/json.hpp>
26__INLINE__ std::string
getType(
const nlohmann::json& config) {
return jaffarCommon::json::getString(config,
"Type"); }
35__INLINE__ std::shared_ptr<void>
createSharedBacking(
const nlohmann::json& config,
const uint32_t numShards)
37 if (
getType(config) ==
"Trie")
return std::make_shared<SequenceInputTrie>(numShards);
46 if (backing ==
nullptr)
return 0;
55 if (backing ==
nullptr)
return 0;
63 if (backing ==
nullptr)
return false;
75__INLINE__ std::unique_ptr<InputHistory>
create(
const nlohmann::json& config,
const uint32_t maxInputIndex,
const uint32_t numShards,
const uint32_t shardId,
76 const std::shared_ptr<void>& backing)
80 const auto type = jaffarCommon::json::popString(cfg,
"Type");
81 std::unique_ptr<InputHistory> result;
83 result = std::make_unique<InputHistoryNone>();
84 else if (type ==
"Raw")
85 result = std::make_unique<InputHistoryRaw>(maxInputIndex, jaffarCommon::json::popNumber<uint32_t>(cfg,
"Max Size"));
86 else if (type ==
"Trie")
87 result = std::make_unique<InputHistoryTrie>(
static_cast<SequenceInputTrie*
>(backing.get()), shardId, numShards - 1, maxInputIndex,
88 jaffarCommon::json::popNumber<uint32_t>(cfg,
"Max Size"));
90 JAFFAR_THROW_LOGIC(
"Unrecognized 'Store Input History' Type: '%s' (expected None, Raw or Trie)", type.c_str());
91 jaffarCommon::json::checkEmpty(cfg,
"Runner Configuration > Store Input History");
size_t getSharedBackingMaxMemoryBytes(const std::shared_ptr< void > &backing)
Hard upper bound (bytes) on the shared backing's memory: the trie's node-storage ceiling for the "Tri...
size_t getSharedBackingApproxMemoryBytes(const std::shared_ptr< void > &backing)
Current (approximate) live memory of the shared backing: the trie's node-storage footprint for the "T...
bool isSharedBackingExhausted(const std::shared_ptr< void > &backing)
True if the shared backing (the trie) has hit its hard node-storage ceiling.
std::shared_ptr< void > createSharedBacking(const nlohmann::json &config, const uint32_t numShards)
Creates the shared backing for the configured strategy (the trie for "Trie"; nullptr otherwise).
std::string getType(const nlohmann::json &config)
The configured strategy name ("None" | "Raw" | "Trie").
std::unique_ptr< InputHistory > create(const nlohmann::json &config, const uint32_t maxInputIndex, const uint32_t numShards, const uint32_t shardId, const std::shared_ptr< void > &backing)
Creates one runner's input-history instance bound to backing.
Input-history strategy that records nothing but the step counter.
Input-history strategy that stores the full bit-packed input sequence in every state.
Input-history strategy that stores each state's path as a single node id into a shared,...
jaffarCommon::sequenceTrie::SequenceTrie< uint16_t > SequenceInputTrie
The shared trie type backing every InputHistoryTrie instance of one search.
Abstract interface for how a search remembers the sequence of inputs ("path") that produced each stat...