@Override public boolean canRemove() { return changeCount < index.getPageStore().getChangeCount(); }
@Override public boolean canRemove() { return changeCount < index.getPageStore().getChangeCount(); }
/** * Change the parent page id. * * @param id the new parent page id */ void setParentPageId(int id) { index.getPageStore().logUndo(this, data); changeCount = index.getPageStore().getChangeCount(); written = false; parentPageId = id; }
/** * Change the parent page id. * * @param id the new parent page id */ void setParentPageId(int id) { index.getPageStore().logUndo(this, data); parentPageId = id; if (written) { changeCount = index.getPageStore().getChangeCount(); data.setInt(START_PARENT, parentPageId); } }
private void addChild(int x, int childPageId, long key) { index.getPageStore().logUndo(this, data); written = false; changeCount = index.getPageStore().getChangeCount(); childPageIds = insert(childPageIds, entryCount + 1, x + 1, childPageId); keys = insert(keys, entryCount, x, key); entryCount++; length += 4 + Data.getVarLongLen(key); }
@Override void setRowCountStored(int rowCount) { this.rowCount = rowCount; if (rowCountStored != rowCount) { rowCountStored = rowCount; index.getPageStore().logUndo(this, data); if (written) { changeCount = index.getPageStore().getChangeCount(); writeHead(); } index.getPageStore().update(this); } }
@Override void setRowCountStored(int rowCount) { if (rowCount < 0 && pageStoreInternalCount) { return; } this.rowCount = rowCount; if (rowCountStored != rowCount) { rowCountStored = rowCount; index.getPageStore().logUndo(this, data); if (written) { changeCount = index.getPageStore().getChangeCount(); writeHead(); } index.getPageStore().update(this); } }
/** * One of the children has moved to a new page. * * @param oldPos the old position * @param newPos the new position */ void moveChild(int oldPos, int newPos) { for (int i = 0; i < entryCount + 1; i++) { if (childPageIds[i] == oldPos) { index.getPageStore().logUndo(this, data); written = false; changeCount = index.getPageStore().getChangeCount(); childPageIds[i] = newPos; index.getPageStore().update(this); return; } } throw DbException.throwInternalError(oldPos + " " + newPos); }
private void removeChild(int i) { index.getPageStore().logUndo(this, data); written = false; changeCount = index.getPageStore().getChangeCount(); int removedKeyIndex = i < entryCount ? i : i - 1; entryCount--; length -= 4 + Data.getVarLongLen(keys[removedKeyIndex]); if (entryCount < 0) { DbException.throwInternalError("" + entryCount); } keys = remove(keys, entryCount + 1, removedKeyIndex); childPageIds = remove(childPageIds, entryCount + 2, i); }
/** * One of the children has moved to another page. * * @param oldPos the old position * @param newPos the new position */ void moveChild(int oldPos, int newPos) { for (int i = 0; i < entryCount + 1; i++) { if (childPageIds[i] == oldPos) { index.getPageStore().logUndo(this, data); written = false; changeCount = index.getPageStore().getChangeCount(); childPageIds[i] = newPos; index.getPageStore().update(this); return; } } throw DbException.throwInternalError(oldPos + " " + newPos); }
/** * Change the page id. * * @param id the new page id */ void setPageId(int id) { changeCount = index.getPageStore().getChangeCount(); written = false; index.getPageStore().removeFromCache(getPos()); setPos(id); index.getPageStore().logUndo(this, null); remapChildren(); }
private void removeRow(int at) { if (!optimizeUpdate) { readAllRows(); } index.getPageStore().logUndo(this, data); entryCount--; written = false; changeCount = index.getPageStore().getChangeCount(); if (entryCount <= 0) { DbException.throwInternalError("" + entryCount); } int startNext = at > 0 ? offsets[at - 1] : index.getPageStore().getPageSize(); int rowLength = startNext - offsets[at]; start -= OFFSET_LENGTH; if (optimizeUpdate) { if (writtenData) { byte[] d = data.getBytes(); int dataStart = offsets[entryCount]; System.arraycopy(d, dataStart, d, dataStart + rowLength, offsets[at] - dataStart); Arrays.fill(d, dataStart, dataStart + rowLength, (byte) 0); } } offsets = remove(offsets, entryCount + 1, at); add(offsets, at, entryCount, rowLength); rows = remove(rows, entryCount + 1, at); }
/** * Set the overflow page id. * * @param old the old overflow page id * @param overflow the new overflow page id */ void setOverflow(int old, int overflow) { if (SysProperties.CHECK && old != firstOverflowPageId) { DbException.throwInternalError("move " + this + " " + firstOverflowPageId); } index.getPageStore().logUndo(this, data); firstOverflowPageId = overflow; if (written) { changeCount = index.getPageStore().getChangeCount(); writeHead(); data.writeInt(firstOverflowPageId); } index.getPageStore().update(this); }
private void removeRow(int i) { index.getPageStore().logUndo(this, data); written = false; changeCount = index.getPageStore().getChangeCount(); if (!optimizeUpdate) { readAllRows();
private void removeChild(int i) { readAllRows(); entryCount--; if (pageStoreInternalCount) { updateRowCount(-index.getPage(childPageIds[i]).getRowCount()); } written = false; changeCount = index.getPageStore().getChangeCount(); if (entryCount < 0) { DbException.throwInternalError("" + entryCount); } if (entryCount > i) { int startNext = i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize(); int rowLength = startNext - offsets[i]; add(offsets, i, entryCount + 1, rowLength); } rows = remove(rows, entryCount + 1, i); offsets = remove(offsets, entryCount + 1, i); childPageIds = remove(childPageIds, entryCount + 2, i); start -= CHILD_OFFSET_PAIR_LENGTH; }
changeCount = index.getPageStore().getChangeCount();
readAllRows(); changeCount = index.getPageStore().getChangeCount(); written = false; int x;
@Override int addRowTry(SearchRow row) { while (true) { int x = find(row, false, true, true); PageBtree page = index.getPage(childPageIds[x]); int splitPoint = page.addRowTry(row); if (splitPoint == -1) { break; } SearchRow pivot = page.getRow(splitPoint - 1); index.getPageStore().logUndo(this, data); int splitPoint2 = addChildTry(pivot); if (splitPoint2 != -1) { return splitPoint2; } PageBtree page2 = page.split(splitPoint); readAllRows(); addChild(x, page2.getPos(), pivot); index.getPageStore().update(page); index.getPageStore().update(page2); index.getPageStore().update(this); } updateRowCount(1); written = false; changeCount = index.getPageStore().getChangeCount(); return -1; }
updateRowCount(-1); written = false; changeCount = index.getPageStore().getChangeCount(); if (last == null) {
changeCount = index.getPageStore().getChangeCount(); last = x == 0 ? pageSize : offsets[x - 1]; int offset = last - rowLength;