ss: no longer have a strings section in the HTNodes
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / internal / statesystem / core / backend / historytree / HistoryTree.java
index 32fbeb6e182026087b17d4a9dd2cf9802e055170..e4154496ac0bd10aca3261fe1d2240bd2964f81d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 Ericsson, École Polytechnique de Montréal, and others
+ * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.statesystem.core.Activator;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
@@ -50,7 +51,7 @@ public class HistoryTree {
     private static final int HISTORY_FILE_MAGIC_NUMBER = 0x05FFA900;
 
     /** File format version. Increment when breaking compatibility. */
-    private static final int FILE_VERSION = 5;
+    private static final int FILE_VERSION = 6;
 
     // ------------------------------------------------------------------------
     // Tree-specific configuration
@@ -73,7 +74,7 @@ public class HistoryTree {
     private int fNodeCount;
 
     /** "Cache" to keep the active nodes in memory */
-    private final List<HTNode> fLatestBranch;
+    private final @NonNull List<@NonNull HTNode> fLatestBranch;
 
     // ------------------------------------------------------------------------
     // Constructors/"Destructors"
@@ -101,7 +102,7 @@ public class HistoryTree {
         fConfig = conf;
         fTreeEnd = conf.getTreeStart();
         fNodeCount = 0;
-        fLatestBranch = Collections.synchronizedList(new ArrayList<HTNode>());
+        fLatestBranch = Collections.synchronizedList(new ArrayList<>());
 
         /* Prepare the IO object */
         fTreeIO = new HT_IO(fConfig, true);
@@ -216,8 +217,8 @@ public class HistoryTree {
      *            start
      * @throws ClosedChannelException
      */
-    private List<HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
-        List<HTNode> list = new ArrayList<>();
+    private @NonNull List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
+        List<@NonNull HTNode> list = new ArrayList<>();
 
         HTNode nextChildNode = fTreeIO.readNode(rootNodeSeqNb);
         list.add(nextChildNode);
@@ -343,7 +344,7 @@ public class HistoryTree {
      *
      * @return The immutable latest branch
      */
-    protected List<HTNode> getLatestBranch() {
+    protected List<@NonNull HTNode> getLatestBranch() {
         return ImmutableList.copyOf(fLatestBranch);
     }
 
@@ -461,7 +462,7 @@ public class HistoryTree {
         HTNode targetNode = fLatestBranch.get(indexOfNode);
 
         /* Verify if there is enough room in this node to store this interval */
-        if (interval.getIntervalSize() > targetNode.getNodeFreeSpace()) {
+        if (interval.getSizeOnDisk() > targetNode.getNodeFreeSpace()) {
             /* Nope, not enough room. Insert in a new sibling instead. */
             addSiblingNode(indexOfNode);
             tryInsertAtNode(interval, fLatestBranch.size() - 1);
@@ -578,7 +579,7 @@ public class HistoryTree {
         // Create new coreNode
         for (int i = 1; i < depth; i++) {
             CoreNode prevNode = (CoreNode) fLatestBranch.get(i - 1);
-            CoreNode newNode = initNewCoreNode(prevNode.getParentSequenceNumber(),
+            CoreNode newNode = initNewCoreNode(prevNode.getSequenceNumber(),
                     splitTime + 1);
             prevNode.linkNewChild(newNode);
             fLatestBranch.add(newNode);
@@ -586,7 +587,7 @@ public class HistoryTree {
 
         // Create the new leafNode
         CoreNode prevNode = (CoreNode) fLatestBranch.get(depth - 1);
-        LeafNode newNode = initNewLeafNode(prevNode.getParentSequenceNumber(), splitTime + 1);
+        LeafNode newNode = initNewLeafNode(prevNode.getSequenceNumber(), splitTime + 1);
         prevNode.linkNewChild(newNode);
         fLatestBranch.add(newNode);
     }
@@ -600,15 +601,10 @@ public class HistoryTree {
      *            Start time of the new node
      * @return The newly created node
      */
-    private CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
+    private @NonNull CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
         CoreNode newNode = new CoreNode(fConfig, fNodeCount, parentSeqNumber,
                 startTime);
         fNodeCount++;
-
-        /* Update the treeEnd if needed */
-        if (startTime >= fTreeEnd) {
-            fTreeEnd = startTime + 1;
-        }
         return newNode;
     }
 
@@ -621,15 +617,10 @@ public class HistoryTree {
      *            Start time of the new node
      * @return The newly created node
      */
-    private LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
+    private @NonNull LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
         LeafNode newNode = new LeafNode(fConfig, fNodeCount, parentSeqNumber,
                 startTime);
         fNodeCount++;
-
-        /* Update the treeEnd if needed */
-        if (startTime >= fTreeEnd) {
-            fTreeEnd = startTime + 1;
-        }
         return newNode;
     }
 
This page took 0.042261 seconds and 5 git commands to generate.