1 /*******************************************************************************
2 * Copyright (c) 2017 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.datastore
.core
.historytree
.overlapping
;
13 import java
.io
.IOException
;
15 import org
.eclipse
.tracecompass
.internal
.provisional
.datastore
.core
.interval
.IHTInterval
;
16 import org
.eclipse
.tracecompass
.internal
.provisional
.datastore
.core
.interval
.IHTIntervalReader
;
19 * Basic implementation of {@link AbstractOverlappingHistoryTree} that can
20 * be used directly by clients.
22 * @author Loic Prieur-Drevon
23 * @author Geneviève Bastien
25 * The type of objects that will be saved in the tree
27 public class OverlappingHistoryTree
<E
extends IHTInterval
>
28 extends AbstractOverlappingHistoryTree
<E
, OverlappingNode
<E
>> {
31 * The magic number for this file format.
33 public static final int HISTORY_FILE_MAGIC_NUMBER
= 0x05FFA800;
35 /** File format version. Increment when breaking compatibility. */
36 private static final int FILE_VERSION
= 1;
38 private final IHTNodeFactory
<E
, OverlappingNode
<E
>> fNodeFactory
=
39 (t
, b
, m
, seq
, p
, start
) -> new OverlappingNode
<>(t
, b
, m
, seq
, p
, start
);
41 // ------------------------------------------------------------------------
42 // Constructors/"Destructors"
43 // ------------------------------------------------------------------------
46 * Create a new Overlapping History Tree from scratch, specifying all
47 * configuration parameters.
49 * @param stateHistoryFile
50 * The name of the history file
52 * The size of each "block" on disk in bytes. One node will
53 * always fit in one block. It should be at least 4096.
55 * The maximum number of children allowed per core (non-leaf)
57 * @param providerVersion
58 * The version of the state provider. If a file already exists,
59 * and their versions match, the history file will not be rebuilt
62 * The start time of the history
63 * @param intervalReader
64 * The factory to create new tree data elements when reading from
67 * If an error happens trying to open/write to the file
68 * specified in the config
70 public OverlappingHistoryTree(File stateHistoryFile
,
75 IHTIntervalReader
<E
> intervalReader
) throws IOException
{
77 super(stateHistoryFile
,
86 * "Reader" constructor : instantiate a SHTree from an existing tree file on
89 * @param existingStateFile
90 * Path/filename of the history-file we are to open
91 * @param expectedProviderVersion
92 * The expected version of the state provider
94 * The factory used to read segments from the history tree
96 * If an error happens reading the file
98 public OverlappingHistoryTree(File existingStateFile
,
99 int expectedProviderVersion
,
100 IHTIntervalReader
<E
> objectReader
) throws IOException
{
101 super(existingStateFile
, expectedProviderVersion
, objectReader
);
105 protected int getMagicNumber() {
106 return HISTORY_FILE_MAGIC_NUMBER
;
110 protected int getFileVersion() {
115 protected IHTNodeFactory
<E
, OverlappingNode
<E
>> getNodeFactory() {