druidparser limit逻辑错误（select * from tableName limit 2查出4条结果）
MPP 单线程异步Job Bug导致排序出现空指针的Bug修复
Merge pull request #23 from opencloudb/master

MPP 单线程异步Job Bug导致排序出现空指针的Bug修复
Merge pull request #22 from wdw1206/master

druidparser limit逻辑错误（select * from tableName limit 2查出4条结果）
删除排序的重复代码，默认改为堆排序
Merge pull request #24 from opencloudb/master

删除排序的重复代码，默认改为堆排序
Update HeapItf.java

区分升降序
Merge pull request #27 from coderczp/patch-2

Update HeapItf.java
重构代码区分升降序

重构代码区分升降序
重构代码区分升降序

重构代码区分升降序
重构代码区分升降序

package org.opencloudb.mpp.tmp;

import java.util.Comparator;

import org.opencloudb.mpp.ColMeta;
import org.opencloudb.mpp.OrderCol;
import org.opencloudb.net.mysql.RowDataPacket;
import org.opencloudb.util.ByteUtil;
import org.opencloudb.util.CompareUtil;

/**
 * 
 * @author coderczp-2014-12-8
 */
public class RowDataCmp implements Comparator<RowDataPacket> {

    private OrderCol[] orderCols;

    public RowDataCmp(OrderCol[] orderCols) {
        this.orderCols = orderCols;
    }

    @Override
    public int compare(RowDataPacket o1, RowDataPacket o2) {
        OrderCol[] tmp = this.orderCols;
        int cmp = 0;
        int len = tmp.length;
        int type = OrderCol.COL_ORDER_TYPE_ASC;
        for (int i = 0; i < len; i++) {
            int colIndex = tmp[i].colMeta.colIndex;
            byte[] left = o1.fieldValues.get(colIndex);
            byte[] right = o2.fieldValues.get(colIndex);
            if (tmp[i].orderType == type) {
                cmp = compareObject(left, right, tmp[i]);
            } else {
                cmp = compareObject(right, left, tmp[i]);
            }
            if (cmp != 0)
                return cmp;
        }
        return cmp;
    }

    public int compareObject(byte[] left, byte[] right, OrderCol orderCol) {
        /*
         * mysql的日期也是数字字符串方式表达，因此可以跟整数等一起对待 BLOB相关类型和GEOMETRY类型不支持排序，略掉
         * ENUM和SET类型都是字符串，按字符串处理
         */
        switch (orderCol.getColMeta().getColType()) {
        case ColMeta.COL_TYPE_INT:
        case ColMeta.COL_TYPE_LONG:
        case ColMeta.COL_TYPE_SHORT:
        case ColMeta.COL_TYPE_FLOAT:
        case ColMeta.COL_TYPE_INT24:
        case ColMeta.COL_TYPE_DOUBLE:
        case ColMeta.COL_TYPE_DECIMAL:
        case ColMeta.COL_TYPE_LONGLONG:
        case ColMeta.COL_TYPE_NEWDECIMAL:
        case ColMeta.COL_TYPE_BIT:
        case ColMeta.COL_TYPE_DATE:
        case ColMeta.COL_TYPE_TIME:
        case ColMeta.COL_TYPE_YEAR:
        case ColMeta.COL_TYPE_NEWDATE:
        case ColMeta.COL_TYPE_DATETIME:
        case ColMeta.COL_TYPE_TIMSTAMP:
            return ByteUtil.compareNumberByte(left, right);
        case ColMeta.COL_TYPE_STRING:
        case ColMeta.COL_TYPE_VAR_STRING:
        case ColMeta.COL_TYPE_SET:
        case ColMeta.COL_TYPE_ENUM:
            return CompareUtil.compareString(ByteUtil.getString(left), ByteUtil.getString(right));
        }
        return 0;
    }
}
重构代码区分升降序

重构代码区分升降序
解决测试程序问题
Merge remote-tracking branch 'origin/master'

Conflicts:
	src/main/java/org/opencloudb/mpp/tmp/HeapItf.java
	src/main/java/org/opencloudb/mpp/tmp/RowDataCmp.java
Merge pull request #28 from opencloudb/master

Merge remote-tracking branch 'origin/master'
Merge branch 'master' of https://github.com/jaggerliu/Mycat-Server.git
Merge remote-tracking branch 'mycat/master'