Examples of ScanController


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

            str = new String();

            for (Iterator it = scanControllers.iterator(); it.hasNext(); )
            {
                ScanController sc = (ScanController) it.next();
                str += "open scan controller: " + sc + "\n";
            }

            for (Iterator it = conglomerateControllers.iterator();
                 it.hasNext(); )
View Full Code Here

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

      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.add(sc);

    return sc;
View Full Code Here

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

                (long[]) null);

    closeBulkFetchScan();

    // Set the "estimated" row count
    ScanController compressHeapSC = tc.openScan(
              newHeapConglom,
              false,
              TransactionController.OPENMODE_FORUPDATE,
              TransactionController.MODE_TABLE,
                            TransactionController.ISOLATION_SERIALIZABLE,
              (FormatableBitSet) null,
              (DataValueDescriptor[]) null,
              0,
              (Qualifier[][]) null,
              (DataValueDescriptor[]) null,
              0);
   
    compressHeapSC.setEstimatedRowCount(rowCount);

    compressHeapSC.close();
    compressHeapSC = null; // RESOLVE DJD CLEANUP

    /*
    ** Inform the data dictionary that we are about to write to it.
    ** There are several calls to data dictionary "get" methods here
View Full Code Here

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

  private int getSemiRowCount(TransactionController tc)
    throws StandardException
  {
    int         numRows = 0;

    ScanController sc = tc.openScan(td.getHeapConglomerateId(),
             false,  // hold
             0,      // open read only
                         TransactionController.MODE_TABLE,
                         TransactionController.ISOLATION_SERIALIZABLE,
             RowUtil.EMPTY_ROW_BITSET, // scanColumnList
             null,  // start position
             ScanController.GE,      // startSearchOperation
             null, // scanQualifier
             null, //stop position - through last row
             ScanController.GT);     // stopSearchOperation

    while (sc.next())
    {
      numRows++;

      // We're only interested in whether the table has 0, 1 or > 1 rows
      if (numRows == 2)
      {
        break;
      }
    }
    sc.close();

    return numRows;
  }
View Full Code Here

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
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.