Package org.hsqldb.index

Examples of org.hsqldb.index.RowIterator


     */
    static void checkReferencedRows(Session session, Table table,
                                    int[] rowColArray,
                                    Index mainIndex) throws HsqlException {

        RowIterator it = table.getPrimaryIndex().firstRow(session);

        while (true) {
            Row row = it.next();

            if (row == null) {
                break;
            }

View Full Code Here


     * Returns the node count.
     */
    int size(Session session) throws HsqlException {

        int         count = 0;
        RowIterator it    = firstRow(session);

        while (it.hasNext()) {
            it.next();

            count++;
        }

        return count;
View Full Code Here

    private Boolean getAnyAllValue(Session session, Object o,
                                   SubQuery subquery) throws HsqlException {

        boolean     empty    = subquery.table.isEmpty(session);
        Index       index    = subquery.table.getPrimaryIndex();
        RowIterator it       = index.findFirstRowNotNull(session);
        Row         firstrow = it.next();

        switch (eArg2.exprType) {

            case ANY : {
                if (empty) {
                    return Boolean.FALSE;
                }

                if (firstrow == null) {
                    return null;
                }

                int range =
                    Column.compareToTypeRange(o, eArg2.eArg.getDataType());

                if (range != 0) {
                    switch (exprType) {

                        case EQUAL :
                            return Boolean.FALSE;

                        case NOT_EQUAL :
                            return Boolean.TRUE;

                        case BIGGER :
                        case BIGGER_EQUAL :
                            return range > 0 ? Boolean.TRUE
                                             : Boolean.FALSE;

                        case SMALLER_EQUAL :
                        case SMALLER :
                            return range < 0 ? Boolean.TRUE
                                             : Boolean.FALSE;
                    }
                }

                o = Column.convertObject(o, eArg2.eArg.getDataType());

                if (exprType == EQUAL) {
                    it = index.findFirstRow(session, o, EQUAL);

                    return it.hasNext() ? Boolean.TRUE
                                        : Boolean.FALSE;
                }

                Row    lastrow   = index.lastRow(session);
                Object firstdata = firstrow.getData()[0];
                Object lastdata  = lastrow.getData()[0];
                int comparefirst = Column.compare(session.database.collation,
                                                  o, firstdata,
                                                  eArg.getDataType());
                int comparelast = Column.compare(session.database.collation,
                                                 o, lastdata,
                                                 eArg.getDataType());

                switch (exprType) {

                    case NOT_EQUAL :
                        return (comparefirst == 0 && comparelast == 0)
                               ? Boolean.FALSE
                               : Boolean.TRUE;

                    case BIGGER :
                        return comparefirst > 0 ? Boolean.TRUE
                                                : Boolean.FALSE;

                    case BIGGER_EQUAL :
                        return comparefirst >= 0 ? Boolean.TRUE
                                                 : Boolean.FALSE;

                    case SMALLER :
                        return comparelast < 0 ? Boolean.TRUE
                                               : Boolean.FALSE;

                    case SMALLER_EQUAL :
                        return comparelast <= 0 ? Boolean.TRUE
                                                : Boolean.FALSE;
                }

                break;
            }
            case ALL : {
                if (empty) {
                    return Boolean.TRUE;
                }

                if (firstrow == null) {
                    return null;
                }

                int range =
                    Column.compareToTypeRange(o, eArg2.eArg.getDataType());

                if (range != 0) {
                    switch (exprType) {

                        case EQUAL :
                            return Boolean.FALSE;

                        case NOT_EQUAL :
                            return Boolean.TRUE;

                        case BIGGER :
                        case BIGGER_EQUAL :
                            return range > 0 ? Boolean.TRUE
                                             : Boolean.FALSE;

                        case SMALLER_EQUAL :
                        case SMALLER :
                            return range < 0 ? Boolean.TRUE
                                             : Boolean.FALSE;
                    }
                }

                o = Column.convertObject(o, eArg2.eArg.getDataType());

                if (exprType == EQUAL || exprType == NOT_EQUAL) {
                    it = index.findFirstRow(session, o, EQUAL);

                    if (exprType == EQUAL) {
                        return (it.hasNext() && subquery.table.getRowCount(session) == 1)
                               ? Boolean.TRUE
                               : Boolean.FALSE;
                    }

                    return (it.hasNext()) ? Boolean.FALSE
                                          : Boolean.TRUE;
                }

                Row    lastrow   = index.lastRow(session);
                Object firstdata = firstrow.getData()[0];
View Full Code Here

                    if (script) {
                        schemaToLog = t.getName().schema;

                        writeTableInit(t);

                        RowIterator it = t.rowIterator(currentSession);

                        rowCount = 0;

                        while (it.hasNext()) {
                            writeRow(currentSession, t, it.next().getData());

                            rowCount++;
                        }

                        writeTableTerm(t);
View Full Code Here

     * Returns the node count.
     */
    int size(Session session) throws HsqlException {

        int         count = 0;
        RowIterator it    = firstRow(session);

        while (it.hasNext()) {
            it.next();

            count++;
        }

        return count;
View Full Code Here

        int   count      = 0;

        pointerLookup.setKeysSearchTarget();
        Trace.printSystemOut("lookup begins: " + stopw.elapsedTime());

        RowIterator it = table.rowIterator(session);

        for (; it.hasNext(); count++) {
            CachedObject row = (CachedObject) it.next();

            pointerLookup.addUnsorted(row.getPos(), (int) (pos / scale));

            if (count % 50000 == 0) {
                Trace.printSystemOut("pointer pair for row " + count + " "
                                     + row.getPos() + " " + pos);
            }

            pos += row.getStorageSize();
        }

        Trace.printSystemOut(table.getName().name + " list done ",
                             stopw.elapsedTime());

        count = 0;
        it    = table.rowIterator(session);

        for (; it.hasNext(); count++) {
            CachedObject row = it.next();

            rowOut.reset();
            row.write(rowOut, pointerLookup);
            fileStreamOut.write(rowOut.getOutputStream().getBuffer(), 0,
                                rowOut.size());
View Full Code Here

    void checkConvertColDataType(Column oldCol,
                                 Column newCol) throws HsqlException {

        int         colIndex = table.getColumnNr(oldCol.columnName.name);
        RowIterator it       = table.getPrimaryIndex().firstRow(session);

        while (it.hasNext()) {
            Row    row = it.next();
            Object o   = row.getData()[colIndex];

            Column.convertObject(session, o, newCol.getType(),
                                 newCol.getSize(), newCol.getScale());
        }
View Full Code Here

                throw Trace.error(Trace.TRY_TO_INSERT_NULL);
            }

            table.checkColumnInFKConstraint(colIndex, Constraint.SET_NULL);
        } else {
            RowIterator it = table.getPrimaryIndex().firstRow(session);

            while (it.hasNext()) {
                Row    row = it.next();
                Object o   = row.getData()[colIndex];

                if (o == null) {
                    throw Trace.error(Trace.TRY_TO_INSERT_NULL);
                }
View Full Code Here

     */
    static void checkReferencedRows(Session session, Table table,
                                    int[] rowColArray,
                                    Index mainIndex) throws HsqlException {

        RowIterator it = table.getPrimaryIndex().firstRow(session);

        while (true) {
            Row row = it.next();

            if (row == null) {
                break;
            }

View Full Code Here

    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);
        }
View Full Code Here

TOP

Related Classes of org.hsqldb.index.RowIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.