Non-working version
This commit is contained in:
parent
73c257af03
commit
397863875e
|
@ -1,3 +1,4 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/com/minres/scviewer/database/test/DatabaseServicesPerformanceTest.java=UTF-8
|
||||||
encoding//src/com/minres/scviewer/database/test/DatabaseServicesTest.java=UTF-8
|
encoding//src/com/minres/scviewer/database/test/DatabaseServicesTest.java=UTF-8
|
||||||
encoding/<project>=UTF-8
|
encoding/<project>=UTF-8
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
<booleanAttribute key="includeOptional" value="true"/>
|
<booleanAttribute key="includeOptional" value="true"/>
|
||||||
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
|
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/com.minres.scviewer.database.test"/>
|
<listEntry value="/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="1"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/>
|
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.minres.scviewer.database.test.DatabaseServicesTest"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.test">
|
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.test">
|
||||||
<implementation class="com.minres.scviewer.database.test.DatabaseServicesTest"/>
|
<implementation class="com.minres.scviewer.database.test.DatabaseFactory"/>
|
||||||
<reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/>
|
<reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/>
|
||||||
</scr:component>
|
</scr:component>
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/.scviewer.*
|
/.scviewer.*
|
||||||
/.my_db.txlog*
|
/.my_db.txlog*
|
||||||
|
/.simple_system.txlog_bdb.*
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
||||||
|
package com.minres.scviewer.database.test;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||||
|
|
||||||
|
public class DatabaseFactory {
|
||||||
|
private static IWaveformDbFactory waveformDbFactory;
|
||||||
|
|
||||||
|
public synchronized void setFactory(IWaveformDbFactory service) {
|
||||||
|
waveformDbFactory = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void unsetFactory(IWaveformDbFactory service) {
|
||||||
|
if (waveformDbFactory == service) {
|
||||||
|
waveformDbFactory = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWaveformDb getDatabase() {
|
||||||
|
return waveformDbFactory.getDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||||
|
* 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:
|
||||||
|
* MINRES Technologies GmbH - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package com.minres.scviewer.database.test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||||
|
|
||||||
|
public class DatabaseServicesPerformanceTest {
|
||||||
|
|
||||||
|
private DatabaseFactory databaseFactory;
|
||||||
|
|
||||||
|
private IWaveformDb waveformDb;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
databaseFactory = new DatabaseFactory();
|
||||||
|
waveformDb=databaseFactory.getDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVCD() throws Exception {
|
||||||
|
File f = new File("inputs/my_db.vcd").getAbsoluteFile();
|
||||||
|
assertTrue(f.exists());
|
||||||
|
waveformDb.load(f);
|
||||||
|
assertNotNull(waveformDb);
|
||||||
|
assertEquals(14, waveformDb.getAllWaves().size());
|
||||||
|
assertEquals(2, waveformDb.getChildNodes().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTxText() throws Exception {
|
||||||
|
File f = new File("inputs/simple_system.txlog").getAbsoluteFile();
|
||||||
|
assertTrue(f.exists());
|
||||||
|
long timeBefore = System.currentTimeMillis();
|
||||||
|
waveformDb.load(f);
|
||||||
|
long timeAfter = System.currentTimeMillis();
|
||||||
|
long elapsed = timeAfter - timeBefore;
|
||||||
|
assertNotNull(waveformDb);
|
||||||
|
System.out.println("elapsed:" + elapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,23 +26,13 @@ import com.minres.scviewer.database.IWaveformDbFactory;
|
||||||
public class DatabaseServicesTest {
|
public class DatabaseServicesTest {
|
||||||
|
|
||||||
|
|
||||||
private static IWaveformDbFactory waveformDbFactory;
|
private DatabaseFactory databaseFactory;
|
||||||
|
|
||||||
private IWaveformDb waveformDb;
|
private IWaveformDb waveformDb;
|
||||||
|
|
||||||
public synchronized void setFactory(IWaveformDbFactory service) {
|
|
||||||
waveformDbFactory = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void unsetFactory(IWaveformDbFactory service) {
|
|
||||||
if (waveformDbFactory == service) {
|
|
||||||
waveformDbFactory = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
waveformDb=waveformDbFactory.getDatabase();
|
waveformDb=new DatabaseFactory().getDatabase();
|
||||||
// Wait for OSGi dependencies
|
// Wait for OSGi dependencies
|
||||||
// for (int i = 0; i < 10; i++) {
|
// for (int i = 0; i < 10; i++) {
|
||||||
// if (waveformDb.size() == 3) // Dependencies fulfilled
|
// if (waveformDb.size() == 3) // Dependencies fulfilled
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
groovy.compiler.level=23
|
groovy.compiler.level=24
|
||||||
|
groovy.script.filters=**/*.dsld,y,**/*.gradle,n
|
||||||
|
|
|
@ -26,17 +26,21 @@ 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 TextDbLoader implements IWaveformDbLoader{
|
public class TextDbLoader implements IWaveformDbLoader, Serializable{
|
||||||
|
|
||||||
private Long maxTime;
|
private Long maxTime;
|
||||||
|
|
||||||
IWaveformDb db;
|
transient IWaveformDb db;
|
||||||
|
|
||||||
DB backingDb;
|
transient DB backingDb;
|
||||||
|
|
||||||
def streams = []
|
transient def streamsById = [:]
|
||||||
|
|
||||||
def relationTypes=[:]
|
transient def generatorsById = [:]
|
||||||
|
|
||||||
|
transient def transactionsById = [:]
|
||||||
|
|
||||||
|
transient def relationTypes=[:]
|
||||||
|
|
||||||
public TextDbLoader() {
|
public TextDbLoader() {
|
||||||
}
|
}
|
||||||
|
@ -48,37 +52,39 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IWaveform> getAllWaves() {
|
public List<IWaveform> getAllWaves() {
|
||||||
return new LinkedList<IWaveform>(streams);
|
return new LinkedList<IWaveform>(streamsById.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Long, ITxGenerator> getGeneratorsById() {
|
// public Map<Long, ITxGenerator> getGeneratorsById() {
|
||||||
TreeMap<Long, ITxGenerator> res = new TreeMap<Long, ITxGenerator>();
|
// TreeMap<Long, ITxGenerator> res = new TreeMap<Long, ITxGenerator>();
|
||||||
streams.each{TxStream stream -> stream.generators.each{res.put(it.id, id)} }
|
// streamsById.values().each{TxStream stream ->
|
||||||
return res;
|
// stream.generators.each{res.put(it.id, id)} }
|
||||||
}
|
// return res;
|
||||||
|
// }
|
||||||
|
|
||||||
static final byte[] x = "scv_tr_stream".bytes
|
static final byte[] x = "scv_tr_stream".bytes
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean load(IWaveformDb db, File file) throws Exception {
|
boolean load(IWaveformDb db, File file) throws Exception {
|
||||||
this.db=db
|
this.db=db
|
||||||
this.streams=[]
|
|
||||||
def gzipped = isGzipped(file)
|
def gzipped = isGzipped(file)
|
||||||
if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
|
if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
|
||||||
if(true) {
|
def parentDir=file.absoluteFile.parent
|
||||||
def parentDir=file.absoluteFile.parent
|
def filename=file.name
|
||||||
def filename=file.name
|
new File(parentDir).eachFileRecurse (FileType.FILES) { f -> if(f.name=~/^\.${filename}/) f.delete() }
|
||||||
new File(parentDir).eachFileRecurse (FileType.FILES) { f -> if(f.name=~/^\.${filename}/) f.delete() }
|
this.backingDb = DBMaker.openFile(parentDir+File.separator+"."+filename+"_bdb")
|
||||||
this.backingDb = DBMaker.openFile(parentDir+File.separator+"."+filename+"_bdb")
|
.deleteFilesAfterClose()
|
||||||
.deleteFilesAfterClose()
|
.useRandomAccessFile()
|
||||||
.useRandomAccessFile()
|
//.enableHardCache()
|
||||||
.setMRUCacheSize(4096)
|
.enableMRUCache()
|
||||||
//.disableTransactions()
|
.setMRUCacheSize(1024*4096)
|
||||||
.disableLocking()
|
.disableTransactions()
|
||||||
.make();
|
.disableLocking()
|
||||||
} else {
|
.make();
|
||||||
this.backingDb = DBMaker.openMemory().disableLocking().make()
|
streamsById = backingDb.createHashMap("streamsById")
|
||||||
}
|
generatorsById = backingDb.createHashMap("generatorsById")
|
||||||
|
transactionsById = backingDb.createHashMap("transactionsById")
|
||||||
|
relationTypes=backingDb.createHashMap("relationTypes")
|
||||||
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
||||||
calculateConcurrencyIndicees()
|
calculateConcurrencyIndicees()
|
||||||
return true
|
return true
|
||||||
|
@ -122,9 +128,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private def parseInput(InputStream inputStream){
|
private def parseInput(InputStream inputStream){
|
||||||
def streamsById = [:]
|
//def transactionsById = backingDb.createHashMap("transactionsById")
|
||||||
def generatorsById = [:]
|
|
||||||
def transactionsById = [:]
|
|
||||||
TxGenerator generator
|
TxGenerator generator
|
||||||
Tx transaction
|
Tx transaction
|
||||||
boolean endTransaction=false
|
boolean endTransaction=false
|
||||||
|
@ -139,15 +143,14 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
case "begin_attribute":
|
case "begin_attribute":
|
||||||
case "end_attribute":
|
case "end_attribute":
|
||||||
if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
|
if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
|
||||||
def id = Integer.parseInt(matcher[0][1])
|
def id = Long.parseLong(matcher[0][1])
|
||||||
def stream = new TxStream(db, id, matcher[0][2], matcher[0][3], backingDb)
|
def stream = new TxStream(this, id, matcher[0][2], matcher[0][3])
|
||||||
streams<<stream
|
|
||||||
streamsById[id]=stream
|
streamsById[id]=stream
|
||||||
} else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
|
} else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
|
||||||
def id = Integer.parseInt(matcher[0][1])
|
def id = Long.parseLong(matcher[0][1])
|
||||||
ITxStream stream=streamsById[Integer.parseInt(matcher[0][3])]
|
ITxStream stream=streamsById[Long.parseLong(matcher[0][3])]
|
||||||
generator=new TxGenerator(id, stream, matcher[0][2])
|
generator=new TxGenerator(this, id, stream.id, matcher[0][2])
|
||||||
stream.generators<<generator
|
stream.generators<<id
|
||||||
generatorsById[id]=generator
|
generatorsById[id]=generator
|
||||||
} else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
|
} else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
|
||||||
generator.begin_attrs << TxAttributeType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.BEGIN)
|
generator.begin_attrs << TxAttributeType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.BEGIN)
|
||||||
|
@ -159,9 +162,9 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
generator=null
|
generator=null
|
||||||
break
|
break
|
||||||
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
||||||
def id = Integer.parseInt(tokens[1])
|
def id = Long.parseLong(tokens[1])
|
||||||
TxGenerator gen=generatorsById[Integer.parseInt(tokens[2])]
|
TxGenerator gen=generatorsById[Long.parseLong(tokens[2])]
|
||||||
transaction = new Tx(id, gen.stream, gen, Long.parseLong(tokens[3])*stringToScale(tokens[4]))
|
transaction = new Tx(this, id, gen.id, Long.parseLong(tokens[3])*stringToScale(tokens[4]))
|
||||||
gen.transactions << transaction
|
gen.transactions << transaction
|
||||||
transactionsById[id]= transaction
|
transactionsById[id]= transaction
|
||||||
gen.begin_attrs_idx=0;
|
gen.begin_attrs_idx=0;
|
||||||
|
@ -169,16 +172,16 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
endTransaction=false
|
endTransaction=false
|
||||||
break
|
break
|
||||||
case "tx_end"://matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
case "tx_end"://matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
||||||
def id = Integer.parseInt(tokens[1])
|
def id = Long.parseLong(tokens[1])
|
||||||
transaction = transactionsById[id]
|
transaction = transactionsById[id]
|
||||||
assert Integer.parseInt(tokens[2])==transaction.generator.id
|
assert Long.parseLong(tokens[2])==transaction.generator.id
|
||||||
transaction.endTime = Long.parseLong(tokens[3])*stringToScale(tokens[4])
|
transaction.endTime = Long.parseLong(tokens[3])*stringToScale(tokens[4])
|
||||||
transaction.generator.end_attrs_idx=0;
|
transaction.generator.end_attrs_idx=0;
|
||||||
maxTime = maxTime>transaction.endTime?maxTime:transaction.endTime
|
maxTime = maxTime>transaction.endTime?maxTime:transaction.endTime
|
||||||
endTransaction=true
|
endTransaction=true
|
||||||
break
|
break
|
||||||
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
|
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
|
||||||
def id = Integer.parseInt(tokens[1])
|
def id = Long.parseLong(tokens[1])
|
||||||
transactionsById[id].attributes<<new TxAttribute(tokens[2][1..-2], DataType.valueOf(tokens[3]), AssociationType.RECORD, tokens[5..-1].join(' '))
|
transactionsById[id].attributes<<new TxAttribute(tokens[2][1..-2], DataType.valueOf(tokens[3]), AssociationType.RECORD, tokens[5..-1].join(' '))
|
||||||
break
|
break
|
||||||
case "a"://matcher = line =~ /^a\s+(.+)$/
|
case "a"://matcher = line =~ /^a\s+(.+)$/
|
||||||
|
@ -189,8 +192,8 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
|
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
|
||||||
Tx tr2= transactionsById[Integer.parseInt(tokens[2])]
|
Tx tr2= transactionsById[Long.parseLong(tokens[2])]
|
||||||
Tx tr1= transactionsById[Integer.parseInt(tokens[3])]
|
Tx tr1= transactionsById[Long.parseLong(tokens[3])]
|
||||||
def relType=tokens[1][1..-2]
|
def relType=tokens[1][1..-2]
|
||||||
if(!relationTypes.containsKey(relType)) relationTypes[relType]=RelationType.create(relType)
|
if(!relationTypes.containsKey(relType)) relationTypes[relType]=RelationType.create(relType)
|
||||||
def rel = new TxRelation(relationTypes[relType], tr1, tr2)
|
def rel = new TxRelation(relationTypes[relType], tr1, tr2)
|
||||||
|
@ -202,14 +205,14 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
|
|
||||||
}
|
}
|
||||||
lineCnt++
|
lineCnt++
|
||||||
if((lineCnt%1000) == 0) {
|
|
||||||
backingDb.commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
backingDb.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private def calculateConcurrencyIndicees(){
|
private def calculateConcurrencyIndicees(){
|
||||||
streams.each{ TxStream stream -> stream.getMaxConcurrency() }
|
streamsById.values().each{ TxStream stream ->
|
||||||
|
stream.getMaxConcurrency()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ package com.minres.scviewer.database.text
|
||||||
|
|
||||||
import com.minres.scviewer.database.*
|
import com.minres.scviewer.database.*
|
||||||
|
|
||||||
class Tx implements ITx {
|
class Tx implements ITx, Serializable {
|
||||||
|
|
||||||
|
TextDbLoader loader
|
||||||
|
|
||||||
Long id
|
Long id
|
||||||
|
|
||||||
TxGenerator generator
|
Long generator_id
|
||||||
|
|
||||||
TxStream stream
|
|
||||||
|
|
||||||
int concurrencyIndex
|
int concurrencyIndex
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ class Tx implements ITx {
|
||||||
|
|
||||||
def outgoingRelations =[]
|
def outgoingRelations =[]
|
||||||
|
|
||||||
Tx(int id, TxStream stream, TxGenerator generator, Long begin){
|
Tx(TextDbLoader loader, Long id, Long generator_id, Long begin){
|
||||||
|
this.loader=loader
|
||||||
this.id=id
|
this.id=id
|
||||||
this.stream=stream
|
this.generator_id=generator_id
|
||||||
this.generator=generator
|
|
||||||
this.beginTime=begin
|
this.beginTime=begin
|
||||||
this.endTime=begin
|
this.endTime=begin
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,14 @@ class Tx implements ITx {
|
||||||
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
|
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITxStream<ITxEvent> getStream() {
|
||||||
|
return generator.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITxGenerator getGenerator() {
|
||||||
|
return loader.generatorsById[generator_id];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import com.minres.scviewer.database.DataType;
|
||||||
import com.minres.scviewer.database.ITxAttributeType;
|
import com.minres.scviewer.database.ITxAttributeType;
|
||||||
import com.minres.scviewer.database.ITxAttribute
|
import com.minres.scviewer.database.ITxAttribute
|
||||||
|
|
||||||
class TxAttribute implements ITxAttribute{
|
class TxAttribute implements ITxAttribute, Serializable {
|
||||||
|
|
||||||
TxAttributeType attributeType
|
TxAttributeType attributeType
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import com.minres.scviewer.database.AssociationType;
|
||||||
import com.minres.scviewer.database.DataType;
|
import com.minres.scviewer.database.DataType;
|
||||||
import com.minres.scviewer.database.ITxAttributeType;
|
import com.minres.scviewer.database.ITxAttributeType;
|
||||||
|
|
||||||
class TxAttributeType implements ITxAttributeType {
|
class TxAttributeType implements ITxAttributeType, Serializable {
|
||||||
String name
|
String name
|
||||||
DataType dataType
|
DataType dataType
|
||||||
AssociationType type
|
AssociationType type
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.minres.scviewer.database.ITx
|
||||||
import com.minres.scviewer.database.ITxEvent
|
import com.minres.scviewer.database.ITxEvent
|
||||||
import com.minres.scviewer.database.IWaveformEvent
|
import com.minres.scviewer.database.IWaveformEvent
|
||||||
|
|
||||||
class TxEvent implements ITxEvent {
|
class TxEvent implements ITxEvent, Serializable {
|
||||||
|
|
||||||
final ITxEvent.Type type;
|
final ITxEvent.Type type;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package com.minres.scviewer.database.text
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.jdbm.DB
|
||||||
import com.minres.scviewer.database.ITxAttributeType
|
import com.minres.scviewer.database.ITxAttributeType
|
||||||
import com.minres.scviewer.database.ITxAttribute;
|
import com.minres.scviewer.database.ITxAttribute;
|
||||||
import com.minres.scviewer.database.ITxEvent;
|
import com.minres.scviewer.database.ITxEvent;
|
||||||
|
@ -21,10 +21,11 @@ import com.minres.scviewer.database.ITxStream;
|
||||||
import com.minres.scviewer.database.ITx;
|
import com.minres.scviewer.database.ITx;
|
||||||
import com.minres.scviewer.database.IWaveformEvent;
|
import com.minres.scviewer.database.IWaveformEvent;
|
||||||
|
|
||||||
class TxGenerator implements ITxGenerator{
|
class TxGenerator implements ITxGenerator, Serializable{
|
||||||
Long id
|
Long id
|
||||||
TxStream stream
|
Long stream_id
|
||||||
String name
|
String name
|
||||||
|
TextDbLoader loader;
|
||||||
Boolean active = false
|
Boolean active = false
|
||||||
ArrayList<ITx> transactions=[]
|
ArrayList<ITx> transactions=[]
|
||||||
|
|
||||||
|
@ -33,14 +34,15 @@ class TxGenerator implements ITxGenerator{
|
||||||
ArrayList<ITxAttributeType> end_attrs= []
|
ArrayList<ITxAttributeType> end_attrs= []
|
||||||
int end_attrs_idx = 0
|
int end_attrs_idx = 0
|
||||||
|
|
||||||
TxGenerator(int id, TxStream stream, name){
|
TxGenerator(TextDbLoader loader, Long id, Long stream_id, name){
|
||||||
this.id=id
|
this.id=id
|
||||||
this.stream=stream
|
this.stream_id=stream_id
|
||||||
this.name=name
|
this.name=name
|
||||||
|
this.loader=loader
|
||||||
}
|
}
|
||||||
|
|
||||||
ITxStream<? extends ITxEvent> getStream(){
|
ITxStream<? extends ITxEvent> getStream(){
|
||||||
return stream;
|
return loader.streamsById[stream_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ITx> getTransactions(){
|
List<ITx> getTransactions(){
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.minres.scviewer.database.ITxRelation
|
||||||
import com.minres.scviewer.database.ITx;
|
import com.minres.scviewer.database.ITx;
|
||||||
import com.minres.scviewer.database.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
|
|
||||||
class TxRelation implements ITxRelation {
|
class TxRelation implements ITxRelation, Serializable {
|
||||||
Tx source
|
Tx source
|
||||||
|
|
||||||
Tx target
|
Tx target
|
||||||
|
|
|
@ -27,11 +27,11 @@ import com.minres.scviewer.database.IHierNode
|
||||||
import com.minres.scviewer.database.ITxStream
|
import com.minres.scviewer.database.ITxStream
|
||||||
import com.minres.scviewer.database.ITx
|
import com.minres.scviewer.database.ITx
|
||||||
|
|
||||||
class TxStream extends HierNode implements ITxStream {
|
class TxStream extends HierNode implements ITxStream, Serializable {
|
||||||
|
|
||||||
Long id
|
Long id
|
||||||
|
|
||||||
IWaveformDb database
|
transient TextDbLoader loader
|
||||||
|
|
||||||
String fullName
|
String fullName
|
||||||
|
|
||||||
|
@ -43,24 +43,24 @@ class TxStream extends HierNode implements ITxStream {
|
||||||
|
|
||||||
private TreeMap<Long, List<ITxEvent>> events
|
private TreeMap<Long, List<ITxEvent>> events
|
||||||
|
|
||||||
TxStream(IWaveformDb db, int id, String name, String kind, DB backingStore){
|
TxStream(TextDbLoader loader, Long id, String name, String kind){
|
||||||
super(name)
|
super(name)
|
||||||
this.id=id
|
this.id=id
|
||||||
this.database=db
|
this.loader=loader
|
||||||
this.fullName=name
|
this.fullName=name
|
||||||
this.kind=kind
|
this.kind=kind
|
||||||
this.maxConcurrency=0
|
this.maxConcurrency=0
|
||||||
//events = new TreeMap<Long, List<ITxEvent>>()
|
events = new TreeMap<Long, List<ITxEvent>>()
|
||||||
events=backingStore.createTreeMap("stream-"+name)
|
//events=backingStore.createTreeMap("stream-"+name)
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ITxGenerator> getGenerators(){
|
List<ITxGenerator> getGenerators(){
|
||||||
return generators as List<ITxGenerator>
|
return generators.collect { loader.generatorsById[it] } as List<ITxGenerator>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IWaveformDb getDb() {
|
public IWaveformDb getDb() {
|
||||||
return database
|
return loader.db
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,18 +12,25 @@ package com.minres.scviewer.database;
|
||||||
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
|
import java.beans.Transient;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HierNode implements IHierNode {
|
public class HierNode implements IHierNode, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -2278641781226609616L;
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
protected String parentName;
|
protected String parentName;
|
||||||
|
|
||||||
protected ArrayList<IHierNode> childs;
|
protected transient ArrayList<IHierNode> childs;
|
||||||
|
|
||||||
protected PropertyChangeSupport pcs;
|
protected transient PropertyChangeSupport pcs;
|
||||||
|
|
||||||
public HierNode() {
|
public HierNode() {
|
||||||
childs = new ArrayList<IHierNode>();
|
childs = new ArrayList<IHierNode>();
|
||||||
|
|
|
@ -10,9 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database;
|
package com.minres.scviewer.database;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class RelationType {
|
public class RelationType implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -5598253591502850283L;
|
||||||
|
|
||||||
private static HashMap<String, RelationType> registry = new HashMap<>();
|
private static HashMap<String, RelationType> registry = new HashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package com.minres.scviewer.database.internal;
|
package com.minres.scviewer.database.internal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -31,7 +32,12 @@ import com.minres.scviewer.database.IWaveformEvent;
|
||||||
import com.minres.scviewer.database.InputFormatException;
|
import com.minres.scviewer.database.InputFormatException;
|
||||||
import com.minres.scviewer.database.RelationType;
|
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 = 4917280760027131179L;
|
||||||
|
|
||||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue