Merge branch 'feature/eclipse_collections' into develop
This commit is contained in:
commit
012395b933
|
@ -29,6 +29,10 @@
|
||||||
id="org.eclipse.emf.common"
|
id="org.eclipse.emf.common"
|
||||||
version="0.0.0"/>
|
version="0.0.0"/>
|
||||||
|
|
||||||
|
<includes
|
||||||
|
id="org.eclipse.collections.feature"
|
||||||
|
version="0.0.0"/>
|
||||||
|
|
||||||
<requires>
|
<requires>
|
||||||
<import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
|
<import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
|
||||||
<import plugin="org.eclipse.core.filesystem" version="1.3.0" match="compatible"/>
|
<import plugin="org.eclipse.core.filesystem" version="1.3.0" match="compatible"/>
|
||||||
|
|
|
@ -14,12 +14,13 @@ import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.EventKind;
|
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.IEventList;
|
||||||
|
import com.minres.scviewer.database.EventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
import com.minres.scviewer.database.RelationTypeFactory;
|
import com.minres.scviewer.database.RelationTypeFactory;
|
||||||
|
@ -35,7 +36,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private Integer maxConcurrency;
|
private Integer maxConcurrency;
|
||||||
|
|
||||||
private TreeMap<Long, IEvent[]> events;
|
private IEventList events;
|
||||||
|
|
||||||
private List<RelationType> usedRelationsList;
|
private List<RelationType> usedRelationsList;
|
||||||
|
|
||||||
|
@ -71,9 +72,9 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NavigableMap<Long, IEvent[]> getEvents(){
|
public IEventList getEvents(){
|
||||||
if(events==null){
|
if(events==null){
|
||||||
events=new TreeMap<>();
|
events=new EventList();
|
||||||
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
|
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
|
||||||
putEvent(new TxEvent(EventKind.BEGIN, entry.getValue()));
|
putEvent(new TxEvent(EventKind.BEGIN, entry.getValue()));
|
||||||
putEvent(new TxEvent(EventKind.END, entry.getValue()));
|
putEvent(new TxEvent(EventKind.END, entry.getValue()));
|
||||||
|
@ -83,22 +84,13 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putEvent(TxEvent ev){
|
private void putEvent(TxEvent ev){
|
||||||
Long time = ev.getTime();
|
events.put(ev.getTime(), ev);
|
||||||
if(events.containsKey(time)) {
|
|
||||||
IEvent[] oldV = events.get(time);
|
|
||||||
IEvent[] newV = new IEvent[oldV.length+1];
|
|
||||||
System.arraycopy(oldV, 0, newV, 0, oldV.length);
|
|
||||||
newV[oldV.length]=ev;
|
|
||||||
events.put(time, newV);
|
|
||||||
} else {
|
|
||||||
events.put(time, new IEvent[] {ev});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Map<Integer, ITx> getTransactions();
|
protected abstract Map<Integer, ITx> getTransactions();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsAtTime(Long time) {
|
public IEvent[] getEventsAtTime(long time) {
|
||||||
return getEvents().get(time);
|
return getEvents().get(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +105,12 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsBeforeTime(Long time) {
|
public IEvent[] getEventsBeforeTime(long time) {
|
||||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
EventEntry e = events.floorEntry(time);
|
||||||
if(e==null)
|
if(e==null)
|
||||||
return new IEvent[]{};
|
return new IEvent[]{};
|
||||||
else
|
else
|
||||||
return events.floorEntry(time).getValue();
|
return events.floorEntry(time).events;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getMaxTime() {
|
public long getMaxTime() {
|
||||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||||
database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
|
database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -37,8 +37,8 @@ public class Tx implements ITx {
|
||||||
private TxGenerator trGenerator;
|
private TxGenerator trGenerator;
|
||||||
private ScvTx scvTx;
|
private ScvTx scvTx;
|
||||||
private List<ITxAttribute> attributes;
|
private List<ITxAttribute> attributes;
|
||||||
private Long begin;
|
private long begin=-1;
|
||||||
private Long end;
|
private long end=-1;
|
||||||
private List<ITxRelation> incoming;
|
private List<ITxRelation> incoming;
|
||||||
private List<ITxRelation> outgoing;
|
private List<ITxRelation> outgoing;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class Tx implements ITx {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return (long) scvTx.getId();
|
return (long) scvTx.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ public class Tx implements ITx {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getBeginTime() {
|
public long getBeginTime() {
|
||||||
if(begin==null){
|
if(begin<0){
|
||||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
|
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
|
||||||
try {
|
try {
|
||||||
|
@ -85,8 +85,8 @@ public class Tx implements ITx {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getEndTime() {
|
public long getEndTime() {
|
||||||
if(end==null){
|
if(end<0){
|
||||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
|
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
|
||||||
try {
|
try {
|
||||||
|
@ -178,11 +178,11 @@ public class Tx implements ITx {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ITx o) {
|
public int compareTo(ITx o) {
|
||||||
int res = this.getBeginTime().compareTo(o.getBeginTime());
|
int res = Long.compare(this.getBeginTime(), o.getBeginTime());
|
||||||
if(res!=0)
|
if(res!=0)
|
||||||
return res;
|
return res;
|
||||||
else
|
else
|
||||||
return this.getId().compareTo(o.getId());
|
return Long.compare(this.getId(), o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class TxEvent implements ITxEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getTime() {
|
public long getTime() {
|
||||||
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime();
|
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class TxGenerator extends AbstractTxStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return (long) scvGenerator.getId();
|
return (long) scvGenerator.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class TxGenerator extends AbstractTxStream {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return(other instanceof TxGenerator && this.getId().equals(other.getId()));
|
return(other instanceof TxGenerator && this.getId() == other.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TxStream extends AbstractTxStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return (long) scvStream.getId();
|
return (long) scvStream.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,13 +89,13 @@ public class TxStream extends AbstractTxStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsAtTime(Long time) {
|
public IEvent[] getEventsAtTime(long time) {
|
||||||
return getEvents().get(time);
|
return getEvents().get(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return(other instanceof TxStream && this.getId().equals(other.getId()));
|
return(other instanceof TxStream && this.getId() == other.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
package com.minres.scviewer.database.text;
|
package com.minres.scviewer.database.text;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
|
import com.minres.scviewer.database.EventList;
|
||||||
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.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
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;
|
||||||
|
@ -39,7 +38,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
protected TextDbLoader loader;
|
protected TextDbLoader loader;
|
||||||
|
|
||||||
/** The events. */
|
/** The events. */
|
||||||
TreeMap<Long, IEvent[]> events = new TreeMap<>();
|
IEventList events = new EventList();
|
||||||
|
|
||||||
/** The max concurrency. */
|
/** The max concurrency. */
|
||||||
private int rowCount = -1;
|
private int rowCount = -1;
|
||||||
|
@ -73,14 +72,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
* @param evt the evt
|
* @param evt the evt
|
||||||
*/
|
*/
|
||||||
public void addEvent(ITxEvent evt) {
|
public void addEvent(ITxEvent evt) {
|
||||||
if (!events.containsKey(evt.getTime()))
|
events.put(evt.getTime(), evt);
|
||||||
events.put(evt.getTime(), new IEvent[] { evt });
|
|
||||||
else {
|
|
||||||
IEvent[] evts = events.get(evt.getTime());
|
|
||||||
IEvent[] newEvts = Arrays.copyOf(evts, evts.length + 1);
|
|
||||||
newEvts[evts.length] = evt;
|
|
||||||
events.put(evt.getTime(), newEvts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +81,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
* @return the events
|
* @return the events
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NavigableMap<Long, IEvent[]> getEvents() {
|
public IEventList getEvents() {
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +92,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
* @return the events at time
|
* @return the events at time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsAtTime(Long time) {
|
public IEvent[] getEventsAtTime(long time) {
|
||||||
return events.get(time);
|
return events.get(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,12 +103,12 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
* @return the events before time
|
* @return the events before time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsBeforeTime(Long time) {
|
public IEvent[] getEventsBeforeTime(long time) {
|
||||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
EventEntry e = events.floorEntry(time);
|
||||||
if (e == null)
|
if (e == null)
|
||||||
return new IEvent[] {};
|
return new IEvent[] {};
|
||||||
else
|
else
|
||||||
return events.floorEntry(time).getValue();
|
return events.floorEntry(time).events;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +127,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +151,8 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
return;
|
return;
|
||||||
ArrayList<Long> rowEndTime = new ArrayList<>();
|
ArrayList<Long> rowEndTime = new ArrayList<>();
|
||||||
HashMap<Long, Integer> rowByTxId = new HashMap<>();
|
HashMap<Long, Integer> rowByTxId = new HashMap<>();
|
||||||
for(Entry<Long, IEvent[]> entry: events.entrySet()) {
|
for(EventEntry entry: events) {
|
||||||
for(IEvent evt:entry.getValue()) {
|
for(IEvent evt:entry.events) {
|
||||||
TxEvent txEvt = (TxEvent) evt;
|
TxEvent txEvt = (TxEvent) evt;
|
||||||
ITx tx = txEvt.getTransaction();
|
ITx tx = txEvt.getTransaction();
|
||||||
int rowIdx = 0;
|
int rowIdx = 0;
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||||
* @return the max time
|
* @return the max time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getMaxTime() {
|
public long getMaxTime() {
|
||||||
return maxTime;
|
return maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,11 @@ class Tx implements ITx {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ITx o) {
|
public int compareTo(ITx o) {
|
||||||
int res = getBeginTime().compareTo(o.getBeginTime());
|
int res = Long.compare(getBeginTime(), o.getBeginTime());
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
return res;
|
return res;
|
||||||
else
|
else
|
||||||
return getId().compareTo(o.getId());
|
return Long.compare(getId(), o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,7 +150,7 @@ class Tx implements ITx {
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return getScvTx().id;
|
return getScvTx().id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class Tx implements ITx {
|
||||||
* @return the begin time
|
* @return the begin time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getBeginTime() {
|
public long getBeginTime() {
|
||||||
if (beginTime < 0) {
|
if (beginTime < 0) {
|
||||||
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
|
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
|
||||||
beginTime = tx.beginTime;
|
beginTime = tx.beginTime;
|
||||||
|
@ -195,7 +195,7 @@ class Tx implements ITx {
|
||||||
* @return the end time
|
* @return the end time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getEndTime() {
|
public long getEndTime() {
|
||||||
if (endTime < 0) {
|
if (endTime < 0) {
|
||||||
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
|
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
|
||||||
beginTime = tx.beginTime;
|
beginTime = tx.beginTime;
|
||||||
|
|
|
@ -95,7 +95,7 @@ class TxEvent implements ITxEvent {
|
||||||
* @return the time
|
* @return the time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getTime() {
|
public long getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class TxGenerator extends AbstractTxStream {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return (other instanceof TxGenerator && this.getId().equals(other.getId()));
|
return (other instanceof TxGenerator && this.getId()==other.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TxStream extends AbstractTxStream {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return (other instanceof TxStream && this.getId().equals(other.getId()));
|
return (other instanceof TxStream && this.getId() == other.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class ArrowPainter implements IPainter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getConcurrencyIndex(ITx tx) {
|
private int getConcurrencyIndex(ITx tx) {
|
||||||
IEvent[] eventList = tx.getStream().getEvents().floorEntry(tx.getBeginTime()).getValue();
|
IEvent[] eventList = tx.getStream().getEventsBeforeTime(tx.getBeginTime());
|
||||||
Optional<Integer> res = Arrays.stream(eventList).map(e -> ((ITxEvent)e).getRowIndex()).findFirst();
|
Optional<Integer> res = Arrays.stream(eventList).map(e -> ((ITxEvent)e).getRowIndex()).findFirst();
|
||||||
return res.isPresent()? res.get():0;
|
return res.isPresent()? res.get():0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ package com.minres.scviewer.database.ui.swt.internal;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NavigableMap;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
@ -26,7 +24,9 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
|
||||||
import com.minres.scviewer.database.BitVector;
|
import com.minres.scviewer.database.BitVector;
|
||||||
import com.minres.scviewer.database.DoubleVal;
|
import com.minres.scviewer.database.DoubleVal;
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
|
import com.minres.scviewer.database.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
|
@ -37,16 +37,16 @@ public class SignalPainter extends TrackPainter {
|
||||||
IEvent value;
|
IEvent value;
|
||||||
boolean fromMap;
|
boolean fromMap;
|
||||||
|
|
||||||
public SignalChange(Entry<Long, IEvent[]> entry) {
|
public SignalChange(EventEntry entry) {
|
||||||
time = entry.getKey();
|
time = entry.timestamp;
|
||||||
value = entry.getValue()[0];
|
value = entry.events[0];
|
||||||
fromMap = true;
|
fromMap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Entry<Long, IEvent[]> entry, Long actTime) {
|
public void set(EventEntry entry, Long actTime) {
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
time = entry.getKey();
|
time = entry.timestamp;
|
||||||
value = entry.getValue()[0];
|
value = entry.events[0];
|
||||||
fromMap = true;
|
fromMap = true;
|
||||||
} else {
|
} else {
|
||||||
time = actTime;
|
time = actTime;
|
||||||
|
@ -100,21 +100,16 @@ public class SignalPainter extends TrackPainter {
|
||||||
long beginTime = beginPos*scaleFactor;
|
long beginTime = beginPos*scaleFactor;
|
||||||
long endTime = beginTime + area.width*scaleFactor;
|
long endTime = beginTime + area.width*scaleFactor;
|
||||||
|
|
||||||
Entry<Long, IEvent[]> first = signal.getEvents().floorEntry(beginTime);
|
EventEntry first = signal.getEvents().floorEntry(beginTime);
|
||||||
Entry<Long, IEvent[]> last = signal.getEvents().floorEntry(endTime);
|
if (first == null)
|
||||||
if (first == null) {
|
|
||||||
if (last == null)
|
|
||||||
return;
|
|
||||||
first = signal.getEvents().firstEntry();
|
first = signal.getEvents().firstEntry();
|
||||||
} else if (last == null) {
|
beginTime = first.timestamp;
|
||||||
last = signal.getEvents().lastEntry();
|
|
||||||
}
|
|
||||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||||
proj.setLineStyle(SWT.LINE_SOLID);
|
proj.setLineStyle(SWT.LINE_SOLID);
|
||||||
proj.setLineWidth(1);
|
proj.setLineWidth(1);
|
||||||
NavigableMap<Long, IEvent[]> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
IEventList entries = signal.getEvents().subMap(beginTime, true, endTime);
|
||||||
SignalChange left = new SignalChange(first);
|
SignalChange left = new SignalChange(entries.firstEntry());
|
||||||
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
|
SignalChange right = new SignalChange(entries.size() > 1 ? entries.higherEntry(left.time) : entries.firstEntry());
|
||||||
maxPosX = area.x + area.width;
|
maxPosX = area.x + area.width;
|
||||||
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||||
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||||
|
@ -153,15 +148,15 @@ public class SignalPainter extends TrackPainter {
|
||||||
if (xSigChangeEndPos == xSigChangeBeginPos) {
|
if (xSigChangeEndPos == xSigChangeBeginPos) {
|
||||||
multiple = true;
|
multiple = true;
|
||||||
long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScaleFactor();
|
long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScaleFactor();
|
||||||
Entry<Long, IEvent[]> entry = entries.floorEntry(eTime);
|
EventEntry entry = entries.floorEntry(eTime);
|
||||||
if(entry!=null && entry.getKey()> right.time)
|
if(entry!=null && entry.timestamp> right.time)
|
||||||
right.set(entry, endTime);
|
right.set(entry, endTime);
|
||||||
xSigChangeEndPos = getXPosEnd(eTime);
|
xSigChangeEndPos = getXPosEnd(eTime);
|
||||||
}
|
}
|
||||||
} while (left.time < endTime);
|
} while (left.time < endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignalStencil getStencil(GC gc, SignalChange left, NavigableMap<Long, IEvent[]> entries) {
|
private SignalStencil getStencil(GC gc, SignalChange left, IEventList entries) {
|
||||||
IEvent val = left.value;
|
IEvent val = left.value;
|
||||||
if(val instanceof BitVector) {
|
if(val instanceof BitVector) {
|
||||||
BitVector bv = (BitVector) val;
|
BitVector bv = (BitVector) val;
|
||||||
|
@ -253,15 +248,15 @@ public class SignalPainter extends TrackPainter {
|
||||||
private long maxVal;
|
private long maxVal;
|
||||||
private long minVal;
|
private long minVal;
|
||||||
double yRange = (yOffsetB-yOffsetT);
|
double yRange = (yOffsetB-yOffsetT);
|
||||||
public MultiBitStencilAnalog(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous, boolean signed) {
|
public MultiBitStencilAnalog(IEventList entries, Object left, boolean continous, boolean signed) {
|
||||||
this.continous=continous;
|
this.continous=continous;
|
||||||
this.signed=signed;
|
this.signed=signed;
|
||||||
Collection<IEvent[]> values = entries.values();
|
Collection<EventEntry> ievents = entries.entrySet();
|
||||||
minVal=signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
minVal=signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||||
if(!values.isEmpty()) {
|
if(!ievents.isEmpty()) {
|
||||||
maxVal=minVal;
|
maxVal=minVal;
|
||||||
for (IEvent[] tp : entries.values())
|
for (EventEntry tp : ievents)
|
||||||
for(IEvent e: tp) {
|
for(IEvent e: tp.events) {
|
||||||
long v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
long v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
||||||
maxVal=Math.max(maxVal, v);
|
maxVal=Math.max(maxVal, v);
|
||||||
minVal=Math.min(minVal, v);
|
minVal=Math.min(minVal, v);
|
||||||
|
@ -358,15 +353,15 @@ public class SignalPainter extends TrackPainter {
|
||||||
|
|
||||||
boolean continous=true;
|
boolean continous=true;
|
||||||
|
|
||||||
public RealStencil(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous) {
|
public RealStencil(IEventList entries, Object left, boolean continous) {
|
||||||
this.continous=continous;
|
this.continous=continous;
|
||||||
Collection<IEvent[]> values = entries.values();
|
Collection<EventEntry> values = entries.entrySet();
|
||||||
minVal=(Double) left;
|
minVal=(Double) left;
|
||||||
range=2.0;
|
range=2.0;
|
||||||
if(!values.isEmpty()) {
|
if(!values.isEmpty()) {
|
||||||
double maxVal=minVal;
|
double maxVal=minVal;
|
||||||
for (IEvent[] val : entries.values())
|
for (EventEntry val : values)
|
||||||
for(IEvent e:val) {
|
for(IEvent e:val.events) {
|
||||||
double v = ((DoubleVal)e).value;
|
double v = ((DoubleVal)e).value;
|
||||||
if(Double.isNaN(maxVal))
|
if(Double.isNaN(maxVal))
|
||||||
maxVal=v;
|
maxVal=v;
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database.ui.swt.internal;
|
package com.minres.scviewer.database.ui.swt.internal;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
@ -19,8 +17,10 @@ import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.EventKind;
|
import com.minres.scviewer.database.EventKind;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
|
import com.minres.scviewer.database.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
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;
|
||||||
|
@ -36,6 +36,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
private IWaveform stream;
|
private IWaveform stream;
|
||||||
private int txBase;
|
private int txBase;
|
||||||
private int txHeight;
|
private int txHeight;
|
||||||
|
// TODO: remove TreeMap usage
|
||||||
private TreeMap<ITx, ITxEvent> seenTx;
|
private TreeMap<ITx, ITxEvent> seenTx;
|
||||||
|
|
||||||
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
|
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
|
||||||
|
@ -71,10 +72,11 @@ public class StreamPainter extends TrackPainter{
|
||||||
long beginTime = beginPos*scaleFactor;
|
long beginTime = beginPos*scaleFactor;
|
||||||
long endTime = beginTime + area.width*scaleFactor;
|
long endTime = beginTime + area.width*scaleFactor;
|
||||||
|
|
||||||
Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(beginTime);
|
IEventList events = stream.getEvents();
|
||||||
Entry<Long, IEvent[]> lastTx=stream.getEvents().ceilingEntry(endTime);
|
EventEntry firstTx = events.floorEntry(beginTime);
|
||||||
if(firstTx==null) firstTx = stream.getEvents().firstEntry();
|
EventEntry lastTx = events.ceilingEntry(endTime);
|
||||||
if(lastTx==null) lastTx=stream.getEvents().lastEntry();
|
if(firstTx==null) firstTx = events.firstEntry();
|
||||||
|
if(lastTx==null) lastTx = events.lastEntry();
|
||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.setLineStyle(SWT.LINE_SOLID);
|
proj.setLineStyle(SWT.LINE_SOLID);
|
||||||
proj.setLineWidth(1);
|
proj.setLineWidth(1);
|
||||||
|
@ -83,16 +85,15 @@ public class StreamPainter extends TrackPainter{
|
||||||
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
||||||
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
||||||
if(firstTx==lastTx) {
|
if(firstTx==lastTx) {
|
||||||
for(IEvent txEvent: firstTx.getValue())
|
for(IEvent txEvent: firstTx.events)
|
||||||
drawTx(proj, area, ((ITxEvent)txEvent).getTransaction(), ((ITxEvent)txEvent).getRowIndex(), false);
|
drawTx(proj, area, ((ITxEvent)txEvent).getTransaction(), ((ITxEvent)txEvent).getRowIndex(), false);
|
||||||
}else{
|
}else{
|
||||||
seenTx.clear();
|
seenTx.clear();
|
||||||
NavigableMap<Long, IEvent[]> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
|
||||||
ITxEvent highlighed=null;
|
ITxEvent highlighed=null;
|
||||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||||
long selectedId=waveCanvas.currentSelection!=null? waveCanvas.currentSelection.getId():-1;
|
long selectedId=waveCanvas.currentSelection!=null? waveCanvas.currentSelection.getId():-1;
|
||||||
for(Entry<Long, IEvent[]> entry: entries.entrySet())
|
for(EventEntry entry: events.subMap(firstTx.timestamp, true, lastTx.timestamp))
|
||||||
for(IEvent e:entry.getValue()){
|
for(IEvent e:entry.events){
|
||||||
ITxEvent evt = (ITxEvent) e;
|
ITxEvent evt = (ITxEvent) e;
|
||||||
ITx tx = evt.getTransaction();
|
ITx tx = evt.getTransaction();
|
||||||
if(selectedId==tx.getId())
|
if(selectedId==tx.getId())
|
||||||
|
@ -154,12 +155,12 @@ public class StreamPainter extends TrackPainter{
|
||||||
|
|
||||||
public ITx getClicked(Point point) {
|
public ITx getClicked(Point point) {
|
||||||
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
||||||
Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
EventEntry firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||||
if(firstTx!=null){
|
if(firstTx!=null){
|
||||||
do {
|
do {
|
||||||
ITx tx = getTxFromEntry(lane, point.x, firstTx);
|
ITx tx = getTxFromEntry(lane, point.x, firstTx.events);
|
||||||
if(tx!=null) return tx;
|
if(tx!=null) return tx;
|
||||||
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
|
firstTx=stream.getEvents().lowerEntry(firstTx.timestamp);
|
||||||
}while(firstTx!=null);
|
}while(firstTx!=null);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -173,11 +174,11 @@ public class StreamPainter extends TrackPainter{
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITx getTxFromEntry(int lane, int offset, Entry<Long, IEvent[]> firstTx) {
|
protected ITx getTxFromEntry(int lane, int offset, IEvent[] firstTx) {
|
||||||
long timePoint=offset*waveCanvas.getScaleFactor();
|
long timePoint=offset*waveCanvas.getScaleFactor();
|
||||||
long timePointLow=(offset-5)*waveCanvas.getScaleFactor();
|
long timePointLow=(offset-5)*waveCanvas.getScaleFactor();
|
||||||
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
||||||
for(IEvent e:firstTx.getValue()){
|
for(IEvent e:firstTx){
|
||||||
if(e instanceof ITxEvent) {
|
if(e instanceof ITxEvent) {
|
||||||
ITxEvent evt = (ITxEvent) e;
|
ITxEvent evt = (ITxEvent) e;
|
||||||
ITx tx=evt.getTransaction();
|
ITx tx=evt.getTransaction();
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
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.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
|
@ -427,8 +428,8 @@ public class WaveformCanvas extends Canvas {
|
||||||
}
|
}
|
||||||
for (IWaveformPainter painter : wave2painterMap.values()) {
|
for (IWaveformPainter painter : wave2painterMap.values()) {
|
||||||
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
|
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
|
||||||
Entry<Long, IEvent[]> entry = tx.getStream().getEvents().floorEntry(tx.getBeginTime());
|
EventEntry entry = tx.getStream().getEvents().floorEntry(tx.getBeginTime());
|
||||||
Optional<IEvent> res = Arrays.stream(entry.getValue()).filter(e -> ((ITxEvent)e).getTransaction().equals(tx)).findFirst();
|
Optional<IEvent> res = Arrays.stream(entry.events).filter(e -> ((ITxEvent)e).getTransaction().equals(tx)).findFirst();
|
||||||
if(res.isPresent()) {
|
if(res.isPresent()) {
|
||||||
int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * ((ITxEvent)res.get()).getRowIndex();
|
int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * ((ITxEvent)res.get()).getRowIndex();
|
||||||
int bottom = top + styleProvider.getTrackHeight();
|
int bottom = top + styleProvider.getTrackHeight();
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -77,8 +76,10 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.minres.scviewer.database.BitVector;
|
import com.minres.scviewer.database.BitVector;
|
||||||
import com.minres.scviewer.database.DoubleVal;
|
import com.minres.scviewer.database.DoubleVal;
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.EventKind;
|
import com.minres.scviewer.database.EventKind;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
|
import com.minres.scviewer.database.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
import com.minres.scviewer.database.WaveformType;
|
import com.minres.scviewer.database.WaveformType;
|
||||||
|
@ -255,29 +256,29 @@ public class WaveformView implements IWaveformView {
|
||||||
long time = waveformCanvas.getTimeForOffset(p.x);
|
long time = waveformCanvas.getTimeForOffset(p.x);
|
||||||
long scaling = 5 * waveformCanvas.getScaleFactor();
|
long scaling = 5 * waveformCanvas.getScaleFactor();
|
||||||
for (Object o : waveformCanvas.getElementsAt(p)) {
|
for (Object o : waveformCanvas.getElementsAt(p)) {
|
||||||
Entry<Long, IEvent[]> floorEntry = null;
|
EventEntry floorEntry = null;
|
||||||
Entry<Long, IEvent[]> ceilEntry = null;
|
EventEntry ceilEntry = null;
|
||||||
if (o instanceof TrackEntry) {
|
if (o instanceof TrackEntry) {
|
||||||
TrackEntry entry = (TrackEntry) o;
|
TrackEntry entry = (TrackEntry) o;
|
||||||
NavigableMap<Long, IEvent[]> map = entry.waveform.getEvents();
|
IEventList map = entry.waveform.getEvents();
|
||||||
floorEntry = map.floorEntry(time);
|
floorEntry = map.floorEntry(time);
|
||||||
ceilEntry = map.ceilingEntry(time);
|
ceilEntry = map.ceilingEntry(time);
|
||||||
} else if (o instanceof ITx) {
|
} else if (o instanceof ITx) {
|
||||||
NavigableMap<Long, IEvent[]> map = ((ITx) o).getStream().getEvents();
|
IEventList map = ((ITx) o).getStream().getEvents();
|
||||||
floorEntry = map.floorEntry(time);
|
floorEntry = map.floorEntry(time);
|
||||||
ceilEntry = map.ceilingEntry(time);
|
ceilEntry = map.ceilingEntry(time);
|
||||||
}
|
}
|
||||||
if (floorEntry != null && time - floorEntry.getKey() > scaling)
|
if (floorEntry != null && time - floorEntry.timestamp > scaling)
|
||||||
floorEntry = null;
|
floorEntry = null;
|
||||||
if (ceilEntry != null && ceilEntry.getKey() - time > scaling)
|
if (ceilEntry != null && ceilEntry.timestamp - time > scaling)
|
||||||
ceilEntry = null;
|
ceilEntry = null;
|
||||||
if (ceilEntry == null && floorEntry != null) {
|
if (ceilEntry == null && floorEntry != null) {
|
||||||
time = floorEntry.getKey();
|
time = floorEntry.timestamp;
|
||||||
} else if (ceilEntry != null && floorEntry == null) {
|
} else if (ceilEntry != null && floorEntry == null) {
|
||||||
time = ceilEntry.getKey();
|
time = ceilEntry.timestamp;
|
||||||
} else if (ceilEntry != null && floorEntry != null) {
|
} else if (ceilEntry != null && floorEntry != null) {
|
||||||
time = time - floorEntry.getKey() < ceilEntry.getKey() - time ? floorEntry.getKey()
|
time = time - floorEntry.timestamp < ceilEntry.timestamp - time ? floorEntry.timestamp
|
||||||
: ceilEntry.getKey();
|
: ceilEntry.timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return time;
|
return time;
|
||||||
|
@ -580,10 +581,10 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
} else if (entry.waveform.getType() == WaveformType.TRANSACTION) {
|
} else if (entry.waveform.getType() == WaveformType.TRANSACTION) {
|
||||||
ITx[] resultsList = new ITx[entry.waveform.getRowCount()];
|
ITx[] resultsList = new ITx[entry.waveform.getRowCount()];
|
||||||
Entry<Long, IEvent[]> firstTx = entry.waveform.getEvents().floorEntry(time);
|
EventEntry firstTx = entry.waveform.getEvents().floorEntry(time);
|
||||||
if (firstTx != null) {
|
if (firstTx != null) {
|
||||||
do {
|
do {
|
||||||
for (IEvent e : firstTx.getValue()) {
|
for (IEvent e : firstTx.events) {
|
||||||
if (e instanceof ITxEvent) {
|
if (e instanceof ITxEvent) {
|
||||||
ITxEvent evt = ((ITxEvent) e);
|
ITxEvent evt = ((ITxEvent) e);
|
||||||
ITx tx = evt.getTransaction();
|
ITx tx = evt.getTransaction();
|
||||||
|
@ -593,7 +594,7 @@ public class WaveformView implements IWaveformView {
|
||||||
resultsList[evt.getRowIndex()] = evt.getTransaction();
|
resultsList[evt.getRowIndex()] = evt.getTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
firstTx = entry.waveform.getEvents().lowerEntry(firstTx.getKey());
|
firstTx = entry.waveform.getEvents().lowerEntry(firstTx.timestamp);
|
||||||
} while (firstTx != null && !isArrayFull(resultsList));
|
} while (firstTx != null && !isArrayFull(resultsList));
|
||||||
boolean separator = false;
|
boolean separator = false;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -854,11 +855,11 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transaction == null) {
|
if (transaction == null) {
|
||||||
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents()
|
EventEntry entry = selectedWaveform.waveform.getEvents()
|
||||||
.higherEntry(currentTxSelection.getBeginTime());
|
.higherEntry(currentTxSelection.getBeginTime());
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
do {
|
do {
|
||||||
for (IEvent evt : entry.getValue()) {
|
for (IEvent evt : entry.events) {
|
||||||
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN
|
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN
|
||||||
|| evt.getKind() == EventKind.SINGLE)) {
|
|| evt.getKind() == EventKind.SINGLE)) {
|
||||||
transaction = ((ITxEvent) evt).getTransaction();
|
transaction = ((ITxEvent) evt).getTransaction();
|
||||||
|
@ -866,7 +867,7 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
entry = selectedWaveform.waveform.getEvents().higherEntry(entry.getKey());
|
entry = selectedWaveform.waveform.getEvents().higherEntry(entry.timestamp);
|
||||||
} while (entry != null && transaction == null);
|
} while (entry != null && transaction == null);
|
||||||
}
|
}
|
||||||
} else if (direction == GotoDirection.PREV) {
|
} else if (direction == GotoDirection.PREV) {
|
||||||
|
@ -883,11 +884,11 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transaction == null) {
|
if (transaction == null) {
|
||||||
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents()
|
EventEntry entry = selectedWaveform.waveform.getEvents()
|
||||||
.lowerEntry(currentTxSelection.getBeginTime());
|
.lowerEntry(currentTxSelection.getBeginTime());
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
do {
|
do {
|
||||||
for (IEvent evt : Lists.reverse(Arrays.asList(entry.getValue()))) {
|
for (IEvent evt : Lists.reverse(Arrays.asList(entry.events))) {
|
||||||
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN
|
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN
|
||||||
|| evt.getKind() == EventKind.SINGLE)) {
|
|| evt.getKind() == EventKind.SINGLE)) {
|
||||||
transaction = ((ITxEvent) evt).getTransaction();
|
transaction = ((ITxEvent) evt).getTransaction();
|
||||||
|
@ -895,7 +896,7 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
|
entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.timestamp);
|
||||||
} while (entry != null && transaction == null);
|
} while (entry != null && transaction == null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -958,14 +959,14 @@ public class WaveformView implements IWaveformView {
|
||||||
return;
|
return;
|
||||||
TrackEntry sel = currentWaveformSelection.get(0);
|
TrackEntry sel = currentWaveformSelection.get(0);
|
||||||
long time = getCursorTime();
|
long time = getCursorTime();
|
||||||
NavigableMap<Long, ?> map = null;
|
IEventList map = null;
|
||||||
if (sel.waveform.getType() == WaveformType.TRANSACTION || sel.waveform.getType() == WaveformType.SIGNAL) {
|
if (sel.waveform.getType() == WaveformType.TRANSACTION || sel.waveform.getType() == WaveformType.SIGNAL) {
|
||||||
map = sel.waveform.getEvents();
|
map = sel.waveform.getEvents();
|
||||||
}
|
}
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
Entry<Long, ?> entry = direction == GotoDirection.PREV ? map.lowerEntry(time) : map.higherEntry(time);
|
EventEntry entry = direction == GotoDirection.PREV ? map.lowerEntry(time) : map.higherEntry(time);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
time = entry.getKey();
|
time = entry.timestamp;
|
||||||
setCursorTime(time);
|
setCursorTime(time);
|
||||||
waveformCanvas.reveal(time);
|
waveformCanvas.reveal(time);
|
||||||
waveformCanvas.redraw();
|
waveformCanvas.redraw();
|
||||||
|
|
|
@ -20,15 +20,13 @@ import java.util.ArrayDeque;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.minres.scviewer.database.BitVector;
|
import com.minres.scviewer.database.BitVector;
|
||||||
import com.minres.scviewer.database.DoubleVal;
|
import com.minres.scviewer.database.DoubleVal;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.IWaveformDb;
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||||
|
@ -115,19 +113,20 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||||
moduleStack=null;
|
moduleStack=null;
|
||||||
throw new InputFormatException(e.toString());
|
throw new InputFormatException(e.toString());
|
||||||
}
|
}
|
||||||
if(!res) throw new InputFormatException("Could not parse VCD file");
|
if(!res)
|
||||||
|
throw new InputFormatException("Could not parse VCD file");
|
||||||
// calculate max time of this database
|
// calculate max time of this database
|
||||||
for(IWaveform waveform:signals) {
|
for(IWaveform waveform:signals) {
|
||||||
NavigableMap<Long, IEvent[]> events =waveform.getEvents();
|
IEventList events =waveform.getEvents();
|
||||||
if(!events.isEmpty())
|
if(!events.isEmpty())
|
||||||
maxTime= Math.max(maxTime, events.lastKey());
|
maxTime= Math.max(maxTime, events.lastKey());
|
||||||
}
|
}
|
||||||
// extend signals to have a last value set at max time
|
// extend signals to have a last value set at max time
|
||||||
for(IWaveform s:signals){
|
for(IWaveform s:signals){
|
||||||
if(s instanceof VCDSignal<?>) {
|
if(s instanceof VCDSignal<?>) {
|
||||||
TreeMap<Long,?> events = (TreeMap<Long, ?>) ((VCDSignal<?>)s).getEvents();
|
IEventList events = ((VCDSignal<?>)s).getEvents();
|
||||||
if(events.size()>0 && events.lastKey()<maxTime){
|
if(events.size()>0 && events.lastKey()<maxTime){
|
||||||
Object val = events.lastEntry().getValue();
|
Object val = events.lastEntry().events[0];
|
||||||
if(val instanceof BitVector) {
|
if(val instanceof BitVector) {
|
||||||
((VCDSignal<BitVector>)s).addSignalChange(maxTime, (BitVector) val);
|
((VCDSignal<BitVector>)s).addSignalChange(maxTime, (BitVector) val);
|
||||||
} else if(val instanceof DoubleVal)
|
} else if(val instanceof DoubleVal)
|
||||||
|
@ -147,7 +146,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||||
* @see com.minres.scviewer.database.ITrDb#getMaxTime()
|
* @see com.minres.scviewer.database.ITrDb#getMaxTime()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getMaxTime() {
|
public long getMaxTime() {
|
||||||
return maxTime;
|
return maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database.vcd;
|
package com.minres.scviewer.database.vcd;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import java.util.NavigableMap;
|
import com.minres.scviewer.database.EventList;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
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.IEventList;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.WaveformType;
|
import com.minres.scviewer.database.WaveformType;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private final int width;
|
private final int width;
|
||||||
|
|
||||||
private NavigableMap<Long, IEvent[]> values;
|
private IEventList values;
|
||||||
|
|
||||||
public VCDSignal(String name) {
|
public VCDSignal(String name) {
|
||||||
this(0, name, 1);
|
this(0, name, 1);
|
||||||
|
@ -42,7 +41,7 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
fullName=name;
|
fullName=name;
|
||||||
this.id=id;
|
this.id=id;
|
||||||
this.width=width;
|
this.width=width;
|
||||||
this.values=new TreeMap<>();
|
this.values=new EventList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VCDSignal(VCDSignal<T> o, int id, String name) {
|
public VCDSignal(VCDSignal<T> o, int id, String name) {
|
||||||
|
@ -63,44 +62,36 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSignalChange(Long time, T value){
|
public void addSignalChange(Long time, T value){
|
||||||
if(values.containsKey(time)) {
|
values.put(time, value);
|
||||||
IEvent[] oldV = values.get(time);
|
|
||||||
IEvent[] newV = new IEvent[oldV.length+1];
|
|
||||||
System.arraycopy(oldV, 0, newV, 0, oldV.length);
|
|
||||||
newV[oldV.length]=value;
|
|
||||||
values.put(time, newV);
|
|
||||||
} else {
|
|
||||||
values.put(time, new IEvent[] {value});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NavigableMap<Long, IEvent[]> getEvents() {
|
public IEventList getEvents() {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsAtTime(Long time) {
|
public IEvent[] getEventsAtTime(long time) {
|
||||||
return values.get(time);
|
return values.get(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsBeforeTime(Long time) {
|
public IEvent[] getEventsBeforeTime(long time) {
|
||||||
Entry<Long, IEvent[]> e = values.floorEntry(time);
|
EventEntry e = values.floorEntry(time);
|
||||||
if(e==null)
|
if(e==null)
|
||||||
return new IEvent[] {};
|
return new IEvent[] {};
|
||||||
else
|
else
|
||||||
return values.floorEntry(time).getValue();
|
return values.floorEntry(time).events;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId()));
|
return( other instanceof VCDSignal<?> && this.getId() == other.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.minres.scviewer.database;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class EventEntry implements Comparable<EventEntry>{
|
||||||
|
public long timestamp; // unsigned
|
||||||
|
public IEvent[] events = null;
|
||||||
|
|
||||||
|
|
||||||
|
public EventEntry(long timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public EventEntry(long timestamp, IEvent[] events) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.events = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(EventEntry o) {
|
||||||
|
return Long.compareUnsigned(timestamp, o.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("e.%d@%d", events.length,timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void append(IEvent value) {
|
||||||
|
if(events.length==0)
|
||||||
|
events = new IEvent[] {value};
|
||||||
|
else {
|
||||||
|
int idx = events.length;
|
||||||
|
events = Arrays.copyOf(events, idx+1);
|
||||||
|
events[idx]=value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,195 @@
|
||||||
|
package com.minres.scviewer.database;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class EventList implements IEventList {
|
||||||
|
|
||||||
|
ArrayList<EventEntry> store = new ArrayList<>();
|
||||||
|
int start = 0;
|
||||||
|
int end = store.size();
|
||||||
|
boolean unmodifiable = false;
|
||||||
|
|
||||||
|
public class Iterator implements java.util.Iterator<EventEntry> {
|
||||||
|
|
||||||
|
EventList list;
|
||||||
|
|
||||||
|
private int pos;
|
||||||
|
|
||||||
|
public Iterator(EventList list) {
|
||||||
|
this.list=list;
|
||||||
|
this.pos=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return pos<(list.end-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry next() {
|
||||||
|
if(hasNext()) {
|
||||||
|
pos++;
|
||||||
|
return list.store.get(pos);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
list.store.remove(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventList() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventList(ArrayList<EventEntry> store , int start, int end) {
|
||||||
|
this.store=store;
|
||||||
|
this.start=start;
|
||||||
|
this.end=end;
|
||||||
|
this.unmodifiable=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEventList subMap(long from, boolean includeFrom, long to) {
|
||||||
|
//the index of the first element greater than the key, or list.size()
|
||||||
|
int beginIndex = Collections.binarySearch(store, new EventEntry(from));
|
||||||
|
int startIndex = beginIndex < 0? -(beginIndex + 1): beginIndex;
|
||||||
|
int endIndex = Collections.binarySearch(store, new EventEntry(to));
|
||||||
|
endIndex = endIndex < 0? -(endIndex + 1): endIndex+1;
|
||||||
|
if(beginIndex>0 && !includeFrom)
|
||||||
|
return new EventList(store, startIndex+1, endIndex);
|
||||||
|
else
|
||||||
|
return new EventList(store, startIndex, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return end-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsKey(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
return index>=0 && index>=start && index<end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent[] get(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
if(index<0) return null;
|
||||||
|
return index>=start && index<end? store.get(index).events: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(long key, IEvent value) {
|
||||||
|
if(unmodifiable) throw new UnsupportedOperationException();
|
||||||
|
if(store.size()==0 || store.get(store.size()-1).timestamp < key) {
|
||||||
|
store.add(new EventEntry(key, new IEvent[] {value}));
|
||||||
|
} else {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
// < 0 if element is not in the list, see Collections.binarySearch
|
||||||
|
if (index < 0) {
|
||||||
|
EventEntry e = new EventEntry(key, new IEvent[] {value});
|
||||||
|
index = -(index + 1);
|
||||||
|
store.add(index, e);
|
||||||
|
} else {
|
||||||
|
// Insertion index is index of existing element, to add new element behind it increase index
|
||||||
|
store.get(index).append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end=store.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<EventEntry> entrySet() {
|
||||||
|
if(start != 0 || end != store.size())
|
||||||
|
return Collections.unmodifiableList(store.subList(start, end));
|
||||||
|
else
|
||||||
|
return Collections.unmodifiableList(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return start==end || store.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long firstKey() {
|
||||||
|
return store.get(start).timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long lastKey() {
|
||||||
|
return store.get(end-1).timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigable map functions
|
||||||
|
@Override
|
||||||
|
public EventEntry firstEntry() {
|
||||||
|
return store.get(start);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry lastEntry() {
|
||||||
|
return store.get(end-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry floorEntry(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
if(index==-1) return null;
|
||||||
|
// < 0 if element is not in the list, see Collections.binarySearch
|
||||||
|
if (index < 0) {
|
||||||
|
index = -(index + 2);
|
||||||
|
}
|
||||||
|
if(index>=end)
|
||||||
|
return store.get(end-1);
|
||||||
|
return index<start? null: store.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry ceilingEntry(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
// < 0 if element is not in the list, see Collections.binarySearch
|
||||||
|
if (index < 0)
|
||||||
|
index = -(index + 1);
|
||||||
|
if(index<start)
|
||||||
|
return store.get(start);
|
||||||
|
return index>=end? null: store.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry lowerEntry(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
// < 0 if element is not in the list, see Collections.binarySearch
|
||||||
|
if (index < 0)
|
||||||
|
index = -(index + 1);
|
||||||
|
index--;
|
||||||
|
if(index>=end)
|
||||||
|
return store.get(end-1);
|
||||||
|
return index>=end || index<start ?null:store.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventEntry higherEntry(long key) {
|
||||||
|
int index = Collections.binarySearch(store, new EventEntry(key));
|
||||||
|
// < 0 if element is not in the list, see Collections.binarySearch
|
||||||
|
if (index < 0)
|
||||||
|
index = -(index + 1);
|
||||||
|
else
|
||||||
|
index++;
|
||||||
|
if(index<start)
|
||||||
|
return store.get(start);
|
||||||
|
return index>=end || index<start ?null:store.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.util.Iterator<EventEntry> iterator() {
|
||||||
|
return new Iterator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.minres.scviewer.database;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface IEventList extends Iterable<EventEntry> {
|
||||||
|
|
||||||
|
int size();
|
||||||
|
|
||||||
|
Collection<EventEntry> entrySet();
|
||||||
|
|
||||||
|
boolean containsKey(long key);
|
||||||
|
|
||||||
|
IEvent[] get(long key);
|
||||||
|
|
||||||
|
void put(long key, IEvent value);
|
||||||
|
|
||||||
|
long firstKey();
|
||||||
|
|
||||||
|
long lastKey();
|
||||||
|
|
||||||
|
boolean isEmpty();
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the greatest key less
|
||||||
|
* than or equal to the given key, or null if there is no such key.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry floorEntry(long key);
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the least key greater
|
||||||
|
* than or equal to the given key, or null if there is no such key.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry ceilingEntry(long key);
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the least key in this map,
|
||||||
|
* or null if the map is empty.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry firstEntry();
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the least key in this map,
|
||||||
|
* or null if the map is empty.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry lastEntry();
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the least key strictly greater
|
||||||
|
* than the given key, or null if there is no such key.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry higherEntry(long key);
|
||||||
|
/**
|
||||||
|
* Returns a key-value mapping associated with the greatest key strictly less
|
||||||
|
* than the given key, or null if there is no such key.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EventEntry lowerEntry(long key);
|
||||||
|
/**
|
||||||
|
* Returns a view of the portion of this map whose keys range from
|
||||||
|
* {@code fromKey} to {@code toKey}. If {@code fromKey} and
|
||||||
|
* {@code toKey} are equal, the returned map is empty unless
|
||||||
|
* {@code fromInclusive} is true. The
|
||||||
|
* returned map is backed by this map, so changes in the returned map are
|
||||||
|
* reflected in this map, and vice-versa. The returned map supports all
|
||||||
|
* optional map operations that this map supports.
|
||||||
|
*
|
||||||
|
* @param fromKey low endpoint of the keys in the returned map
|
||||||
|
* @param fromInclusive {@code true} if the low endpoint
|
||||||
|
* is to be included in the returned view
|
||||||
|
* @param toKey high endpoint of the keys in the returned map (inclusive)
|
||||||
|
*/
|
||||||
|
IEventList subMap(long key, boolean b, long key2);
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database;
|
package com.minres.scviewer.database;
|
||||||
|
|
||||||
import java.util.NavigableMap;
|
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +24,7 @@ public interface IWaveform extends IHierNode {
|
||||||
*
|
*
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public Long getId();
|
public long getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is same.
|
* Checks if is same.
|
||||||
|
@ -40,7 +39,7 @@ public interface IWaveform extends IHierNode {
|
||||||
*
|
*
|
||||||
* @return the events
|
* @return the events
|
||||||
*/
|
*/
|
||||||
public NavigableMap<Long, IEvent[]> getEvents();
|
public IEventList getEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the events at time.
|
* Gets the events at time.
|
||||||
|
@ -48,7 +47,7 @@ public interface IWaveform extends IHierNode {
|
||||||
* @param time the time
|
* @param time the time
|
||||||
* @return the events at time
|
* @return the events at time
|
||||||
*/
|
*/
|
||||||
public IEvent[] getEventsAtTime(Long time);
|
public IEvent[] getEventsAtTime(long time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the events before time.
|
* Gets the events before time.
|
||||||
|
@ -56,7 +55,7 @@ public interface IWaveform extends IHierNode {
|
||||||
* @param time the time
|
* @param time the time
|
||||||
* @return the events before time
|
* @return the events before time
|
||||||
*/
|
*/
|
||||||
public IEvent[] getEventsBeforeTime(Long time);
|
public IEvent[] getEventsBeforeTime(long time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type.
|
* Gets the type.
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface IWaveformDb extends IHierNode {
|
||||||
*
|
*
|
||||||
* @return the max time
|
* @return the max time
|
||||||
*/
|
*/
|
||||||
public Long getMaxTime();
|
public long getMaxTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the stream by name.
|
* Gets the stream by name.
|
||||||
|
|
|
@ -69,7 +69,7 @@ public interface IWaveformDbLoader {
|
||||||
*
|
*
|
||||||
* @return the max time
|
* @return the max time
|
||||||
*/
|
*/
|
||||||
public Long getMaxTime();
|
public long getMaxTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the all waves.
|
* Gets the all waves.
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
|
||||||
private Map<String, IWaveform> waveforms;
|
private Map<String, IWaveform> waveforms;
|
||||||
|
|
||||||
/** The max time. */
|
/** The max time. */
|
||||||
private Long maxTime;
|
private long maxTime = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind.
|
* Bind.
|
||||||
|
@ -90,7 +90,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
|
||||||
* @return the max time
|
* @return the max time
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long getMaxTime() {
|
public long getMaxTime() {
|
||||||
return maxTime;
|
return maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public interface ITx extends Comparable<ITx> {
|
||||||
*
|
*
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public Long getId();
|
public long getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the stream.
|
* Gets the stream.
|
||||||
|
@ -46,14 +46,14 @@ public interface ITx extends Comparable<ITx> {
|
||||||
*
|
*
|
||||||
* @return the begin time
|
* @return the begin time
|
||||||
*/
|
*/
|
||||||
public Long getBeginTime();
|
public long getBeginTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the end time.
|
* Gets the end time.
|
||||||
*
|
*
|
||||||
* @return the end time
|
* @return the end time
|
||||||
*/
|
*/
|
||||||
public Long getEndTime();
|
public long getEndTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the attributes.
|
* Gets the attributes.
|
||||||
|
|
|
@ -22,7 +22,7 @@ public interface ITxEvent extends IEvent {
|
||||||
*
|
*
|
||||||
* @return the time
|
* @return the time
|
||||||
*/
|
*/
|
||||||
public Long getTime();
|
public long getTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the transaction.
|
* Gets the transaction.
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class WaveformPopupMenuContribution {
|
||||||
if(elem instanceof TrackEntry) {
|
if(elem instanceof TrackEntry) {
|
||||||
TrackEntry e = (TrackEntry) elem;
|
TrackEntry e = (TrackEntry) elem;
|
||||||
if(e.waveform.getType() == WaveformType.SIGNAL) {
|
if(e.waveform.getType() == WaveformType.SIGNAL) {
|
||||||
Object o = e.waveform.getEvents().firstEntry().getValue()[0];
|
Object o = e.waveform.getEvents().firstEntry().events[0];
|
||||||
if(checkForDouble && o instanceof DoubleVal)
|
if(checkForDouble && o instanceof DoubleVal)
|
||||||
return true;
|
return true;
|
||||||
else if(o instanceof BitVector && ((BitVector)o).getWidth()>1)
|
else if(o instanceof BitVector && ((BitVector)o).getWidth()>1)
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.eclipse.swt.widgets.TableColumn;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import com.minres.scviewer.database.DataType;
|
import com.minres.scviewer.database.DataType;
|
||||||
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.EventKind;
|
import com.minres.scviewer.database.EventKind;
|
||||||
import com.minres.scviewer.database.IEvent;
|
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
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;
|
||||||
|
@ -249,8 +249,10 @@ public class TransactionList extends Composite {
|
||||||
}catch(SecurityException e){}
|
}catch(SecurityException e){}
|
||||||
updateThread = new Thread(()-> {
|
updateThread = new Thread(()-> {
|
||||||
final ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<>();
|
final ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<>();
|
||||||
Collection<IEvent[]> values = stream.getEvents().values();
|
Collection<EventEntry> values = stream.getEvents().entrySet();
|
||||||
final List<ITx> txList = values.parallelStream().map(Arrays::asList)
|
final List<ITx> txList = values.parallelStream()
|
||||||
|
.map(e->e.events)
|
||||||
|
.map(Arrays::asList)
|
||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
.filter(evt -> evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)
|
.filter(evt -> evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)
|
||||||
.map(evt-> {
|
.map(evt-> {
|
||||||
|
@ -258,7 +260,7 @@ public class TransactionList extends Composite {
|
||||||
tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType()));
|
tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType()));
|
||||||
return tx;
|
return tx;
|
||||||
})
|
})
|
||||||
.sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime()))
|
.sorted((t1, t2)-> Long.compare(t1.getBeginTime(),t2.getBeginTime()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream()
|
final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream()
|
||||||
.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))
|
.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))
|
||||||
|
|
|
@ -815,9 +815,18 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
String trackentryName = state.get(SELECTED_TRACKENTRY_NAME);
|
String trackentryName = state.get(SELECTED_TRACKENTRY_NAME);
|
||||||
//get TrackEntry Object based on name and TX Object by id and put into selectionList
|
//get TrackEntry Object based on name and TX Object by id and put into selectionList
|
||||||
trackEntries.stream().filter(e->trackentryName.equals(e.waveform.getFullName())).forEach(trackEntry ->
|
trackEntries.stream().filter(e->trackentryName.equals(e.waveform.getFullName())).forEach(trackEntry ->
|
||||||
trackEntry.waveform.getEvents().values().stream().filter(Objects::nonNull).forEach(entries->
|
trackEntry.waveform.getEvents().entrySet().stream()
|
||||||
Arrays.stream(entries).filter(e->e instanceof ITxEvent && txId.equals(((ITxEvent)e).getTransaction().getId())).forEach(event ->
|
.map(e->e.events)
|
||||||
waveformPane.setSelection(new StructuredSelection(new Object[] {((ITxEvent)event).getTransaction(), trackEntry})))));
|
.filter(Objects::nonNull)
|
||||||
|
.forEach(entries->
|
||||||
|
Arrays.stream(entries)
|
||||||
|
.filter(e->e instanceof ITxEvent && txId.equals(((ITxEvent)e).getTransaction().getId()))
|
||||||
|
.forEach(event ->
|
||||||
|
waveformPane.setSelection(new StructuredSelection(
|
||||||
|
new Object[] {((ITxEvent)event).getTransaction(), trackEntry}))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class AttributeLabelProvider extends LabelProvider implements IStyledLabe
|
||||||
ITx iTx = (ITx) element;
|
ITx iTx = (ITx) element;
|
||||||
switch(field){
|
switch(field){
|
||||||
case NAME:
|
case NAME:
|
||||||
return new StyledString(iTx.getId().toString());
|
return new StyledString(String.format("%d", iTx.getId()));
|
||||||
case TX_TIME:
|
case TX_TIME:
|
||||||
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
|
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
|
||||||
case TYPE:
|
case TYPE:
|
||||||
|
|
|
@ -182,9 +182,9 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||||
else if (columnIndex == 2 && element instanceof ITxRelation){
|
else if (columnIndex == 2 && element instanceof ITxRelation){
|
||||||
ITxRelation rel = (ITxRelation) element;
|
ITxRelation rel = (ITxRelation) element;
|
||||||
if(rel.getTarget()==iTr)
|
if(rel.getTarget()==iTr)
|
||||||
return ((ITxRelation) element).getSource().getId().toString();
|
return String.format("%d", ((ITxRelation) element).getSource().getId());
|
||||||
else
|
else
|
||||||
return ((ITxRelation) element).getTarget().getId().toString();
|
return String.format("%d", ((ITxRelation) element).getTarget().getId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -51,17 +51,13 @@
|
||||||
<feature id="com.minres.scviewer.e4.platform.feature" installMode="root"/>
|
<feature id="com.minres.scviewer.e4.platform.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.equinox.p2.core.feature" installMode="root"/>
|
<feature id="org.eclipse.equinox.p2.core.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.emf.ecore" installMode="root"/>
|
<feature id="org.eclipse.emf.ecore" installMode="root"/>
|
||||||
<feature id="org.eclipse.rcptt.core" installMode="root"/>
|
|
||||||
<feature id="org.eclipse.emf.common" installMode="root"/>
|
<feature id="org.eclipse.emf.common" installMode="root"/>
|
||||||
<feature id="org.eclipse.ecf.core.feature" installMode="root"/>
|
<feature id="org.eclipse.ecf.core.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.ecf.filetransfer.httpclient45.feature" installMode="root"/>
|
<feature id="org.eclipse.ecf.filetransfer.httpclient45.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.rcptt.ecl.core" installMode="root"/>
|
|
||||||
<feature id="org.eclipse.ecf.filetransfer.feature" installMode="root"/>
|
<feature id="org.eclipse.ecf.filetransfer.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.rcptt.tesla" installMode="root"/>
|
|
||||||
<feature id="org.eclipse.ecf.core.ssl.feature" installMode="root"/>
|
<feature id="org.eclipse.ecf.core.ssl.feature" installMode="root"/>
|
||||||
<feature id="com.minres.scviewer.ui.feature" installMode="root"/>
|
<feature id="com.minres.scviewer.ui.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.ecf.filetransfer.ssl.feature" installMode="root"/>
|
<feature id="org.eclipse.ecf.filetransfer.ssl.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.rcptt.tesla.ecl" installMode="root"/>
|
|
||||||
<feature id="org.eclipse.equinox.executable" installMode="root"/>
|
<feature id="org.eclipse.equinox.executable" installMode="root"/>
|
||||||
<feature id="com.minres.scviewer.database.feature" installMode="root"/>
|
<feature id="com.minres.scviewer.database.feature" installMode="root"/>
|
||||||
<feature id="org.eclipse.e4.rcp" installMode="root"/>
|
<feature id="org.eclipse.e4.rcp" installMode="root"/>
|
||||||
|
|
|
@ -16,13 +16,12 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.EventEntry;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.IWaveformDb;
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
|
||||||
|
@ -50,11 +49,11 @@ public class DatabaseServicesTest {
|
||||||
assertEquals(14, waves.size());
|
assertEquals(14, waves.size());
|
||||||
assertEquals(2, waveformDb.getChildNodes().size());
|
assertEquals(2, waveformDb.getChildNodes().size());
|
||||||
IWaveform bus_data_wave = waves.get(0);
|
IWaveform bus_data_wave = waves.get(0);
|
||||||
Entry<Long, IEvent[]> bus_data_entry = bus_data_wave.getEvents().floorEntry(1400000000L);
|
EventEntry bus_data_entry = bus_data_wave.getEvents().floorEntry(1400000000L);
|
||||||
assertEquals("01111000", bus_data_entry.getValue()[0].toString());
|
assertEquals("01111000", bus_data_entry.events[0].toString());
|
||||||
IWaveform rw_wave = waves.get(2);
|
IWaveform rw_wave = waves.get(2);
|
||||||
Entry<Long, IEvent[]> rw_entry = rw_wave.getEvents().floorEntry(2360000000L);
|
EventEntry rw_entry = rw_wave.getEvents().floorEntry(2360000000L);
|
||||||
assertEquals("1", rw_entry.getValue()[0].toString());
|
assertEquals("1", rw_entry.events[0].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -77,11 +76,11 @@ public class DatabaseServicesTest {
|
||||||
assertEquals(3, waveforms.size());
|
assertEquals(3, waveforms.size());
|
||||||
assertEquals(1, waveformDb.getChildNodes().size());
|
assertEquals(1, waveformDb.getChildNodes().size());
|
||||||
for(IWaveform w:waveforms) {
|
for(IWaveform w:waveforms) {
|
||||||
if(w.getId().equals(1l)) {
|
if(w.getId()==1) {
|
||||||
assertEquals(2, w.getRowCount());
|
assertEquals(2, w.getRowCount());
|
||||||
} else if(w.getId().equals(2l)) {
|
} else if(w.getId()==2l) {
|
||||||
assertEquals(1, w.getRowCount());
|
assertEquals(1, w.getRowCount());
|
||||||
} else if(w.getId().equals(3l)) {
|
} else if(w.getId()==3l) {
|
||||||
assertEquals(1, w.getRowCount());
|
assertEquals(1, w.getRowCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
package com.minres.scviewer.database.test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.EventList;
|
||||||
|
import com.minres.scviewer.database.IEventList;
|
||||||
|
|
||||||
|
public class EventListTest {
|
||||||
|
|
||||||
|
EventList createList(int[] times) {
|
||||||
|
EventList list = new EventList();
|
||||||
|
for(int time: times)
|
||||||
|
list.put(time, null);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long[] getTimestamps(IEventList list) {
|
||||||
|
return list.entrySet().stream().map(e->e.timestamp).collect(Collectors.toList()).toArray(new Long[] {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsertion() throws Exception {
|
||||||
|
IEventList list = createList(new int[] {5, 7, 3, 6, 2, 0});
|
||||||
|
assertEquals(6, list.size());
|
||||||
|
assertArrayEquals(new Long[]{0L, 2L, 3L, 5L, 6L, 7L}, getTimestamps(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSublist() throws Exception {
|
||||||
|
IEventList list = createList(new int[] {5, 7, 3, 8, 2, 0});
|
||||||
|
{
|
||||||
|
IEventList subList = list.subMap(3, true, 5);
|
||||||
|
assertEquals(2, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{3L, 5L}, getTimestamps(subList));
|
||||||
|
} {
|
||||||
|
IEventList subList = list.subMap(3, false, 5);
|
||||||
|
assertEquals(1, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{5L}, getTimestamps(subList));
|
||||||
|
} {
|
||||||
|
IEventList subList = list.subMap(4, true, 6);
|
||||||
|
assertEquals(1, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{5L}, getTimestamps(subList));
|
||||||
|
} {
|
||||||
|
IEventList subList = list.subMap(4, false, 6);
|
||||||
|
assertEquals(1, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{5L}, getTimestamps(subList));
|
||||||
|
} {
|
||||||
|
IEventList subList = list.subMap(4, true, 9);
|
||||||
|
assertEquals(3, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{5L, 7L, 8L}, getTimestamps(subList));
|
||||||
|
} {
|
||||||
|
IEventList subList = list.subMap(4, false, 9);
|
||||||
|
assertEquals(3, subList.size());
|
||||||
|
assertArrayEquals(new Long[]{5L, 7L, 8L}, getTimestamps(subList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEntries() throws Exception {
|
||||||
|
IEventList list = createList(new int[] {2, 5, 8, 11});
|
||||||
|
assertEquals(2, list.firstEntry().timestamp);
|
||||||
|
assertEquals(11, list.lastEntry().timestamp);
|
||||||
|
|
||||||
|
assertNull(list.floorEntry(1));
|
||||||
|
assertEquals(2, list.floorEntry(2).timestamp);
|
||||||
|
assertEquals(2, list.floorEntry(3).timestamp);
|
||||||
|
assertEquals(2, list.floorEntry(4).timestamp);
|
||||||
|
assertEquals(5, list.floorEntry(5).timestamp);
|
||||||
|
assertEquals(5, list.floorEntry(6).timestamp);
|
||||||
|
assertEquals(8, list.floorEntry(10).timestamp);
|
||||||
|
assertEquals(11, list.floorEntry(11).timestamp);
|
||||||
|
assertEquals(11, list.floorEntry(12).timestamp);
|
||||||
|
|
||||||
|
assertEquals(2, list.ceilingEntry(1).timestamp);
|
||||||
|
assertEquals(2, list.ceilingEntry(2).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(3).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(4).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(5).timestamp);
|
||||||
|
assertEquals(8, list.ceilingEntry(6).timestamp);
|
||||||
|
assertEquals(11, list.ceilingEntry(10).timestamp);
|
||||||
|
assertEquals(11, list.ceilingEntry(11).timestamp);
|
||||||
|
assertNull(list.ceilingEntry(12));
|
||||||
|
|
||||||
|
assertNull(list.lowerEntry(1));
|
||||||
|
assertNull(list.lowerEntry(2));
|
||||||
|
assertEquals(2, list.lowerEntry(3).timestamp);
|
||||||
|
assertEquals(2, list.lowerEntry(4).timestamp);
|
||||||
|
assertEquals(2, list.lowerEntry(5).timestamp);
|
||||||
|
assertEquals(5, list.lowerEntry(6).timestamp);
|
||||||
|
assertEquals(8, list.lowerEntry(10).timestamp);
|
||||||
|
assertEquals(8, list.lowerEntry(11).timestamp);
|
||||||
|
assertEquals(11, list.lowerEntry(12).timestamp);
|
||||||
|
|
||||||
|
assertEquals(2, list.higherEntry(1).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(2).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(3).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(4).timestamp);
|
||||||
|
assertEquals(8, list.higherEntry(5).timestamp);
|
||||||
|
assertEquals(8, list.higherEntry(6).timestamp);
|
||||||
|
assertEquals(11, list.higherEntry(10).timestamp);
|
||||||
|
assertNull(list.higherEntry(11));
|
||||||
|
assertNull(list.higherEntry(12));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubListEntries() throws Exception {
|
||||||
|
IEventList fullList = createList(new int[] {2, 5, 8, 11});
|
||||||
|
IEventList list = fullList.subMap(5, true, 8);
|
||||||
|
|
||||||
|
assertEquals(5, list.firstEntry().timestamp);
|
||||||
|
assertEquals(8, list.lastEntry().timestamp);
|
||||||
|
|
||||||
|
assertNull(list.floorEntry(1));
|
||||||
|
assertNull(list.floorEntry(2));
|
||||||
|
assertNull(list.floorEntry(3));
|
||||||
|
assertNull(list.floorEntry(4));
|
||||||
|
assertEquals(5, list.floorEntry(5).timestamp);
|
||||||
|
assertEquals(5, list.floorEntry(6).timestamp);
|
||||||
|
assertEquals(8, list.floorEntry(10).timestamp);
|
||||||
|
assertEquals(8, list.floorEntry(11).timestamp);
|
||||||
|
assertEquals(8, list.floorEntry(12).timestamp);
|
||||||
|
|
||||||
|
assertEquals(5, list.ceilingEntry(1).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(2).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(3).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(4).timestamp);
|
||||||
|
assertEquals(5, list.ceilingEntry(5).timestamp);
|
||||||
|
assertEquals(8, list.ceilingEntry(6).timestamp);
|
||||||
|
assertEquals(8, list.ceilingEntry(8).timestamp);
|
||||||
|
assertNull(list.ceilingEntry(10));
|
||||||
|
assertNull(list.ceilingEntry(11));
|
||||||
|
assertNull(list.ceilingEntry(12));
|
||||||
|
|
||||||
|
assertNull(list.lowerEntry(1));
|
||||||
|
assertNull(list.lowerEntry(2));
|
||||||
|
assertNull(list.lowerEntry(3));
|
||||||
|
assertNull(list.lowerEntry(4));
|
||||||
|
assertNull(list.lowerEntry(5));
|
||||||
|
assertEquals(5, list.lowerEntry(6).timestamp);
|
||||||
|
assertEquals(8, list.lowerEntry(10).timestamp);
|
||||||
|
assertEquals(8, list.lowerEntry(11).timestamp);
|
||||||
|
assertEquals(8, list.lowerEntry(12).timestamp);
|
||||||
|
|
||||||
|
assertEquals(5, list.higherEntry(1).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(2).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(3).timestamp);
|
||||||
|
assertEquals(5, list.higherEntry(4).timestamp);
|
||||||
|
assertEquals(8, list.higherEntry(5).timestamp);
|
||||||
|
assertEquals(8, list.higherEntry(6).timestamp);
|
||||||
|
assertNull(list.higherEntry(8));
|
||||||
|
assertNull(list.higherEntry(10));
|
||||||
|
assertNull(list.higherEntry(11));
|
||||||
|
assertNull(list.higherEntry(12));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInterface() throws Exception {
|
||||||
|
EventList emptyList = new EventList();
|
||||||
|
IEventList populatedList = createList(new int[] {0, 2, 3, 5, 6, 7});
|
||||||
|
assertEquals(0, emptyList.size());
|
||||||
|
assertEquals(6, populatedList.size());
|
||||||
|
assertTrue(emptyList.isEmpty());
|
||||||
|
assertFalse(populatedList.isEmpty());
|
||||||
|
assertFalse(emptyList.containsKey(5));
|
||||||
|
assertTrue(populatedList.containsKey(5));
|
||||||
|
assertFalse(populatedList.containsKey(8));
|
||||||
|
assertNull(emptyList.get(5));
|
||||||
|
assertNotNull(populatedList.get(5));
|
||||||
|
assertNull(populatedList.get(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInterfaceSublist() throws Exception {
|
||||||
|
IEventList fullList = createList(new int[] {0, 2, 3, 5, 6, 7});
|
||||||
|
IEventList emptyList = fullList.subMap(3, false, 4);
|
||||||
|
IEventList populatedList = fullList.subMap(2, true, 6);
|
||||||
|
assertEquals(0, emptyList.size());
|
||||||
|
assertEquals(4, populatedList.size());
|
||||||
|
assertTrue(emptyList.isEmpty());
|
||||||
|
assertFalse(populatedList.isEmpty());
|
||||||
|
assertFalse(emptyList.containsKey(5));
|
||||||
|
assertTrue(populatedList.containsKey(5));
|
||||||
|
assertFalse(populatedList.containsKey(8));
|
||||||
|
assertNull(emptyList.get(5));
|
||||||
|
assertNotNull(populatedList.get(5));
|
||||||
|
assertNull(populatedList.get(7));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue