cache some more infos for stream

This commit is contained in:
Eyck Jentzsch 2021-01-14 23:36:29 +01:00
parent 5bae086712
commit 59859e5d90
1 changed files with 26 additions and 9 deletions

View File

@ -29,10 +29,16 @@ class Tx implements ITx {
/** The loader. */ /** The loader. */
private final TextDbLoader loader; private final TextDbLoader loader;
private ScvTx scvTx =null;
/** The id. */ /** The id. */
private final long id; private final long id;
private final long generatorId;
private final long streamId;
/** The begin time. */ /** The begin time. */
long beginTime = -1; long beginTime = -1;
@ -48,6 +54,8 @@ class Tx implements ITx {
public Tx(TextDbLoader loader, ScvTx scvTx) { public Tx(TextDbLoader loader, ScvTx scvTx) {
this.loader = loader; this.loader = loader;
id = scvTx.id; id = scvTx.id;
generatorId=scvTx.generatorId;
streamId=scvTx.streamId;
beginTime=scvTx.beginTime; beginTime=scvTx.beginTime;
endTime=scvTx.endTime; endTime=scvTx.endTime;
} }
@ -58,9 +66,11 @@ class Tx implements ITx {
* @param loader the loader * @param loader the loader
* @param txId the tx id * @param txId the tx id
*/ */
public Tx(TextDbLoader loader, long txId) { public Tx(TextDbLoader loader, long id, long generatorId, long streamId) {
this.loader = loader; this.loader = loader;
id = txId; this.id = id;
this.generatorId=generatorId;
this.streamId = streamId;
} }
/** /**
@ -152,7 +162,7 @@ class Tx implements ITx {
*/ */
@Override @Override
public IWaveform getStream() { public IWaveform getStream() {
return loader.txStreams.get(getScvTx().streamId); return loader.txStreams.get(streamId);
} }
/** /**
@ -162,7 +172,7 @@ class Tx implements ITx {
*/ */
@Override @Override
public ITxGenerator getGenerator() { public ITxGenerator getGenerator() {
return loader.txGenerators.get(getScvTx().generatorId); return loader.txGenerators.get(generatorId);
} }
/** /**
@ -172,8 +182,11 @@ class Tx implements ITx {
*/ */
@Override @Override
public Long getBeginTime() { public Long getBeginTime() {
if (beginTime < 0) if (beginTime < 0) {
beginTime = getScvTx().beginTime; ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime;
endTime = tx.endTime;
}
return beginTime; return beginTime;
} }
@ -184,8 +197,11 @@ class Tx implements ITx {
*/ */
@Override @Override
public Long getEndTime() { public Long getEndTime() {
if (endTime < 0) if (endTime < 0) {
endTime = getScvTx().endTime; ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime;
endTime = tx.endTime;
}
return endTime; return endTime;
} }
@ -209,7 +225,8 @@ class Tx implements ITx {
} }
private ScvTx getScvTx() { private ScvTx getScvTx() {
ScvTx scvTx=loader.getScvTx(id); if(scvTx==null)
scvTx=loader.getScvTx(id);
return scvTx; return scvTx;
} }
} }