X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=statesystem%2Forg.eclipse.tracecompass.statesystem.core%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Finternal%2Fstatesystem%2Fcore%2Fbackend%2Fhistorytree%2FHTNode.java;h=9cada2d4f4e989f8ea981490187fd168b34ba40e;hb=f4baf640acb2940d56ade46f42d7e5cbad0a598f;hp=651120bb7da9e5e3506946ff63d5af08b316ff74;hpb=dbf883bb5dc68619836a9b9318239e8bcd96e6e1;p=deliverable%2Ftracecompass.git diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java index 651120bb7d..9cada2d4f4 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java @@ -104,7 +104,10 @@ public abstract class HTNode { * 1 - byte (done or not) * */ - private static final int COMMON_HEADER_SIZE = 34; + private static final int COMMON_HEADER_SIZE = Byte.BYTES + + 2 * Long.BYTES + + 4 * Integer.BYTES + + Byte.BYTES; // ------------------------------------------------------------------------ // Attributes @@ -165,11 +168,13 @@ public abstract class HTNode { * @param fc * FileChannel to the history file, ALREADY SEEKED at the start * of the node. + * @param nodeFactory + * The factory to create the nodes for this tree * @return The node object * @throws IOException * If there was an error reading from the file channel */ - public static final @NonNull HTNode readNode(HTConfig config, FileChannel fc) + public static final @NonNull HTNode readNode(HTConfig config, FileChannel fc, IHistoryTree.IHTNodeFactory nodeFactory) throws IOException { HTNode newNode = null; int res, i; @@ -195,13 +200,13 @@ public abstract class HTNode { switch (type) { case CORE: /* Core nodes */ - newNode = new CoreNode(config, seqNb, parentSeqNb, start); + newNode = nodeFactory.createCoreNode(config, seqNb, parentSeqNb, start); newNode.readSpecificHeader(buffer); break; case LEAF: /* Leaf nodes */ - newNode = new LeafNode(config, seqNb, parentSeqNb, start); + newNode = nodeFactory.createLeafNode(config, seqNb, parentSeqNb, start); newNode.readSpecificHeader(buffer); break; @@ -445,7 +450,7 @@ public abstract class HTNode { * null anyway). */ ITmfStateInterval interval = fIntervals.get(i); - if (interval.getStartTime() <= t && + if (t >= interval.getStartTime() && interval.getAttribute() < stateInfo.size()) { stateInfo.set(interval.getAttribute(), interval); } @@ -607,8 +612,8 @@ public abstract class HTNode { writer.println("Intervals for node #" + fSequenceNumber + ":"); /* Array of children */ - if (getNodeType() == NodeType.CORE) { /* Only Core Nodes can have children */ - CoreNode thisNode = (CoreNode) this; + if (getNodeType() != NodeType.LEAF) { /* Only Core Nodes can have children */ + ParentNode thisNode = (ParentNode) this; writer.print(" " + thisNode.getNbChildren() + " children"); if (thisNode.getNbChildren() >= 1) { writer.print(": [ " + thisNode.getChild(0));