datastore: Add a classic history tree implementation
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.datastore.core.tests / src / org / eclipse / tracecompass / internal / provisional / datastore / core / historytree / classic / ClassicHistoryTreeTest.java
1 /*******************************************************************************
2 * Copyright (c) 2017 École Polytechnique de Montréal
3 *
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 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.classic;
11
12 import java.io.File;
13 import java.io.IOException;
14
15 import org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.AbstractHistoryTree;
16 import org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.AbstractHistoryTreeTestBase;
17 import org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.classic.ClassicHistoryTreeStub;
18 import org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.classic.ClassicNode;
19 import org.eclipse.tracecompass.internal.provisional.datastore.core.interval.HTInterval;
20
21 /**
22 * Test the classic history tree
23 *
24 * @author Geneviève Bastien
25 */
26 public class ClassicHistoryTreeTest
27 extends AbstractHistoryTreeTestBase<HTInterval, ClassicNode<HTInterval>> {
28
29 private static final HTInterval DEFAULT_OBJECT = new HTInterval(0, 0);
30
31
32 @Override
33 protected ClassicHistoryTreeStub createHistoryTree(
34 File stateHistoryFile,
35 int blockSize,
36 int maxChildren,
37 int providerVersion,
38 long treeStart) throws IOException {
39
40 return new ClassicHistoryTreeStub(stateHistoryFile,
41 blockSize,
42 maxChildren,
43 providerVersion,
44 treeStart);
45 }
46
47 @Override
48 protected ClassicHistoryTreeStub createHistoryTree(
49 File existingStateFile, int expectedProviderVersion) throws IOException {
50 return new ClassicHistoryTreeStub(existingStateFile, expectedProviderVersion);
51 }
52
53 @Override
54 protected HTInterval createInterval(long start, long end) {
55 return new HTInterval(start, end);
56 }
57
58 @Override
59 protected long fillValues(AbstractHistoryTree<HTInterval, ClassicNode<HTInterval>> ht,
60 int fillSize, long start) {
61
62 int nbValues = fillSize / DEFAULT_OBJECT.getSizeOnDisk();
63 for (int i = 0; i < nbValues; i++) {
64 ht.insert(new HTInterval(start + i, start + i + 1));
65 }
66 return start + nbValues;
67 }
68
69 }
This page took 0.039719 seconds and 5 git commands to generate.