Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * 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);
   }
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 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;
 }
Example #5
0
 @Override
 public boolean canRemove() {
   if (changeCount >= index.getPageStore().getChangeCount()) {
     return false;
   }
   return true;
 }
Example #6
0
 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);
   }
 }
Example #7
0
 PageData(PageDataIndex index, int pageId, Data data) {
   this.index = index;
   this.data = data;
   setPos(pageId);
   memoryEstimated = index.getMemoryPerPage();
 }
Example #8
0
 public double getCost(Session session, int[] masks) {
   return 10 * getCostRangeIndex(masks, mainIndex.getRowCount(session));
 }
Example #9
0
 public int getColumnIndex(Column col) {
   return mainIndex.getColumnIndex(col);
 }
Example #10
0
 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);
 }
Example #11
0
 public long getRowCountApproximation() {
   return mainIndex.getRowCountApproximation();
 }
Example #12
0
 public long getRowCount(Session session) {
   return mainIndex.getRowCount(session);
 }
Example #13
0
 public void remove(Session session) throws SQLException {
   mainIndex.setMainIndexColumn(-1);
   session.getDatabase().getPageStore().removeMeta(this, session);
 }
Example #14
0
 private PageDataLeaf(PageDataIndex index, int pageId, Data data) {
   super(index, pageId, data);
   this.optimizeUpdate = index.getDatabase().getSettings().optimizeUpdate;
 }