⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tablefilter.java

📁 一個Light Weighted的Java Database Engin 適合各個領域之Java數据庫編輯.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            // ok include this        } else if ((e2.getFilter() == this)                   && (conditionType != CONDITION_UNORDERED)) {            // swap and try again to allow index usage            e.swapCondition();            setCondition(session, e);            return;        } else if (e1.outerFilter == this) {            // fredt - this test is last to allow swapping the terms above            conditionType = CONDITION_OUTER;        } else {            // unrelated: don't include            return;        }//        Trace.doAssert(e1.getFilter() == this, "setCondition");        if (!e2.isResolved()) {            return;        }        // fredt - condition defined in outer but not this one        if (e1.outerFilter != null && e1.outerFilter != this) {            return;        }        if (conditionType == CONDITION_UNORDERED) {            addAndCondition(e);            return;        }        if (conditionType == CONDITION_OUTER) {            addAndCondition(e);            return;        }        int   i     = e1.getColumnNr();        Index index = filterTable.getIndexForColumn(session, i);        if (index == null || (filterIndex != index && filterIndex != null)) {            addAndCondition(e);            return;        }        filterIndex = index;        switch (conditionType) {            case CONDITION_START_END : {                // candidate for both start and end                if ((eStart != null) || (eEnd != null)) {                    addAndCondition(e);                    return;                }                eStart = new Expression(e);                eEnd   = eStart;                break;            }            case CONDITION_START : {                // candidate for start                if (eStart != null) {                    addAndCondition(e);                    return;                }                eStart = new Expression(e);                break;            }            case CONDITION_END : {                // candidate for end                if (eEnd != null) {                    addAndCondition(e);                    return;                }                eEnd = new Expression(e);                break;            }        }        e.setTrue();    }    /**     * Finds the first row in the table (using an index if there is one) and     * checks it against the eEnd (range) and eAnd (other conditions)     * Expression objects. (fredt)     *     * @return true if first row was found, else false     */    boolean findFirst(Session session) throws HsqlException {        nonJoinIsNull  = false;        isCurrentOuter = false;        if (filterIndex == null) {            filterIndex = filterTable.getPrimaryIndex();        }        if (isMultiFindFirst) {            boolean convertible = true;            int[]   types       = filterTable.getColumnTypes();            for (int i = 0; i < findFirstExpressions.length; i++) {                Expression e = findFirstExpressions[i];                if (e != null) {                    Object value = e.getValue(session);                    if (Column.compareToTypeRange(value, types[i]) != 0) {                        convertible = false;                        break;                    }                    value = Column.convertObject(value, types[i]);                    currentJoinData[i] = e.getValue(session, types[i]);                }            }            it = convertible                 ? filterIndex.findFirstRow(session, currentJoinData)                 : filterIndex.emptyIterator();            if (!it.hasNext()) {                ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_OBJECT,                                     currentJoinData, 0,                                     currentJoinData.length);            }        } else if (eStart == null) {            it = eEnd == null ? filterIndex.firstRow(session)                              : filterIndex.findFirstRowNotNull(session);        } else {            Object value      = eStart.getArg2().getValue(session);            int    valuetype  = eStart.getArg2().getDataType();            int    targettype = eStart.getArg().getDataType();            it = getFirstIterator(session, eStart.getType(), value,                                  valuetype, filterIndex, targettype);        }        while (true) {            currentRow = it.next();            if (currentRow == null) {                break;            }            currentData = currentRow.getData();            if (!(eEnd == null || eEnd.testCondition(session))) {                break;            }            if (eAnd == null || eAnd.testCondition(session)) {                return true;            }        }        currentRow  = null;        currentData = emptyData;        return false;    }    static RowIterator getFirstIterator(Session session, int eType,                                        Object value, int valueType,                                        Index index,                                        int targetType) throws HsqlException {        RowIterator it;        int         range = 0;        if (targetType != valueType) {            range = Column.compareToTypeRange(value, targetType);        }        if (range == 0) {            value = Column.convertObject(value, targetType);            it    = index.findFirstRow(session, value, eType);        } else {            switch (eType) {                case Expression.BIGGER_EQUAL :                case Expression.BIGGER :                    if (range < 0) {                        it = index.findFirstRowNotNull(session);                        break;                    }                default :                    it = index.emptyIterator();            }        }        return it;    }    /**     * Advances to the next available value. <p>     *     * @return true if a next value is available upon exit     *     * @throws HsqlException if a database access error occurs     */    boolean next(Session session) throws HsqlException {        boolean result = false;        nonJoinIsNull  = false;        isCurrentOuter = false;        while (true) {            currentRow = it.next();            if (currentRow == null) {                break;            }            currentData = currentRow.getData();            if (!(eEnd == null || eEnd.testCondition(session))) {                break;            }            if (eAnd == null || eAnd.testCondition(session)) {                result = true;                break;            }        }        if (result) {            return true;        }        currentRow  = null;        currentData = emptyData;        return false;    }    boolean nextOuter(Session session) throws HsqlException {        nonJoinIsNull  = false;        isCurrentOuter = true;        currentData    = emptyData;        currentRow     = null;        return eAnd == null || (eAnd.getFilter() != this && eAnd.isInJoin)               || eAnd.testCondition(session);    }    /**     * Forms a new conjunction using the given condition and this filter's     * pre-existing AND condition, or sets the given condition as this filter's     * AND condition when there is no such pre-exisiting object.     *     * @param e the condition to add     */    private void addAndCondition(Expression e) {        Expression e2 = new Expression(e);        if (eAnd == null) {            eAnd = e2;        } else {            Expression and = new Expression(Expression.AND, eAnd, e2);            eAnd = and;        }        e.setTrue();    }    /**     * Removes reference to Index to avoid possible memory leaks after alter     * table or drop index     */    void setAsCheckFilter() {        filterIndex = null;    }// boucheb@users 20030415 - added for debugging support    /**     * Retreives a String representation of this obejct. <p>     *     * The returned String describes this object's table, alias     * access mode, index, join mode, Start, End and And conditions.     *     * @return a String representation of this object     */    public String describe(Session session) {        StringBuffer sb;        String       temp;        Index        index;        Index        primaryIndex;        int[]        primaryKey;        boolean      hidden;        boolean      fullScan;        sb           = new StringBuffer();        index        = filterIndex;        primaryIndex = filterTable.getPrimaryIndex();        primaryKey   = filterTable.getPrimaryKey();        hidden       = false;        fullScan     = (eStart == null && eEnd == null);        if (index == null) {            index = primaryIndex;        }        if (index == primaryIndex && primaryKey.length == 0) {            hidden   = true;            fullScan = true;        }        sb.append(super.toString()).append('\n');        sb.append("table=[").append(filterTable.getName().name).append("]\n");        sb.append("alias=[").append(tableAlias).append("]\n");        sb.append("access=[").append(fullScan ? "FULL SCAN"                                              : "INDEX PRED").append("]\n");        sb.append("index=[");        sb.append(index == null ? "NONE"                                : index.getName() == null ? "UNNAMED"                                                          : index.getName()                                                          .name);        sb.append(hidden ? "[HIDDEN]]\n"                         : "]\n");        sb.append("isOuterJoin=[").append(isOuterJoin).append("]\n");        temp = eStart == null ? "null"                              : eStart.describe(session);        sb.append("eStart=[").append(temp).append("]\n");        temp = eEnd == null ? "null"                            : eEnd.describe(session);        sb.append("eEnd=[").append(temp).append("]\n");        temp = eAnd == null ? "null"                            : eAnd.describe(session);        sb.append("eAnd=[").append(temp).append("]");        return sb.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -