Skip to content

Commit 4f0b31b

Browse files
author
DvirDukhan
committed
after rebase & format
1 parent 85cb8c6 commit 4f0b31b

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/libtorch_c/torch_extensions/torch_redis_value.h

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,40 @@
33
#include "torch/custom_class.h"
44
#include "../../redismodule.h"
55

6-
7-
8-
struct RedisValue: torch::CustomClassHolder {
9-
private:
6+
struct RedisValue : torch::CustomClassHolder {
7+
private:
108
union {
119
int intValue;
1210
std::string stringValue;
13-
std::vector<RedisValue*> arrayValue;
11+
std::vector<RedisValue *> arrayValue;
1412
};
15-
public:
13+
14+
public:
1615
RedisValue(RedisModuleCallReply *reply) {
17-
if(RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_ARRAY) {
18-
size_t len = RedisModule_CallReplyLength(reply);
19-
for(auto i = 0 ; i < len ; ++i){
20-
RedisModuleCallReply *subReply = RedisModule_CallReplyArrayElement(reply, i);
21-
RedisValue value(subReply);
22-
arrayValue.push_back(value);
16+
if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_ARRAY) {
17+
size_t len = RedisModule_CallReplyLength(reply);
18+
for (auto i = 0; i < len; ++i) {
19+
RedisModuleCallReply *subReply = RedisModule_CallReplyArrayElement(reply, i);
20+
RedisValue value(subReply);
21+
arrayValue.push_back(value);
22+
}
2323
}
24-
}
2524

26-
if(RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_STRING ||
27-
RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_ERROR){
28-
size_t len;
29-
const char* replyStr = RedisModule_CallReplyStringPtr(reply, &len);
30-
PyObject* ret = PyUnicode_FromStringAndSize(replyStr, len);
31-
if(!ret){
32-
PyErr_Clear();
33-
ret = PyByteArray_FromStringAndSize(replyStr, len);
25+
if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_STRING ||
26+
RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_ERROR) {
27+
size_t len;
28+
const char *replyStr = RedisModule_CallReplyStringPtr(reply, &len);
29+
PyObject *ret = PyUnicode_FromStringAndSize(replyStr, len);
30+
if (!ret) {
31+
PyErr_Clear();
32+
ret = PyByteArray_FromStringAndSize(replyStr, len);
33+
}
34+
return ret;
3435
}
35-
return ret;
36-
}
3736

38-
if(RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_INTEGER){
39-
long long val = RedisModule_CallReplyInteger(reply);
40-
return PyLong_FromLongLong(val);
41-
}
37+
if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_INTEGER) {
38+
long long val = RedisModule_CallReplyInteger(reply);
39+
return PyLong_FromLongLong(val);
40+
}
4241
}
43-
4442
};

0 commit comments

Comments
 (0)