Exemplo n.º 1
0
  public void truncate() throws JournalException {
    beginTx();
    int partitionCount = getPartitionCount();
    for (int i = 0; i < partitionCount; i++) {
      Partition<T> partition = getPartition(i, true);
      partition.truncate(0);
      partition.close();
      Files.deleteOrException(partition.getPartitionDir());
    }

    closePartitions();

    for (int i = 0, sz = getSymbolTableCount(); i < sz; i++) {
      getSymbolTable(i).truncate();
    }
    appendTimestampLo = -1;
    commitDurable();
  }
Exemplo n.º 2
0
  private void rollbackPartitions(Tx tx) throws JournalException {
    int partitionIndex = tx.journalMaxRowID == -1 ? 0 : Rows.toPartitionIndex(tx.journalMaxRowID);
    while (true) {
      Partition<T> p = partitions.getLast();
      if (p == null) {
        break;
      }

      if (p.getPartitionIndex() > partitionIndex) {
        p.close();
        Files.deleteOrException(p.getPartitionDir());
        partitions.remove(partitions.size() - 1);
      } else if (p.getPartitionIndex() == partitionIndex) {
        p.open();
        p.truncate(tx.journalMaxRowID == -1 ? 0 : Rows.toLocalRowID(tx.journalMaxRowID));
        break;
      } else {
        break;
      }
    }
  }