/** * Change the page id. * * @param id the new page id */ void setPageId(int id) { int old = getPos(); index.getPageStore().removeRecord(getPos()); setPos(id); index.getPageStore().logUndo(this, null); remapChildren(old); }
/** * 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); } }
/** * Create a new page. * * @param index the index * @param pageId the page id * @param parentPageId the parent * @return the page */ static PageDataLeaf create(PageDataIndex index, int pageId, int parentPageId) { PageDataLeaf p = new PageDataLeaf(index, pageId, index.getPageStore().createData()); index.getPageStore().logUndo(p, null); p.rows = Row.EMPTY_ARRAY; p.parentPageId = parentPageId; p.columnCount = index.getTable().getColumns().length; p.writeHead(); p.start = p.data.length(); return p; }
public Cursor findFirstOrLast(Session session, boolean first) throws SQLException { Cursor cursor; if (first) { cursor = mainIndex.find(session, Long.MIN_VALUE, Long.MAX_VALUE, false); } else { long x = mainIndex.getLastKey(); cursor = mainIndex.find(session, x, x, false); } cursor.next(); return cursor; }
@Override public boolean canRemove() { if (changeCount >= index.getPageStore().getChangeCount()) { return false; } return true; }
public PageDelegateIndex( TableData table, int id, String name, IndexType indexType, PageDataIndex mainIndex, int headPos, Session session) throws SQLException { IndexColumn[] columns = IndexColumn.wrap(new Column[] {table.getColumn(mainIndex.getMainIndexColumn())}); this.initBaseIndex(table, id, name, columns, indexType); this.mainIndex = mainIndex; if (!database.isPersistent() || id < 0) { throw Message.throwInternalError("" + name); } PageStore store = database.getPageStore(); store.addIndex(this); if (headPos == Index.EMPTY_HEAD) { store.addMeta(this, session); } }
PageData(PageDataIndex index, int pageId, Data data) { this.index = index; this.data = data; setPos(pageId); memoryEstimated = index.getMemoryPerPage(); }
public double getCost(Session session, int[] masks) { return 10 * getCostRangeIndex(masks, mainIndex.getRowCount(session)); }
public int getColumnIndex(Column col) { return mainIndex.getColumnIndex(col); }
public Cursor find(Session session, SearchRow first, SearchRow last) throws SQLException { long min = mainIndex.getLong(first, Long.MIN_VALUE); long max = mainIndex.getLong(last, Long.MAX_VALUE); return mainIndex.find(session, min, max, false); }
public long getRowCountApproximation() { return mainIndex.getRowCountApproximation(); }
public long getRowCount(Session session) { return mainIndex.getRowCount(session); }
public void remove(Session session) throws SQLException { mainIndex.setMainIndexColumn(-1); session.getDatabase().getPageStore().removeMeta(this, session); }
private PageDataLeaf(PageDataIndex index, int pageId, Data data) { super(index, pageId, data); this.optimizeUpdate = index.getDatabase().getSettings().optimizeUpdate; }