4949public class FtrDbLoader implements IWaveformDbLoader {
5050
5151 enum FileType { NONE , PLAIN , GZIP , LZ4 };
52-
52+
5353 /** The max time. */
5454 private Long maxTime = 0L ;
5555
@@ -243,29 +243,31 @@ public List<? extends ITxAttribute> parseAtrributes(byte[] chunk, long blockOffs
243243 assert (sz ==3 );
244244 long name_id = cborDecoder .readInt ();
245245 long type_id = cborDecoder .readInt ();
246+ DataType type = DataType .values ()[(int )type_id ];
246247 String attrName = strDict .get ((int )name_id );
247- TxAttributeType attrType = getOrAddAttributeType (tag , type_id , attrName );
248- switch (( int ) type_id ) {
249- case 0 : // BOOLEAN
248+ TxAttributeType attrType = getOrAddAttributeType (tag , type , attrName );
249+ switch (type ) {
250+ case BOOLEAN :
250251 ITxAttribute b = new TxAttribute (attrType , cborDecoder .readBoolean ()?"True" :"False" );
251252 ret .add (b );
252253 break ;
253- case 2 : // INTEGER
254- case 3 : // UNSIGNED
255- case 10 : // POINTER
254+ case INTEGER :
255+ case UNSIGNED :
256+ case POINTER :
257+ case TIME :
256258 ITxAttribute a = new TxAttribute (attrType , String .valueOf (cborDecoder .readInt ()));
257259 ret .add (a );
258260 break ;
259- case 4 : // FLOATING_POINT_NUMBER
260- case 7 : // FIXED_POINT_INTEGER
261- case 8 : // UNSIGNED_FIXED_POINT_INTEGER
261+ case FLOATING_POINT_NUMBER :
262+ case FIXED_POINT_INTEGER :
263+ case UNSIGNED_FIXED_POINT_INTEGER :
262264 ITxAttribute v = new TxAttribute (attrType , String .valueOf (cborDecoder .readFloat ()));
263265 ret .add (v );
264266 break ;
265- case 1 : // ENUMERATION
266- case 5 : // BIT_VECTOR
267- case 6 : // LOGIC_VECTOR
268- case 12 : // STRING
267+ case ENUMERATION :
268+ case BIT_VECTOR :
269+ case LOGIC_VECTOR :
270+ case STRING :
269271 ITxAttribute s = new TxAttribute (attrType , strDict .get ((int )cborDecoder .readInt ()));
270272 ret .add (s );
271273 break ;
@@ -281,9 +283,9 @@ public List<? extends ITxAttribute> parseAtrributes(byte[] chunk, long blockOffs
281283 return ret ;
282284 }
283285
284- private synchronized TxAttributeType getOrAddAttributeType (long tag , long type_id , String attrName ) {
286+ private synchronized TxAttributeType getOrAddAttributeType (long tag , DataType type , String attrName ) {
285287 if (!attributeTypes .containsKey (attrName )) {
286- attributeTypes .put (attrName , new TxAttributeType (attrName , DataType . values ()[( int ) type_id ] , AssociationType .values ()[(int )tag -7 ]));
288+ attributeTypes .put (attrName , new TxAttributeType (attrName , type , AssociationType .values ()[(int )tag -7 ]));
287289 }
288290 TxAttributeType attrType = attributeTypes .get (attrName );
289291 return attrType ;
@@ -328,7 +330,6 @@ public CborDbParser(FtrDbLoader loader, FileInputStream inputStream) {
328330 long array_len = readArrayLength ();
329331 assert (array_len ==-1 );
330332 CborType next = peekType ();
331- int chunk_idx =0 ;
332333 while (next != null && !break_type .isEqualType (next )) {
333334 long tag = readTag ();
334335 switch ((int )tag ) {
@@ -404,7 +405,6 @@ public CborDbParser(FtrDbLoader loader, FileInputStream inputStream) {
404405 }
405406 }
406407 next = peekType ();
407- chunk_idx ++;
408408 }
409409 } catch (IOException e ) {
410410 long pos = 0 ;
@@ -472,7 +472,6 @@ private void parseTx(TxStream txStream, long blockId, byte[] chunk) throws IOExc
472472 long tx_size = cborDecoder .readArrayLength ();
473473 long txId = 0 ;
474474 long genId = 0 ;
475- long attr_idx =0 ;
476475 for (long i = 0 ; i <tx_size ; ++i ) {
477476 long tag = cborDecoder .readTag ();
478477 switch ((int )tag ) {
@@ -501,22 +500,23 @@ private void parseTx(TxStream txStream, long blockId, byte[] chunk) throws IOExc
501500 default : { // skip over 7:begin attr, 8:record attr, 9:end attr
502501 long sz = cborDecoder .readArrayLength ();
503502 assert (sz ==3 );
504- long name_id = cborDecoder .readInt ();
505- String name = loader .strDict .get ((int )name_id );
503+ cborDecoder .readInt ();
506504 long type_id = cborDecoder .readInt ();
507- switch (( int )type_id ) {
508- case 0 : // BOOLEAN
505+ switch (DataType . values ()[( int )type_id ] ) {
506+ case BOOLEAN :
509507 cborDecoder .readBoolean ();
510508 break ;
511- case 4 : // FLOATING_POINT_NUMBER
512- case 7 : // FIXED_POINT_INTEGER
513- case 8 : // UNSIGNED_FIXED_POINT_INTEGER
509+ case FLOATING_POINT_NUMBER : // FLOATING_POINT_NUMBER
510+ case FIXED_POINT_INTEGER : // FIXED_POINT_INTEGER
511+ case UNSIGNED_FIXED_POINT_INTEGER : // UNSIGNED_FIXED_POINT_INTEGER
514512 cborDecoder .readFloat ();
515513 break ;
514+ case NONE : // UNSIGNED_FIXED_POINT_INTEGER
515+ LOG .warn ("Unsupported data type: " +type_id );
516+ break ;
516517 default :
517518 cborDecoder .readInt ();
518519 }
519- attr_idx ++;
520520 }
521521 }
522522 }
0 commit comments