alibaba / alibaba/QLExpress

com.ql.util.express.ExpressUtil#getSimpleDataType 有bug,而且性能超低

Open
#202 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

getSimpleDataType 函数的本意是检测传入的Class类型是否为基本数据类型的包装类型,如果是基本数据类型的包装类型,则返回基本数据类型的class类型。
但是观察getSimpleDataType函数的三个调用点,传入的class类型都是Object对象的Class,因此即使原始的Operator返回的结果类型是基本类型,都会自动装箱为基本类型的包装类型。这样调用进getSimpleDataType函数后,第一个
if (!clazz.isPrimitive()) {
return clazz;
}
都会成立。
同时因为加了 if (!clazz.isPrimitive()) 这个判断,传入的class如果是基本类型的包装类型,都会成立,后面的所有条件都执行不到,因此无法实现预期中的目标。
而且isPrimitive很耗性能,我一个脚本执行了100万次条件表达式,99.9%的性能都耗在这个函数里。
![image](https://user-images.githubusercontent.com/7670478/178733936-be84e5e1-d5ea-4423-9160-fac8024c2ff5.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating com.ql.util.express.ExpressUtil#getSimpleDataType and inspect its three call sites, which pass Object Class values. Reproduce the reported case with one million conditional-expression evaluations and compare the type result and runtime. Done means wrapper classes are handled as intended and the reported performance bottleneck is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.