BiteTheDDDDt commented on code in PR #10103:
URL: https://github.com/apache/incubator-doris/pull/10103#discussion_r896396705
##########
be/src/exprs/runtime_filter.cpp:
##########
@@ -294,6 +283,95 @@ Expr* create_literal(ObjectPool* pool, PrimitiveType type,
const void* data) {
return pool->add(new Literal(node));
}
+Status create_literal(ObjectPool* pool, PrimitiveType type, const void* data,
+ doris::vectorized::VExpr** vexpr) {
+ TExprNode node;
+
+ switch (type) {
+ case TYPE_BOOLEAN: {
+ TBoolLiteral boolLiteral;
+ boolLiteral.__set_value(*reinterpret_cast<const bool*>(data));
+ node.__set_bool_literal(boolLiteral);
+ break;
+ }
+ case TYPE_TINYINT: {
+ TIntLiteral intLiteral;
+ intLiteral.__set_value(*reinterpret_cast<const int8_t*>(data));
+ node.__set_int_literal(intLiteral);
+ break;
+ }
+ case TYPE_SMALLINT: {
+ TIntLiteral intLiteral;
+ intLiteral.__set_value(*reinterpret_cast<const int16_t*>(data));
+ node.__set_int_literal(intLiteral);
+ break;
+ }
+ case TYPE_INT: {
+ TIntLiteral intLiteral;
+ intLiteral.__set_value(*reinterpret_cast<const int32_t*>(data));
+ node.__set_int_literal(intLiteral);
+ break;
+ }
+ case TYPE_BIGINT: {
+ TIntLiteral intLiteral;
+ intLiteral.__set_value(*reinterpret_cast<const int64_t*>(data));
+ node.__set_int_literal(intLiteral);
+ break;
+ }
+ case TYPE_LARGEINT: {
+ TLargeIntLiteral largeIntLiteral;
+ largeIntLiteral.__set_value(
+ LargeIntValue::to_string(*reinterpret_cast<const
int128_t*>(data)));
+ node.__set_large_int_literal(largeIntLiteral);
+ break;
+ }
+ case TYPE_FLOAT: {
+ TFloatLiteral floatLiteral;
+ floatLiteral.__set_value(*reinterpret_cast<const float*>(data));
+ node.__set_float_literal(floatLiteral);
+ break;
+ }
+ case TYPE_DOUBLE: {
+ TFloatLiteral floatLiteral;
+ floatLiteral.__set_value(*reinterpret_cast<const double*>(data));
+ node.__set_float_literal(floatLiteral);
+ break;
+ }
+ case TYPE_DATE:
+ case TYPE_DATETIME: {
+ TDateLiteral dateLiteral;
+ char convert_buffer[30];
+ reinterpret_cast<const
DateTimeValue*>(data)->to_string(convert_buffer);
+ dateLiteral.__set_value(convert_buffer);
+ node.__set_date_literal(dateLiteral);
+ break;
+ }
+ case TYPE_DECIMALV2: {
+ TDecimalLiteral decimalLiteral;
+ decimalLiteral.__set_value(reinterpret_cast<const
DecimalV2Value*>(data)->to_string());
+ node.__set_decimal_literal(decimalLiteral);
+ break;
+ }
+ case TYPE_CHAR:
+ case TYPE_VARCHAR:
+ case TYPE_STRING: {
+ const StringValue* string_value = reinterpret_cast<const
StringValue*>(data);
+ TStringLiteral tstringLiteral;
+ tstringLiteral.__set_value(std::string(string_value->ptr,
string_value->len));
+ node.__set_string_literal(tstringLiteral);
+ break;
+ }
+ default:
+ DCHECK(false);
+ return Status::InvalidArgument("Invalid type!");
+ }
+ node.__set_node_type(get_expr_node_type(type));
+ node.__set_type(create_type_desc(type));
+
+ *vexpr = pool->add(new doris::vectorized::VLiteral(node));
Review Comment:
Maybe we can reuse `Expr* create_literal(ObjectPool* pool, PrimitiveType
type, const void* data)` and make it to template function just like `new
T(node)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]