Package org.apache.derby.iapi.sql.execute

Examples of org.apache.derby.iapi.sql.execute.RowChanger


  {
    ConglomerateController    heapCC;
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    RowChanger           rc;
    ExecRow            baseRow = crf.makeEmptyRow();
    int                         rowsDeleted = 0;
    boolean            passedFilter = true;
   
    rc = getRowChanger( tc, (int[])null,baseRow );

    /*
    ** If we have a start and a stop key, then we are going to
    ** get row locks, otherwise, we are getting table locks.
    ** This may be excessive locking for the case where there
    ** is a start key and no stop key or vice versa.
    */
    int lockMode = ((startKey != null) && (stopKey != null)) ?
        tc.MODE_RECORD :
        tc.MODE_TABLE;

    /*
    ** Don't use level 3 if we have the same start/stop key.
    */
    int isolation =
            ((startKey != null) && (stopKey != null) && (startKey == stopKey)) ?
        TransactionController.ISOLATION_REPEATABLE_READ :
        TransactionController.ISOLATION_SERIALIZABLE;

    // Row level locking
    rc.open(lockMode, wait);

    DataValueDescriptor[] startKeyRow =
            startKey == null ? null : startKey.getRowArray();

    DataValueDescriptor[] stopKeyRow =
            stopKey == null  ? null : stopKey.getRowArray();

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    lockMode,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
        ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            lockMode,
      isolation,
      (FormatableBitSet) null, // all fields as objects
      startKeyRow,   // start position - first row
            startOp,      // startSearchOperation
      qualifier, //scanQualifier
      stopKeyRow,   // stop position - through last row
            stopOp);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());

      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }

      // only delete rows which pass the base-row filter
      if ( filter != null ) { passedFilter = filter.execute( baseRow ).equals( true ); }
      if ( passedFilter )
      {
        rc.deleteRow( baseRow, baseRowLocation );
        rowsDeleted++;
      }
    }

    heapCC.close();
    drivingScan.close();
    rc.close();
   
    return rowsDeleted;
  }
View Full Code Here


    {
      SanityManager.ASSERT( indicesToUpdate.length == crf.getNumIndexes(),
                 "Wrong number of indices." );
    }

    RowChanger           rc  = getRowChanger( tc, colsToUpdate,baseRow );

    // Row level locking
    rc.openForUpdate(indicesToUpdate, TransactionController.MODE_RECORD, wait);

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                    ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_REPEATABLE_READ,
      (FormatableBitSet) null,     // all fields as objects
      key.getRowArray(),   // start position - first row
            ScanController.GE,      // startSearchOperation
      null, //scanQualifier
      key.getRowArray(),   // stop position - through last row
            ScanController.GT);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    int rowNum = 0;
    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());
      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }
     
      rc.updateRow(baseRow, (rowNum == newRows.length - 1) ?
            newRows[rowNum] : newRows[rowNum++], baseRowLocation );
    }
    rc.finish();
    heapCC.close();
    drivingScan.close();
    rc.close();
  }
View Full Code Here

  {
    ConglomerateController    heapCC;
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    RowChanger           rc;
    ExecRow            baseRow = crf.makeEmptyRow();
    int                         rowsDeleted = 0;
    boolean            passedFilter = true;
   
    rc = getRowChanger( tc, (int[])null,baseRow );

    /*
    ** If we have a start and a stop key, then we are going to
    ** get row locks, otherwise, we are getting table locks.
    ** This may be excessive locking for the case where there
    ** is a start key and no stop key or vice versa.
    */
    int lockMode = ((startKey != null) && (stopKey != null)) ?
        tc.MODE_RECORD :
        tc.MODE_TABLE;

    /*
    ** Don't use level 3 if we have the same start/stop key.
    */
    int isolation =
            ((startKey != null) && (stopKey != null) && (startKey == stopKey)) ?
        TransactionController.ISOLATION_REPEATABLE_READ :
        TransactionController.ISOLATION_SERIALIZABLE;

    // Row level locking
    rc.open(lockMode, wait);

    DataValueDescriptor[] startKeyRow =
            startKey == null ? null : startKey.getRowArray();

    DataValueDescriptor[] stopKeyRow =
            stopKey == null  ? null : stopKey.getRowArray();

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    lockMode,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
        ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            lockMode,
      isolation,
      (FormatableBitSet) null, // all fields as objects
      startKeyRow,   // start position - first row
            startOp,      // startSearchOperation
      qualifier, //scanQualifier
      stopKeyRow,   // stop position - through last row
            stopOp);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());

      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }

      // only delete rows which pass the base-row filter
      if ( filter != null ) { passedFilter = filter.execute( baseRow ).equals( true ); }
      if ( passedFilter )
      {
        rc.deleteRow( baseRow, baseRowLocation );
        rowsDeleted++;
      }
    }

    heapCC.close();
    drivingScan.close();
    rc.close();
   
    return rowsDeleted;
  }
View Full Code Here

    {
      SanityManager.ASSERT( indicesToUpdate.length == crf.getNumIndexes(),
                 "Wrong number of indices." );
    }

    RowChanger           rc  = getRowChanger( tc, colsToUpdate,baseRow );

    // Row level locking
    rc.openForUpdate(indicesToUpdate, TransactionController.MODE_RECORD, wait);

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                    ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_REPEATABLE_READ,
      (FormatableBitSet) null,     // all fields as objects
      key.getRowArray(),   // start position - first row
            ScanController.GE,      // startSearchOperation
      null, //scanQualifier
      key.getRowArray(),   // stop position - through last row
            ScanController.GT);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    int rowNum = 0;
    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());
      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }
     
      rc.updateRow(baseRow, (rowNum == newRows.length - 1) ?
            newRows[rowNum] : newRows[rowNum++], baseRowLocation );
    }
    rc.finish();
    heapCC.close();
    drivingScan.close();
    rc.close();
  }
View Full Code Here

  private  RowChanger  getRowChanger( TransactionController tc,
                     int[] changedCols,
                     ExecRow baseRow)
    throws StandardException
  {
    RowChanger           rc;
    int              indexCount = crf.getNumIndexes();
    IndexRowGenerator[]      irgs = new IndexRowGenerator[ indexCount ];
    long[]            cids = new long[ indexCount ];

    if (SanityManager.DEBUG)
View Full Code Here

  {
    ConglomerateController    heapCC;
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    RowChanger           rc;
    ExecRow            baseRow = crf.makeEmptyRow();
    int                         rowsDeleted = 0;
    boolean            passedFilter = true;
   
    rc = getRowChanger( tc, (int[])null,baseRow );

    /*
    ** If we have a start and a stop key, then we are going to
    ** get row locks, otherwise, we are getting table locks.
    ** This may be excessive locking for the case where there
    ** is a start key and no stop key or vice versa.
    */
    int lockMode = ((startKey != null) && (stopKey != null)) ?
                TransactionController.MODE_RECORD :
                TransactionController.MODE_TABLE;

    /*
    ** Don't use level 3 if we have the same start/stop key.
    */
    int isolation =
            ((startKey != null) && (stopKey != null) && (startKey == stopKey)) ?
        TransactionController.ISOLATION_REPEATABLE_READ :
        TransactionController.ISOLATION_SERIALIZABLE;

    // Row level locking
    rc.open(lockMode, wait);

    DataValueDescriptor[] startKeyRow =
            startKey == null ? null : startKey.getRowArray();

    DataValueDescriptor[] stopKeyRow =
            stopKey == null  ? null : stopKey.getRowArray();

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    lockMode,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
        ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            lockMode,
      isolation,
      (FormatableBitSet) null, // all fields as objects
      startKeyRow,   // start position - first row
            startOp,      // startSearchOperation
      qualifier, //scanQualifier
      stopKeyRow,   // stop position - through last row
            stopOp);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());

      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }

      // only delete rows which pass the base-row filter
      if ( filter != null ) { passedFilter = filter.execute( baseRow ).equals( true ); }
      if ( passedFilter )
      {
        rc.deleteRow( baseRow, baseRowLocation );
        rowsDeleted++;
      }
    }

    heapCC.close();
    drivingScan.close();
    rc.close();
   
    return rowsDeleted;
  }
View Full Code Here

    {
      SanityManager.ASSERT( indicesToUpdate.length == crf.getNumIndexes(),
                 "Wrong number of indices." );
    }

    RowChanger           rc  = getRowChanger( tc, colsToUpdate,baseRow );

    // Row level locking
    rc.openForUpdate(indicesToUpdate, TransactionController.MODE_RECORD, true);

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    TransactionController.OPENMODE_FORUPDATE,
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      TransactionController.OPENMODE_FORUPDATE,
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_REPEATABLE_READ,
      (FormatableBitSet) null,     // all fields as objects
      key.getRowArray(),   // start position - first row
            ScanController.GE,      // startSearchOperation
      null, //scanQualifier
      key.getRowArray(),   // stop position - through last row
            ScanController.GT);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    int rowNum = 0;
    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());
      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }
     
      rc.updateRow(baseRow, (rowNum == newRows.length - 1) ?
            newRows[rowNum] : newRows[rowNum++], baseRowLocation );
    }
    rc.finish();
    heapCC.close();
    drivingScan.close();
    rc.close();
  }
View Full Code Here

  private  RowChanger  getRowChanger( TransactionController tc,
                     int[] changedCols,
                     ExecRow baseRow)
    throws StandardException
  {
    RowChanger           rc;
    int              indexCount = crf.getNumIndexes();
    IndexRowGenerator[]      irgs = new IndexRowGenerator[ indexCount ];
    long[]            cids = new long[ indexCount ];

    if (SanityManager.DEBUG)
View Full Code Here

  {
    ConglomerateController    heapCC;
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    RowChanger           rc;
    ExecRow            baseRow = crf.makeEmptyRow();
    int                         rowsDeleted = 0;
    boolean            passedFilter = true;
   
    rc = getRowChanger( tc, (int[])null,baseRow );

    /*
    ** If we have a start and a stop key, then we are going to
    ** get row locks, otherwise, we are getting table locks.
    ** This may be excessive locking for the case where there
    ** is a start key and no stop key or vice versa.
    */
    int lockMode = ((startKey != null) && (stopKey != null)) ?
                TransactionController.MODE_RECORD :
                TransactionController.MODE_TABLE;

    /*
    ** Don't use level 3 if we have the same start/stop key.
    */
    int isolation =
            ((startKey != null) && (stopKey != null) && (startKey == stopKey)) ?
        TransactionController.ISOLATION_REPEATABLE_READ :
        TransactionController.ISOLATION_SERIALIZABLE;

    // Row level locking
    rc.open(lockMode, wait);

    DataValueDescriptor[] startKeyRow =
            startKey == null ? null : startKey.getRowArray();

    DataValueDescriptor[] stopKeyRow =
            stopKey == null  ? null : stopKey.getRowArray();

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    (TransactionController.OPENMODE_FORUPDATE |
                            ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
                    lockMode,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      (TransactionController.OPENMODE_FORUPDATE |
        ((wait) ? 0 : TransactionController.OPENMODE_LOCK_NOWAIT)),
            lockMode,
      isolation,
      (FormatableBitSet) null, // all fields as objects
      startKeyRow,   // start position - first row
            startOp,      // startSearchOperation
      qualifier, //scanQualifier
      stopKeyRow,   // stop position - through last row
            stopOp);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());

      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }

      // only delete rows which pass the base-row filter
      if ( filter != null ) { passedFilter = filter.execute( baseRow ).equals( true ); }
      if ( passedFilter )
      {
        rc.deleteRow( baseRow, baseRowLocation );
        rowsDeleted++;
      }
    }

    heapCC.close();
    drivingScan.close();
    rc.close();
   
    return rowsDeleted;
  }
View Full Code Here

    {
      SanityManager.ASSERT( indicesToUpdate.length == crf.getNumIndexes(),
                 "Wrong number of indices." );
    }

    RowChanger           rc  = getRowChanger( tc, colsToUpdate,baseRow );

    // Row level locking
    rc.openForUpdate(indicesToUpdate, TransactionController.MODE_RECORD, true);

    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(
                    getHeapConglomerate(),
                    false,
                    TransactionController.OPENMODE_FORUPDATE,
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber)// conglomerate to open
      false, // don't hold open across commit
      TransactionController.OPENMODE_FORUPDATE,
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_REPEATABLE_READ,
      (FormatableBitSet) null,     // all fields as objects
      key.getRowArray(),   // start position - first row
            ScanController.GE,      // startSearchOperation
      null, //scanQualifier
      key.getRowArray(),   // stop position - through last row
            ScanController.GT);     // stopSearchOperation

    // Get an index row based on the base row
    drivingIndexRow = getIndexRowFromHeapRow(
      getIndexRowGenerator( indexNumber ),
      heapCC.newRowLocationTemplate(),
      crf.makeEmptyRow());

    int rowNum = 0;
    while (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
    {
      baseRowLocation = (RowLocation)
            drivingIndexRow.getColumn(drivingIndexRow.nColumns());
      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, baseRow.getRowArray(), (FormatableBitSet) null);

            if (SanityManager.DEBUG)
            {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }
     
      rc.updateRow(baseRow, (rowNum == newRows.length - 1) ?
            newRows[rowNum] : newRows[rowNum++], baseRowLocation );
    }
    rc.finish();
    heapCC.close();
    drivingScan.close();
    rc.close();
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.execute.RowChanger

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.