⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basecontainer.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		RawTransaction tran = handle.getTransaction();		LockingPolicy lp =             tran.newLockingPolicy(                LockingPolicy.MODE_RECORD,                TransactionController.ISOLATION_REPEATABLE_READ,                 true); // striterOK				PageKey pkey = new PageKey(identity, deallocLock.getPageNumber());		if (lp != null)        {			if (zeroDuration)				return lp.zeroDurationLockRecordForWrite(                        tran, deallocLock, false, wait); 			else				return lp.lockRecordForWrite(tran, deallocLock, false, wait);        }		else		{			throw StandardException.newException(                    SQLState.DATA_CANNOT_GET_DEALLOC_LOCK, pkey);		}	}	/**		Get an allocation page and latch it.		@exception StandardException Standard Cloudscape error policy	*/	protected Page getAllocPage(BaseContainerHandle handle, long pageNumber, boolean wait)		 throws StandardException	{		return latchPage(handle, getAllocPage(pageNumber), wait);	}	/**		Get any page and latch it .		@exception StandardException Standard Cloudscape error policy	*/	protected Page getAnyPage(BaseContainerHandle handle, long pageNumber, boolean wait)		 throws StandardException	{		return latchPage(handle, getAnyPage(handle, pageNumber), wait);	}	/**		Get the first valid page. Result is latched.		@exception StandardException Standard Cloudscape error policy	*/	protected Page getFirstPage(BaseContainerHandle handle) throws StandardException	{		return getFirstHeadPage(handle, true /* wait */);	}	/**		Get the next valid page and latch it		@exception StandardException Standard Cloudscape error policy	*/	protected Page getNextPage(BaseContainerHandle handle, long pageNumber)        throws StandardException	{		return getNextHeadPage(handle, pageNumber, true /* wait */);	}	/*		utility to latch a page	*/	protected BasePage latchPage(BaseContainerHandle handle, BasePage foundPage, boolean wait)		 throws StandardException	{		if (foundPage != null) {			 if (wait) {				foundPage.setExclusive(handle);			 } else {				 if (!foundPage.setExclusiveNoWait(handle))				 {					 // sub-class will release page from the cache if required.					 return null;				 }			 }		}		if (SanityManager.DEBUG) {			SanityManager.ASSERT((foundPage == null) || foundPage.isLatched());		}		return foundPage;	}	/**		Lock the container and mark the container as in-use by this container handle.		@param droppedOK if true, use this container even if it is dropped.,		@return true if the container can be used, false if it has been dropped		since the lock was requested and droppedOK is not true.		@exception StandardException I cannot be opened for update.	*/	protected boolean use(BaseContainerHandle handle, boolean forUpdate,						  boolean droppedOK) 		throws StandardException {		// see if the container can be updated		if (forUpdate && !canUpdate())        {			throw StandardException.newException(                    SQLState.DATA_CONTAINER_READ_ONLY);        }		// if the container is dropped, cannot see if unless droppedOK is set		if (!droppedOK && (getDroppedState() || getCommittedDropState())) {			return false;		}		return true;	}	/**		Discontinue use of this container. Note that the unlockContainer		call made from this method may not release any locks. The container		lock may be held until the end of the transaction.	*/	protected void letGo(BaseContainerHandle handle) {		RawTransaction t = handle.getTransaction();		handle.getLockingPolicy().unlockContainer(t, handle);	}	protected boolean getDroppedState() {		return isDropped;	}	protected boolean getCommittedDropState()	{		return isCommittedDrop;	}	protected boolean isReusableRecordId()	{		return isReusableRecordId;	}	public int getContainerStatus()	{		if (getCommittedDropState())			return RawContainerHandle.COMMITTED_DROP;		if (getDroppedState())			return RawContainerHandle.DROPPED;		return RawContainerHandle.NORMAL;	}	public long getContainerId() {		return identity.getContainerId();	}	public long getSegmentId() {		return identity.getSegmentId();	}	//public int getPageSize() {	//	return pageSize();	//}	/*	**	Methods that need to be provided by a sub-class.	*/    /**    Get information about space used by the container.    **/    protected abstract SpaceInfo getSpaceInfo(BaseContainerHandle handle)        throws StandardException;	/**		Can the container be updated.		@return true if the container can be updated, false otherwise.	*/	protected abstract boolean canUpdate();	/**		The container is about to be modified.		Loggable actions use this to make sure the container gets cleaned if a		checkpoint is taken after any log record is sent to the log stream but		before the container is actually dirtied.	 */	protected abstract void preDirty(boolean preDirtyOn);	/**		Return a BasePage that represents the given page number in this container.        The resulting page is latched.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract BasePage getPage(BaseContainerHandle handle, long pageNumber,        boolean wait) throws StandardException;	/**		Return a BasePage that represents the given alloc page number in this container.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract BasePage getAllocPage(long pageNumber) throws StandardException;	/**		Return a BasePage that represents any page - alloc page, valid page, free page,		dealloced page etc.  The only requirement is that the page is initialized...		@exception StandardException Cloudscape Standard error policy	*/	protected abstract BasePage getAnyPage(BaseContainerHandle handle, long pageNumber)		 throws StandardException;	/**		ReCreate a page for load tran.  The argument passed in need to be		sufficient for the page cache to materialize a brand new page and write		it to disk.  The reason why this method is necessary is because we		first create the page, write it to disk, and then log the init page log		record to make sure there are enough space on disk.  During load tran,		the page creation part is missing.		<p>Load tran will do no preallocation.		<p>Only called during recovery redo.		@exception StandardException Cloudscape Standard error policy	 */	protected abstract BasePage	reCreatePageForLoadTran(BaseContainerHandle handle,							int pageFormat,							long pageNumber,							long pageOffset)		 throws StandardException;	/**		Log all information on the container creation necessary to recreate teh		container during a load tran.		@exception StandardException Cloudscape Standard error policy	 */	 protected abstract ByteArray logCreateContainerInfo()		 throws StandardException;	/**		Get only a valid, non-overflow page.  If page number is either invalid		or overflow, returns null		@exception StandardException Cloudscape Standard error policy	 */	protected abstract BasePage getHeadPage(BaseContainerHandle handle,        long pagenumber, boolean wait) throws StandardException;	/**		Get the first page in the container.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract BasePage getFirstHeadPage(BaseContainerHandle handle,        boolean wait) throws StandardException;	/**		Get the next page in the container.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract BasePage getNextHeadPage(BaseContainerHandle handle,        long pageNumber, boolean wait) throws StandardException;	/**		Get a potentially suitable page for insert and latch it.		@exception StandardException Standard Cloudscape error policy	 */	protected abstract BasePage getPageForInsert(BaseContainerHandle handle,												 int flag)		 throws StandardException;	protected abstract BasePage getPageForCompress(    BaseContainerHandle handle,    int                 flag,    long                pageno)		 throws StandardException;	protected abstract void truncatePages(long lastValidPagenum)        throws StandardException;	/**		Create a new page in the container.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract BasePage newPage(BaseContainerHandle userhandle,										RawTransaction t,										BaseContainerHandle allocHandle,										boolean isOverflow) throws StandardException;	protected abstract void compressContainer(    RawTransaction      t,    BaseContainerHandle allocHandle)        throws StandardException;	/**		Deallocate a page from the container.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract void deallocatePage(BaseContainerHandle userhandle,										   BasePage page) throws StandardException;	protected void truncate(BaseContainerHandle handle) throws StandardException {		if (SanityManager.DEBUG) {			SanityManager.THROWASSERT("truncate not supported");		}	}	/**		Mark the container as drop or not drop depending on the input value.	*/	protected abstract void dropContainer(LogInstant instant, boolean drop);	/**		Remove the container and reclaim its space.  Once executed, this		operation cannot be undone - as opposed to dropContainer which only		marks the container as dropped and can be rolled back.		<BR><B> This operation should only be called by post commit clean up </B>		@param leaveStub if true, leave a stub.  If false, remove everything		@see org.apache.derby.iapi.store.raw.data.RawContainerHandle#removeContainer		@exception StandardException Standard Cloudscape error policy	*/	protected abstract void removeContainer(LogInstant instant, boolean leaveStub) throws StandardException;	/**		Get the logged container version.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract long getContainerVersion() throws StandardException;	/**		Flush all outstanding changes in this container to persistent storage.		@exception StandardException Standard Cloudscape error policy	*/	protected abstract void flushAll() throws StandardException;	/**		The container will be grown vastly, prepare for it.	*/	protected abstract void prepareForBulkLoad(BaseContainerHandle handle,											   int numPage);	/**		The container will have no pre-allocate threshold, i.e., if the		implementation supports it, page preallocation will happen		the next time a new page is allocated.	*/	protected abstract void clearPreallocThreshold();	/*		Cost estimates	*/	/**		@see ContainerHandle#getEstimatedRowCount		@exception StandardException Standard Cloudscape error policy	 */	public abstract long getEstimatedRowCount(int flag) throws StandardException;	/**		@see ContainerHandle#setEstimatedRowCount		@exception StandardException Standard Cloudscape error policy	 */	public abstract void setEstimatedRowCount(long count, int flag) throws StandardException;	/**		@see ContainerHandle#getEstimatedPageCount		@exception StandardException Standard Cloudscape error policy	 */	public abstract long getEstimatedPageCount(BaseContainerHandle handle, int flag) throws StandardException;	/*	** Methods to be used by sub-classes.	*/	/**		Set the container's dropped state	*/	protected void setDroppedState(boolean isDropped) {		this.isDropped = isDropped;	}	protected void setCommittedDropState(boolean isCommittedDrop)	{		this.isCommittedDrop = isCommittedDrop;	}	protected void setReusableRecordIdState(boolean isReusableRecordId)	{		this.isReusableRecordId = isReusableRecordId;	}	//protected void setPageSize(int pageSize) {	//	identity.setPageSize(pageSize);	//}	// Not interested in participating in the diagnostic virtual lock table.	public boolean lockAttributes(int flag, Hashtable attributes)	{		return false;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -