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