本文整理汇总了Java中com.alibaba.druid.sql.ast.SQLOrderingSpecification类的典型用法代码示例。如果您正苦于以下问题:Java SQLOrderingSpecification类的具体用法?Java SQLOrderingSpecification怎么用?Java SQLOrderingSpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLOrderingSpecification类属于com.alibaba.druid.sql.ast包,在下文中一共展示了SQLOrderingSpecification类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildOrderByCols
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
protected LinkedHashMap<String, Integer> buildOrderByCols(List<SQLSelectOrderByItem> orderByItems,Map<String, String> aliaColumns) {
LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
for(int i= 0; i < orderByItems.size(); i++) {
SQLOrderingSpecification type = orderByItems.get(i).getType();
//orderColumn只记录字段名称,因为返回的结果集是不带表名的。
SQLExpr expr = orderByItems.get(i).getExpr();
String col;
if (expr instanceof SQLName) {
col = ((SQLName)expr).getSimpleName();
}
else {
col =expr.toString();
}
if(type == null) {
type = SQLOrderingSpecification.ASC;
}
col=getAliaColumn(aliaColumns,col);//此步骤得到的col必须是不带.的,有别名的用别名,无别名的用字段名
map.put(col, type == SQLOrderingSpecification.ASC ? OrderCol.COL_ORDER_TYPE_ASC : OrderCol.COL_ORDER_TYPE_DESC);
}
return map;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:22,代码来源:DruidSelectParser.java
示例2: TwoTableComparator
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public TwoTableComparator(List<FieldPacket> fps1, List<FieldPacket> fps2, List<Order> leftOrders,
List<Order> rightOrders, boolean isAllPushDown, DMLResponseHandler.HandlerType type) {
this.leftFields = HandlerTool.createFields(fps1);
this.rightFields = HandlerTool.createFields(fps2);
ascList = new ArrayList<>();
for (Order order : leftOrders) {
ascList.add(order.getSortOrder() == SQLOrderingSpecification.ASC);
}
comparators = new ArrayList<>();
for (int index = 0; index < ascList.size(); index++) {
Order leftOrder = leftOrders.get(index);
Order rightOrder = rightOrders.get(index);
Item leftCmpItem = HandlerTool.createItem(leftOrder.getItem(), leftFields, 0, isAllPushDown, type);
Item rightCmpItem = HandlerTool.createItem(rightOrder.getItem(), rightFields, 0, isAllPushDown,
type);
ArgComparator comparator = new ArgComparator(leftCmpItem, rightCmpItem);
comparator.setCmpFunc(null, leftCmpItem, rightCmpItem, false);
comparators.add(comparator);
}
}
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:TwoTableComparator.java
示例3: RowDataComparator
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public RowDataComparator(List<FieldPacket> fps, List<Order> orders, boolean allPushDown, DMLResponseHandler.HandlerType type) {
sourceFields = HandlerTool.createFields(fps);
if (orders != null && orders.size() > 0) {
ascList = new ArrayList<>();
cmpFields = new ArrayList<>();
cmpItems = new ArrayList<>();
for (Order order : orders) {
Item cmpItem = HandlerTool.createItem(order.getItem(), sourceFields, 0, allPushDown, type);
cmpItems.add(cmpItem);
FieldPacket tmpFp = new FieldPacket();
cmpItem.makeField(tmpFp);
Field cmpField = HandlerTool.createField(tmpFp);
cmpFields.add(cmpField);
ascList.add(order.getSortOrder() == SQLOrderingSpecification.ASC);
}
}
}
开发者ID:actiontech,项目名称:dble,代码行数:18,代码来源:RowDataComparator.java
示例4: reverseAppendTo
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private void reverseAppendTo(SQLSelectOrderByItem order, SQLServerOutputVisitor visitor, String tmpTableAlias, List<SQLSelectItem> items) {
SQLExpr expression=order.getExpr();
if(expression instanceof SQLPropertyExpr){
SQLPropertyExpr c=(SQLPropertyExpr)expression;
if(items!=null){
fixWithSelects(c,items);
}
if(c.getOwner()!=null){
c.setOwner(new SQLIdentifierExpr(tmpTableAlias));
}
}
expression.accept(visitor);
if(order.getType()==SQLOrderingSpecification.ASC || order.getType()==null){
try {
visitor.getAppender().append(" DESC");
} catch (IOException e) {
e.printStackTrace();
}
}
}
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:22,代码来源:SQL2000LimitHandler.java
示例5: getSQLExprToAsc
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private String getSQLExprToAsc(SQLOrderingSpecification ASC){
if (ASC==null ) {
return " ASC ";
}
if (ASC==SQLOrderingSpecification.DESC){
return " DESC ";
}
else {
return " ASC ";
}
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:12,代码来源:JoinParser.java
示例6: getSQLExprToAsc
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
private int getSQLExprToAsc(SQLOrderingSpecification ASC){
if (ASC==null ) {
return 1;
}
if (ASC==SQLOrderingSpecification.DESC){
return -1;
}
else {
return 1;
}
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:12,代码来源:SequoiaSQLParser.java
示例7: orderBy
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public PlanNode orderBy(Item c, SQLOrderingSpecification sortOrder) {
if (sortOrder == null) {
sortOrder = SQLOrderingSpecification.ASC;
}
Order order = new Order(c, sortOrder);
if (!this.orderBys.contains(order)) {
this.orderBys.add(order);
}
return this;
}
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:PlanNode.java
示例8: makeOrder
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
/**
* make order by from distinct
*
* @param selects
* @return
*/
public static List<Order> makeOrder(List<Item> selects) {
List<Order> orders = new ArrayList<>();
for (Item sel : selects) {
Order order = new Order(sel, SQLOrderingSpecification.ASC);
orders.add(order);
}
return orders;
}
开发者ID:actiontech,项目名称:dble,代码行数:15,代码来源:HandlerTool.java
示例9: buildOrderbyType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public static OrderbyType buildOrderbyType(SQLOrderingSpecification type){
if (SQLOrderingSpecification.ASC == type){
return OrderbyType.ASC;
}
if (SQLOrderingSpecification.DESC == type){
return OrderbyType.DESC;
}
return OrderbyType.ASC;
}
开发者ID:tongbanjie,项目名称:baymax,代码行数:10,代码来源:OrderbyColumn.java
示例10: getType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getType() {
return this.type;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SQLSelectOrderByItem.java
示例11: setType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public void setType(SQLOrderingSpecification type) {
this.type = type;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SQLSelectOrderByItem.java
示例12: MySqlOrderingExpr
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public MySqlOrderingExpr(SQLExpr expr, SQLOrderingSpecification type){
super();
setExpr(expr);
this.type = type;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:6,代码来源:MySqlOrderingExpr.java
示例13: getType
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getType() {
return type;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:MySqlOrderingExpr.java
示例14: Order
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public Order(Item item) {
this(item, SQLOrderingSpecification.ASC);
}
开发者ID:actiontech,项目名称:dble,代码行数:4,代码来源:Order.java
示例15: getSortOrder
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public SQLOrderingSpecification getSortOrder() {
return sortOrder;
}
开发者ID:actiontech,项目名称:dble,代码行数:4,代码来源:Order.java
示例16: setSortOrder
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public void setSortOrder(SQLOrderingSpecification sortOrder) {
this.sortOrder = sortOrder;
}
开发者ID:actiontech,项目名称:dble,代码行数:4,代码来源:Order.java
示例17: groupBy
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public PlanNode groupBy(Item c, SQLOrderingSpecification sortOrder) {
Order order = new Order(c, sortOrder);
this.groups.add(order);
return this;
}
开发者ID:actiontech,项目名称:dble,代码行数:6,代码来源:PlanNode.java
示例18: process
import com.alibaba.druid.sql.ast.SQLOrderingSpecification; //导入依赖的package包/类
public List<RowData> process(List<RowData> sourceData, MergeContext mergeContext) throws SQLException {
if (mergeContext.getOrderBy() != null) {
SQLOrderBy orderBy = mergeContext.getOrderBy();
final List<SQLSelectOrderByItem> items = orderBy.getItems();
Collections.sort(sourceData, new Comparator<RowData>() {
@Override
public int compare(RowData o1, RowData o2) {
try {
for (SQLSelectOrderByItem orderByEle : items) {
SQLName identifier = (SQLName) orderByEle.getExpr();
Object value1 = o1.get(identifier.getSimpleName()).getValue();
Class<?> type1 = o1.get(identifier.getSimpleName()).getType();
Object value2 = o2.get(identifier.getSimpleName()).getValue();
Class<?> type2 = o2.get(identifier.getSimpleName()).getType();
if (!type1.equals(type2)) {
throw new SQLException("Invalid data");
}
if (!Comparable.class.isAssignableFrom(type1)) {
throw new SQLException(
"Can not orderBy column : " + identifier + " which isn't comparable.");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
int compareRes = ((Comparable) value1).compareTo((Comparable) value2);
if (orderByEle.getType() == null
|| ((SQLOrderingSpecification) orderByEle.getType()).name().equals("ASC")) {
if (compareRes != 0) {
return compareRes;
}
} else {
if (compareRes != 0) {
return compareRes < 0 ? 1 : -1;
}
}
}
return 0;
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
});
}
return sourceData;
}
开发者ID:dianping,项目名称:zebra,代码行数:53,代码来源:OrderByDataMerger.java
注:本文中的com.alibaba.druid.sql.ast.SQLOrderingSpecification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论