Package org.apache.derby.iapi.store.raw

Examples of org.apache.derby.iapi.store.raw.RecordHandle


    if (undo != null) {
      t.checkLogicalOperationOk();
    }

        int recordId;
        RecordHandle handle;

        do {

            // loop until we get a new record id we can get a lock on.
View Full Code Here


                    SQLState.DATA_CONTAINER_READ_ONLY);
        }


    // Handle of the first portion of the chain
    RecordHandle headHandle = null;
    RecordHandle handleToUpdate = null;

    RawTransaction t = curPage.owner.getTransaction();

    for (;;) {

      if (SanityManager.DEBUG) {
        SanityManager.ASSERT(curPage.isLatched());
      }

      if (!curPage.allowInsert())
        return null;

      // 'this' is the head page
      if (curPage != this)
        slot = curPage.recordCount;

      boolean isLongColumns   = false;
      int     realStartColumn = -1;
      int     realSpaceOnPage = -1;

      DynamicByteArrayOutputStream logBuffer = null;

            // allocate new record id and handle
            int          recordId = curPage.newRecordIdAndBump();
      RecordHandle handle   =
                new RecordId(curPage.getPageId(), recordId, slot);

      if (curPage == this) {


        // Lock the row, if it is the very first portion of the record.
        if (handleToUpdate == null) {

                    while (!owner.getLockingPolicy().lockRecordForWrite(
                                t, handle,
                                true  /* lock is for insert */,
                                false /* don't wait for grant */)) {

                        // loop until we get a new record id we can get a lock
                        // on.  If we can't get the lock without waiting then
                        // assume the record id is owned by another xact.  The
                        // current heap overflow algorithm makes this likely,
                        // as it first try's to insert a row telling raw store
                        // to fail if it doesn't fit on the page getting a lock
                        // on an id that never makes it to disk.   The
                        // inserting transaction will hold a lock on this
                        // "unused" record id until it commits.  The page can
                        // leave the cache at this point, and the inserting
                        // transaction has not dirtied the page (it failed
                        // after getting the lock but before logging anything),
                        // another inserting transaction will then get the
                        // same id as the previous inserter - thus the loop on
                        // lock waits.
                        //
                        // The lock we request indicates that this is a lock
                        // for insert, which the locking policy may use to
                        // perform locking concurrency optimizations.

                        // allocate new record id and handle
                        recordId = curPage.newRecordIdAndBump();
                        handle   =
                            new RecordId(curPage.getPageId(), recordId, slot);
                    }
        }

        headHandle = handle;
      }

      do {

        // do this loop at least once.  If we caught a long Column,
        // then, we redo the insert with saved logBuffer.
        try {

          startColumn =
                        owner.getActionSet().actionInsert(
                            t, curPage, slot, recordId,
                            row, validColumns, (LogicalUndo) null,
                            insertFlag, startColumn, false,
                            realStartColumn, logBuffer, realSpaceOnPage,
                            overflowThreshold);
          isLongColumns = false;

        } catch (LongColumnException lce) {


          // we caught a long column exception
          // three things should happen here:
          // 1. insert the long column into overflow pages.
          // 2. append the overflow field header in the main chain.
          // 3. continue the insert in the main data chain.
          logBuffer = new DynamicByteArrayOutputStream(lce.getLogBuffer());

          // step 1: insert the long column ... use the same
          // insertFlag as the rest of the row.
          RecordHandle longColumnHandle =
            insertLongColumn(curPage, lce, insertFlag);

          // step 2: append the overflow field header to the log buffer
          int overflowFieldLen = 0;
          try {
View Full Code Here

    // Object[] row = new Object[1];
    // row[0] = (Object) lce.getColumn();
    Object[] row = new Object[1];
    row[0] = lce.getColumn();

    RecordHandle firstHandle = null;
    RecordHandle handle = null;
    RecordHandle prevHandle = null;
    BasePage curPage = mainChainPage;
    BasePage prevPage = null;
    boolean isFirstPage = true;

    // when inserting a long column startCOlumn is just used
View Full Code Here

      throw StandardException.newException(
                    SQLState.DATA_UPDATE_DELETED_RECORD);
        }


    RecordHandle handle = getRecordHandleAtSlot(slot);

    RawTransaction t = owner.getTransaction();

    doUpdateAtSlot(t, slot, handle.getId(), row, validColumns);
   
    return handle;
  }
View Full Code Here

      throw StandardException.newException(
                    SQLState.DATA_UPDATE_DELETED_RECORD);
        }

    RawTransaction t = owner.getTransaction();
    RecordHandle handle = getRecordHandleAtSlot(slot);

    owner.getActionSet().actionUpdateField(t, this, slot,
        handle.getId(), fieldId, newValue, undo);

    return handle;
  }
View Full Code Here

    // logical operations not allowed in internal transactions.
    if (undo != null) {
      t.checkLogicalOperationOk();
    }

    RecordHandle handle = getRecordHandleAtSlot(slot);

    owner.getActionSet().actionDelete(t, this, slot, handle.getId(), delete, undo);
   
    // delete/undelete the record in the stored version
    // and in the in memory version performed by the PageActions item

    return handle;
View Full Code Here

    for (int i = 0; i < numpurges; i++)
    {
      recordIds[i] = getHeaderAtSlot(slot + i).getId();

      // get row lock on head row piece
      RecordHandle handle = getRecordHandleAtSlot(slot);
      owner.getLockingPolicy().lockRecordForWrite(t, handle, false, true);

      // Before we purge these rows, we need to make sure they don't have
      // overflow rows and columns.  Only clean up long rows and long
      // columns if this is not a temporary container, otherwise, just
      // loose the space.

      if (owner.isTemporaryContainer() ||  entireRecordOnPage(slot+i))
        continue;

      // row[slot+i] has overflow rows and/or long columns, reclaim
      // them in a loop.
      RecordHandle headRowHandle =
        getHeaderAtSlot(slot+i).getHandle(pageId, slot+i);
      purgeRowPieces(t, slot+i, headRowHandle, needDataLogged);
    }

    owner.getActionSet().actionPurge(t, this, slot, numpurges, recordIds, needDataLogged);
View Full Code Here

    RawTransaction t = owner.getTransaction();

    // lock the records to be purged and calculate total space needed
    for (int i = 0; i < num_rows; i++)
    {
      RecordHandle handle = getRecordHandleAtSlot(src_slot+i);
      owner.getLockingPolicy().lockRecordForWrite(t, handle, false, true);

      recordIds[i] = getHeaderAtSlot(src_slot + i).getId();
    }
View Full Code Here

      if (i == 0)
        recordIds[i] = newRecordId();
      else
        recordIds[i] = newRecordId(recordIds[i-1]);

      RecordHandle handle = new RecordId(pageId, recordIds[i], i);
      owner.getLockingPolicy().lockRecordForWrite(t, handle, false, true);
    }

    // RESOLVE: need try block here to invalidate self and crash the system
    owner.getActionSet().actionCopyRows(t, this, srcPage,
View Full Code Here

        // This operation is only done as part of a new tree or split, which
        // which both will be undone physically so no logical undo record is
        // needed.
    byte insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_DEFAULT;
        RecordHandle rh =
            page.insertAtSlot(Page.FIRST_SLOT_NUMBER,
                control_row.getRow(),
                (FormatableBitSet) null,
                (LogicalUndo) null, insertFlag,
        AccessFactoryGlobals.BTREE_OVERFLOW_THRESHOLD);

        if (SanityManager.DEBUG)
        {
            RecordHandle    rh2 = null;

            rh2 = page.fetchFromSlot(
                    (RecordHandle) null, page.FIRST_SLOT_NUMBER,
                    new DataValueDescriptor[0], (FetchDescriptor) null, true);

            SanityManager.ASSERT(rh.getId() == rh2.getId() &&
                                 rh.getPageNumber() == rh2.getPageNumber());
        }

        // Page is returned latched.
        return(control_row);
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.raw.RecordHandle

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.