Examples of ScanController


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

  {
    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

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

            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

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

    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

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

  {
    SYSCONSTRAINTSRowFactory rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
    ConglomerateController  heapCC;
    ExecRow         outRow;
    ExecRow         templateRow;
    ScanController      scanController;
    TransactionController  tc;
    ConstraintDescriptor  cd = null;

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

    outRow = rf.makeEmptyRow();

    /*
    ** Table scan
    */
    scanController = tc.openScan(
        ti.getHeapConglomerate(),    // conglomerate to open
        false,               // don't hold open across commit
        0,                 // for read
        TransactionController.MODE_TABLE,
                TransactionController.ISOLATION_REPEATABLE_READ,
        (FormatableBitSet) null,               // all fields as objects
        (DataValueDescriptor[]) null, // start position - first row
        0,                    // startSearchOperation - none
        scanQualifiers,           // scanQualifier,
        (DataValueDescriptor[]) null, // stop position -through last row
        0);                   // stopSearchOperation - none

    try
    {
      while (scanController.fetchNext(outRow.getRowArray()))
      {
        SubConstraintDescriptor subCD = null;
 
        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");
        }
        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 (list == null)
        {
          break;
        }
        else
        {
          list.add(cd);
        }
      }
    }
    finally
    {
      scanController.close();
    }
    return cd;
  }
View Full Code Here

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

    ExecIndexRow        indexRow1;
    ExecIndexRow      indexTemplateRow;
    ExecRow         outRow;
    RowLocation        baseRowLocation;
    ConglomerateController  heapCC = null;
    ScanController      scanController = null;
    TransactionController  tc;
    TabInfoImpl         ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    SYSCONSTRAINTSRowFactory rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
    TableDescriptor      td = null;
    List          slist = newSList();

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX1_ID ||
                 indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX3_ID,
                  "bad index id, must be one of the indexes on a uuid");
      SanityManager.ASSERT(columnNum > 0 &&
                 columnNum <= SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT,
                  "invalid column number for column to be retrieved");
    }

    try
    {
      /* Use tableIDOrderable in both start and stop positions for scan */
      DataValueDescriptor orderable = getIDValueAsCHAR(uuid);
 
      /* Set up the start/stop position for the scan */
      ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
      keyRow.setColumn(1, orderable);

      // Get the current transaction controller
      tc = getTransactionCompile();
 
      outRow = rf.makeEmptyRow();
 
      heapCC =
                tc.openConglomerate(
                    ti.getHeapConglomerate(), false, 0,
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

      // create an index row template
      indexRow1 = getIndexRowFromHeapRow(
                ti.getIndexRowGenerator(indexId),
                heapCC.newRowLocationTemplate(),
                outRow);
 
      // just interested in one column
      DataValueDescriptor[] rowTemplate    =
              new DataValueDescriptor[SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT];
      FormatableBitSet  columnToGetSet =
              new FormatableBitSet(SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT);
      columnToGetSet.set(columnNum - 1);

      rowTemplate[columnNum - 1] = new SQLChar();
 
      // Scan the index and go to the data pages for qualifying rows
      scanController = tc.openScan(
          ti.getIndexConglomerate(indexId),// conglomerate to open
          false,               // don't hold open across commit
          0,                 // for read
                  TransactionController.MODE_RECORD,
                  TransactionController.ISOLATION_REPEATABLE_READ,// RESOLVE: should be level 2
          (FormatableBitSet) null,                 // all fields as objects
          keyRow.getRowArray(),      // start position - exact key match.
          ScanController.GE,         // startSearchOperation
          null,               // scanQualifier (none)
          keyRow.getRowArray(),      // stop position - exact key match.
          ScanController.GT);        // stopSearchOperation

      while (scanController.fetchNext(indexRow1.getRowArray()))
      { 
        baseRowLocation = (RowLocation
                    indexRow1.getColumn(indexRow1.nColumns());
 
        // get the row and grab the uuid
        boolean base_row_exists =
                    heapCC.fetch(
                        baseRowLocation, rowTemplate, columnToGetSet);

                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");
                }

        slist.add(uuidFactory.recreateUUID(
                    (String)((DataValueDescriptor)rowTemplate[columnNum - 1]).getObject()));
      }
    }
    finally
    {
      if (heapCC != null)
      {
        heapCC.close();
      }
      if (scanController != null)
      {
        scanController.close();
      }
    }
    return slist;
  }
View Full Code Here

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

  public Hashtable hashAllConglomerateDescriptorsByNumber(TransactionController tc)
    throws StandardException
  {
    Hashtable ht = new Hashtable();
    ConglomerateDescriptor    cd = null;
    ScanController        scanController;
    ExecRow           outRow;
    // ExecIndexRow        keyRow = null;
    TabInfoImpl            ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    SYSCONGLOMERATESRowFactory  rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();

    outRow = rf.makeEmptyRow();
    scanController = tc.openScan(
        ti.getHeapConglomerate()// conglomerate to open
        false, // don't hold open across commit
        0, // for read
                TransactionController.MODE_RECORD,  // scans whole table.
                TransactionController.ISOLATION_READ_UNCOMMITTED,
        (FormatableBitSet) null, // all fields as objects
        (DataValueDescriptor[]) null, //keyRow.getRowArray(),   // start position - first row
        ScanController.GE,      // startSearchOperation
        (ScanQualifier [][]) null,
        (DataValueDescriptor[]) null, //keyRow.getRowArray(),   // stop position - through last row
        ScanController.GT);     // stopSearchOperation

        // it is important for read uncommitted scans to use fetchNext() rather
        // than fetch, so that the fetch happens while latch is held, otherwise
        // the next() might position the scan on a row, but the subsequent
        // fetch() may find the row deleted or purged from the table.
    while (scanController.fetchNext(outRow.getRowArray()))
    {
      cd = (ConglomerateDescriptor) rf.buildDescriptor(
                        outRow,
                        (TupleDescriptor) null,
                        this );
      Long hashKey = new Long(cd.getConglomerateNumber());
      ht.put(hashKey, cd);
    }

        scanController.close();

    return ht;
  }
View Full Code Here

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

   */
  public Hashtable hashAllTableDescriptorsByTableId(TransactionController tc)
    throws StandardException
  {
    Hashtable ht = new Hashtable();
    ScanController        scanController;
    ExecRow           outRow;
    TabInfoImpl          ti = coreInfo[SYSTABLES_CORE_NUM];
    SYSTABLESRowFactory
          rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();

    outRow = rf.makeEmptyRow();

    scanController = tc.openScan(
        ti.getHeapConglomerate(),       // sys.systable
        false,                          // don't hold open across commit
        0,                              // for read
                TransactionController.MODE_RECORD,// scans whole table.
                TransactionController.ISOLATION_READ_UNCOMMITTED,
        (FormatableBitSet) null,                 // all fields as objects
        (DataValueDescriptor[])null,    // start position - first row
        ScanController.GE,              // startSearchOperation
        (ScanQualifier[][])null,        //scanQualifier,
        (DataValueDescriptor[])null,    //stop position-through last row
        ScanController.GT);             // stopSearchOperation

        // it is important for read uncommitted scans to use fetchNext() rather
        // than fetch, so that the fetch happens while latch is held, otherwise
        // the next() might position the scan on a row, but the subsequent
        // fetch() may find the row deleted or purged from the table.
    while(scanController.fetchNext(outRow.getRowArray()))
    {
      TableDescriptor td = (TableDescriptor)
        rf.buildDescriptor(outRow, (TupleDescriptor)null,
                   this);
      ht.put(td.getUUID(), td);
    }
    scanController.close();
    return ht;
  }
View Full Code Here

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

   */
    public ConglomerateDescriptor[] getConglomerateDescriptors(
                    long conglomerateNumber)
                    throws StandardException
    {
      ScanController        scanController;
      TransactionController    tc;
      ExecRow           outRow;
      DataValueDescriptor      conglomNumberOrderable = null;
      TabInfoImpl            ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
      SYSCONGLOMERATESRowFactory  rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();
View Full Code Here

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

              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

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

                  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
TOP
Copyright © 2018 www.massapi.com. 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.