Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
39a0ceb6
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39a0ceb6
编写于
4月 30, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor SQLParsedResult
上级
0e402179
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
33 addition
and
28 deletion
+33
-28
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingStatement.java
...dangdang/ddframe/rdb/sharding/jdbc/ShardingStatement.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/SQLParseEngine.java
.../dangdang/ddframe/rdb/sharding/parser/SQLParseEngine.java
+1
-2
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/result/SQLParsedResult.java
...g/ddframe/rdb/sharding/parser/result/SQLParsedResult.java
+4
-3
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/context/GeneratedKeyContext.java
.../rdb/sharding/parser/sql/context/GeneratedKeyContext.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/context/InsertSQLContext.java
...ame/rdb/sharding/parser/sql/context/InsertSQLContext.java
+0
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/PreparedSQLRouter.java
...ngdang/ddframe/rdb/sharding/router/PreparedSQLRouter.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
.../dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
+1
-2
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/ResultSetMergeContextTest.java
...dframe/rdb/sharding/merger/ResultSetMergeContextTest.java
+10
-9
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/AggregationResultSetTest.java
...ng/merger/pipeline/coupling/AggregationResultSetTest.java
+2
-1
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/NullableAggregationResultSetTest.java
...r/pipeline/coupling/NullableAggregationResultSetTest.java
+2
-1
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/OrderByResultSetTest.java
...arding/merger/pipeline/coupling/OrderByResultSetTest.java
+2
-1
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/reducer/IteratorResultSetTest.java
...arding/merger/pipeline/reducer/IteratorResultSetTest.java
+4
-3
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/parser/AbstractBaseParseTest.java
...ng/ddframe/rdb/sharding/parser/AbstractBaseParseTest.java
+2
-1
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/parser/result/SQLParsedResultTest.java
...frame/rdb/sharding/parser/result/SQLParsedResultTest.java
+2
-1
未找到文件。
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingStatement.java
浏览文件 @
39a0ceb6
...
...
@@ -21,7 +21,7 @@ import com.dangdang.ddframe.rdb.sharding.executor.StatementExecutor;
import
com.dangdang.ddframe.rdb.sharding.executor.wrapper.StatementExecutorWrapper
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractStatementAdapter
;
import
com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory
;
import
com.dangdang.ddframe.rdb.sharding.parser.
resul
t.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.
sql.contex
t.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.router.SQLExecutionUnit
;
import
com.dangdang.ddframe.rdb.sharding.router.SQLRouteResult
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/SQLParseEngine.java
浏览文件 @
39a0ceb6
...
...
@@ -60,11 +60,10 @@ public final class SQLParseEngine {
}
private
SQLParsedResult
getSQLParsedResult
(
final
SQLContext
sqlContext
)
{
SQLParsedResult
result
=
new
SQLParsedResult
(
sqlContext
.
getConditionContext
());
SQLParsedResult
result
=
new
SQLParsedResult
(
sqlContext
.
get
Type
(),
sqlContext
.
get
ConditionContext
());
for
(
TableContext
each
:
sqlContext
.
getTables
())
{
result
.
getTables
().
add
(
each
);
}
result
.
setSqlType
(
sqlContext
.
getType
());
return
result
;
}
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/result/SQLParsedResult.java
浏览文件 @
39a0ceb6
...
...
@@ -21,6 +21,7 @@ import com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.SQLBuilder
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.AggregationSelectItemContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.GroupByContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.LimitContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.OrderByContext
;
...
...
@@ -47,12 +48,14 @@ import java.util.List;
@ToString
public
final
class
SQLParsedResult
{
private
SQLType
sqlType
;
private
final
SQLType
sqlType
;
private
SQLBuilder
sqlBuilder
;
private
GeneratedKeyContext
generatedKeyContext
=
new
GeneratedKeyContext
();
private
LimitContext
limit
;
private
final
ConditionContext
conditionContext
;
private
final
Collection
<
TableContext
>
tables
=
new
LinkedHashSet
<>();
...
...
@@ -62,6 +65,4 @@ public final class SQLParsedResult {
private
final
List
<
GroupByContext
>
groupByContexts
=
new
ArrayList
<>();
private
final
List
<
AggregationSelectItemContext
>
aggregationColumns
=
new
ArrayList
<>();
private
LimitContext
limit
;
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/
resul
t/GeneratedKeyContext.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/
sql/contex
t/GeneratedKeyContext.java
浏览文件 @
39a0ceb6
...
...
@@ -15,7 +15,7 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parser.
resul
t
;
package
com.dangdang.ddframe.rdb.sharding.parser.
sql.contex
t
;
import
com.google.common.collect.Table
;
import
com.google.common.collect.TreeBasedTable
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/context/InsertSQLContext.java
浏览文件 @
39a0ceb6
...
...
@@ -17,7 +17,6 @@
package
com.dangdang.ddframe.rdb.sharding.parser.sql.context
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
lombok.Getter
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/PreparedSQLRouter.java
浏览文件 @
39a0ceb6
...
...
@@ -19,7 +19,7 @@ package com.dangdang.ddframe.rdb.sharding.router;
import
com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule
;
import
com.dangdang.ddframe.rdb.sharding.api.rule.TableRule
;
import
com.dangdang.ddframe.rdb.sharding.parser.
resul
t.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.
sql.contex
t.GeneratedKeyContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.google.common.base.Optional
;
import
lombok.RequiredArgsConstructor
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
浏览文件 @
39a0ceb6
...
...
@@ -97,8 +97,7 @@ public final class SQLRouteEngine {
}
private
SQLParsedResult
buildHintParsedResult
(
final
String
logicSql
)
{
SQLParsedResult
result
=
new
SQLParsedResult
(
new
ConditionContext
());
result
.
setSqlType
(
SQLUtil
.
getTypeByStart
(
logicSql
));
SQLParsedResult
result
=
new
SQLParsedResult
(
SQLUtil
.
getTypeByStart
(
logicSql
),
new
ConditionContext
());
log
.
trace
(
"Get {} SQL Statement"
,
result
.
getSqlType
());
SQLBuilder
sqlBuilder
=
new
SQLBuilder
();
try
{
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/ResultSetMergeContextTest.java
浏览文件 @
39a0ceb6
...
...
@@ -19,6 +19,7 @@ package com.dangdang.ddframe.rdb.sharding.merger;
import
com.dangdang.ddframe.rdb.sharding.merger.fixture.MergerTestUtil
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.GroupByContext
;
...
...
@@ -53,7 +54,7 @@ public final class ResultSetMergeContextTest {
}
private
SQLParsedResult
createSQLParsedResult
()
{
SQLParsedResult
result
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
result
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
result
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"order_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
result
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"group_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
result
.
getAggregationColumns
().
add
(
MergerTestUtil
.
createAggregationColumn
(
AggregationType
.
COUNT
,
"count_col"
,
"count_col"
,
-
1
));
...
...
@@ -64,13 +65,13 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertIsNotNeedMemorySortForGroupByWithoutGroupBy
()
throws
SQLException
{
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.<
String
>
emptyList
()))),
new
SQLParsedResult
(
new
ConditionContext
()));
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.<
String
>
emptyList
()))),
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
()));
assertFalse
(
actual
.
isNeedMemorySortForGroupBy
());
}
@Test
public
void
assertIsNeedMemorySortForGroupByWithGroupByAndOrderBySame
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.
singletonList
(
"col"
)))),
sqlParsedResult
);
...
...
@@ -79,7 +80,7 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertIsNeedMemorySortForGroupByWithGroupByAndOrderByDifferent
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"order_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"group_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
...
...
@@ -89,7 +90,7 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertSetGroupByKeysToCurrentOrderByKeys
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"order_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"group_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
...
...
@@ -102,13 +103,13 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertIsNotNeedMemorySortForOrderByWithoutOrderBy
()
throws
SQLException
{
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.<
String
>
emptyList
()))),
new
SQLParsedResult
(
new
ConditionContext
()));
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.<
String
>
emptyList
()))),
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
()));
assertFalse
(
actual
.
isNeedMemorySortForOrderBy
());
}
@Test
public
void
assertIsNeedMemorySortForOrderByWithGroupByAndOrderBySame
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
new
ShardingResultSets
(
Collections
.
singletonList
(
MergerTestUtil
.
mockResult
(
Collections
.
singletonList
(
"col"
)))),
sqlParsedResult
);
...
...
@@ -117,7 +118,7 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertIsNeedMemorySortForOrderByWithGroupByAndOrderByDifferent
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"order_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"group_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
...
...
@@ -128,7 +129,7 @@ public final class ResultSetMergeContextTest {
@Test
public
void
assertSetOrderByKeysToCurrentOrderByKeys
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"order_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
sqlParsedResult
.
getGroupByContexts
().
add
(
new
GroupByContext
(
Optional
.<
String
>
absent
(),
"group_col"
,
OrderType
.
ASC
,
Optional
.<
String
>
absent
()));
ResultSetMergeContext
actual
=
new
ResultSetMergeContext
(
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/AggregationResultSetTest.java
浏览文件 @
39a0ceb6
...
...
@@ -22,6 +22,7 @@ import com.dangdang.ddframe.rdb.sharding.merger.fixture.MergerTestUtil;
import
com.dangdang.ddframe.rdb.sharding.merger.fixture.TestResultSetRow
;
import
com.dangdang.ddframe.rdb.sharding.merger.resultset.memory.row.ResultSetRow
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -68,7 +69,7 @@ public final class AggregationResultSetTest {
@Test
public
void
assertNext
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getAggregationColumns
().
add
(
MergerTestUtil
.
createAggregationColumn
(
aggregationType
,
columnNames
.
get
(
0
),
null
,
1
));
ResultSet
resultSet
=
ResultSetFactory
.
getResultSet
(
Arrays
.
asList
(
MergerTestUtil
.
mockResult
(
columnNames
,
Collections
.<
ResultSetRow
>
singletonList
(
new
TestResultSetRow
(
resultSetData1
))),
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/NullableAggregationResultSetTest.java
浏览文件 @
39a0ceb6
...
...
@@ -20,6 +20,7 @@ package com.dangdang.ddframe.rdb.sharding.merger.pipeline.coupling;
import
com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory
;
import
com.dangdang.ddframe.rdb.sharding.merger.fixture.MergerTestUtil
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -53,7 +54,7 @@ public class NullableAggregationResultSetTest {
@Test
public
void
assertNullable
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
getAggregationColumns
().
add
(
MergerTestUtil
.
createAggregationColumn
(
aggregationType
,
aggregationType
.
name
()
+
"(*)"
,
aggregationType
.
name
(),
1
));
ResultSet
resultSet1
;
ResultSet
resultSet2
;
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/coupling/OrderByResultSetTest.java
浏览文件 @
39a0ceb6
...
...
@@ -19,6 +19,7 @@ package com.dangdang.ddframe.rdb.sharding.merger.pipeline.coupling;
import
com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory
;
import
com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.OrderByContext
;
...
...
@@ -68,7 +69,7 @@ public final class OrderByResultSetTest {
}
private
SQLParsedResult
createSQLParsedResult
(
final
OrderType
orderType
)
{
SQLParsedResult
result
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
result
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
result
.
getOrderByContexts
().
add
(
new
OrderByContext
(
"name"
,
orderType
,
Optional
.<
String
>
absent
()));
return
result
;
}
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/merger/pipeline/reducer/IteratorResultSetTest.java
浏览文件 @
39a0ceb6
...
...
@@ -19,6 +19,7 @@ package com.dangdang.ddframe.rdb.sharding.merger.pipeline.reducer;
import
com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory
;
import
com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext
;
import
com.dangdang.ddframe.rdb.sharding.parser.sql.context.LimitContext
;
...
...
@@ -36,7 +37,7 @@ public final class IteratorResultSetTest {
@Test
public
void
assertNext
()
throws
SQLException
{
ResultSet
resultSet
=
ResultSetFactory
.
getResultSet
(
Arrays
.<
ResultSet
>
asList
(
new
MockResultSet
<>(
1
),
new
MockResultSet
<>(
2
,
4
),
new
MockResultSet
<
Integer
>()),
new
SQLParsedResult
(
new
ConditionContext
()));
Arrays
.<
ResultSet
>
asList
(
new
MockResultSet
<>(
1
),
new
MockResultSet
<>(
2
,
4
),
new
MockResultSet
<
Integer
>()),
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
()));
int
count
=
0
;
while
(
resultSet
.
next
())
{
count
++;
...
...
@@ -46,7 +47,7 @@ public final class IteratorResultSetTest {
@Test
public
void
assertNextWithLimitForAllData
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
setLimit
(
new
LimitContext
(
1
,
10
,
-
1
,
-
1
));
ResultSet
resultSet
=
ResultSetFactory
.
getResultSet
(
Arrays
.<
ResultSet
>
asList
(
new
MockResultSet
<>(
1
),
new
MockResultSet
<>(
2
,
4
),
new
MockResultSet
<
Integer
>()),
sqlParsedResult
);
int
count
=
0
;
...
...
@@ -58,7 +59,7 @@ public final class IteratorResultSetTest {
@Test
public
void
assertNextWithLimitForPartData
()
throws
SQLException
{
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
sqlParsedResult
.
setLimit
(
new
LimitContext
(
1
,
1
,
-
1
,
-
1
));
ResultSet
resultSet
=
ResultSetFactory
.
getResultSet
(
Arrays
.<
ResultSet
>
asList
(
new
MockResultSet
<>(
1
),
new
MockResultSet
<>(
2
,
4
),
new
MockResultSet
<
Integer
>()),
sqlParsedResult
);
int
count
=
0
;
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/parser/AbstractBaseParseTest.java
浏览文件 @
39a0ceb6
...
...
@@ -17,6 +17,7 @@
package
com.dangdang.ddframe.rdb.sharding.parser
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.jaxb.Assert
;
import
com.dangdang.ddframe.rdb.sharding.parser.jaxb.Asserts
;
import
com.dangdang.ddframe.rdb.sharding.parser.jaxb.Value
;
...
...
@@ -149,7 +150,7 @@ public abstract class AbstractBaseParseTest {
}
});
}
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
new
ConditionContext
());
SQLParsedResult
sqlParsedResult
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
new
ConditionContext
());
if
(
null
!=
assertObj
.
getOrderByColumns
())
{
sqlParsedResult
.
getOrderByContexts
().
addAll
(
Lists
.
transform
(
assertObj
.
getOrderByColumns
(),
new
Function
<
com
.
dangdang
.
ddframe
.
rdb
.
sharding
.
parser
.
jaxb
.
OrderByColumn
,
OrderByContext
>()
{
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/parser/result/SQLParsedResultTest.java
浏览文件 @
39a0ceb6
...
...
@@ -19,6 +19,7 @@ package com.dangdang.ddframe.rdb.sharding.parser.result;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.OrderType
;
import
com.dangdang.ddframe.rdb.sharding.parser.contstant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.Condition
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.Condition.BinaryOperator
;
import
com.dangdang.ddframe.rdb.sharding.parser.result.router.Condition.Column
;
...
...
@@ -44,7 +45,7 @@ public final class SQLParsedResultTest {
@Test
@Ignore
public
void
assertToString
()
throws
IOException
{
SQLParsedResult
actual
=
new
SQLParsedResult
(
generateConditionContext
());
SQLParsedResult
actual
=
new
SQLParsedResult
(
SQLType
.
SELECT
,
generateConditionContext
());
generateRouteContext
(
actual
);
generateMergeContext
(
actual
);
assertThat
(
actual
.
toString
(),
is
(
"SQLParsedResult(routeContext=RouteContext(tables=[TableContext(originalLiterals=order, name=order, alias=Optional.of(o)), "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录