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