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

📄 filecontainer.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		}        else        {             return null;        }	}	public Cacheable createIdentity(Object key, Object createParameter)         throws StandardException     {		if (SanityManager.DEBUG)         {			SanityManager.ASSERT(                !(key instanceof PageKey), "PageKey input to create container");		}		return createIdent((ContainerKey) key, createParameter);	}	// should be same name as createIdentity but seems to cause method     // resolution ambiguities	protected Cacheable createIdent(    ContainerKey    newIdentity,     Object          createParameter) 		 throws StandardException 	{		// createParameter will be this object if this method is being called         // from itself to re-initialize the container (only for tempRAF)		// if createParameter == this, do not reinitialize the header, this		// object is not being reused for another container		if (createParameter != this) 		{			initContainerHeader(true /* change to different container */);			if (createParameter != null && 				(createParameter instanceof ByteArray))			{				// this is called during load tran, the create container				// Operation has a byte array created by logCreateContainerInfo				// which contains all the information necessary to recreate the				// container.  Use that to recreate the container properties.				createInfoFromLog((ByteArray)createParameter);			}			else			{				if (SanityManager.DEBUG)				{					if (createParameter != null &&						!(createParameter instanceof Properties))					{						SanityManager.THROWASSERT(							"Expecting a  non-null createParameter to a " +                            "Properties instead of " +							createParameter.getClass().getName());					}				}				createInfoFromProp((Properties)createParameter);			}		}		else		{			// we don't need to completely re-initialize the header			// just re-initialize the relavent fields			initContainerHeader(false);		}		if (initialPages > 1)		{			PreAllocThreshold           = 0;			PreAllocSize                = initialPages;			bulkIncreaseContainerSize   = true;		}		else		{			PreAllocThreshold           = PRE_ALLOC_THRESHOLD;		}		createContainer(newIdentity);		setDirty(true);		// set up our identity.		// If we raise an exception after this we must clear our identity.		fillInIdentity(newIdentity);		return this;	}	public void clearIdentity()     {		closeContainer();        initializeLastInsertedPage(1);		lastUnfilledPage = ContainerHandle.INVALID_PAGE_NUMBER;		lastAllocatedPage = ContainerHandle.INVALID_PAGE_NUMBER;		canUpdate = false;		super.clearIdentity();	}	/**		We treat this container as dirty if it has the container file open.		@see Cacheable#isDirty	*/	public boolean isDirty()     {		synchronized (this)         {			return isDirty;		}	}	public void preDirty(boolean preDirtyOn)     {		synchronized (this)         {			if (preDirtyOn)			{				// prevent the cleaner from cleaning this container or skipping				// over it until the operation which preDirtied it got a chance				// to do the change.				preDirty = true;			}			else			{				preDirty = false;				// if a cleaner is waiting on the dirty bit, wake it up				notifyAll();			}		}	}	protected void setDirty(boolean dirty)	{		synchronized(this)         {			preDirty = false;			isDirty  = dirty;			// if a cleaner is waiting on the dirty bit, wake it up			notifyAll();		}	}	/*	** Container creation, opening, and closing	*/    /**     * Create a new container.     * <p>     * Create a new container, all references to identity must be through the     * passed in identity, this object will no identity until after this      * method returns.     *     * @exception StandardException Cloudscape Standard error policy     **/	abstract void createContainer(ContainerKey newIdentity)         throws StandardException;	    /**     * Open a container.     * <p>     * Longer descrption of routine.     * <p>     * Open a container. Open the file that maps to this container, if the     * file does not exist then we assume the container was never created.     * If the file exists but we have trouble opening it then we throw some      * exception.     *     * <BR> MT - single thread required - Enforced by cache manager.     *	 * @exception  StandardException  Standard exception policy.     **/	abstract boolean openContainer(ContainerKey newIdentity)         throws StandardException;	abstract void closeContainer();    /**     * Drop Container.     * <p>     *     * @see Transaction#dropContainer     *     **/	protected void dropContainer(    LogInstant  instant,     boolean     isDropped)	{		synchronized(this)		{			setDroppedState(isDropped);			setDirty(true);			bumpContainerVersion(instant);		}	}	/**		increment the version by one and return the new version.		<BR> MT - caller must synchronized this in the same sync block that		modifies the container header.	*/	protected final void bumpContainerVersion(LogInstant instant) 	{			lastLogInstant = instant;		++containerVersion;	}	protected long getContainerVersion()	{		// it is not really necessary to synchronized this because the only time the		// container version is looked at is during recovery, which is single		// threaded at the moment.  Put it in an sync block anyway just in case		// some other people want to look at this for some bizarre reasons		synchronized(this)		{			return containerVersion;		}	}    /**     * Request the system properties associated with a container.      * <p>     * Request the value of properties that are associated with a container.      * The following properties can be requested:     *     derby.storage.pageSize      *     derby.storage.pageReservedSpace     *     derby.storage.minimumRecordSize     *     derby.storage.reusableRecordId	 *     cloudsacpe.storage.initialPages     * <p>     * To get the value of a particular property add it to the property list,     * and on return the value of the property will be set to it's current      * value.  For example:     *     * get_prop(ConglomerateController cc)     * {     *     Properties prop = new Properties();     *     prop.put("derby.storage.pageSize", "");     *     cc.getContainerProperties(prop);     *     *     System.out.println(     *         "table's page size = " +      *         prop.getProperty("derby.storage.pageSize");     * }     *     * @param prop   Property list to fill in.     *	 * @exception  StandardException  Standard exception policy.     **/    public void getContainerProperties(Properties prop)		throws StandardException    {        // derby.storage.pageSize        if (prop.getProperty(Property.PAGE_SIZE_PARAMETER) != null)        {            prop.put(                Property.PAGE_SIZE_PARAMETER,                 Integer.toString(pageSize));        }        // derby.storage.minimumRecordSize        if (prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER) !=                 null)        {            prop.put(                RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER,                 Integer.toString(minimumRecordSize));        }        // derby.storage.pageReservedSpace        if (prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER) !=                 null)        {            prop.put(                RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER,                 Integer.toString(spareSpace));        }		// derby.storage.reusableRecordId		if (prop.getProperty(RawStoreFactory.PAGE_REUSABLE_RECORD_ID) != null)		{			Boolean bool = new Boolean(isReusableRecordId());			prop.put(RawStoreFactory.PAGE_REUSABLE_RECORD_ID,					 bool.toString());		}		// derby.storage.initialPages		if (prop.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES) != null)		{			prop.put(RawStoreFactory.CONTAINER_INITIAL_PAGES,					 Integer.toString(initialPages));		}    }	/**		Read the container's header.  Assumes the input stream (fileData)		is positioned at the beginning of the file.		Subclass that implements openContainer is expected to manufacture a DataInput 		stream which is used here to read the header.		<BR> MT - single thread required - Enforced by caller.		@exception StandardException Cloudscape Standard error policy		@exception IOException error in reading the header from file	*/	protected void readHeader(DataInput fileData) 		 throws IOException, StandardException	{		// Always read the header from the input stread even if the alloc page may		// still be in cache.  This is because a stubbify operation only writes		// the stub to disk, it did not get rid of any stale page from the page		// cache.  So if it so happen that the stubbified container object is		// aged out of the container cache but the first alloc page hasn't,		// then when any stale page of this container wants to be written out,		// the container needs to be reopened, which is when this routine is		// called.  We must not get the alloc page in cache because it may be		// stale page and it may still say the container has not been dropped.		byte[] epage = getEmbryonicPage(fileData);		// read persistent container header into containerInfo		AllocPage.ReadContainerInfo(containerInfo, epage);		// initialize header from information stored in containerInfo		readHeaderFromArray(containerInfo);		epage = null;	}	// initialize header information so this container object can be safely	// reused as if this container object has just been new'ed	private void initContainerHeader(boolean changeContainer)	{		if (containerInfo == null)			containerInfo = new byte[CONTAINER_INFO_SIZE];		if (checksum == null)			checksum = new CRC32();		else			checksum.reset();		if (allocCache == null)			allocCache = new AllocationCache();		else			allocCache.reset();		if (changeContainer)		{			pageSize = 0;			spareSpace = 0;			minimumRecordSize = 0;		}		initialPages = 1;		firstAllocPageNumber = ContainerHandle.INVALID_PAGE_NUMBER;			firstAllocPageOffset = -1;		containerVersion = 0;		estimatedRowCount = 0;		setDroppedState(false);		setCommittedDropState(false);		setReusableRecordIdState(false);		// instance variables that are not stored on disk		lastLogInstant = null;        initializeLastInsertedPage(1);		lastUnfilledPage = ContainerHandle.INVALID_PAGE_NUMBER;		lastAllocatedPage = ContainerHandle.INVALID_PAGE_NUMBER;		estimatedPageCount = -1;		PreAllocThreshold = PRE_ALLOC_THRESHOLD;		PreAllocSize = DEFAULT_PRE_ALLOC_SIZE;		bulkIncreaseContainerSize = false;	}

⌨️ 快捷键说明

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