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(); }
private void rollbackPartitionDirs() throws JournalException { File[] files = getLocation() .listFiles( new FileFilter() { public boolean accept(File f) { return f.isDirectory() && !f.getName().startsWith(Constants.TEMP_DIRECTORY_PREFIX); } }); if (files != null) { Arrays.sort(files); for (int i = getPartitionCount(); i < files.length; i++) { Files.deleteOrException(files[i]); } } }
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; } } }
/** * Deletes entire Journal. * * @throws com.nfsdb.exceptions.JournalException if the Journal is open (must be closed) */ public void delete() throws JournalException { if (isOpen()) { throw new JournalException("Cannot delete open journal: %s", this); } Files.deleteOrException(getLocation()); }