The default checkpoint indexer uses a TmfMemoryIndex.
This prevents TmfTraceType from creating unnecessary empty index files
for every trace type instance, and actual traces from creating index
files that become obsolete as soon as initTrace() is called.
Change-Id: I40c407d68ce9d6cd6f9c7f736ca5fa33b9c41b37
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/45057
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
/*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson
+ * Copyright (c) 2009, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
fEmptyTrace = null;
}
- interface TestIndexerInterface extends ITmfTraceIndexer {
+ interface ITestIndexer extends ITmfTraceIndexer {
ITmfCheckpointIndex getCheckpoints();
}
/**
* A test indexer
*/
- protected static class TestIndexer extends TmfCheckpointIndexer implements TestIndexerInterface {
+ protected static class TestIndexer extends TmfCheckpointIndexer implements ITestIndexer {
/**
* Constructs the test indexer for a normal test trace
*
* the trace
* @return the indexer for testing
*/
- protected TestIndexerInterface createTestIndexer(TestTrace trace) {
+ protected ITestIndexer createTestIndexer(TestTrace trace) {
return new TestIndexer(trace);
}
}
@Override
- public TestIndexerInterface getIndexer() {
- return (TestIndexerInterface) super.getIndexer();
+ public ITestIndexer getIndexer() {
+ return (ITestIndexer) super.getIndexer();
}
}
private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- init(getClass().getSimpleName(), TmfEvent.class);
+ public EmptyTestTrace(String path) throws TmfTraceException {
+ super(path);
}
@Override
}
@Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
+ public ITestIndexer getIndexer() {
+ return (ITestIndexer) super.getIndexer();
}
}
}
if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
+ try {
+ File file = File.createTempFile("empty", "txt");
+ fEmptyTrace = new EmptyTestTrace(file.getAbsolutePath());
+ } catch (TmfTraceException | IOException e) {
+ fail(e.getMessage());
+ }
}
}
* @return the indexer for testing
*/
@Override
- protected TestIndexerInterface createTestIndexer(TestTrace trace) {
+ protected ITestIndexer createTestIndexer(TestTrace trace) {
return new TestBTreeIndexer(trace);
}
- private static class TestBTreeIndexer extends TmfBTreeTraceIndexer implements TestIndexerInterface {
+ private static class TestBTreeIndexer extends TmfBTreeTraceIndexer implements ITestIndexer {
public TestBTreeIndexer(TestTrace testTrace) {
super(testTrace, BLOCK_SIZE);
}
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
+import org.eclipse.tracecompass.tmf.core.tests.trace.indexer.checkpoint.AbstractIndexTest.ITestIndexer;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
// Helper classes
// ------------------------------------------------------------------------
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
+ private static class TestIndexer extends TmfCheckpointIndexer implements ITestIndexer {
public TestIndexer(TestTrace testTrace) {
super(testTrace, BLOCK_SIZE);
}
- @SuppressWarnings({ })
+
public TestIndexer(EmptyTestTrace testTrace) {
super(testTrace, BLOCK_SIZE);
}
+
+ @Override
public ITmfCheckpointIndex getCheckpoints() {
return getTraceIndex();
}
}
@Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
+ public ITestIndexer getIndexer() {
+ return (ITestIndexer) super.getIndexer();
}
}
private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- init(getClass().getSimpleName(), TmfEvent.class);
+ public EmptyTestTrace(String path) throws TmfTraceException {
+ super(path);
}
@Override
}
@Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
+ public ITestIndexer getIndexer() {
+ return (ITestIndexer) super.getIndexer();
}
}
}
if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
+ try {
+ File file = File.createTempFile("empty", "txt");
+ fEmptyTrace = new EmptyTestTrace(file.getAbsolutePath());
+ } catch (TmfTraceException | IOException e) {
+ e.printStackTrace();
+ }
}
}
/*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson
+ * Copyright (c) 2009, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.tracecompass.tmf.tests.stubs.trace;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
*/
public class TmfEmptyTraceStub extends TmfTraceStub {
- /**
- *
- */
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
+ * Constructor
+ *
+ * @param path
+ * the empty trace path
*
+ * @throws TmfTraceException
+ * if an exception occurs
*/
- public TmfEmptyTraceStub() {
- super();
+ public TmfEmptyTraceStub(String path) throws TmfTraceException {
+ super(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, 0L);
}
// ------------------------------------------------------------------------
/*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2009, 2015 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*/
public TmfTrace() {
super();
- fIndexer = createIndexer(DEFAULT_BLOCK_SIZE);
+ fIndexer = new TmfCheckpointIndexer(this);
}
/**