Package org.apache.derby.iapi.store.access

Examples of org.apache.derby.iapi.store.access.ScanController


  /* Open an unqualified scan on the heap for update */
  private ScanController openUnqualifiedHeapScan()
    throws StandardException
  {
    ScanController heapScan;

    heapScan = tc.openScan(td.getHeapConglomerateId(),
                false,  // hold
                TransactionController.OPENMODE_FORUPDATE,    //  forUpdate
                TransactionController.MODE_TABLE,
View Full Code Here


  /* Open an unqualified scan on the index for update */
  private ScanController openUnqualifiedIndexScan()
    throws StandardException
  {
    ScanController indexScan;

    indexScan = tc.openScan(id.getConglomerateNumber(),
                false,  // hold
                TransactionController.OPENMODE_FORUPDATE,    //  forUpdate
                TransactionController.MODE_TABLE,
View Full Code Here

              int indexNumber,
              boolean wait)
     throws StandardException
  {
    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

                  int indexNumber,
                  RowLocation rl[])

     throws StandardException
  {
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    ExecRow            baseRow = crf.makeEmptyRow();

    drivingScan = tc.openScan(
      getIndexConglomerate(indexNumber),
                           // conglomerate to open
      false,               // don't hold open across commit
      0,                   // open for read
            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());

    try  {
      if (drivingScan.fetchNext(drivingIndexRow.getRowArray()))
      {
        rl[0] = 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");
                }

        return baseRow;
      }
      else
      {
        return null;
      }
    }

    finally {
      drivingScan.close();
    }
  }
View Full Code Here

               TransactionController  tc,
               boolean wait)
    throws StandardException
  {
    ConglomerateController    heapCC;
    ScanController        drivingScan;
    ExecIndexRow         drivingIndexRow;
    RowLocation          baseRowLocation;
    ExecIndexRow        templateRow;
    ExecRow            baseRow = crf.makeEmptyRow();

    if (SanityManager.DEBUG)
    {
      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

            str = new String();

            e = scanControllers.elements();
            while (e.hasMoreElements())
            {
                ScanController sc = (ScanController) e.nextElement();
                str += "open scan controller: " + sc + "\n";
            }

            e = conglomerateControllers.elements();
            while (e.hasMoreElements())
View Full Code Here

      throw StandardException.newException(
                    SQLState.AM_NO_SUCH_SORT, new Long(id));
    }

    // Open a scan on it.
    ScanController sc = sort.openSortScan(this, hold);

    // Keep track of it so we can release on close.
    scanControllers.addElement(sc);

    return sc;
View Full Code Here

  {
    ConglomerateController  heapCC = null;
    ExecIndexRow        indexRow1;
    ExecIndexRow      indexTemplateRow;
    ExecRow         outRow;
    ScanController      scanController = null;
    boolean          foundRow;
    FormatableBitSet          colToCheck = new FormatableBitSet(indexCol);
    CatalogRowFactory    rf = ti.getCatalogRowFactory()

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(indexId >= 0, "code needs to be enhanced"+
        " to support a table scan to find the index id");
    }

    colToCheck.set(indexCol - 1);

    ScanQualifier[][] qualifier = exFactory.getScanQualifier(1);
    qualifier[0][0].setQualifier
        (indexCol - 1,
         schemaIdOrderable,
         Orderable.ORDER_OP_EQUALS,
         false,
         false,
         false);

    outRow = rf.makeEmptyRow();

    try
    {
      heapCC =
              tc.openConglomerate(
                  ti.getHeapConglomerate(), false, 0,
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);
 
      scanController = tc.openScan(
          ti.getIndexConglomerate(indexId)// conglomerate to open
          false,                 // don't hold open across commit
          0,                                  // for read
                  TransactionController.MODE_RECORD,  // row locking
                    TransactionController.ISOLATION_REPEATABLE_READ,
          colToCheck,             // don't get any rows
          null,                 // start position - first row
          ScanController.GE,            // startSearchOperation
          qualifier,               // scanQualifier,
          null,                 // stop position - through last row
          ScanController.GT);           // stopSearchOperation
 
      foundRow = (scanController.next());
    }
    finally
    {
      if (scanController != null
      {
        scanController.close();
      }
      if (heapCC != null)
      {
        heapCC.close();
      }
View Full Code Here

            dvf.getDataValue(false);
    replaceRow[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE - 1] =
            dvf.getDataValue((Object) null);

    /* Scan the entire heap */
    ScanController sc =
            tc.openScan(
                ti.getHeapConglomerate(),
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_TABLE,
                TransactionController.ISOLATION_REPEATABLE_READ,
                columnToReadSet,
                (DataValueDescriptor[]) null,
                ScanController.NA,
                (Qualifier[][]) null,
                (DataValueDescriptor[]) null,
                ScanController.NA);

    while (sc.fetchNext((DataValueDescriptor[]) null))
    {
      /* Replace the column in the table */
      sc.replace(replaceRow, columnToUpdateSet);
    }

    sc.close();
  }
View Full Code Here

    ConstraintDescriptor  cd = null;
    ExecIndexRow        indexRow1;
    ExecIndexRow      indexTemplateRow;
    ExecRow         outRow;
    RowLocation        baseRowLocation;
    ScanController      scanController;
    TransactionController  tc;

    // Get the current transaction controller
    tc = getTransactionCompile();

    outRow = rf.makeEmptyRow();

    heapCC =
            tc.openConglomerate(
                ti.getHeapConglomerate(), false, 0,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_REPEATABLE_READ);


    /* Scan the index and go to the data pages for qualifying rows to
     * build the column descriptor.
     */
    scanController = tc.openScan(
        ti.getIndexConglomerate(indexId)// conglomerate to open
        false, // don't hold open across commit
        (forUpdate) ? TransactionController.OPENMODE_FORUPDATE : 0,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_REPEATABLE_READ,
        (FormatableBitSet) null,         // all fields as objects
        keyRow.getRowArray(),   // start position - exact key match.
        ScanController.GE,      // startSearchOperation
        null,                   //scanQualifier,
        keyRow.getRowArray(),   // stop position - exact key match.
        ScanController.GT);     // stopSearchOperation

    while (scanController.next())
    {
      SubConstraintDescriptor subCD = null;

      // create an index row template
      indexRow1 = getIndexRowFromHeapRow(
                  ti.getIndexRowGenerator(indexId),
                  heapCC.newRowLocationTemplate(),
                  outRow);

      scanController.fetch(indexRow1.getRowArray());

      baseRowLocation = (RowLocationindexRow1.getColumn(
                        indexRow1.nColumns());

      boolean base_row_exists =
                heapCC.fetch(
                    baseRowLocation, outRow.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 doesn't exist");
            }

      switch (rf.getConstraintType(outRow))
      {
        case DataDictionary.PRIMARYKEY_CONSTRAINT:
        case DataDictionary.FOREIGNKEY_CONSTRAINT:
        case DataDictionary.UNIQUE_CONSTRAINT:
          subCD = getSubKeyConstraint(
                rf.getConstraintId(outRow), rf.getConstraintType(outRow));
          break;

        case DataDictionary.CHECK_CONSTRAINT:
          subCD = getSubCheckConstraint(
                rf.getConstraintId(outRow));
          break;

        default:
          if (SanityManager.DEBUG)
          {
            SanityManager.THROWASSERT("unexpected value "+
                "from rf.getConstraintType(outRow)" +
                rf.getConstraintType(outRow));
          }
      }

      if (SanityManager.DEBUG)
      {
        SanityManager.ASSERT(subCD != null,
                   "subCD is expected to be non-null");
      }

      /* Cache the TD in the SCD so that
       * the row factory doesn't need to go
       * out to disk to get it.
       */
      subCD.setTableDescriptor(td);

      cd = (ConstraintDescriptor) rf.buildDescriptor(
                        outRow,
                        subCD,
                        this);

      /* If dList is null, then caller only wants a single descriptor - we're done
       * else just add the current descriptor to the list.
       */
      if (dList == null)
      {
        break;
      }
      else
      {
        dList.add(cd);
      }
    }
        scanController.close();
    heapCC.close();
    return cd;
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.access.ScanController

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.