mirror of
https://github.com/wassname/ray.git
synced 2026-07-04 23:38:05 +08:00
Convert task_spec to flatbuffers (#255)
* convert Ray to C++ * convert task_spec to flatbuffers * fix * it compiles * latest * tests are passing * task2 -> task * fix * fix * fix * fix * fix * linting * fix valgrind * upgrade flatbuffers * use debug mode for valgrind * fix naming and comments * downgrade flatbuffers * fix linting * reintroduce TaskSpec_free * rename TaskSpec -> TaskInfo * refactoring * linting
This commit is contained in:
committed by
Robert Nishihara
parent
65a8659f3d
commit
0b8d279ef2
@@ -0,0 +1,26 @@
|
||||
#include "common_protocol.h"
|
||||
|
||||
flatbuffers::Offset<flatbuffers::String> to_flatbuf(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
ObjectID object_id) {
|
||||
return fbb.CreateString((char *) &object_id.id[0], sizeof(object_id.id));
|
||||
}
|
||||
|
||||
ObjectID from_flatbuf(const flatbuffers::String *string) {
|
||||
ObjectID object_id;
|
||||
CHECK(string->size() == sizeof(object_id.id));
|
||||
memcpy(&object_id.id[0], string->data(), sizeof(object_id.id));
|
||||
return object_id;
|
||||
}
|
||||
|
||||
flatbuffers::Offset<
|
||||
flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
to_flatbuf(flatbuffers::FlatBufferBuilder &fbb,
|
||||
ObjectID object_ids[],
|
||||
int64_t num_objects) {
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> results;
|
||||
for (size_t i = 0; i < num_objects; i++) {
|
||||
results.push_back(to_flatbuf(fbb, object_ids[i]));
|
||||
}
|
||||
return fbb.CreateVector(results);
|
||||
}
|
||||
Reference in New Issue
Block a user