/** * Allocate a page. * * @return the page id */ public synchronized int allocatePage() { openForWriting(); int pos = allocatePage(null, 0); if (!recoveryRunning) { if (logMode != LOG_MODE_OFF) { log.addUndo(pos, emptyPage); } } return pos; }
/** * Allocate a number of pages. * * @param list the list where to add the allocated pages * @param pagesToAllocate the number of pages to allocate * @param exclude the exclude list * @param after all allocated pages are higher than this page */ void allocatePages(IntArray list, int pagesToAllocate, BitField exclude, int after) { list.ensureCapacity(list.size() + pagesToAllocate); for (int i = 0; i < pagesToAllocate; i++) { int page = allocatePage(exclude, after); after = page; list.add(page); } }
private void openForWriting() { if (!readMode || database.isReadOnly()) { return; } readMode = false; recoveryRunning = true; log.free(); logFirstTrunkPage = allocatePage(); log.openForWriting(logFirstTrunkPage, false); recoveryRunning = false; freed.set(0, pageCount, true); checkpoint(); }
/** * Add a page to the free list. * * @param pageId the page id * @param undo if the undo record must have been written */ void free(int pageId, boolean undo) { if (trace.isDebugEnabled()) { // trace.debug("free " + pageId + " " + undo); } cache.remove(pageId); if (SysProperties.CHECK && !recoveryRunning && undo) { // ensure the undo entry is already written if (logMode != LOG_MODE_OFF) { log.addUndo(pageId, null); } } freePage(pageId); if (recoveryRunning) { writePage(pageId, createData()); if (reservedPages != null && reservedPages.containsKey(pageId)) { // re-allocate the page if it is used later on again int latestPos = reservedPages.get(pageId); if (latestPos > log.getLogPos()) { allocatePage(pageId); } } } }
@Override PageData split(int splitPoint) { int newPageId = index.getPageStore().allocatePage(); PageDataLeaf p2 = PageDataLeaf.create(index, newPageId, parentPageId); while (splitPoint < entryCount) { int split = p2.addRowTry(getRowAt(splitPoint)); if (split != -1) { DbException.throwInternalError("split " + split); } removeRow(splitPoint); } return p2; }
@Override PageBtree split(int splitPoint) { int newPageId = index.getPageStore().allocatePage(); PageBtreeLeaf p2 = PageBtreeLeaf.create(index, newPageId, parentPageId); while (splitPoint < entryCount) { p2.addRow(getRow(splitPoint), false); removeRow(splitPoint); } memoryChange(); p2.memoryChange(); return p2; }
trace.debug("reserve " + r); allocatePage(r); allocatePage(PAGE_ID_META_ROOT); writeIndexRowCounts(); recoveryRunning = false;
@Override PageData split(int splitPoint) { int newPageId = index.getPageStore().allocatePage(); PageDataNode p2 = PageDataNode.create(index, newPageId, parentPageId); int firstChild = childPageIds[splitPoint]; while (splitPoint < entryCount) { p2.addChild(p2.entryCount, childPageIds[splitPoint + 1], keys[splitPoint]); removeChild(splitPoint); } int lastChild = childPageIds[splitPoint - 1]; removeChild(splitPoint - 1); childPageIds[splitPoint - 1] = lastChild; p2.childPageIds[0] = firstChild; p2.remapChildren(getPos()); return p2; }
key++; if (it.canDelete()) { store.allocatePage(it.getCurrentPageId()); store.allocatePage(n);
/** * Update a page. * * @param page the page */ public synchronized void update(Page page) { if (trace.isDebugEnabled()) { if (!page.isChanged()) { trace.debug("updateRecord " + page.toString()); } } checkOpen(); database.checkWritingAllowed(); page.setChanged(true); int pos = page.getPos(); if (SysProperties.CHECK && !recoveryRunning) { // ensure the undo entry is already written if (logMode != LOG_MODE_OFF) { log.addUndo(pos, null); } } allocatePage(pos); cache.update(pos, page); }
allocatePage(rootPageId);
private void openNew() { setPageSize(pageSize); freeListPagesPerList = PageFreeList.getPagesAddressed(pageSize); file = database.openFile(fileName, accessMode, false); lockFile(); recoveryRunning = true; writeStaticHeader(); writeVariableHeader(); log = new PageLog(this); increaseFileSize(MIN_PAGE_COUNT); openMetaIndex(); logFirstTrunkPage = allocatePage(); log.openForWriting(logFirstTrunkPage, false); isNew = true; recoveryRunning = false; increaseFileSize(); }
@Override PageBtree split(int splitPoint) { int newPageId = index.getPageStore().allocatePage(); PageBtreeNode p2 = PageBtreeNode.create(index, newPageId, parentPageId); index.getPageStore().logUndo(this, data); if (onlyPosition) { // TODO optimize: maybe not required p2.onlyPosition = true; } int firstChild = childPageIds[splitPoint]; readAllRows(); while (splitPoint < entryCount) { p2.addChild(p2.entryCount, childPageIds[splitPoint + 1], getRow(splitPoint)); removeChild(splitPoint); } int lastChild = childPageIds[splitPoint - 1]; removeChild(splitPoint - 1); childPageIds[splitPoint - 1] = lastChild; if (p2.childPageIds == null) { p2.childPageIds = new int[1]; } p2.childPageIds[0] = firstChild; p2.remapChildren(); return p2; }
PageData page1 = root; PageData page2 = root.split(splitPoint); int id = store.allocatePage(); page1.setPageId(id); page1.setParentPageId(rootPageId);
rootPageId = store.allocatePage(); store.addMeta(this, session); PageDataLeaf root = PageDataLeaf.create(this, rootPageId, PageData.ROOT);
PageBtree page2 = root.split(splitPoint); store.logUndo(page2, null); int id = store.allocatePage(); page1.setPageId(id); page1.setParentPageId(rootPageId);
try { logFirstTrunkPage = lastUsed + 1; allocatePage(logFirstTrunkPage); log.openForWriting(logFirstTrunkPage, true);
if (create) { rootPageId = store.allocatePage();
int previous = getPos(); int dataOffset = pageSize; int page = index.getPageStore().allocatePage(); firstOverflowPageId = page; this.overflowRowSize = pageSize + rowLength; type = Page.TYPE_DATA_OVERFLOW; size = pageSize - PageDataOverflow.START_MORE; next = index.getPageStore().allocatePage();
@Override PageBtree split(int splitPoint) { int newPageId = index.getPageStore().allocatePage(); PageBtreeLeaf p2 = PageBtreeLeaf.create(index, newPageId, parentPageId); for (int i = splitPoint; i < entryCount;) { p2.addRow(getRow(splitPoint), false); removeRow(splitPoint); } memoryChange(); p2.memoryChange(); return p2; }