refactor internal transaction representation

This commit is contained in:
eyck committed 2021-01-03 14:16:56 +01:00
1 parent b44f3418f4
commit 85ce07f11f
15 files changed
+373 -287

No files matched your search

@@ -1,34 +1,22 @@
package com.minres.scviewer.database.text;
import java.io.Serializable;
import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.WaveformType;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxEvent;
class TxEvent implements ITxEvent, Serializable {
/**
*
*/
private static final long serialVersionUID = 4481575593229248159L;
class TxEvent implements ITxEvent {
final TextDbLoader loader;
final EventKind kind;
final ITx transaction;
final Long transaction;
final Long time;
TxEvent(EventKind kind, ITx transaction) {
super();
this.kind = kind;
this.transaction = transaction;
this.time = kind==EventKind.BEGIN?transaction.getBeginTime():transaction.getEndTime();
}
public TxEvent(EventKind kind, ITx transaction, Long time) {
super();
TxEvent(TextDbLoader loader, EventKind kind, Long transaction, Long time) {
this.loader=loader;
this.kind = kind;
this.transaction = transaction;
this.time = time;
@@ -37,13 +25,13 @@ class TxEvent implements ITxEvent, Serializable {
@Override
public
ITxEvent duplicate() throws CloneNotSupportedException {
return new TxEvent(kind, transaction, time);
return new TxEvent(loader, kind, transaction, time);
}
@Override
public
String toString() {
return kind.toString()+"@"+time+" of tx #"+transaction.getId();
return kind.toString()+"@"+time+" of tx #"+transaction;
}
@Override
@@ -63,6 +51,6 @@ class TxEvent implements ITxEvent, Serializable {
@Override
public ITx getTransaction() {
return transaction;
return loader.getTransaction(transaction);
}
}