import java.util.logging.Logger;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.internal.statesystem.core.Activator;
+import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.IHistoryTree.IHTNodeFactory;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
*
* @author Alexandre Montplaisir
*/
-class HT_IO {
+public class HT_IO {
private static final Logger LOGGER = TraceCompassLog.getLogger(HT_IO.class);
synchronized (io) {
io.seekFCToNodePos(io.fFileChannelIn, seqNb);
- return HTNode.readNode(io.fConfig, io.fFileChannelIn);
+ return HTNode.readNode(io.fConfig, io.fFileChannelIn, key.fStateHistory.fNodeFactory);
}
}
}));
private final FileChannel fFileChannelIn;
private final FileChannel fFileChannelOut;
+ private final IHTNodeFactory fNodeFactory;
+
// ------------------------------------------------------------------------
// Methods
// ------------------------------------------------------------------------
* The configuration object for the StateHistoryTree
* @param newFile
* Flag indicating that the file must be created from scratch
+ * @param nodeFactory
+ * The factory to create new nodes for this tree
*
* @throws IOException
* An exception can be thrown when file cannot be accessed
*/
- public HT_IO(HTConfig config, boolean newFile) throws IOException {
+ public HT_IO(HTConfig config, boolean newFile, IHTNodeFactory nodeFactory) throws IOException {
fConfig = config;
File historyTreeFile = config.getStateFile();
}
fFileChannelIn = fFileInputStream.getChannel();
fFileChannelOut = fFileOutputStream.getChannel();
+ fNodeFactory = nodeFactory;
}
/**
}
}
+ /**
+ * Write the given node to disk.
+ *
+ * @param node
+ * The node to write.
+ */
public void writeNode(HTNode node) {
try {
int seqNumber = node.getSequenceNumber();
}
}
+ /**
+ * Get the output file channel, used for writing.
+ *
+ * @return The output file channel
+ */
public FileChannel getFcOut() {
return fFileChannelOut;
}
+ /**
+ * Retrieve the input stream with which to write the attribute tree.
+ *
+ * @param nodeOffset
+ * The offset in the file, in number of nodes. This should be
+ * after all the nodes.
+ * @return The correctly-seeked input stream
+ */
public FileInputStream supplyATReader(int nodeOffset) {
try {
/*
return fFileInputStream;
}
+ /**
+ * Close all file channels and streams.
+ */
public synchronized void closeFile() {
try {
fFileInputStream.close();
}
}
+ /**
+ * Delete the history tree file
+ */
public synchronized void deleteFile() {
closeFile();