@@ -1068,9 +1068,8 @@ tdb_unique_ptr<ASTNode> condition_ast_from_capnp(
10681068 tdb_new (ASTNodeExpr, std::move (ast_nodes), combination_op));
10691069}
10701070
1071- Status condition_from_capnp (
1072- const capnp::Condition::Reader& condition_reader,
1073- QueryCondition* const condition) {
1071+ QueryCondition condition_from_capnp (
1072+ const capnp::Condition::Reader& condition_reader) {
10741073 if (condition_reader.hasClauses ()) { // coming from older API
10751074 // Accumulating the AST value nodes from the clause list.
10761075 std::vector<tdb_unique_ptr<ASTNode>> ast_nodes;
@@ -1104,19 +1103,20 @@ Status condition_from_capnp(
11041103 // Constructing the tree from the list of AST nodes.
11051104 assert (ast_nodes.size () > 0 );
11061105 if (ast_nodes.size () == 1 ) {
1107- condition-> set_ast (std::move (ast_nodes[0 ]));
1106+ return QueryCondition (std::move (ast_nodes[0 ]));
11081107 } else {
11091108 auto tree_ptr = tdb_unique_ptr<ASTNode>(tdb_new (
11101109 ASTNodeExpr, std::move (ast_nodes), QueryConditionCombinationOp::AND));
1111- condition-> set_ast (std::move (tree_ptr));
1110+ return QueryCondition (std::move (tree_ptr));
11121111 }
11131112 } else if (condition_reader.hasTree ()) {
11141113 // Constructing the query condition from the AST representation.
11151114 // We assume that the deserialized values of the AST are validated properly.
11161115 auto ast_reader = condition_reader.getTree ();
1117- condition-> set_ast (condition_ast_from_capnp (ast_reader));
1116+ return QueryCondition (condition_ast_from_capnp (ast_reader));
11181117 }
1119- return Status::Ok ();
1118+ throw std::runtime_error (
1119+ " condition_from_capnp: serialized QC has no tree or clauses." );
11201120}
11211121
11221122Status reader_from_capnp (
@@ -1144,8 +1144,7 @@ Status reader_from_capnp(
11441144 // Query condition
11451145 if (reader_reader.hasCondition ()) {
11461146 auto condition_reader = reader_reader.getCondition ();
1147- QueryCondition condition;
1148- RETURN_NOT_OK (condition_from_capnp (condition_reader, &condition));
1147+ QueryCondition condition = condition_from_capnp (condition_reader);
11491148 RETURN_NOT_OK (query->set_condition (condition));
11501149 }
11511150
@@ -1186,8 +1185,7 @@ Status index_reader_from_capnp(
11861185 // Query condition
11871186 if (reader_reader.hasCondition ()) {
11881187 auto condition_reader = reader_reader.getCondition ();
1189- QueryCondition condition;
1190- RETURN_NOT_OK (condition_from_capnp (condition_reader, &condition));
1188+ QueryCondition condition = condition_from_capnp (condition_reader);
11911189 RETURN_NOT_OK (query->set_condition (condition));
11921190 }
11931191
@@ -1229,8 +1227,7 @@ Status dense_reader_from_capnp(
12291227 // Query condition
12301228 if (reader_reader.hasCondition ()) {
12311229 auto condition_reader = reader_reader.getCondition ();
1232- QueryCondition condition;
1233- RETURN_NOT_OK (condition_from_capnp (condition_reader, &condition));
1230+ QueryCondition condition = condition_from_capnp (condition_reader);
12341231 RETURN_NOT_OK (query->set_condition (condition));
12351232 }
12361233
@@ -1253,8 +1250,7 @@ Status delete_from_capnp(
12531250 // Query condition
12541251 if (delete_reader.hasCondition ()) {
12551252 auto condition_reader = delete_reader.getCondition ();
1256- QueryCondition condition;
1257- RETURN_NOT_OK (condition_from_capnp (condition_reader, &condition));
1253+ QueryCondition condition = condition_from_capnp (condition_reader);
12581254 RETURN_NOT_OK (query->set_condition (condition));
12591255 }
12601256
0 commit comments