fixes FTR reading and makes it more robust
This commit is contained in:
parent
07062d5618
commit
d95683a146
|
@ -182,8 +182,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rowCount=rowEndTime.size()>0?rowEndTime.size():1;
|
rowCount=rowEndTime.size()>0?rowEndTime.size():1;
|
||||||
//getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
|
getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
|
||||||
getChildNodes().stream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
* @param txId the tx id
|
* @param txId the tx id
|
||||||
* @return the transaction
|
* @return the transaction
|
||||||
*/
|
*/
|
||||||
public ITx getTransaction(long txId) {
|
public synchronized ITx getTransaction(long txId) {
|
||||||
if (txCache.containsKey(txId))
|
if (txCache.containsKey(txId))
|
||||||
return txCache.get(txId);
|
return txCache.get(txId);
|
||||||
if(transactions.containsKey(txId)) {
|
if(transactions.containsKey(txId)) {
|
||||||
|
@ -185,8 +185,10 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
this.file=file;
|
this.file=file;
|
||||||
try(FileInputStream fis = new FileInputStream(file)) {
|
try(FileInputStream fis = new FileInputStream(file)) {
|
||||||
new CborDbParser(this, fis);
|
new CborDbParser(this, fis);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.warn("Problem parsing file "+file.getName()+": " , e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error parsing file "+file.getName(), e);
|
LOG.error("Error parsing file "+file.getName()+ ": ", e);
|
||||||
transactions.clear();
|
transactions.clear();
|
||||||
throw new InputFormatException(e.toString());
|
throw new InputFormatException(e.toString());
|
||||||
}
|
}
|
||||||
|
@ -242,17 +244,15 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
long name_id = cborDecoder.readInt();
|
long name_id = cborDecoder.readInt();
|
||||||
long type_id = cborDecoder.readInt();
|
long type_id = cborDecoder.readInt();
|
||||||
String attrName = strDict.get((int)name_id);
|
String attrName = strDict.get((int)name_id);
|
||||||
if(!attributeTypes.containsKey(attrName)) {
|
TxAttributeType attrType = getOrAddAttributeType(tag, type_id, attrName);
|
||||||
attributeTypes.put(attrName, new TxAttributeType(attrName, DataType.values()[(int)type_id], AssociationType.values()[(int)tag-7]));
|
|
||||||
}
|
|
||||||
TxAttributeType attrType = attributeTypes.get(attrName);
|
|
||||||
switch((int)type_id) {
|
switch((int)type_id) {
|
||||||
case 0: // BOOLEAN
|
case 0: // BOOLEAN
|
||||||
ITxAttribute b = new TxAttribute(attrType, cborDecoder.readInt()>0?"True":"False");
|
ITxAttribute b = new TxAttribute(attrType, cborDecoder.readBoolean()?"True":"False");
|
||||||
ret.add(b);
|
ret.add(b);
|
||||||
break;
|
break;
|
||||||
case 2: // INTEGER
|
case 2: // INTEGER
|
||||||
case 3: // UNSIGNED
|
case 3: // UNSIGNED
|
||||||
|
case 10: // POINTER
|
||||||
ITxAttribute a = new TxAttribute(attrType, String.valueOf(cborDecoder.readInt()));
|
ITxAttribute a = new TxAttribute(attrType, String.valueOf(cborDecoder.readInt()));
|
||||||
ret.add(a);
|
ret.add(a);
|
||||||
break;
|
break;
|
||||||
|
@ -269,6 +269,8 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
ITxAttribute s = new TxAttribute(attrType, strDict.get((int)cborDecoder.readInt()));
|
ITxAttribute s = new TxAttribute(attrType, strDict.get((int)cborDecoder.readInt()));
|
||||||
ret.add(s);
|
ret.add(s);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
LOG.warn("Unsupported data type: "+type_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,6 +281,14 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized TxAttributeType getOrAddAttributeType(long tag, long type_id, String attrName) {
|
||||||
|
if(!attributeTypes.containsKey(attrName)) {
|
||||||
|
attributeTypes.put(attrName, new TxAttributeType(attrName, DataType.values()[(int)type_id], AssociationType.values()[(int)tag-7]));
|
||||||
|
}
|
||||||
|
TxAttributeType attrType = attributeTypes.get(attrName);
|
||||||
|
return attrType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose.
|
* Dispose.
|
||||||
*/
|
*/
|
||||||
|
@ -318,6 +328,7 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
long array_len = readArrayLength();
|
long array_len = readArrayLength();
|
||||||
assert(array_len==-1);
|
assert(array_len==-1);
|
||||||
CborType next = peekType();
|
CborType next = peekType();
|
||||||
|
int chunk_idx=0;
|
||||||
while(next != null && !break_type.isEqualType(next)) {
|
while(next != null && !break_type.isEqualType(next)) {
|
||||||
long tag = readTag();
|
long tag = readTag();
|
||||||
switch((int)tag) {
|
switch((int)tag) {
|
||||||
|
@ -389,9 +400,12 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next = peekType();
|
next = peekType();
|
||||||
|
chunk_idx++;
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
LOG.error("Error parsing file input stream", e);
|
long pos = 0;
|
||||||
|
try {pos=inputStream.getChannel().position(); } catch (Exception ee) {}
|
||||||
|
LOG.error("Error parsing file input stream at position" + pos, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,6 +451,7 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
long gen_id = cborDecoder.readInt();
|
long gen_id = cborDecoder.readInt();
|
||||||
long name_id = cborDecoder.readInt();
|
long name_id = cborDecoder.readInt();
|
||||||
long stream_id = cborDecoder.readInt();
|
long stream_id = cborDecoder.readInt();
|
||||||
|
if(loader.txStreams.containsKey(stream_id))
|
||||||
add(gen_id, new TxGenerator(loader, gen_id, loader.strDict.get((int)name_id), loader.txStreams.get(stream_id)));
|
add(gen_id, new TxGenerator(loader, gen_id, loader.strDict.get((int)name_id), loader.txStreams.get(stream_id)));
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Illegal tage ncountered: "+id);
|
throw new IOException("Illegal tage ncountered: "+id);
|
||||||
|
@ -451,14 +466,17 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
while(next != null && !break_type.isEqualType(next)) {
|
while(next != null && !break_type.isEqualType(next)) {
|
||||||
long blockOffset = cborDecoder.getPos();
|
long blockOffset = cborDecoder.getPos();
|
||||||
long tx_size = cborDecoder.readArrayLength();
|
long tx_size = cborDecoder.readArrayLength();
|
||||||
|
long txId = 0;
|
||||||
|
long genId = 0;
|
||||||
|
long attr_idx=0;
|
||||||
for(long i = 0; i<tx_size; ++i) {
|
for(long i = 0; i<tx_size; ++i) {
|
||||||
long tag = cborDecoder.readTag();
|
long tag = cborDecoder.readTag();
|
||||||
switch((int)tag) {
|
switch((int)tag) {
|
||||||
case 6: // id/generator/start/end
|
case 6: // id/generator/start/end
|
||||||
long len = cborDecoder.readArrayLength();
|
long len = cborDecoder.readArrayLength();
|
||||||
assert(len==4);
|
assert(len==4);
|
||||||
long txId = cborDecoder.readInt();
|
txId = cborDecoder.readInt();
|
||||||
long genId = cborDecoder.readInt();
|
genId = cborDecoder.readInt();
|
||||||
long startTime = cborDecoder.readInt()*loader.time_scale_factor;
|
long startTime = cborDecoder.readInt()*loader.time_scale_factor;
|
||||||
long endTime = cborDecoder.readInt()*loader.time_scale_factor;
|
long endTime = cborDecoder.readInt()*loader.time_scale_factor;
|
||||||
TxGenerator gen = loader.txGenerators.get(genId);
|
TxGenerator gen = loader.txGenerators.get(genId);
|
||||||
|
@ -479,9 +497,23 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
||||||
default: { // skip over 7:begin attr, 8:record attr, 9:end attr
|
default: { // skip over 7:begin attr, 8:record attr, 9:end attr
|
||||||
long sz = cborDecoder.readArrayLength();
|
long sz = cborDecoder.readArrayLength();
|
||||||
assert(sz==3);
|
assert(sz==3);
|
||||||
for(long j = 0; j<sz; ++j)
|
long name_id = cborDecoder.readInt();
|
||||||
|
String name = loader.strDict.get((int)name_id);
|
||||||
|
long type_id = cborDecoder.readInt();
|
||||||
|
switch((int)type_id) {
|
||||||
|
case 0: // BOOLEAN
|
||||||
|
cborDecoder.readBoolean();
|
||||||
|
break;
|
||||||
|
case 4: // FLOATING_POINT_NUMBER
|
||||||
|
case 7: // FIXED_POINT_INTEGER
|
||||||
|
case 8: // UNSIGNED_FIXED_POINT_INTEGER
|
||||||
|
cborDecoder.readFloat();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
cborDecoder.readInt();
|
cborDecoder.readInt();
|
||||||
}
|
}
|
||||||
|
attr_idx++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next = cborDecoder.peekType();
|
next = cborDecoder.peekType();
|
||||||
|
|
|
@ -435,9 +435,10 @@ public class CborDecoder {
|
||||||
} else if (breakAllowed && length == BREAK) {
|
} else if (breakAllowed && length == BREAK) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (result < 0) {
|
// unsigned values larger than long.MAX are shown as negative values
|
||||||
fail("Not well-formed CBOR integer found, invalid length: %d!", result);
|
// if (result < 0) {
|
||||||
}
|
// fail("Not well-formed CBOR integer found, invalid length: %d!", result);
|
||||||
|
// }
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue