in glean/rts/query.cpp [447:501]
std::unique_ptr<QueryResults> restartQuery(
Inventory& inventory,
Define& facts,
DefineOwnership* ownership,
folly::Optional<uint64_t> maxResults,
folly::Optional<uint64_t> maxBytes,
folly::Optional<uint64_t> maxTime,
Depth depth,
std::unordered_set<Pid, folly::hasher<Pid>>& expandPids,
bool wantStats,
void* serializedCont,
uint64_t serializedContLen) {
thrift::internal::QueryCont queryCont;
// Deserialize the continuation into thrift::internal::QueryCont
using namespace apache::thrift;
Serializer<BinaryProtocolReader, BinaryProtocolWriter>::deserialize(
folly::ByteRange(
reinterpret_cast<unsigned char*>(serializedCont), serializedContLen),
queryCont);
// Build a Subroutine
uint64_t* code = reinterpret_cast<uint64_t*>(
const_cast<char*>(queryCont.sub()->code()->data()));
auto code_size = queryCont.sub()->code()->size() / sizeof(uint64_t);
Subroutine sub{std::vector<uint64_t>(code, code + code_size),
static_cast<size_t>(*queryCont.sub()->inputs()),
queryCont.outputs()->size(),
static_cast<size_t>(queryCont.sub()->locals()->size()),
{}, // no constants - they're already on the stack
std::move(*queryCont.sub()->literals())};
std::shared_ptr<Subroutine> traverse;
if (queryCont.traverse().has_value()) {
traverse = Subroutine::fromThrift(*queryCont.traverse());
}
// Setup the state as it was before, and execute the Subroutine
auto pid = Pid::fromWord(*queryCont.pid());
return executeQuery(
inventory,
facts,
ownership,
sub,
pid,
traverse,
maxResults,
maxBytes,
maxTime,
depth,
expandPids,
wantStats,
std::move(queryCont));
}