public void truncate(Session session) {
   if (trace.isDebugEnabled()) {
     trace.debug("{0} truncate", this);
   }
   store.logTruncate(session, tableData.getId());
   removeAllRows();
   if (tableData.getContainsLargeObject() && tableData.isPersistData()) {
     // unfortunately, the data is gone on rollback
     session.commit(false);
     database.getLobStorage().removeAllForTable(table.getId());
   }
   if (multiVersion) {
     sessionRowCount.clear();
   }
   tableData.setRowCount(0);
 }
  public PageDataIndex(
      RegularTable table,
      int id,
      IndexColumn[] columns,
      IndexType indexType,
      boolean create,
      Session session) {
    initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType);
    RegularDatabase database = (RegularDatabase) this.database;
    this.multiVersion = database.isMultiVersion();

    // trace = database.getTrace(Trace.PAGE_STORE + "_di");
    // trace.setLevel(TraceSystem.DEBUG);
    if (multiVersion) {
      sessionRowCount = New.hashMap();
      isMultiVersion = true;
    } else {
      sessionRowCount = null;
    }
    tableData = table;
    this.store = database.getPageStore();
    store.addIndex(this);
    if (!database.isPersistent()) {
      throw DbException.throwInternalError(table.getName());
    }
    if (create) {
      rootPageId = store.allocatePage();
      store.addMeta(this, session);
      PageDataLeaf root = PageDataLeaf.create(this, rootPageId, PageData.ROOT);
      store.update(root);
    } else {
      rootPageId = store.getRootPageId(id);
      PageData root = getPage(rootPageId, 0);
      lastKey = root.getLastKey();
      rowCount = root.getRowCount();
    }
    if (trace.isDebugEnabled()) {
      trace.debug("{0} opened rows: {1}", this, rowCount);
    }
    table.setRowCount(rowCount);
    memoryPerPage = (Constants.MEMORY_PAGE_DATA + store.getPageSize()) >> 2;
  }