Package org.apache.derby.iapi.sql.dictionary

Examples of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor


   */
  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();

View Full Code Here


  {
    SchemaDescriptor    sd = getSystemSchemaDescriptor( );
    DataDescriptorGenerator ddg = getDataDescriptorGenerator();
    long          indexConglomerateNumber;

    ConglomerateDescriptor  conglomerateDescriptor = bootstrapOneIndex
      ( sd, tc, ddg, ti, indexNumber, heapConglomerateNumber );

    indexConglomerateNumber = conglomerateDescriptor.getConglomerateNumber();

    addDescriptor(conglomerateDescriptor, sd,
            SYSCONGLOMERATES_CATALOG_NUM, false, tc);
           
    return indexConglomerateNumber;
View Full Code Here

    int              numColumns;
    long            conglomId;
    RowLocation          rl;
    CatalogRowFactory      rf = ti.getCatalogRowFactory();
    IndexRowGenerator      irg;
    ConglomerateDescriptor  conglomerateDescriptor;

    initSystemIndexVariables(ddg, ti, indexNumber);

    irg = ti.getIndexRowGenerator(indexNumber);
View Full Code Here

    addDescriptor(td, sd, SYSTABLES_CATALOG_NUM,
            false, tc);
    toid = td.getUUID();
 
    /* Add the conglomerate for the heap */
    ConglomerateDescriptor cgd = ddg.newConglomerateDescriptor(conglomId,
                                  heapName,
                                  false,
                                  null,
                                  false,
                                  heapUUID,
View Full Code Here

      if (td == null)
      {
        return;
      }

      ConglomerateDescriptor cd = null;
      ConglomerateDescriptor[] cds = td.getConglomerateDescriptors();

      /* Init the heap conglomerate here */
      for (int index = 0; index < cds.length; index++)
      {
        cd = cds[index];

        if (! cd.isIndex())
        {
          ti.setHeapConglomerate(cd.getConglomerateNumber());
          break;
        }
      }
     
      if (SanityManager.DEBUG)
      {
        if (cd == null)
        {
          SanityManager.THROWASSERT("No heap conglomerate found for "
            + ti.getTableName());
        }
      }

      /* Initialize the index conglomerates */
      numIndexes = ti.getCatalogRowFactory().getNumIndexes();
      if (numIndexes == 0)
      {
        return;
      }

      /* For each index, we get its id from the CDL */
      ConglomerateDescriptor icd = null;
      int  indexCount = 0;

      for (int index = 0; index < cds.length; index++)
      {
        icd = cds[index];

        if (icd.isIndex())
        {
          ti.setIndexConglomerate(icd);
          indexCount++;
        }
        continue;
View Full Code Here

        /* Now we have a lot of painful work to get the
         * table name for the error message.  All we have
         * is the conglomerate number to work with.
         */
        DataDictionary dd = activation.getLanguageConnectionContext().getDataDictionary();
        ConglomerateDescriptor cd = dd.getConglomerateDescriptor( heapConglom );
        TableDescriptor td = dd.getTableDescriptor(cd.getTableID());

        StandardException se = StandardException.newException(SQLState.LANG_CHECK_CONSTRAINT_VIOLATED,
          td.getQualifiedName(), checkName);

        throw se;
View Full Code Here

     * RESOLVE - this will change in 1.4 because we will get
     * back the same conglomerate number
     */
    // Get the ConglomerateDescriptor for the heap
    long oldHeapConglom       = td.getHeapConglomerateId();
    ConglomerateDescriptor cd =
            td.getConglomerateDescriptor(oldHeapConglom);

    // Update sys.sysconglomerates with new conglomerate #
    dd.updateConglomerateDescriptor(cd, newHeapConglom, tc);

View Full Code Here

    }

    // Update the DataDictionary
    // Get the ConglomerateDescriptor for the heap
    long oldHeapConglom = td.getHeapConglomerateId();
    ConglomerateDescriptor cd = td.getConglomerateDescriptor(oldHeapConglom);

    // Update sys.sysconglomerates with new conglomerate #
    dd.updateConglomerateDescriptor(cd, newHeapConglom, tc);
    // Drop the old conglomerate
    tc.dropConglomerate(oldHeapConglom);
View Full Code Here

    throws StandardException
  {
    Properties properties = new Properties();

    // Get the ConglomerateDescriptor for the index
    ConglomerateDescriptor cd =
            td.getConglomerateDescriptor(indexConglomerateNumbers[index]);

    // Build the properties list for the new conglomerate
    ConglomerateController indexCC =
            tc.openConglomerate(
                indexConglomerateNumbers[index],
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_TABLE,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Get the properties on the old index
    indexCC.getInternalTablePropertySet(properties);

    /* Create the properties that language supplies when creating the
     * the index.  (The store doesn't preserve these.)
     */
    int indexRowLength = indexRows[index].nColumns();
    properties.put("baseConglomerateId", Long.toString(newHeapConglom));
    if (cd.getIndexDescriptor().isUnique())
    {
      properties.put(
                "nUniqueColumns", Integer.toString(indexRowLength - 1));
    }
    else
    {
      properties.put(
                "nUniqueColumns", Integer.toString(indexRowLength));
    }
    properties.put(
            "rowLocationColumn", Integer.toString(indexRowLength - 1));
    properties.put(
            "nKeyFields", Integer.toString(indexRowLength));

    indexCC.close();

    // We can finally drain the sorter and rebuild the index
    // Populate the index.
   
    RowLocationRetRowSource cCount           = null;
    boolean                 statisticsExist  = false;

    if (!truncateTable)
    {
      sorters[index].completedInserts();
      sorters[index] = null;

      if (td.statisticsExist(cd))
      {
        cCount =
                    new CardinalityCounter(
                            tc.openSortRowSource(sortIds[index]));

        statisticsExist = true;
      }
      else
            {
        cCount =
                    new CardinalityCounter(
                            tc.openSortRowSource(sortIds[index]));
            }

            newIndexCongloms[index] =
                tc.createAndLoadConglomerate(
                    "BTREE",
                    indexRows[index].getRowArray(),
                    ordering[index],
                    collation[index],
                    properties,
                    TransactionController.IS_DEFAULT,
                    cCount,
                    (long[]) null);

      //For an index, if the statistics already exist, then drop them.
      //The statistics might not exist for an index if the index was
      //created when the table was empty.
            //
            //For all alter table actions, including ALTER TABLE COMPRESS,
      //for both kinds of indexes (ie. one with preexisting statistics
            //and with no statistics), create statistics for them if the table
            //is not empty.
      if (statisticsExist)
        dd.dropStatisticsDescriptors(td.getUUID(), cd.getUUID(), tc);
     
      long numRows;
      if ((numRows = ((CardinalityCounter)cCount).getRowCount()) > 0)
      {
        long[] c = ((CardinalityCounter)cCount).getCardinality();
        for (int i = 0; i < c.length; i++)
        {
          StatisticsDescriptor statDesc =
            new StatisticsDescriptor(
                            dd,
                            dd.getUUIDFactory().createUUID(),
                            cd.getUUID(),
                            td.getUUID(),
                            "I",
                            new StatisticsImpl(numRows, c[i]),
                            i + 1);

          dd.addDescriptor(
                            statDesc,
                            null,   // no parent descriptor
              DataDictionary.SYSSTATISTICS_CATALOG_NUM,
              true,   // no error on duplicate.
                            tc)
        }
      }
    }
        else
    {
            newIndexCongloms[index] =
                tc.createConglomerate(
                    "BTREE",
                    indexRows[index].getRowArray(),
                    ordering[index],
                    collation[index],
                    properties,
                    TransactionController.IS_DEFAULT);


      //on truncate drop the statistics because we know for sure
      //rowscount is zero and existing statistic will be invalid.
      if (td.statisticsExist(cd))
        dd.dropStatisticsDescriptors(td.getUUID(), cd.getUUID(), tc);
    }

    /* Update the DataDictionary
     *
     * Update sys.sysconglomerates with new conglomerate #, we need to
View Full Code Here

        {
          numIndexes--;
          /* get first conglomerate with this conglom number each time
           * and each duplicate one will be eventually all dropped
           */
          ConglomerateDescriptor cd = td.getConglomerateDescriptor
                        (indexConglomerateNumbers[i]);
          cd.drop(activation.getLanguageConnectionContext(), td);

          compressIRGs[i] = null;    // mark it
          continue;
        }
        // give an error for unique index on multiple columns including
        // the column we are to drop (restrict), such index is not for
        // a constraint, because constraints have already been handled
        if (compressIRGs[i].isUnique())
        {
          ConglomerateDescriptor cd = td.getConglomerateDescriptor
                        (indexConglomerateNumbers[i]);
          throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
                    dm.getActionString(DependencyManager.DROP_COLUMN),
                    columnInfo[0].name, "UNIQUE INDEX",
                    cd.getConglomerateName() );
        }
      }
      IndexRowGenerator[] newIRGs = new IndexRowGenerator[numIndexes];
      long[] newIndexConglomNumbers = new long[numIndexes];

View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor

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.