int[] createArgs,
long pageOffset,
boolean reuse,
boolean overflow) throws StandardException
{
BasePage page = null;
boolean releasePage = true;
try
{
if (reuse) // read the page in first
{
// Cannot go thru the container handle because all read pages are blocked.
// do it underneath the handle and directly to the cache.
// Nobody can get thru becuase getPage will block at getting the alloc page.
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON(SPACE_TRACE))
{
SanityManager.DEBUG(
SPACE_TRACE, "reusing page " + pkey);
}
}
page = (BasePage)pageCache.find(pkey);
if (page == null) // hmmm?
{
throw StandardException.newException(
SQLState.FILE_REUSE_PAGE_NOT_FOUND, pkey);
}
}
else
{
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON(SPACE_TRACE))
{
SanityManager.DEBUG(
SPACE_TRACE, "allocation new page " + pkey);
}
}
// a brand new page, initialize and a new page in cache
page = (BasePage) pageCache.create(pkey, createArgs);
if (SanityManager.DEBUG)
SanityManager.ASSERT(page != null, "page Cache create return a null page");
}
releasePage = false;
page = latchPage(allochandle, page, true /* may need to wait, track3822 */);
if (page == null)
{
throw StandardException.newException(
SQLState.FILE_NEW_PAGE_NOT_LATCHED, pkey);
}
// page is either brand new or is read from disk, in either case,
// it knows how to get itself initialized.
int initPageFlag = 0;
if (reuse) initPageFlag |= BasePage.INIT_PAGE_REUSE;
if (overflow) initPageFlag |= BasePage.INIT_PAGE_OVERFLOW;
if (reuse && isReusableRecordId())
initPageFlag |= BasePage.INIT_PAGE_REUSE_RECORDID;
page.initPage(initPageFlag, pageOffset);
page.setContainerRowCount(estimatedRowCount);
}
finally
{
if (releasePage && page != null)