mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Include object size and hash in the table returned by the object_table function in the GlobalStateAPI. (#665)
* added log_table function and a test * fixed log_files and added task_profiles * fixed formatting * fixed linting errors * fixes * removed file * more fixes * hopefully fixed * Small changes. * Fix linting. * Fix bug in log monitor. * Small changes. * Fix bug in travis. * Including data_size and hash in the ResultTableReply. * Included data_size and hash info in object_table. * Fixed bugs in ray_redis_module.cc. * Removing commented out code. * Fixes * Freed hash and data_size strings after using, and checked if they're null along with task_id and is_put. * Changed it so that data_size is set correctly. * Removed iostream import. * Included a check to ensure that the Redis string to long long conversion was successful. * Included separate data_size and hash null checks. * Fixed bug. * Made linting changes. * Another linting error. * Slight simplication.
This commit is contained in:
parent
019ba07e9c
commit
4d5ac9dad5
3 changed files with 40 additions and 5 deletions
|
@ -150,7 +150,9 @@ class GlobalState(object):
|
|||
|
||||
result = {"ManagerIDs": manager_ids,
|
||||
"TaskID": binary_to_hex(result_table_message.TaskId()),
|
||||
"IsPut": bool(result_table_message.IsPut())}
|
||||
"IsPut": bool(result_table_message.IsPut()),
|
||||
"DataSize": result_table_message.DataSize(),
|
||||
"Hash": binary_to_hex(result_table_message.Hash())}
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
@ -136,6 +136,10 @@ table ResultTableReply {
|
|||
task_id: string;
|
||||
// Whether the task created the object through a ray.put.
|
||||
is_put: bool;
|
||||
// The size of the object created.
|
||||
data_size: long;
|
||||
// The hash of the object created.
|
||||
hash: string;
|
||||
}
|
||||
|
||||
root_type ResultTableReply;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "redismodule.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -832,9 +831,12 @@ int ResultTableLookup_RedisCommand(RedisModuleCtx *ctx,
|
|||
|
||||
RedisModuleString *task_id;
|
||||
RedisModuleString *is_put;
|
||||
RedisModuleString *data_size;
|
||||
RedisModuleString *hash;
|
||||
RedisModule_HashGet(key, REDISMODULE_HASH_CFIELDS, "task", &task_id, "is_put",
|
||||
&is_put, NULL);
|
||||
&is_put, "data_size", &data_size, "hash", &hash, NULL);
|
||||
RedisModule_CloseKey(key);
|
||||
|
||||
if (task_id == NULL || is_put == NULL) {
|
||||
return RedisModule_ReplyWithNull(ctx);
|
||||
}
|
||||
|
@ -851,8 +853,27 @@ int ResultTableLookup_RedisCommand(RedisModuleCtx *ctx,
|
|||
|
||||
/* Make and return the flatbuffer reply. */
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = CreateResultTableReply(fbb, RedisStringToFlatbuf(fbb, task_id),
|
||||
bool(is_put_integer));
|
||||
long long data_size_value;
|
||||
|
||||
if (data_size == NULL) {
|
||||
data_size_value = -1;
|
||||
} else {
|
||||
RedisModule_StringToLongLong(data_size, &data_size_value);
|
||||
CHECK(RedisModule_StringToLongLong(data_size, &data_size_value) ==
|
||||
REDISMODULE_OK);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::String> hash_str;
|
||||
if (hash == NULL) {
|
||||
hash_str = fbb.CreateString("", strlen(""));
|
||||
} else {
|
||||
hash_str = RedisStringToFlatbuf(fbb, hash);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<ResultTableReply> message =
|
||||
CreateResultTableReply(fbb, RedisStringToFlatbuf(fbb, task_id),
|
||||
bool(is_put_integer), data_size_value, hash_str);
|
||||
|
||||
fbb.Finish(message);
|
||||
RedisModuleString *reply = RedisModule_CreateString(
|
||||
ctx, (const char *) fbb.GetBufferPointer(), fbb.GetSize());
|
||||
|
@ -863,6 +884,14 @@ int ResultTableLookup_RedisCommand(RedisModuleCtx *ctx,
|
|||
RedisModule_FreeString(ctx, is_put);
|
||||
RedisModule_FreeString(ctx, task_id);
|
||||
|
||||
if (data_size != NULL) {
|
||||
RedisModule_FreeString(ctx, data_size);
|
||||
}
|
||||
|
||||
if (hash != NULL) {
|
||||
RedisModule_FreeString(ctx, hash);
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue