aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Wininger2014-04-14 14:06:15 (EDT)
committerAlexandre Montplaisir2014-04-14 17:53:26 (EDT)
commitce2036ab67c0eb642237ba2c401433e47cdc336f (patch)
tree20bfbed41ab491a4cd0a5bd98b05af43440a9440
parentbee3ee2a686e618c0a868801cd42be4965d006fa (diff)
downloadorg.eclipse.linuxtools-ce2036ab67c0eb642237ba2c401433e47cdc336f.zip
org.eclipse.linuxtools-ce2036ab67c0eb642237ba2c401433e47cdc336f.tar.gz
org.eclipse.linuxtools-ce2036ab67c0eb642237ba2c401433e47cdc336f.tar.bz2
tmf: allow intervals with variable sizerefs/changes/95/24795/4
Remove the fix data size of a HTInterval in HTNode. Change-Id: I116053884328318379a72643e7c4bf64b3b912c0 Signed-off-by: Florian Wininger <florian.wininger@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/24795 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTInterval.java20
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java19
2 files changed, 23 insertions, 16 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTInterval.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTInterval.java
index aa1a12f..f99cb8b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTInterval.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTInterval.java
@@ -1,6 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
- * Copyright (c) 2010, 2011 École Polytechnique de Montréal
+ * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* All rights reserved. This program and the accompanying materials are
@@ -8,6 +7,9 @@
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Florian Wininger - Allow to change the size of a interval
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.historytree;
@@ -31,6 +33,18 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
private static final String errMsg = "Invalid interval data. Maybe your file is corrupt?"; //$NON-NLS-1$
+ /**
+ * Size of an entry in the data section.
+ *
+ * <pre>
+ * 16 2 x Timevalue/long (interval start + end)
+ * + 4 int (key)
+ * + 1 byte (type)
+ * + 4 int (valueOffset)
+ * </pre>
+ */
+ private static final int DATA_ENTRY_SIZE = 25;
+
/* 'Byte' equivalent for state values types */
private static final byte TYPE_NULL = -1;
private static final byte TYPE_INTEGER = 0;
@@ -368,7 +382,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
* @return The interval size
*/
public int getIntervalSize() {
- return stringsEntrySize + HTNode.DATA_ENTRY_SIZE;
+ return stringsEntrySize + DATA_ENTRY_SIZE;
}
private int computeStringsEntrySize() {
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java
index a81afe7..37c70e2 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java
@@ -33,18 +33,6 @@ import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
*/
public abstract class HTNode {
- /**
- * Size of an entry in the data section.
- *
- * <pre>
- * 16 2 x Timevalue/long (interval start + end)
- * + 4 int (key)
- * + 1 byte (type)
- * + 4 int (valueOffset)
- * </pre>
- */
- protected static final int DATA_ENTRY_SIZE = 25;
-
/* Configuration of the History Tree to which belongs this node */
private final HTConfig config;
@@ -59,6 +47,9 @@ public abstract class HTNode {
/* Where the Strings section begins (from the start of the node */
private int stringSectionOffset;
+ /* Sum of bytes of all intervals in the node */
+ private int sizeOfIntervalSection;
+
/* True if this node was read from disk (meaning its end time is now fixed) */
private volatile boolean isOnDisk;
@@ -87,6 +78,7 @@ public abstract class HTNode {
this.parentSequenceNumber = parentSeqNumber;
this.stringSectionOffset = config.getBlockSize();
+ this.sizeOfIntervalSection = 0;
this.isOnDisk = false;
this.intervals = new ArrayList<>();
}
@@ -322,6 +314,7 @@ public abstract class HTNode {
assert (newInterval.getIntervalSize() <= this.getNodeFreeSpace());
intervals.add(newInterval);
+ sizeOfIntervalSection += newInterval.getIntervalSize();
/* Update the in-node offset "pointer" */
stringSectionOffset -= (newInterval.getStringsEntrySize());
@@ -510,7 +503,7 @@ public abstract class HTNode {
* @return The offset, within the node, where the Data section ends
*/
private int getDataSectionEndOffset() {
- return this.getTotalHeaderSize() + HTNode.DATA_ENTRY_SIZE * intervals.size();
+ return this.getTotalHeaderSize() + sizeOfIntervalSection;
}
/**