Skip to content

Commit

Permalink
Fix ColumnExpression encode and decode unmatch (#4413)
Browse files Browse the repository at this point in the history
Co-authored-by: shylock <[email protected]>
Co-authored-by: Sophie <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2022
1 parent 2dd6f15 commit 930afc1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/expression/ColumnExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ColumnExpression::writeTo(Encoder &encoder) const {
}

void ColumnExpression::resetFrom(Decoder &decoder) {
index_ = decoder.readValue().getInt();
index_ = decoder.readSize();
}

} // namespace nebula
19 changes: 19 additions & 0 deletions src/common/expression/test/ColumnExpressionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ TEST_F(ExpressionTest, ColumnExpression) {
auto eval = Expression::eval(expr, gExpCtxt);
EXPECT_EQ(eval, 1);
}
// test encode and decode
{
auto originExpr = ColumnExpression::make(&pool, 0);
auto str = Expression::encode(*originExpr);
auto decodeExpr = Expression::decode(&pool, str);
EXPECT_EQ(*decodeExpr, *originExpr);
}
{
auto originExpr = ColumnExpression::make(&pool, -1);
auto str = Expression::encode(*originExpr);
auto decodeExpr = Expression::decode(&pool, str);
EXPECT_EQ(*decodeExpr, *originExpr);
}
{
auto originExpr = ColumnExpression::make(&pool, 1);
auto str = Expression::encode(*originExpr);
auto decodeExpr = Expression::decode(&pool, str);
EXPECT_EQ(*decodeExpr, *originExpr);
}
}

} // namespace nebula

0 comments on commit 930afc1

Please sign in to comment.