fix stream row calculation

This commit is contained in:
Eyck Jentzsch 2021-01-15 08:53:06 +01:00
parent a42f086339
commit bca94ceb9d
6 changed files with 22 additions and 46 deletions

View File

@ -40,10 +40,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
TreeMap<Long, IEvent[]> events = new TreeMap<>();
/** The max concurrency. */
private int maxConcurrency = 0;
/** The concurrency calculated. */
boolean concurrencyCalculated = false;
private int rowCount = -1;
/**
* Instantiates a new abstract tx stream.
@ -137,21 +134,21 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
*/
@Override
public int getRowCount() {
if (!concurrencyCalculated)
if (rowCount<0)
calculateConcurrency();
return maxConcurrency;
return rowCount;
}
/**
* Calculate concurrency.
*/
public void calculateConcurrency() {
if (concurrencyCalculated)
void calculateConcurrency() {
if (rowCount>=0)
return;
ArrayList<Long> rowEndTime = new ArrayList<>();
HashMap<Long, Integer> rowByTxId = new HashMap<>();
events.entrySet().stream().forEach(entry -> {
Arrays.asList(entry.getValue()).stream().forEach(evt -> {
for(Entry<Long, IEvent[]> entry: events.entrySet()) {
for(IEvent evt:entry.getValue()) {
TxEvent txEvt = (TxEvent) evt;
ITx tx = txEvt.getTransaction();
int rowIdx = 0;
@ -162,7 +159,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
rowByTxId.remove(txId);
break;
case SINGLE:
for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx) > tx.getBeginTime(); rowIdx++);
for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx)>tx.getBeginTime(); rowIdx++);
if (rowEndTime.size() <= rowIdx)
rowEndTime.add(tx.getEndTime());
else
@ -170,7 +167,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
((TxEvent) evt).setConcurrencyIndex(rowIdx);
break;
case BEGIN:
for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx) > tx.getBeginTime(); rowIdx++);
for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx)>tx.getBeginTime(); rowIdx++);
if (rowEndTime.size() <= rowIdx)
rowEndTime.add(tx.getEndTime());
else
@ -179,10 +176,9 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
rowByTxId.put(tx.getId(), rowIdx);
break;
}
});
});
maxConcurrency=rowEndTime.size();
concurrencyCalculated = true;
}
}
rowCount=rowEndTime.size()>0?rowEndTime.size():1;
getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
}

View File

@ -420,16 +420,13 @@ public class TextDbLoader implements IWaveformDbLoader {
TxGenerator gen = loader.txGenerators.get(scvTx.generatorId);
TxStream stream = loader.txStreams.get(gen.stream.getId());
if (scvTx.beginTime == scvTx.endTime) {
TxEvent evt = new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime);
stream.addEvent(evt);
gen.addEvent(evt);
stream.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
gen.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
} else {
TxEvent begEvt = new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime);
stream.addEvent(begEvt);
gen.addEvent(begEvt);
TxEvent endEvt = new TxEvent(loader, EventKind.END, id, scvTx.endTime);
stream.addEvent(endEvt);
gen.addEvent(endEvt);
stream.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
gen.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
stream.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
gen.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
}
if (nextLine != null && nextLine.charAt(0) == 'a') {
int idx = 0;

View File

@ -83,13 +83,4 @@ class TxGenerator extends AbstractTxStream {
return stream.getKind();
}
/**
* Gets the width.
*
* @return the width
*/
@Override
public int getRowCount() {
return stream.getRowCount();
}
}

View File

@ -118,8 +118,4 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
return "signal";
}
@Override
public void calculateConcurrency() {
}
}

View File

@ -79,8 +79,4 @@ public interface IWaveform extends IHierNode {
*/
public int getRowCount();
/**
* Calculate the concurrency (th enumber of parallel ongoing events) of the waveform.
*/
public void calculateConcurrency();
}

View File

@ -19,18 +19,18 @@
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.minres.scviewer.database.test"/>
<listEntry value="/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.minres.scviewer.database.test.DatabaseServicesTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>