diff --git a/plugins/com.minres.scviewer.database.text/.classpath b/plugins/com.minres.scviewer.database.text/.classpath
index 289f0a4..f0eb6dc 100644
--- a/plugins/com.minres.scviewer.database.text/.classpath
+++ b/plugins/com.minres.scviewer.database.text/.classpath
@@ -18,5 +18,6 @@
+
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy
deleted file mode 100644
index 0f07966..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text;
-
-import java.nio.charset.CharsetDecoder;
-import java.util.Collection;
-import java.util.zip.GZIPInputStream
-
-import org.codehaus.groovy.ast.stmt.CatchStatement
-import org.mapdb.DB
-import org.mapdb.DBMaker
-
-import groovy.io.FileType
-
-import com.minres.scviewer.database.AssociationType
-import com.minres.scviewer.database.DataType
-import com.minres.scviewer.database.IWaveform
-import com.minres.scviewer.database.IWaveformDb
-import com.minres.scviewer.database.IWaveformDbLoader
-import com.minres.scviewer.database.InputFormatException
-import com.minres.scviewer.database.RelationType
-import com.minres.scviewer.database.tx.ITxGenerator
-
-public class TextDbLoader implements IWaveformDbLoader{
-
- private Long maxTime;
-
- IWaveformDb db;
-
- def streams = []
-
- def relationTypes=[:]
-
- DB mapDb
-
- public TextDbLoader() {
- }
-
- @Override
- public Long getMaxTime() {
- return maxTime;
- }
-
- @Override
- public Collection getAllWaves() {
- return streams;
- }
-
- public Map getGeneratorsById() {
- TreeMap res = new TreeMap();
- streams.each{TxStream stream -> stream.generators.each{res.put(it.id, id)} }
- return res;
- }
-
- static final byte[] x = "scv_tr_stream".bytes
-
- @Override
- boolean load(IWaveformDb db, File file) throws InputFormatException {
- if(file.isDirectory() || !file.exists()) return false;
- this.db=db
- this.streams=[]
- try {
- def gzipped = isGzipped(file)
- if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
- def mapDbFile = File.createTempFile("."+file.name, null /*"tmp"*/, null /*file.parentFile*/)
- mapDbFile.delete()
- mapDbFile.deleteOnExit()
- this.mapDb = DBMaker
- .fileDB(mapDbFile)
- .fileMmapEnableIfSupported()
- .fileMmapPreclearDisable()
- .cleanerHackEnable()
- .allocateStartSize(64*1024*1024)
- .allocateIncrement(64*1024*1024)
- .make()
- // NPE here --->
- parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
- streams.each{ TxStream stream -> stream.getWidth() }
- return true
- }
- } catch (IndexOutOfBoundsException e) {
- return false
- } catch (IllegalArgumentException e) {
- return false
- } catch (NumberFormatException e) {
- return false
- } 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. StackTrace following... ");
- //e.printStackTrace()
- } catch(Error e) {
- System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
- e.printStackTrace()
- }
- return false;
- }
-
- private static boolean isTxfile(InputStream istream) {
- byte[] buffer = new byte[x.size()]
- def readCnt = istream.read(buffer, 0, x.size())
- istream.close()
- if(readCnt==x.size()){
- for(int i=0; i
- def tokens = line.split(/\s+/) as ArrayList
- switch(tokens[0]){
- case "scv_tr_stream":
- if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
- def id = Integer.parseInt(matcher[0][1])
- def stream = new TxStream(this, id, matcher[0][2], matcher[0][3])
- streams<transaction.beginTime?maxTime:transaction.beginTime
- endTransaction=false
- break
- case "tx_end"://matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
- def id = Integer.parseInt(tokens[1])
- transaction = transactionsById[id]
- assert Integer.parseInt(tokens[2])==transaction.generator.id
- transaction.endTime = Long.parseLong(tokens[3])*stringToScale(tokens[4])
- transaction.generator.end_attrs_idx=0;
- maxTime = maxTime>transaction.endTime?maxTime:transaction.endTime
- endTransaction=true
- break
- case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
- def id = Integer.parseInt(tokens[1])
- def name = tokens[2][1..-2]
- def type = tokens[3] as DataType
- def remaining = tokens.size()>5?tokens[5..-1].join(' '):""
- transactionsById[id].attributes< getAllRelationTypes(){
- return relationTypes.values();
- }
-
-}
-
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
new file mode 100644
index 0000000..1eac0e0
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+
+import org.mapdb.DB;
+import org.mapdb.DBMaker;
+
+import com.minres.scviewer.database.AssociationType;
+import com.minres.scviewer.database.DataType;
+import com.minres.scviewer.database.IWaveform;
+import com.minres.scviewer.database.IWaveformDb;
+import com.minres.scviewer.database.IWaveformDbLoader;
+import com.minres.scviewer.database.InputFormatException;
+import com.minres.scviewer.database.RelationType;
+import com.minres.scviewer.database.tx.ITxGenerator;
+
+public class TextDbLoader implements IWaveformDbLoader{
+
+ private Long maxTime=0L;
+
+ IWaveformDb db;
+
+ List streams;
+
+ Map relationTypes=new HashMap();
+
+ DB mapDb;
+
+ public TextDbLoader() {
+ }
+
+ @Override
+ public Long getMaxTime() {
+ return maxTime;
+ }
+
+ @Override
+ public Collection getAllWaves() {
+ return streams;
+ }
+
+ public Map getGeneratorsById() {
+ TreeMap res = new TreeMap();
+ for(IWaveform stream: streams){ for(ITxGenerator it: ((TxStream)stream).getGenerators()){res.put(it.getId(), it);} }
+ return res;
+ }
+
+ static final byte[] x = "scv_tr_stream".getBytes();
+
+ @Override
+ public boolean load(IWaveformDb db, File file) throws InputFormatException {
+ if(file.isDirectory() || !file.exists()) return false;
+ this.db=db;
+ this.streams = new ArrayList<>();
+ try {
+ boolean gzipped = isGzipped(file);
+ if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
+ File mapDbFile = File.createTempFile("."+file.getName(), null /*"tmp"*/, null /*file.parentFile*/);
+ mapDbFile.delete();
+ mapDbFile.deleteOnExit();
+ this.mapDb = DBMaker
+ .fileDB(mapDbFile)
+ .fileMmapEnableIfSupported()
+ .fileMmapPreclearDisable()
+ .cleanerHackEnable()
+ .allocateStartSize(64*1024*1024)
+ .allocateIncrement(64*1024*1024)
+ .make();
+ // NPE here --->
+ 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) {
+ 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;
+ }
+
+ private static boolean isTxfile(InputStream istream) {
+ byte[] buffer = new byte[x.length];
+ try {
+ int readCnt = istream.read(buffer, 0, x.length);
+ istream.close();
+ if(readCnt==x.length){
+ for(int i=0; i streamsById = new HashMap();
+ HashMap generatorsById = new HashMap();
+ HashMap transactionsById = new HashMap();
+ TxGenerator generator = null;
+ Tx transaction = null;
+ boolean endTransaction=false;
+ BufferedReader reader =null;
+
+ private void parseInput(InputStream inputStream) throws IOException{
+ reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+ String curLine = reader.readLine();
+ String nextLine = null;
+ while((nextLine=reader.readLine())!=null && curLine!=null) {
+ curLine=parseLine(curLine, nextLine);
+ }
+ if(curLine!=null)
+ parseLine(curLine, nextLine);
+ }
+
+ private String parseLine(String curLine, String nextLine) throws IOException{
+ String[] tokens = curLine.split("\\s+");
+ if("tx_record_attribute".equals(tokens[0])){//matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
+ Long id = Long.parseLong(tokens[1]);
+ String name = tokens[2].substring(1, tokens[2].length());
+ DataType type = DataType.valueOf(tokens[3]);
+ String remaining = tokens.length>5?String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length-1)):"";
+ transactionsById.get(id).getAttributes().add(new TxAttribute(name, type, AssociationType.RECORD, remaining));
+ } else if("tx_begin".equals(tokens[0])){//matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
+ Long id = Long.parseLong(tokens[1]);
+ TxGenerator gen=generatorsById.get(Long.parseLong(tokens[2]));
+ transaction = new Tx(id, gen.getStream(), gen, Long.parseLong(tokens[3])*stringToScale(tokens[4]));
+ gen.getTransactions().add(transaction);
+ transactionsById.put(id, transaction);
+ maxTime = maxTime>transaction.getBeginTime()?maxTime:transaction.getBeginTime();
+ if(nextLine!=null && nextLine.charAt(0)=='a') {
+ int idx=0;
+ while(nextLine!=null && nextLine.charAt(0)=='a') {
+ String[] attrTokens=nextLine.split("\\s+");
+ TxAttribute attr = new TxAttribute(gen.getBeginAttrs().get(idx), attrTokens[1]);
+ transaction.getAttributes().add(attr);
+ idx++;
+ nextLine=reader.readLine();
+ }
+ }
+ } else if("tx_end".equals(tokens[0])){//matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
+ Long id = Long.parseLong(tokens[1]);
+ transaction = transactionsById.get(id);
+ assert Integer.parseInt(tokens[2])==transaction.getGenerator().getId();
+ transaction.setEndTime(Long.parseLong(tokens[3])*stringToScale(tokens[4]));
+ maxTime = maxTime>transaction.getEndTime()?maxTime:transaction.getEndTime();
+ if(nextLine!=null && nextLine.charAt(0)=='a') {
+ TxGenerator gen = (TxGenerator) transaction.getGenerator();
+ int idx=0;
+ while(nextLine!=null && nextLine.charAt(0)=='a') {
+ String[] attrTokens=nextLine.split("\\s+");
+ TxAttribute attr = new TxAttribute(gen.getEndAttrs().get(idx), attrTokens[1]);
+ transaction.getAttributes().add(attr);
+ idx++;
+ nextLine=reader.readLine();
+ }
+ }
+ } else if("tx_relation".equals(tokens[0])){//matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
+ Tx tr2= transactionsById.get(Long.parseLong(tokens[2]));
+ Tx tr1= transactionsById.get(Long.parseLong(tokens[3]));
+ String relType=tokens[1].substring(1, tokens[1].length()-2);
+ if(!relationTypes.containsKey(relType))
+ relationTypes.put(relType, RelationType.create(relType));
+ TxRelation rel = new TxRelation(relationTypes.get(relType), tr1, tr2);
+ tr1.getOutgoingRelations().add(rel);
+ tr2.getIncomingRelations().add(rel);
+ } else if("scv_tr_stream".equals(tokens[0])){
+ Matcher matcher = scv_tr_stream.matcher(curLine);
+ if (matcher.matches()) {
+ Long id = Long.parseLong(matcher.group(1));
+ TxStream stream = new TxStream(this, id, matcher.group(2), matcher.group(3));
+ streams.add(stream);
+ streamsById.put(id, stream);
+ }
+ } else if("scv_tr_generator".equals(tokens[0])){
+ Matcher matcher = scv_tr_generator.matcher(curLine);
+ if ((matcher.matches())) {
+ Long id = Long.parseLong(matcher.group(1));
+ TxStream stream=streamsById.get(Long.parseLong(matcher.group(3)));
+ generator=new TxGenerator(id, stream, matcher.group(2));
+ stream.getGenerators().add(generator);
+ generatorsById.put(id, generator);
+ }
+ } else if("begin_attribute".equals(tokens[0])){
+ Matcher matcher = begin_attribute.matcher(curLine);
+ if ((matcher.matches())) {
+ generator.getBeginAttrs().add(TxAttributeType.getAttrType(matcher.group(2), DataType.valueOf(matcher.group(3)), AssociationType.BEGIN));
+ }
+ } else if("end_attribute".equals(tokens[0])){
+ Matcher matcher = end_attribute.matcher(curLine);
+ if ((matcher.matches())) {
+ generator.getEndAttrs().add(TxAttributeType.getAttrType(matcher.group(2), DataType.valueOf(matcher.group(3)), AssociationType.END));
+ }
+ } else if(")".equals(tokens[0])){
+ generator=null;
+ } else if("a".equals(tokens[0])){//matcher = line =~ /^a\s+(.+)$/
+ System.out.println("Don't know what to do with: '"+curLine+"'");
+ } else
+ System.out.println("Don't know what to do with: '"+curLine+"'");
+ return nextLine;
+ }
+
+ public Collection getAllRelationTypes(){
+ return relationTypes.values();
+ }
+
+}
+
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy
deleted file mode 100644
index 32fa2a6..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import com.minres.scviewer.database.*
-import com.minres.scviewer.database.tx.ITx
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxRelation
-
-class Tx implements ITx {
-
- Long id
-
- TxGenerator generator
-
- TxStream stream
-
- int concurrencyIndex
-
- Long beginTime
-
- Long endTime
-
- ArrayList attributes = new ArrayList()
-
- def incomingRelations =[]
-
- def outgoingRelations =[]
-
- Tx(int id, TxStream stream, TxGenerator generator, Long begin){
- this.id=id
- this.stream=stream
- this.generator=generator
- this.beginTime=begin
- this.endTime=begin
- }
-
- @Override
- public Collection getIncomingRelations() {
- return incomingRelations;
- }
-
- @Override
- public Collection getOutgoingRelations() {
- return outgoingRelations;
- }
-
- @Override
- public int compareTo(ITx o) {
- def res =beginTime.compareTo(o.beginTime)
- if(res!=0)
- return res
- else
- return id.compareTo(o.id)
- }
-
- @Override
- public String toString() {
- return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
- }
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java
new file mode 100644
index 0000000..190eee9
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.minres.scviewer.database.*;
+import com.minres.scviewer.database.tx.ITx;
+import com.minres.scviewer.database.tx.ITxAttribute;
+import com.minres.scviewer.database.tx.ITxGenerator;
+import com.minres.scviewer.database.tx.ITxRelation;
+
+class Tx implements ITx, Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -855200240003328221L;
+
+ private final Long id;
+
+ private final TxGenerator generator;
+
+ private final IWaveform stream;
+
+ private int concurrencyIndex;
+
+ private final Long beginTime;
+
+ private Long endTime;
+
+ private final List attributes = new ArrayList<>();
+
+ private final List incomingRelations = new ArrayList<>();
+
+ private final List outgoingRelations = new ArrayList<>();
+
+ Tx(Long id, IWaveform stream, TxGenerator generator, Long begin){
+ this.id=id;
+ this.stream=stream;
+ this.generator=generator;
+ this.beginTime=begin;
+ this.endTime=begin;
+ }
+
+ @Override
+ public Collection getIncomingRelations() {
+ return incomingRelations;
+ }
+
+ @Override
+ public Collection getOutgoingRelations() {
+ return outgoingRelations;
+ }
+
+ @Override
+ public int compareTo(ITx o) {
+ int res =beginTime.compareTo(o.getBeginTime());
+ if(res!=0)
+ return res;
+ else
+ return id.compareTo(o.getId());
+ }
+
+ @Override
+ public String toString() {
+ return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public IWaveform getStream() {
+ return stream;
+ }
+
+ @Override
+ public ITxGenerator getGenerator() {
+ return generator;
+ }
+
+ @Override
+ public Long getBeginTime() {
+ return beginTime;
+ }
+
+ @Override
+ public Long getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(long l) {
+ endTime=l;
+ }
+
+ @Override
+ public int getConcurrencyIndex() {
+ return concurrencyIndex;
+ }
+
+ public void setConcurrencyIndex(int idx) {
+ concurrencyIndex=idx;
+ }
+
+ @Override
+ public List getAttributes() {
+ return attributes;
+ }
+
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
similarity index 50%
rename from plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy
rename to plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
index bc4a884..948e0fe 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
@@ -8,37 +8,44 @@
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.database.text
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxAttributeType
+import com.minres.scviewer.database.tx.ITxAttribute;
+import com.minres.scviewer.database.tx.ITxAttributeType;
-class TxAttribute implements ITxAttribute{
+public class TxAttribute implements ITxAttribute, Serializable {
- TxAttributeType attributeType
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4767726016651807152L;
- def value
+ ITxAttributeType attributeType;
+
+ String value;
- TxAttribute(String name, DataType dataType, AssociationType type, value){
- attributeType = TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
+ TxAttribute(String name, DataType dataType, AssociationType type, String value){
+ attributeType = TxAttributeTypeFactory.INSTANCE.getAttrType(name, dataType, type);
switch(dataType){
- case DataType.STRING:
- case DataType.ENUMERATION:
- this.value=value[1..-2]
+ case STRING:
+ case ENUMERATION:
+ this.value=value.substring(1, value.length()-2);
break;
default:
- this.value=value
+ this.value=value;
}
}
- TxAttribute(TxAttributeType other){
- attributeType=other
+ TxAttribute(ITxAttributeType type){
+ attributeType=type;
}
- TxAttribute(TxAttributeType other, value){
- this(other.name, other.dataType, other.type, value)
+ TxAttribute(ITxAttributeType type, String value){
+ this(type.getName(), type.getDataType(), type.getType(), value);
}
@Override
@@ -48,12 +55,17 @@ class TxAttribute implements ITxAttribute{
@Override
public AssociationType getType() {
- attributeType.type;
+ return attributeType.getType();
}
@Override
public DataType getDataType() {
- attributeType.dataType;
+ return attributeType.getDataType();
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy
deleted file mode 100644
index 6a7c0b6..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import com.minres.scviewer.database.AssociationType;
-import com.minres.scviewer.database.DataType;
-import com.minres.scviewer.database.tx.ITxAttributeType
-
-class TxAttributeType implements ITxAttributeType {
- String name
- DataType dataType
- AssociationType type
-
- static TxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
- TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
- }
-
- TxAttributeType(String name, DataType dataType, AssociationType type){
- this.name=name
- this.dataType=dataType
- this.type=type
- }
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java
new file mode 100644
index 0000000..de25fac
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+
+import com.minres.scviewer.database.AssociationType;
+import com.minres.scviewer.database.DataType;
+import com.minres.scviewer.database.tx.ITxAttributeType;
+
+class TxAttributeType implements ITxAttributeType, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7159721937208946828L;
+
+ private String name;
+
+ private DataType dataType;
+
+ private AssociationType type;
+
+ static ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
+ return TxAttributeTypeFactory.INSTANCE.getAttrType(name, dataType, type);
+ }
+
+ TxAttributeType(String name, DataType dataType, AssociationType type){
+ this.name=name;
+ this.dataType=dataType;
+ this.type=type;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ @Override
+ public AssociationType getType() {
+ return type;
+ }
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.java
similarity index 54%
rename from plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy
rename to plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.java
index 18647d9..dbc482b 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.java
@@ -8,31 +8,30 @@
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.database.text
+package com.minres.scviewer.database.text;
+
+import java.util.HashMap;
import com.minres.scviewer.database.AssociationType;
-import com.minres.scviewer.database.DataType
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxAttributeType
+import com.minres.scviewer.database.DataType;
+import com.minres.scviewer.database.tx.ITxAttributeType;
-class TxAttributeTypeFactory {
- static final TxAttributeTypeFactory instance = new TxAttributeTypeFactory()
+public class TxAttributeTypeFactory {
+ public static final TxAttributeTypeFactory INSTANCE = new TxAttributeTypeFactory();
- def attributes = [:]
+ HashMap attributes = new HashMap<>();
- private TxAttributeTypeFactory() {
- TxAttributeTypeFactory.metaClass.constructor = {-> instance }
- }
+ private TxAttributeTypeFactory() {}
ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
- def key = name+":"+dataType.toString()
- ITxAttributeType res
+ String key = name+":"+dataType.toString();
+ ITxAttributeType res;
if(attributes.containsKey(key)){
- res=attributes[key]
+ res=attributes.get(key);
} else {
- res=new TxAttributeType(name, dataType, type)
- attributes[key]=res
+ res=new TxAttributeType(name, dataType, type);
+ attributes.put(key, res);
}
- return res
+ return res;
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
index 75b3aef..67ea2af 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
@@ -1,11 +1,18 @@
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 {
+class TxEvent implements ITxEvent, Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4481575593229248159L;
final EventKind kind;
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy
deleted file mode 100644
index f51a70c..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.minres.scviewer.database.IWaveform
-import com.minres.scviewer.database.tx.ITx
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxAttributeType
-import com.minres.scviewer.database.tx.ITxGenerator
-
-class TxGenerator implements ITxGenerator{
- Long id
- IWaveform stream
- String name
- Boolean active = false
- ArrayList transactions=[]
-
- ArrayList begin_attrs = []
- int begin_attrs_idx = 0
- ArrayList end_attrs= []
- int end_attrs_idx = 0
-
- TxGenerator(int id, TxStream stream, name){
- this.id=id
- this.stream=stream
- this.name=name
- }
-
- IWaveform getStream(){
- return stream;
- }
-
- List getTransactions(){
- return transactions
- }
-
- Boolean isActive() {return active};
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java
new file mode 100644
index 0000000..8b00e30
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.minres.scviewer.database.IWaveform;
+import com.minres.scviewer.database.tx.ITx;
+import com.minres.scviewer.database.tx.ITxAttributeType;
+import com.minres.scviewer.database.tx.ITxGenerator;
+
+class TxGenerator implements ITxGenerator, Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1477511353554904763L;
+
+ Long id;
+
+ IWaveform stream;
+
+ String name;
+
+ Boolean active = false;
+
+ ArrayList transactions=new ArrayList();
+
+ ArrayList beginAttrs = new ArrayList();
+
+ ArrayList endAttrs= new ArrayList();
+
+ TxGenerator(Long id, TxStream stream, String name){
+ this.id=id;
+ this.stream=stream;
+ this.name=name;
+ }
+
+ public IWaveform getStream(){
+ return stream;
+ }
+
+ public List getTransactions(){
+ return transactions;
+ }
+
+ Boolean isActive() {return active;}
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public ArrayList getBeginAttrs() {
+ return beginAttrs;
+ }
+
+ public ArrayList getEndAttrs() {
+ return endAttrs;
+ }
+
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
index 6990b4f..034ad1e 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
@@ -1,10 +1,17 @@
package com.minres.scviewer.database.text;
+import java.io.Serializable;
+
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxRelation;
-class TxRelation implements ITxRelation {
+class TxRelation implements ITxRelation, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -347668857680574140L;
+
final Tx source;
final Tx target;
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy
deleted file mode 100644
index 619e334..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.Map.Entry
-
-import org.mapdb.Serializer
-
-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
-import com.minres.scviewer.database.tx.ITxGenerator
-import com.minres.scviewer.database.EventKind
-import com.minres.scviewer.database.HierNode;
-import com.minres.scviewer.database.IEvent
-import com.minres.scviewer.database.IHierNode
-
-class TxStream extends HierNode implements IWaveform {
-
- Long id
-
- IWaveformDb database
-
- String fullName
-
- def generators = []
-
- int maxConcurrency
-
- private TreeMap events
-
- TxStream(TextDbLoader loader, int id, String name, String kind){
- super(name)
- this.id=id
- this.database=loader.db
- this.fullName=name
- this.maxConcurrency=0
- //events = new TreeMap>()
- events = loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
- }
-
- List getGenerators(){
- return generators as List
- }
-
- @Override
- public IWaveformDb getDb() {
- return database
- }
-
- @Override
- public int getWidth() {
- if(!maxConcurrency){
- generators.each {TxGenerator generator ->
- generator.transactions.each{ Tx tx ->
- putEvent(new TxEvent(EventKind.BEGIN, tx))
- putEvent(new TxEvent(EventKind.END, tx))
- }
- }
- def rowendtime = [0]
- events.keySet().each{long time ->
- def value=events.get(time)
- def starts=value.findAll{IEvent event ->event.kind==EventKind.BEGIN}
- starts.each {ITxEvent event ->
- Tx tx = event.transaction
- def rowIdx = 0
- for(rowIdx=0; rowIdxtx.beginTime; rowIdx++);
- if(rowendtime.size<=rowIdx)
- rowendtime< getEvents() {
- return events;
- }
-
- @Override
- public IEvent[] getEventsAtTime(Long time) {
- return events.get(time);
- }
-
- @Override
- public boolean isSame(IWaveform other) {
- return(other instanceof TxStream && this.getId()==other.getId());
- }
-
- @Override
- public IEvent[] getEventsBeforeTime(Long time) {
- Entry e = events.floorEntry(time);
- if(e==null)
- return null;
- else
- return events.floorEntry(time).getValue();
- }
-
- @Override
- public WaveformType getType() {
- return WaveformType.TRANSACTION;
- }
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java
new file mode 100644
index 0000000..1495681
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.NavigableMap;
+
+import org.mapdb.BTreeMap;
+import org.mapdb.Serializer;
+
+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;
+import com.minres.scviewer.database.tx.ITxGenerator;
+
+class TxStream extends HierNode implements IWaveform, Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6721893017334753858L;
+
+ private Long id;
+
+ private IWaveformDb database;
+
+ private ArrayList generators = new ArrayList();
+
+ private int maxConcurrency;
+
+ private BTreeMap events;
+
+ @SuppressWarnings("unchecked")
+ TxStream(TextDbLoader loader, Long id, String name, String kind){
+ super(name);
+ this.id=id;
+ this.database=loader.db;
+ this.maxConcurrency=0;
+ //events = new TreeMap>()
+ events = (BTreeMap) loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
+ }
+
+ List getGenerators(){
+ return generators;
+ }
+
+ @Override
+ public IWaveformDb getDb() {
+ return database;
+ }
+
+ @Override
+ public int getWidth() {
+ if(maxConcurrency==0){
+ for(ITxGenerator generator:getGenerators()) {
+ for(ITx tx:generator.getTransactions()){
+ putEvent(new TxEvent(EventKind.BEGIN, tx));
+ putEvent(new TxEvent(EventKind.END, tx));
+ }
+ }
+ ArrayList rowendtime = new ArrayList();
+ rowendtime.add(0l);
+ for(Long time: events.keySet()){
+ IEvent[] value=events.get(time);
+ Arrays.asList(value).stream().filter(event -> event.getKind()==EventKind.BEGIN).forEach(event -> {
+ ITx tx = ((ITxEvent)event).getTransaction();
+ int rowIdx = 0;
+ for(rowIdx=0; rowIdxtx.getBeginTime(); rowIdx++);
+ if(rowendtime.size()<=rowIdx)
+ rowendtime.add(tx.getEndTime());
+ else
+ rowendtime.set(rowIdx, tx.getEndTime());
+ ((Tx)tx).setConcurrencyIndex(rowIdx);
+
+ });
+ }
+ maxConcurrency=rowendtime.size();
+ }
+ return maxConcurrency;
+ }
+
+ private void putEvent(ITxEvent event){
+ if(!events.containsKey(event.getTime()))
+ events.put(event.getTime(), new ITxEvent[]{event} );
+ else {
+ IEvent[] entries = events.get(event.getTime());
+ IEvent[] newEntries = Arrays.copyOf(entries, entries.length+1);
+ newEntries[entries.length]=event;
+ events.put(event.getTime(), newEntries);
+ }
+ }
+
+ @Override
+ public NavigableMap getEvents() {
+ return (NavigableMap)events;
+ }
+
+ @Override
+ public IEvent[] getEventsAtTime(Long time) {
+ return events.get(time);
+ }
+
+ @Override
+ public boolean isSame(IWaveform other) {
+ return(other instanceof TxStream && this.getId()==other.getId());
+ }
+
+ @Override
+ public IEvent[] getEventsBeforeTime(Long time) {
+ Entry e = events.floorEntry(time);
+ if(e==null)
+ return null;
+ else
+ return events.floorEntry(time).getValue();
+ }
+
+ @Override
+ public WaveformType getType() {
+ return WaveformType.TRANSACTION;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+}
diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/RelationType.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/RelationType.java
index 1011edf..d0b7727 100644
--- a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/RelationType.java
+++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/RelationType.java
@@ -10,10 +10,16 @@
*******************************************************************************/
package com.minres.scviewer.database;
+import java.io.Serializable;
import java.util.HashMap;
-public class RelationType {
+public class RelationType implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6394859077558971735L;
+
private static HashMap registry = new HashMap<>();
private String name;
diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java
index 32d20e8..99ef49c 100644
--- a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java
+++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java
@@ -11,6 +11,7 @@
package com.minres.scviewer.database.internal;
import java.io.File;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -25,7 +26,12 @@ 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 {
+public class WaveformDb extends HierNode implements IWaveformDb, Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3274692080405194894L;
private static List loaders=new LinkedList<>();
diff --git a/plugins/com.minres.scviewer.ui/.classpath b/plugins/com.minres.scviewer.ui/.classpath
index cf36b56..1619e35 100644
--- a/plugins/com.minres.scviewer.ui/.classpath
+++ b/plugins/com.minres.scviewer.ui/.classpath
@@ -3,5 +3,6 @@
+