Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

流式排序的聚集结果集 StreamingOrderByReducerResultSet性能优化 #215

Closed
iamhuzl opened this issue Jan 6, 2017 · 0 comments
Closed

Comments

@iamhuzl
Copy link
Contributor

iamhuzl commented Jan 6, 2017

流式排序的聚集结果集 StreamingOrderByReducerResultSet处理流程多次创建OrderByResultSetRow造成额外性能消耗
流式排序在排序比对时每次都从上次排序后会获取当前第一个(最大或最小)ResultSet的下一条数据,其他结果集都不会变化,不用每次创建OrderByResultSetRow

private void setDelegateResultSet() throws SQLException {
        OrderByResultSetRow chosenOrderByValue = null;
        for (ResultSet each : resultSets) {
           //此段代码有重复创建对象的额外消耗
            OrderByResultSetRow eachOrderByValue = new OrderByResultSetRow(each, orderByColumns);
            if (null == chosenOrderByValue || chosenOrderByValue.compareTo(eachOrderByValue) > 0) {
                chosenOrderByValue = eachOrderByValue;
                setDelegate(each);
            }
        }
        log.trace("Chosen order by value: {}, current result set hashcode: {}", chosenOrderByValue, getDelegate().hashCode());
    }

建议的新功能行为

  • 构造StreamingOrderByReducerResultSet对象时包装ResultSet,调用next方法时获取排序值
  • 在setDelegateResultSet方法中直接比对,并设置委托ResultSet即可
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants