Skip to content

Commit 031529d

Browse files
committed
address review comment
1 parent a863e81 commit 031529d

1 file changed

Lines changed: 8 additions & 29 deletions

File tree

coord/src/dist_aggregate.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void netCursorCallback(MRIteratorCallbackCtx *ctx, MRReply *rep) {
130130
MRReply *results = NULL;
131131
if (map && MRReply_Type(map) == MR_REPLY_MAP) {
132132
results = MRReply_MapElement(map, "results");
133-
if (results && MRReply_Type(results) == MR_REPLY_ARRAY && MRReply_Length(results) >= 0) {
133+
if (results && MRReply_Type(results) == MR_REPLY_ARRAY) {
134134
MRIteratorCallback_AddReply(ctx, rep); // to be picked up by getNextReply
135135
// User code now owns the reply, so we can't free it here ourselves!
136136
rep = NULL;
@@ -266,34 +266,13 @@ static int getNextReply(RPNet *nc) {
266266

267267
MRReply *rows = MRReply_ArrayElement(root, 0);
268268
// Perform sanity check to avoid processing empty replies
269-
// Assume the reply is empty, unless all checks pass
270-
bool is_empty = true;
271-
do {
272-
if (!rows) {
273-
break;
274-
}
275-
if (nc->cmd.protocol == 3) { // RESP3
276-
if (MRReply_Type(rows) != MR_REPLY_MAP) {
277-
break;
278-
}
279-
MRReply *results = MRReply_MapElement(rows, "results");
280-
if (!results || MRReply_Type(results) != MR_REPLY_ARRAY) {
281-
break;
282-
}
283-
if (MRReply_Length(results) == 0) {
284-
break;
285-
}
286-
} else { // RESP2
287-
if (MRReply_Type(rows) != MR_REPLY_ARRAY) {
288-
break;
289-
}
290-
if (MRReply_Length(rows) <= 1) {
291-
break;
292-
}
293-
}
294-
// All checks passed - the reply is not empty
295-
is_empty = false;
296-
} while (false);
269+
bool is_empty;
270+
if (nc->cmd.protocol == 3) { // RESP3
271+
MRReply *results = MRReply_MapElement(rows, "results");
272+
is_empty = MRReply_Length(results) == 0;
273+
} else { // RESP2
274+
is_empty = MRReply_Length(rows) == 1;
275+
}
297276

298277
if (is_empty) {
299278
MRReply_Free(root);

0 commit comments

Comments
 (0)