Merge branch 'hotfix/tx_end_time_fix'

This commit is contained in:
Eyck Jentzsch 2021-01-12 07:18:24 +01:00
commit 25170d0d83
3 changed files with 29 additions and 18 deletions

View File

@ -76,6 +76,8 @@ public class TextDbLoader implements IWaveformDbLoader {
/** The transactions. */
Map<Long, ScvTx> transactions = null;
Map<Long, Long> id2index = new HashMap<>();
/** The attribute types. */
final Map<String, TxAttributeType> attributeTypes = UnifiedMap.newMap();
@ -107,6 +109,10 @@ public class TextDbLoader implements IWaveformDbLoader {
return maxTime;
}
public ScvTx getScvTx(long id) {
return transactions.get(id2index.get(id));
}
/**
* Gets the all waves.
*
@ -280,6 +286,7 @@ public class TextDbLoader implements IWaveformDbLoader {
/** The attr value lut. */
Map<String, Integer> attrValueLut = new HashMap<>();
long indexCount = 0;
/**
* Instantiates a new text db parser.
*
@ -367,7 +374,6 @@ public class TextDbLoader implements IWaveformDbLoader {
nextLine = reader.readLine();
}
}
txSink.put(id, scvTx);
transactionById.put(id, scvTx);
} else if ("tx_end".equals(tokens[0])) {
Long id = Long.parseLong(tokens[1]);
@ -401,6 +407,9 @@ public class TextDbLoader implements IWaveformDbLoader {
nextLine = reader.readLine();
}
}
txSink.put(indexCount, scvTx);
loader.id2index.put(scvTx.getId(), indexCount++);
transactionById.remove(id);
} else if ("tx_relation".equals(tokens[0])) {
Long tr2 = Long.parseLong(tokens[2]);
Long tr1 = Long.parseLong(tokens[3]);

View File

@ -113,7 +113,7 @@ class Tx implements ITx {
return true;
if (obj == null || getClass() != obj.getClass())
return false;
return this.getScvTx().equals(((Tx) obj).getScvTx());
return this.loader.getScvTx(id).equals(((Tx) obj).loader.getScvTx(id));
}
/**
@ -123,7 +123,7 @@ class Tx implements ITx {
*/
@Override
public int hashCode() {
return getScvTx().hashCode();
return loader.getScvTx(id).hashCode();
}
/**
@ -143,7 +143,7 @@ class Tx implements ITx {
*/
@Override
public Long getId() {
return getScvTx().id;
return loader.getScvTx(id).id;
}
/**
@ -153,7 +153,7 @@ class Tx implements ITx {
*/
@Override
public IWaveform getStream() {
return loader.txStreams.get(getScvTx().streamId);
return loader.txStreams.get(loader.getScvTx(id).streamId);
}
/**
@ -163,7 +163,7 @@ class Tx implements ITx {
*/
@Override
public ITxGenerator getGenerator() {
return loader.txGenerators.get(getScvTx().generatorId);
return loader.txGenerators.get(loader.getScvTx(id).generatorId);
}
/**
@ -174,7 +174,7 @@ class Tx implements ITx {
@Override
public Long getBeginTime() {
if (beginTime < 0)
beginTime = getScvTx().beginTime;
beginTime = loader.getScvTx(id).beginTime;
return beginTime;
}
@ -186,7 +186,7 @@ class Tx implements ITx {
@Override
public Long getEndTime() {
if (endTime < 0)
endTime = getScvTx().endTime;
endTime = loader.getScvTx(id).endTime;
return endTime;
}
@ -196,7 +196,7 @@ class Tx implements ITx {
* @param time the new end time
*/
void setEndTime(Long time) {
getScvTx().endTime = time;
loader.getScvTx(id).endTime = time;
}
/**
@ -225,15 +225,7 @@ class Tx implements ITx {
*/
@Override
public List<ITxAttribute> getAttributes() {
return getScvTx().attributes;
return loader.getScvTx(id).attributes;
}
/**
* Gets the scv tx.
*
* @return the scv tx
*/
private ScvTx getScvTx() {
return loader.transactions.get(id);
}
}

View File

@ -120,5 +120,15 @@ public class DatabaseServicesTest {
assertEquals(1, waveformDb.getChildNodes().size());
}
@Test
public void testLargeTxText() throws Exception {
File f = new File("inputs/hw_config_10_10.txlog").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
List<IWaveform> waveforms = waveformDb.getAllWaves();
assertEquals(100, waveforms.size());
assertEquals(1, waveformDb.getChildNodes().size());
}
}