fix serialization issue
This commit is contained in:
parent
a51f922ea4
commit
bfbc40c282
|
@ -38,8 +38,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
|
|
||||||
private List<RelationType> usedRelationsList = new ArrayList<>();
|
private List<RelationType> usedRelationsList = new ArrayList<>();
|
||||||
|
|
||||||
private IWaveformDb db;
|
|
||||||
|
|
||||||
private ScvSimProps scvSimProps;
|
private ScvSimProps scvSimProps;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,7 +61,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
List<IWaveform> streams=new ArrayList<>();
|
List<IWaveform> streams=new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
for(ScvStream scvStream:handler.selectObjects()){
|
for(ScvStream scvStream:handler.selectObjects()){
|
||||||
TxStream stream = new TxStream(database, db, scvStream);
|
TxStream stream = new TxStream(database, scvStream);
|
||||||
stream.setRelationTypeList(usedRelationsList);
|
stream.setRelationTypeList(usedRelationsList);
|
||||||
streams.add(stream);
|
streams.add(stream);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +76,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
@Override
|
@Override
|
||||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||||
if(file.isDirectory() || !file.exists()) return false;
|
if(file.isDirectory() || !file.exists()) return false;
|
||||||
this.db=db;
|
|
||||||
try(FileInputStream fis = new FileInputStream(file)) {
|
try(FileInputStream fis = new FileInputStream(file)) {
|
||||||
byte[] buffer = new byte[x.length];
|
byte[] buffer = new byte[x.length];
|
||||||
int read = fis.read(buffer, 0, x.length);
|
int read = fis.read(buffer, 0, x.length);
|
||||||
|
@ -88,7 +85,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
database=new SQLiteDatabase(file.getAbsolutePath());
|
database=new SQLiteDatabase(file.getAbsolutePath(), db);
|
||||||
database.setData("TIMERESOLUTION", 1L);
|
database.setData("TIMERESOLUTION", 1L);
|
||||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class Tx implements ITx {
|
||||||
List<ScvStream> streams = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database,
|
List<ScvStream> streams = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database,
|
||||||
"id="+res.get(0).getStream()).selectObjects();
|
"id="+res.get(0).getStream()).selectObjects();
|
||||||
if(streams.size()!=1) return null;
|
if(streams.size()!=1) return null;
|
||||||
TxStream tgtStream = (TxStream) trStream.getDb().getStreamByName(streams.get(0).getName());
|
TxStream tgtStream = (TxStream) database.getWaveformDb().getStreamByName(streams.get(0).getName());
|
||||||
Tx that = (Tx) tgtStream.getTransactions().get(otherId);
|
Tx that = (Tx) tgtStream.getTransactions().get(otherId);
|
||||||
if(outgoing)
|
if(outgoing)
|
||||||
return new TxRelation(trStream.getRelationType(rel.getName()), this, that);
|
return new TxRelation(trStream.getRelationType(rel.getName()), this, that);
|
||||||
|
|
|
@ -41,8 +41,6 @@ public class TxStream extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private String fullName;
|
private String fullName;
|
||||||
|
|
||||||
private IWaveformDb db;
|
|
||||||
|
|
||||||
private ScvStream scvStream;
|
private ScvStream scvStream;
|
||||||
|
|
||||||
private TreeMap<Integer, TxGenerator> generators;
|
private TreeMap<Integer, TxGenerator> generators;
|
||||||
|
@ -55,17 +53,11 @@ public class TxStream extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private List<RelationType> usedRelationsList;
|
private List<RelationType> usedRelationsList;
|
||||||
|
|
||||||
public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
|
public TxStream(IDatabase database, ScvStream scvStream) {
|
||||||
super(scvStream.getName());
|
super(scvStream.getName());
|
||||||
this.database=database;
|
this.database=database;
|
||||||
fullName=scvStream.getName();
|
fullName=scvStream.getName();
|
||||||
this.scvStream=scvStream;
|
this.scvStream=scvStream;
|
||||||
db=waveformDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWaveformDb getDb() {
|
|
||||||
return db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,6 +16,8 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Creates a connection to a database.
|
* Creates a connection to a database.
|
||||||
|
@ -58,4 +60,6 @@ public interface IDatabase {
|
||||||
public void setData(String name, Object value);
|
public void setData(String name, Object value);
|
||||||
|
|
||||||
public Object getData(String name);
|
public Object getData(String name);
|
||||||
|
|
||||||
|
public IWaveformDb getWaveformDb();
|
||||||
}
|
}
|
|
@ -20,10 +20,14 @@ import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
|
||||||
public class SQLiteDatabase implements IDatabase {
|
public class SQLiteDatabase implements IDatabase {
|
||||||
|
|
||||||
protected String dbFileName;
|
protected String dbFileName;
|
||||||
|
|
||||||
|
protected IWaveformDb waveformDb;
|
||||||
|
|
||||||
protected HashMap<String, Object> props;
|
protected HashMap<String, Object> props;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -39,9 +43,10 @@ public class SQLiteDatabase implements IDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteDatabase(String dbFileName) {
|
public SQLiteDatabase(String dbFileName, IWaveformDb waveformDb) {
|
||||||
super();
|
super();
|
||||||
this.dbFileName = dbFileName;
|
this.dbFileName = dbFileName;
|
||||||
|
this.waveformDb = waveformDb;
|
||||||
props = new HashMap<String, Object>();
|
props = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,4 +94,9 @@ public class SQLiteDatabase implements IDatabase {
|
||||||
return props.get(name);
|
return props.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWaveformDb getWaveformDb() {
|
||||||
|
return waveformDb;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,21 +96,14 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file));
|
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file));
|
||||||
for(IWaveform stream: streams){ stream.getWidth(); }
|
for(IWaveform stream: streams){ stream.getWidth(); }
|
||||||
return true;
|
return true;
|
||||||
}
|
} else
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
return false;
|
return false;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch(IllegalArgumentException|ArrayIndexOutOfBoundsException e) {
|
||||||
return false;
|
} catch(Throwable e) {
|
||||||
} catch(EOFException e) {
|
|
||||||
return true;
|
|
||||||
} catch(Exception e) {
|
|
||||||
System.out.println("---->>> Exception "+e.toString()+" caught while loading database");
|
System.out.println("---->>> Exception "+e.toString()+" caught while loading database");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch(Error e) {
|
|
||||||
System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isTxfile(InputStream istream) {
|
private static boolean isTxfile(InputStream istream) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import com.minres.scviewer.database.EventKind;
|
||||||
import com.minres.scviewer.database.HierNode;
|
import com.minres.scviewer.database.HierNode;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.IWaveformDb;
|
|
||||||
import com.minres.scviewer.database.WaveformType;
|
import com.minres.scviewer.database.WaveformType;
|
||||||
import com.minres.scviewer.database.tx.ITx;
|
import com.minres.scviewer.database.tx.ITx;
|
||||||
import com.minres.scviewer.database.tx.ITxEvent;
|
import com.minres.scviewer.database.tx.ITxEvent;
|
||||||
|
@ -39,8 +38,6 @@ class TxStream extends HierNode implements IWaveform, Serializable {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private IWaveformDb database;
|
|
||||||
|
|
||||||
private ArrayList<ITxGenerator> generators = new ArrayList<ITxGenerator>();
|
private ArrayList<ITxGenerator> generators = new ArrayList<ITxGenerator>();
|
||||||
|
|
||||||
private int maxConcurrency;
|
private int maxConcurrency;
|
||||||
|
@ -51,7 +48,6 @@ class TxStream extends HierNode implements IWaveform, Serializable {
|
||||||
TxStream(TextDbLoader loader, Long id, String name, String kind){
|
TxStream(TextDbLoader loader, Long id, String name, String kind){
|
||||||
super(name);
|
super(name);
|
||||||
this.id=id;
|
this.id=id;
|
||||||
this.database=loader.db;
|
|
||||||
this.maxConcurrency=0;
|
this.maxConcurrency=0;
|
||||||
//events = new TreeMap<Long, List<ITxEvent>>()
|
//events = new TreeMap<Long, List<ITxEvent>>()
|
||||||
events = (BTreeMap<Long, IEvent[]>) loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
|
events = (BTreeMap<Long, IEvent[]>) loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
|
||||||
|
@ -61,11 +57,6 @@ class TxStream extends HierNode implements IWaveform, Serializable {
|
||||||
return generators;
|
return generators;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWaveformDb getDb() {
|
|
||||||
return database;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
if(maxConcurrency==0){
|
if(maxConcurrency==0){
|
||||||
|
|
|
@ -41,9 +41,6 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||||
/** The Constant TIME_RES. */
|
/** The Constant TIME_RES. */
|
||||||
private static final Long TIME_RES = 1000L; // ps
|
private static final Long TIME_RES = 1000L; // ps
|
||||||
|
|
||||||
/** The db. */
|
|
||||||
private IWaveformDb db;
|
|
||||||
|
|
||||||
/** The module stack. */
|
/** The module stack. */
|
||||||
private ArrayDeque<String> moduleStack;
|
private ArrayDeque<String> moduleStack;
|
||||||
|
|
||||||
|
@ -72,7 +69,6 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||||
@Override
|
@Override
|
||||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||||
if(file.isDirectory() || !file.exists()) return false;
|
if(file.isDirectory() || !file.exists()) return false;
|
||||||
this.db=db;
|
|
||||||
this.maxTime=0;
|
this.maxTime=0;
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
try {
|
try {
|
||||||
|
@ -159,10 +155,10 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||||
String netName = moduleStack.isEmpty()? name: moduleStack.peek()+"."+name;
|
String netName = moduleStack.isEmpty()? name: moduleStack.peek()+"."+name;
|
||||||
int id = signals.size();
|
int id = signals.size();
|
||||||
if(width==0) {
|
if(width==0) {
|
||||||
signals.add( i<0 ? new VCDSignal<DoubleVal>(db, id, netName, width) :
|
signals.add( i<0 ? new VCDSignal<DoubleVal>(id, netName, width) :
|
||||||
new VCDSignal<DoubleVal>((VCDSignal<DoubleVal>)signals.get(i), id, netName));
|
new VCDSignal<DoubleVal>((VCDSignal<DoubleVal>)signals.get(i), id, netName));
|
||||||
} else if(width>0){
|
} else if(width>0){
|
||||||
signals.add( i<0 ? new VCDSignal<BitVector>(db, id, netName, width) :
|
signals.add( i<0 ? new VCDSignal<BitVector>(id, netName, width) :
|
||||||
new VCDSignal<BitVector>((VCDSignal<BitVector>)signals.get(i), id, netName));
|
new VCDSignal<BitVector>((VCDSignal<BitVector>)signals.get(i), id, netName));
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -28,21 +28,18 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private final int width;
|
private final int width;
|
||||||
|
|
||||||
private IWaveformDb db;
|
|
||||||
|
|
||||||
private NavigableMap<Long, IEvent[]> values;
|
private NavigableMap<Long, IEvent[]> values;
|
||||||
|
|
||||||
public VCDSignal(IWaveformDb db, String name) {
|
public VCDSignal(String name) {
|
||||||
this(db, 0, name, 1);
|
this(0, name, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VCDSignal(IWaveformDb db, int id, String name) {
|
public VCDSignal(int id, String name) {
|
||||||
this(db, id,name,1);
|
this(id,name,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VCDSignal(IWaveformDb db, int id, String name, int width) {
|
public VCDSignal(int id, String name, int width) {
|
||||||
super(name);
|
super(name);
|
||||||
this.db=db;
|
|
||||||
fullName=name;
|
fullName=name;
|
||||||
this.id=id;
|
this.id=id;
|
||||||
this.width=width;
|
this.width=width;
|
||||||
|
@ -55,7 +52,6 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
this.id=id;
|
this.id=id;
|
||||||
this.width=o.width;
|
this.width=o.width;
|
||||||
this.values=o.values;
|
this.values=o.values;
|
||||||
this.db=o.getDb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,11 +68,6 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IWaveformDb getDb() {
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSignalChange(Long time, T value){
|
public void addSignalChange(Long time, T value){
|
||||||
if(values.containsKey(time)) {
|
if(values.containsKey(time)) {
|
||||||
IEvent[] oldV = values.get(time);
|
IEvent[] oldV = values.get(time);
|
||||||
|
|
|
@ -16,8 +16,6 @@ public interface IWaveform extends IHierNode {
|
||||||
|
|
||||||
public Long getId();
|
public Long getId();
|
||||||
|
|
||||||
public IWaveformDb getDb();
|
|
||||||
|
|
||||||
public boolean isSame(IWaveform other);
|
public boolean isSame(IWaveform other);
|
||||||
|
|
||||||
public NavigableMap<Long, IEvent[]> getEvents();
|
public NavigableMap<Long, IEvent[]> getEvents();
|
||||||
|
|
|
@ -26,12 +26,7 @@ import com.minres.scviewer.database.IWaveformDb;
|
||||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||||
import com.minres.scviewer.database.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
|
|
||||||
public class WaveformDb extends HierNode implements IWaveformDb, Serializable {
|
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 3274692080405194894L;
|
|
||||||
|
|
||||||
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
|
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue