Search in sources :

Example 1 with TemporaryRowHolder

use of org.apache.derby.iapi.sql.execute.TemporaryRowHolder in project derby by apache.

the class DependentResultSet method getNextParentRow.

// this function will return the rows from the parent result sets
private ExecRow getNextParentRow() throws StandardException {
    ExecRow cRow;
    TemporaryRowHolder rowHolder;
    if (sourceOpened[sArrayIndex] == 0) {
        rowHolder = sourceRowHolders[sArrayIndex];
        source = (TemporaryRowHolderResultSet) rowHolder.getResultSet();
        // open the cursor result set
        source.open();
        sourceOpened[sArrayIndex] = -1;
        sourceResultSets[sArrayIndex] = source;
    }
    if (sourceOpened[sArrayIndex] == 1) {
        source = sourceResultSets[sArrayIndex];
        source.reStartScan(sourceRowHolders[sArrayIndex].getTemporaryConglomId(), sourceRowHolders[sArrayIndex].getPositionIndexConglomId());
        sourceOpened[sArrayIndex] = -1;
    }
    if (sVector.size() > sourceRowHolders.length) {
        addNewSources();
    }
    cRow = source.getNextRow();
    while (cRow == null && (sArrayIndex + 1) < sourceRowHolders.length) {
        // opening the next source;
        sArrayIndex++;
        if (sourceOpened[sArrayIndex] == 0) {
            rowHolder = sourceRowHolders[sArrayIndex];
            source = (TemporaryRowHolderResultSet) rowHolder.getResultSet();
            // open the cursor result set
            source.open();
            sourceOpened[sArrayIndex] = -1;
            sourceResultSets[sArrayIndex] = source;
        }
        if (sourceOpened[sArrayIndex] == 1) {
            source = sourceResultSets[sArrayIndex];
            source.reStartScan(sourceRowHolders[sArrayIndex].getTemporaryConglomId(), sourceRowHolders[sArrayIndex].getPositionIndexConglomId());
            sourceOpened[sArrayIndex] = -1;
        }
        cRow = source.getNextRow();
    }
    if (cRow == null) {
        // which means no source has any more  currently rows.
        sArrayIndex = 0;
        // mark all the sources to  restartScan.
        for (int i = 0; i < sourceOpened.length; i++) sourceOpened[i] = 1;
    }
    return cRow;
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) TemporaryRowHolder(org.apache.derby.iapi.sql.execute.TemporaryRowHolder)

Example 2 with TemporaryRowHolder

use of org.apache.derby.iapi.sql.execute.TemporaryRowHolder in project derby by apache.

the class DeleteCascadeResultSet method mergeResultSets.

@SuppressWarnings("UseOfObsoleteCollectionType")
private void mergeResultSets() throws StandardException {
    Vector<TemporaryRowHolder> sVector = activation.getParentResultSet(resultSetId);
    int size = sVector.size();
    // temporary result set.
    if (size > 1) {
        ExecRow row;
        int rowHolderId = 0;
        // copy all the vallues in the result set to the current resultset row holder
        while (rowHolderId < size) {
            if (rowHolderId == tempRowHolderId) {
                // skipping the row holder that  we are copying the rows into.
                rowHolderId++;
                continue;
            }
            TemporaryRowHolder currentRowHolder = sVector.elementAt(rowHolderId);
            CursorResultSet rs = currentRowHolder.getResultSet();
            rs.open();
            while ((row = rs.getNextRow()) != null) {
                rowHolder.insert(row);
            }
            rs.close();
            rowHolderId++;
        }
    }
}
Also used : CursorResultSet(org.apache.derby.iapi.sql.execute.CursorResultSet) TemporaryRowHolder(org.apache.derby.iapi.sql.execute.TemporaryRowHolder) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow)

Example 3 with TemporaryRowHolder

use of org.apache.derby.iapi.sql.execute.TemporaryRowHolder in project derby by apache.

the class DeleteCascadeResultSet method setRowHoldersTypeToUniqueStream.

/*
	**Incases where we have multiple paths we could get the same
	**rows to be deleted  mutiple time and also in case of cycles
	**there might be new rows getting added to the row holders through
	**multiple iterations. To handle these case we set the temporary row holders
	** to be  'uniqStream' type.
	**/
@SuppressWarnings("UseOfObsoleteCollectionType")
private void setRowHoldersTypeToUniqueStream() {
    for (Enumeration<String> e = activation.getParentResultSetKeys(); e.hasMoreElements(); ) {
        String rsId = e.nextElement();
        Vector<TemporaryRowHolder> sVector = activation.getParentResultSet(rsId);
        int size = sVector.size();
        int rowHolderId = 0;
        while (rowHolderId < size) {
            TemporaryRowHolder currentRowHolder = sVector.elementAt(rowHolderId);
            currentRowHolder.setRowHolderTypeToUniqueStream();
            rowHolderId++;
        }
    }
}
Also used : TemporaryRowHolder(org.apache.derby.iapi.sql.execute.TemporaryRowHolder)

Aggregations

TemporaryRowHolder (org.apache.derby.iapi.sql.execute.TemporaryRowHolder)3 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)2 CursorResultSet (org.apache.derby.iapi.sql.execute.CursorResultSet)1