This commit is contained in:
2020-11-28 14:08:34 +01:00
parent 21d83f93dc
commit 90f09cc222
26 changed files with 324 additions and 477 deletions

View File

@ -82,7 +82,7 @@ public class TextDbLoader implements IWaveformDbLoader{
.make()
// NPE here --->
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
streams.each{ TxStream stream -> stream.getMaxConcurrency() }
streams.each{ TxStream stream -> stream.getWidth() }
return true
}
} catch (IndexOutOfBoundsException e) {
@ -97,6 +97,9 @@ public class TextDbLoader implements IWaveformDbLoader{
System.out.println("---->>> Exception "+e.toString()+" caught while loading database");
//System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
//e.printStackTrace()
} catch(Error e) {
System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
e.printStackTrace()
}
return false;
}

View File

@ -16,7 +16,7 @@ import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITxAttribute
class TxAttributeTypeFactory {
private static final instance = new TxAttributeTypeFactory()
static final TxAttributeTypeFactory instance = new TxAttributeTypeFactory()
def attributes = [:]

View File

@ -1,41 +0,0 @@
package com.minres.scviewer.database.text;
import com.minres.scviewer.database.EventKind
import com.minres.scviewer.database.ITx
import com.minres.scviewer.database.ITxEvent
class TxEvent implements ITxEvent {
final EventKind kind;
final Tx transaction;
final Long time
TxEvent(EventKind kind, ITx transaction) {
super();
this.kind = kind;
this.transaction = transaction;
this.time = kind==EventKind.BEGIN?transaction.beginTime:transaction.endTime
}
@Override
ITxEvent duplicate() throws CloneNotSupportedException {
new TxEvent(type, transaction, time)
}
// @Override
// int compareTo(IWaveformEvent o) {
// time.compareTo(o.time)
// }
@Override
String toString() {
kind.toString()+"@"+time+" of tx #"+transaction.id;
}
@Override
Class<?> getType() {
return this.getClass();
}
}

View File

@ -0,0 +1,66 @@
package com.minres.scviewer.database.text;
import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.WaveformType;
class TxEvent implements ITxEvent {
final EventKind kind;
final ITx 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();
this.kind = kind;
this.transaction = transaction;
this.time = time;
}
@Override
public
ITxEvent duplicate() throws CloneNotSupportedException {
return new TxEvent(kind, transaction, time);
}
// @Override
// int compareTo(IWaveformEvent o) {
// time.compareTo(o.time)
// }
@Override
public
String toString() {
return kind.toString()+"@"+time+" of tx #"+transaction.getId();
}
@Override
public WaveformType getType() {
return WaveformType.TRANSACTION;
}
@Override
public EventKind getKind() {
return kind;
}
@Override
public Long getTime() {
return time;
}
@Override
public ITx getTransaction() {
return transaction;
}
}

View File

@ -1,16 +1,15 @@
package com.minres.scviewer.database.text
package com.minres.scviewer.database.text;
import com.minres.scviewer.database.ITxRelation
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType;
class TxRelation implements ITxRelation {
Tx source
final Tx source;
Tx target
RelationType relationType
final Tx target;
final RelationType relationType;
public TxRelation(RelationType relationType, Tx source, Tx target) {
this.source = source;

View File

@ -23,6 +23,7 @@ import org.mapdb.Serializer
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb
import com.minres.scviewer.database.WaveformType
import com.minres.scviewer.database.ITxGenerator
import com.minres.scviewer.database.EventKind
import com.minres.scviewer.database.HierNode;
@ -38,8 +39,6 @@ class TxStream extends HierNode implements IWaveform {
String fullName
String kind
def generators = []
int maxConcurrency
@ -51,7 +50,6 @@ class TxStream extends HierNode implements IWaveform {
this.id=id
this.database=loader.db
this.fullName=name
this.kind=kind
this.maxConcurrency=0
//events = new TreeMap<Long, List<ITxEvent>>()
events = loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
@ -67,7 +65,7 @@ class TxStream extends HierNode implements IWaveform {
}
@Override
public int getMaxConcurrency() {
public int getWidth() {
if(!maxConcurrency){
generators.each {TxGenerator generator ->
generator.transactions.each{ Tx tx ->
@ -97,9 +95,12 @@ class TxStream extends HierNode implements IWaveform {
private putEvent(ITxEvent event){
if(!events.containsKey(event.time))
events.put(event.time, [event])
else
events[event.time]<<event
events.put(event.time, [event] as IEvent[])
else {
def entries = events[event.time] as List
entries<<event
events.put(event.time, entries as IEvent[])
}
}
@Override
@ -127,8 +128,8 @@ class TxStream extends HierNode implements IWaveform {
}
@Override
public Class<?> getType() {
return TxEvent.class;
public WaveformType getType() {
return WaveformType.TRANSACTION;
}
}