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

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


      baseRowLocation =
        (RowLocation) (rlColumn).getObject();
   
      if(!uniqueIndexCreated)
      {
        TransactionController tc =
          activation.getTransactionController();
        int numKeys = 2;
        uniqueIndexRow = new DataValueDescriptor[numKeys];
        uniqueIndexRow[0] = baseRowLocation;
        uniqueIndexRow[1] = baseRowLocation;
        Properties props = makeIndexProperties(uniqueIndexRow, CID);
        uniqueIndexConglomId =
          tc.createConglomerate(
                        "BTREE",
                        uniqueIndexRow,
                        null, 
                        null, // no collation needed for index on row locations.
                        props,
                        (TransactionController.IS_TEMPORARY |
                         TransactionController.IS_KEPT));

        uniqueIndex_cc = tc.openConglomerate(
                uniqueIndexConglomId,
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_TABLE,
                TransactionController.ISOLATION_SERIALIZABLE);
View Full Code Here


  private void insertToPositionIndex(int position, RowLocation rl ) throws  StandardException
  {
    if(!positionIndexCreated)
    {
      TransactionController tc = activation.getTransactionController();
      int numKeys = 2;
      position_sqllong = new SQLLongint();
      positionIndexRow = new DataValueDescriptor[numKeys];
      positionIndexRow[0] = position_sqllong;
      positionIndexRow[1] = rl;       
      Properties props = makeIndexProperties(positionIndexRow, CID);
      positionIndexConglomId =
                tc.createConglomerate(
                    "BTREE",
                    positionIndexRow,
                    null, 
                    null, // no collation needed for index on row locations.
                    props,
                    (TransactionController.IS_TEMPORARY |
                     TransactionController.IS_KEPT));

      positionIndex_cc =
                tc.openConglomerate(
                    positionIndexConglomId,
                    false,
                    TransactionController.OPENMODE_FORUPDATE,
                    TransactionController.MODE_TABLE,
                    TransactionController.ISOLATION_SERIALIZABLE);
View Full Code Here

   * @return a result set to use
   */
  public CursorResultSet getResultSet()
  {
    state = STATE_DRAIN;
    TransactionController tc = activation.getTransactionController();
    if(isUniqueStream)
    {
      return new TemporaryRowHolderResultSet(tc, rowArray,
                           resultDescription, isVirtualMemHeap,
                           true, positionIndexConglomId, this);
View Full Code Here

    {
      positionIndex_cc.close();
      positionIndex_cc = null;
    }

    TransactionController tc = activation.getTransactionController();

    if (uniqueIndexCreated)
    {
      tc.dropConglomerate(uniqueIndexConglomId);
      uniqueIndexCreated = false;
    }

    if (positionIndexCreated)
    {
      tc.dropConglomerate(positionIndexConglomId);
      positionIndexCreated = false;
    }

    if (conglomCreated)
    {
      tc.dropConglomerate(CID);
      conglomCreated = false;
            CID = 0;
    }
        else
        {
View Full Code Here

        // Extract/derive information from the table descriptor
        long[] conglomerateNumber = new long[cds.length];
        ExecIndexRow[] indexRow = new ExecIndexRow[cds.length];
        UUID[] objectUUID = new UUID[cds.length];

        TransactionController tc = lcc.getTransactionExecute();
        ConglomerateController heapCC =
            tc.openConglomerate(td.getHeapConglomerateId(), false,
                    0,
                    TransactionController.MODE_RECORD,
                    asBackgroundTask
                        ? TransactionController.ISOLATION_READ_UNCOMMITTED
                        : TransactionController.ISOLATION_REPEATABLE_READ
                );
        try
        {
            for (int i = 0; i < cds.length; i++)
            {
                if (!cds[i].isIndex())
                {
                    conglomerateNumber[i] = -1;
                    continue;
                }

                conglomerateNumber[i] = cds[i].getConglomerateNumber();

                objectUUID[i] = cds[i].getUUID();

                indexRow[i] =
                    cds[i].getIndexDescriptor().getNullIndexRow(
                        td.getColumnDescriptorList(),
                        heapCC.newRowLocationTemplate());
            }
        }
        finally
        {
            heapCC.close();
        }

        // [x][0] = conglomerate number, [x][1] = start time, [x][2] = stop time
        long[][] scanTimes = new long[conglomerateNumber.length][3];
        int sci = 0;
        for (int indexNumber = 0;
             indexNumber < conglomerateNumber.length;
             indexNumber++)
        {
            if (conglomerateNumber[indexNumber] == -1)
                continue;

            // Check if daemon has been disabled.
            if (asBackgroundTask) {
                if (isShuttingDown()) {
                    break;
                }
            }

            scanTimes[sci][0] = conglomerateNumber[indexNumber];
            scanTimes[sci][1] = System.currentTimeMillis();
            // Subtract one for the RowLocation added for indexes.
            int numCols = indexRow[indexNumber].nColumns() - 1;
            long[] cardinality = new long[numCols];
            KeyComparator cmp = new KeyComparator(indexRow[indexNumber]);

            /* Read uncommitted, with record locking. Actually CS store may
               not hold record locks */
            GroupFetchScanController gsc =
                tc.openGroupFetchScan(
                        conglomerateNumber[indexNumber],
                        false,  // hold
                        0,
                        TransactionController.MODE_RECORD, // locking
                        TransactionController.ISOLATION_READ_UNCOMMITTED,
View Full Code Here

    private void writeUpdatedStats(LanguageConnectionContext lcc,
                                   TableDescriptor td, UUID index,
                                   long numRows, long[] cardinality,
                                   boolean asBackgroundTask)
            throws StandardException {
        TransactionController tc = lcc.getTransactionExecute();
        trace(1, "writing new stats (xid=" + tc.getTransactionIdString() + ")");
        UUID table = td.getUUID();
        DataDictionary dd = lcc.getDataDictionary();
        UUIDFactory uf = dd.getUUIDFactory();

        // Update the heap row count estimate.
View Full Code Here

                        "failed to initialize index statistics updater");
                return;
            }
        }

        TransactionController tc = null;
        try {
            tc = daemonLCC.getTransactionExecute();
            trace(0, "worker thread started (xid=" +
                    tc.getTransactionIdString() + ")");

            TableDescriptor td = null;
            long start = 0;
            while (true) {
                synchronized (queue) {
                    if (daemonDisabled) {
                        // Clean the lcc and exit.
                        try {
                            tc.destroy();
                        } catch (ShutdownException se) {
                            // Ignore
                        }
                        tc = null;
                        daemonLCC = null;
View Full Code Here

    try {
    Authorizer a = lcc.getAuthorizer();
    a.authorize((Activation) null, Authorizer.PROPERTY_WRITE_OP);

        // Get the current transaction controller
        TransactionController tc = lcc.getTransactionExecute();

    tc.setProperty(key, value, false);
    } catch (StandardException se) {
      throw PublicAPI.wrapStandardException(se);
    }
  }
View Full Code Here

        // find the language context.
        LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();

        // Get the current transaction controller
        TransactionController tc = lcc.getTransactionExecute();

    try {

    // find the DataDictionary
    DataDictionary dd = lcc.getDataDictionary();


    // get the SchemaDescriptor
    SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
    if ( !isIndex)
    {
      // get the TableDescriptor for the table
      TableDescriptor td = dd.getTableDescriptor(conglomerateName, sd);

      // Return an empty Properties if table does not exist or if it is for a view.
      if ((td == null) || td.getTableType() == TableDescriptor.VIEW_TYPE) { return new Properties(); }

      conglomerateNumber = td.getHeapConglomerateId();
    }
    else
    {
      // get the ConglomerateDescriptor for the index
      ConglomerateDescriptor cd = dd.getConglomerateDescriptor(conglomerateName, sd, false);

      // Return an empty Properties if index does not exist
      if (cd == null) { return new Properties(); }

      conglomerateNumber = cd.getConglomerateNumber();
    }

    ConglomerateController cc = tc.openConglomerate(
                conglomerateNumber,
                false,
                0,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    Properties properties = tc.getUserCreateConglomPropList();
    cc.getTableProperties( properties );

    cc.close();
        return properties;
View Full Code Here

            throws SQLException
  {
    DataDictionary      dd;
    TableDescriptor      td;
    long          baseRowCount = -1;
    TransactionController  tc;
    ConglomerateDescriptor  heapCD;
    ConglomerateDescriptor  indexCD;
    ExecRow          baseRow;
    ExecRow          indexRow;
    RowLocation        rl = null;
    RowLocation        scanRL = null;
    ScanController      scan = null;
    int[]          baseColumnPositions;
    int            baseColumns = 0;
    DataValueFactory    dvf;
    long          indexRows;
    ConglomerateController  baseCC = null;
    ConglomerateController  indexCC = null;
    SchemaDescriptor    sd;
    ConstraintDescriptor  constraintDesc;

    LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
    tc = lcc.getTransactionExecute();

    try {

            dd = lcc.getDataDictionary();

            dvf = lcc.getDataValueFactory();
           
            ExecutionFactory ef = lcc.getLanguageConnectionFactory().getExecutionFactory();

            sd = dd.getSchemaDescriptor(schemaName, tc, true);
            td = dd.getTableDescriptor(tableName, sd);

            if (td == null)
            {
                throw StandardException.newException(
                    SQLState.LANG_TABLE_NOT_FOUND,
                    schemaName + "." + tableName);
            }

            /* Skip views */
            if (td.getTableType() == TableDescriptor.VIEW_TYPE)
            {
                return true;
            }

      /* Open the heap for reading */
      baseCC = tc.openConglomerate(
                  td.getHeapConglomerateId(), false, 0,
                TransactionController.MODE_TABLE,
              TransactionController.ISOLATION_SERIALIZABLE);

      /* Check the consistency of the heap */
      baseCC.checkConsistency();

      heapCD = td.getConglomerateDescriptor(td.getHeapConglomerateId());

      /* Get a row template for the base table */
      baseRow = ef.getValueRow(td.getNumberOfColumns());

      /* Fill the row with nulls of the correct type */
      ColumnDescriptorList cdl = td.getColumnDescriptorList();
      int           cdlSize = cdl.size();

      for (int index = 0; index < cdlSize; index++)
      {
        ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
        baseRow.setColumn(cd.getPosition(),
                    cd.getType().getNull());
      }

      /* Look at all the indexes on the table */
      ConglomerateDescriptor[] cds = td.getConglomerateDescriptors();
      for (int index = 0; index < cds.length; index++)
      {
        indexCD = cds[index];
        /* Skip the heap */
        if ( ! indexCD.isIndex())
          continue;

        /* Check the internal consistency of the index */
        indexCC =
              tc.openConglomerate(
                indexCD.getConglomerateNumber(),
                        false,
              0,
            TransactionController.MODE_TABLE,
                      TransactionController.ISOLATION_SERIALIZABLE);

        indexCC.checkConsistency();
        indexCC.close();
        indexCC = null;

        /* if index is for a constraint check that the constraint exists */

        if (indexCD.isConstraint())
        {
          constraintDesc = dd.getConstraintDescriptor(td, indexCD.getUUID());
          if (constraintDesc == null)
          {
            throw StandardException.newException(
                    SQLState.LANG_OBJECT_NOT_FOUND,
                    "CONSTRAINT for INDEX",
                    indexCD.getConglomerateName());
          }
        }

        /*
        ** Set the base row count when we get to the first index.
        ** We do this here, rather than outside the index loop, so
        ** we won't do the work of counting the rows in the base table
        ** if there are no indexes to check.
        */
        if (baseRowCount < 0)
        {
          scan = tc.openScan(heapCD.getConglomerateNumber(),
                    false,  // hold
                    0,    // not forUpdate
                      TransactionController.MODE_TABLE,
                      TransactionController.ISOLATION_SERIALIZABLE,
                                        RowUtil.EMPTY_ROW_BITSET,
                    null,  // startKeyValue
                    0,    // not used with null start posn.
                    null,  // qualifier
                    null,  // stopKeyValue
                    0);    // not used with null stop posn.

          /* Also, get the row location template for index rows */
          rl = scan.newRowLocationTemplate();
          scanRL = scan.newRowLocationTemplate();

          for (baseRowCount = 0; scan.next(); baseRowCount++)
            /* Empty statement */

          scan.close();
          scan = null;
        }

        baseColumnPositions =
            indexCD.getIndexDescriptor().baseColumnPositions();
        baseColumns = baseColumnPositions.length;

        FormatableBitSet indexColsBitSet = new FormatableBitSet();
        for (int i = 0; i < baseColumns; i++)
        {
          indexColsBitSet.grow(baseColumnPositions[i]);
          indexColsBitSet.set(baseColumnPositions[i] - 1);
        }

        /* Get one row template for the index scan, and one for the fetch */
        indexRow = ef.getValueRow(baseColumns + 1);

        /* Fill the row with nulls of the correct type */
        for (int column = 0; column < baseColumns; column++)
        {
          /* Column positions in the data dictionary are one-based */
           ColumnDescriptor cd = td.getColumnDescriptor(baseColumnPositions[column]);
          indexRow.setColumn(column + 1,
                      cd.getType().getNull());
        }

        /* Set the row location in the last column of the index row */
        indexRow.setColumn(baseColumns + 1, rl);

        /* Do a full scan of the index */
        scan = tc.openScan(indexCD.getConglomerateNumber(),
                  false,  // hold
                  0,    // not forUpdate
                    TransactionController.MODE_TABLE,
                        TransactionController.ISOLATION_SERIALIZABLE,
                  (FormatableBitSet) null,
View Full Code Here

TOP

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

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.