TangCheng
2025-02-28 d787e447e95c7b897c2cc9c0e832f8d2e5084934
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
package com.smtaiserver.smtaiserver.javaai.ast;
 
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
 
import org.apache.ibatis.ognl.Ognl;
 
import java.util.Map.Entry;
import java.util.Set;
import com.smtaiserver.smtaiserver.core.SMTAIServerApp;
import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecords;
import com.smtaiserver.smtaiserver.javaai.SMTJavaAIError;
import com.smtaiserver.smtaiserver.javaai.ast.ASTCubeRecs.ASTCubeRecsType;
import com.smtaiserver.smtaiserver.javaai.metrics.base.SMTDimensionDef;
import com.smtservlet.util.SMTStatic;
import com.smtservlet.util.SMTStatic.SMTCalcTime;
 
public class ASTCubeRecsValue 
{
    private enum GROUP_OP
    {
        MIN,
        MAX,
        AVG,
        SUM,
        COUNT
    }
    
    private enum GROUP_UNIT
    {
        NONE,
        MINUTE,
        MONTH,
    }
    
    private enum DIFF_OP
    {
        ADD,
        SUB,
        YOY
    }
    
    private static class TimeGroupInfo
    {
        public GROUP_OP                    _op;
        public GROUP_UNIT                _unit;
        public int                        _step;
    }
 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public String                            _countField;
    public String                            _groupField;
    public char                             _groupType;
    public String                            _chartType = null;
    public DBRecords                        _recsValue;
    public String                            _title;
    public ASTTimeRange                        _timeRange = null;
    
    private static Date                        _baseTime = SMTStatic.toDate("1980-01-01");
    
    public ASTCubeRecsValue cloneCubeRecsValue()
    {
        ASTCubeRecsValue newRecsValue = new ASTCubeRecsValue();
        
        newRecsValue._countField = this._countField;
        newRecsValue._groupField = this._groupField;
        newRecsValue._groupType = this._groupType;
        newRecsValue._chartType = this._chartType;
        newRecsValue._title = this._title;
        if(_timeRange != null)
            newRecsValue._timeRange = _timeRange.cloneTimeRange();
        
        newRecsValue._recsValue = new DBRecords();
        newRecsValue._recsValue.initColumn(this._recsValue.getFieldMap());
        for(DBRecord rec : _recsValue.getRecords())
        {
            newRecsValue._recsValue.addRecord(rec.getValues());
        }
        
        return newRecsValue;
    }
 
    public void distinctRecTime() throws Exception
    {
        if(_timeRange == null)
            return;
        
        List<DBRecord> recs = _recsValue.getRecords();
        
        Set<Date> setExistTime = new HashSet<>();
        for(int recIndex = recs.size() - 1; recIndex >= 0; recIndex --)
        {
            Date curTime = recs.get(recIndex).getDate(_timeRange._timeField);
            if(setExistTime.contains(curTime))
            {
                recs.remove(recIndex);
                continue;
            }
            else
            {
                setExistTime.add(curTime);
            }
        }
    }
    
    
    public void limitRecords(int limit)
    {
        _recsValue.limitRecord(limit);
    }
    
    private Object convGroupTypeValue(char groupType, Object value) throws Exception
    {
        if(value == null)
            return null;
        switch(groupType)
        {
        case 'D':
            return SMTStatic.toDouble(value);
        case 'S':
            return SMTStatic.toString(value);
        case 'L':
            return SMTStatic.toLong(value);
        case 'I':
            return SMTStatic.toInt(value);
        case 'T':
            return SMTStatic.toDate(value);
            
        default:
            throw new Exception("can't convert to type : " + groupType);
        }
    }
    
    private int compGroupTypeValue(char groupType, Object v1, Object v2) throws Exception
    {
        switch(groupType)
        {
        case 'I':
            return Integer.compare(SMTStatic.toInt(v1), SMTStatic.toInt(v2));
        case 'L':
            return Long.compare(SMTStatic.toLong(v1), SMTStatic.toLong(v2));
        case 'D':
            return Double.compare(SMTStatic.toDouble(v1), SMTStatic.toDouble(v2));
        case 'S':
            return ((String)v1).compareTo((String)v2);
        case 'T':
            return ((Date)v1).compareTo((Date)v2);
            
        default:
            throw new Exception("can't convert to type : " + groupType);
        }        
    }
 
    private Date alignGroupTime(TimeGroupInfo timeGroupInfo, Date time)
    {
        if(timeGroupInfo._unit == GROUP_UNIT.NONE)
            return _baseTime;
        else if(timeGroupInfo._unit == GROUP_UNIT.MINUTE)
        {
            long minutes = (time.getTime() - _baseTime.getTime()) / 1000 / 60;
            return new Date(_baseTime.getTime() + (minutes / timeGroupInfo._step) * timeGroupInfo._step * 1000 * 60); 
        }
        else if(timeGroupInfo._unit == GROUP_UNIT.MONTH)
        {
            int subMonths = ((time.getYear() + 1900) * 12 + time.getMonth()) % timeGroupInfo._step;
            return SMTStatic.calculateTime(time, SMTCalcTime.ZERO_TIME, 0, SMTCalcTime.SET_DATE, 1, SMTCalcTime.ADD_MONTH, - subMonths);
        }
        
        return null;
    }
    
    public SMTJavaAIError groupEvalValueRecords(ASTEvalColInfo evalColInfo, String sGroupOP, String sGroupStep, ASTCubeRecsType[] r_isSummary, String[][] r_colNames) throws Exception
    {
        if(_recsValue == null)
            return null;
        
        if(!SMTStatic.isNullOrEmpty(sGroupStep) && SMTStatic.isNullOrEmpty(_timeRange._timeField))
            return new SMTJavaAIError("未指定时间字段无法聚合");
        
        TimeGroupInfo timeGroupInfo = new TimeGroupInfo();
        
        if(SMTStatic.isNullOrEmpty(sGroupStep))
        {
            timeGroupInfo._unit = GROUP_UNIT.NONE;
            if(r_isSummary[0] != ASTCubeRecsType.RECORD)
                r_isSummary[0] = ASTCubeRecsType.SUMMARY;
            if(r_colNames != null && r_colNames[0] != null)
                r_colNames[0] = new String[] {"值"};
        }
        else
        {
            int[] aTimeStep = SMTAIServerApp.convStrToTimeStep(sGroupStep);
            if(aTimeStep == null)
                return new SMTJavaAIError("无法辨认分组步长:" + sGroupStep);
            
            timeGroupInfo._unit = aTimeStep[0] == 0 ? GROUP_UNIT.MINUTE : GROUP_UNIT.MONTH;
            timeGroupInfo._step = aTimeStep[1];
            
            if(SMTStatic.isNullOrEmpty(this._chartType) && (aTimeStep[0] == 1 || aTimeStep[1] >= 24 * 60))
            {
                this._chartType = "bar";
            }
            
            if(r_colNames != null && r_colNames[0] != null)
                r_colNames[0] = new String[] {"时间", "值"};
 
        }
        
        TreeMap<Date, Map<String, Object>> mapTime2Recs = new TreeMap<>();
        SMTJavaAIError errors[] = new SMTJavaAIError[1];
        DBRecords[] recsGroups = new DBRecords[1];
        
        if(_timeRange == null)
        {
            throw new Exception("_timeRange can't null");
        }
        else
        {
            for(DBRecord rec : _recsValue.getRecords())
            {
                // 初始化字段名
                if(recsGroups[0] == null)
                {
                    recsGroups[0] = new DBRecords();
                    
                    if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                        recsGroups[0].initColumn(new String[] {_groupField});
                    else
                        recsGroups[0].initColumn(new String[] {_timeRange._timeField, _groupField});
                }
                
                // 对齐时间
                Date time = alignGroupTime(timeGroupInfo, rec.getDate(_timeRange._timeField));
                
                for(SMTDimensionDef dimDef : evalColInfo._setDimDef)
                {
                    char valueType = dimDef.getType();
                    
                    // 获取原始值,忽略空值
                    Object curValue = convGroupTypeValue(valueType, rec.getValue(dimDef.getId()));
                    
                    Map<String, Object> orgValueMap = mapTime2Recs.get(time);
                    if(orgValueMap == null)
                    {
                        orgValueMap = new HashMap<>();
                        mapTime2Recs.put(time, orgValueMap);
                    }
                    
                    Object orgValue;
                    
                    // 进行统计计算
                    orgValue = orgValueMap.get("min$" + dimDef.getId());
                    if(orgValue == null || compGroupTypeValue(valueType, orgValue, curValue) > 0)
                        orgValueMap.put("min$" + dimDef.getId(), SMTStatic.toDouble(curValue));
                        
                    orgValue = orgValueMap.get("max$" + dimDef.getId());
                    if(orgValue == null || compGroupTypeValue(valueType, orgValue, curValue) < 0)
                        orgValueMap.put("max$" + dimDef.getId(), SMTStatic.toDouble(curValue));
                        
                    orgValue = orgValueMap.get("count$" + dimDef.getId());
                    if(orgValue == null)
                    {
                        orgValueMap.put("count$" + dimDef.getId(), 1);
                    }
                    else
                    {
                        orgValueMap.put("count$" + dimDef.getId(), SMTStatic.toInt(orgValue) + 1);
                    }
                    
                    orgValue = orgValueMap.get("sum$" + dimDef.getId());
                    if(orgValue == null)
                        orgValue = (double)0;
                    orgValueMap.put("sum$" + dimDef.getId(), SMTStatic.toDouble(orgValue) + SMTStatic.toDouble(curValue));
 
                }
            }
                
    
            if(errors[0] != null)
                return errors[0];
            
            // 汇总成记录
            for(Entry<Date, Map<String, Object>> entry : mapTime2Recs.entrySet())
            {
                Object[] values = new Object[2];
                values[0] = entry.getKey();
                values[1] = Ognl.getValue(evalColInfo._evalBin, entry.getValue());
            
                if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                    recsGroups[0].addRecord(new Object[] {values[1]});
                else
                    recsGroups[0].addRecord(values);
            }
            
            // 输出结果
            if(recsGroups[0] == null)
            {
                recsGroups[0] = new DBRecords();
                
                if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                    recsGroups[0].initColumn(new String[] {_groupField});
                else
                    recsGroups[0].initColumn(new String[] {_timeRange._timeField,  _groupField});
                
                recsGroups[0].addRecord(new Object[] {0});
 
            }
            
            _recsValue = recsGroups[0];
        }
        
        return null;
    }
 
    public SMTJavaAIError groupValueRecords(String sGroupOP, String sGroupStep, ASTCubeRecsType[] r_isSummary, String[][] r_colNames) throws Exception
    {
        if(_recsValue == null)
            return null;
        
        if(!SMTStatic.isNullOrEmpty(sGroupStep) && SMTStatic.isNullOrEmpty(_timeRange._timeField))
            return new SMTJavaAIError("未指定时间字段无法聚合");
        
        TimeGroupInfo timeGroupInfo = new TimeGroupInfo();
        
        boolean noGroupField = SMTStatic.isNullOrEmpty(_groupField);
        
        String sGroupTitle;
        if("MAX".equalsIgnoreCase(sGroupOP))
        {
            timeGroupInfo._op = GROUP_OP.MAX;
            sGroupTitle = "最大值";
        }
        else if("MIN".equalsIgnoreCase(sGroupOP))
        {
            timeGroupInfo._op = GROUP_OP.MIN;
            sGroupTitle = "最小值";
        }
        else if("AVG".equalsIgnoreCase(sGroupOP))
        {
            timeGroupInfo._op = GROUP_OP.AVG;
            sGroupTitle = "平均值";
        }
        else if("SUM".equalsIgnoreCase(sGroupOP))
        {
            timeGroupInfo._op = GROUP_OP.SUM;
            sGroupTitle = "累计值";
        }
        else if("COUNT".equalsIgnoreCase(sGroupOP))
        {
            timeGroupInfo._op = GROUP_OP.COUNT;
            sGroupTitle = "个数";
        }
        else
            return new SMTJavaAIError("无法辨认分组操作符:" + sGroupOP);
        
        if(timeGroupInfo._op != GROUP_OP.COUNT && SMTStatic.isNullOrEmpty(_groupField))
            return new SMTJavaAIError("未指定值字段无法统计");
        
        
        if(SMTStatic.isNullOrEmpty(sGroupStep))
        {
            timeGroupInfo._unit = GROUP_UNIT.NONE;
            if(r_isSummary[0] != ASTCubeRecsType.RECORD)
                r_isSummary[0] = ASTCubeRecsType.SUMMARY;
            if(r_colNames != null && r_colNames[0] != null)
                r_colNames[0] = new String[] {sGroupTitle};
        }
        else
        {
            int[] aTimeStep = SMTAIServerApp.convStrToTimeStep(sGroupStep);
            if(aTimeStep == null)
                return new SMTJavaAIError("无法辨认分组步长:" + sGroupStep);
            
            timeGroupInfo._unit = aTimeStep[0] == 0 ? GROUP_UNIT.MINUTE : GROUP_UNIT.MONTH;
            timeGroupInfo._step = aTimeStep[1];
            
            if(SMTStatic.isNullOrEmpty(this._chartType) && (aTimeStep[0] == 1 || aTimeStep[1] >= 24 * 60))
            {
                this._chartType = "bar";
            }
            
            if(r_colNames != null && r_colNames[0] != null)
                r_colNames[0] = new String[] {"时间", sGroupTitle};
 
        }
        
        TreeMap<Date, Object> mapTime2Recs = new TreeMap<>();
        TreeMap<Date, Integer> mapTime2Count = new TreeMap<>();
        SMTJavaAIError errors[] = new SMTJavaAIError[1];
        DBRecords[] recsGroups = new DBRecords[1];
        
        if(_timeRange == null)
        {
            DBRecords recsValue = new DBRecords();
            if(noGroupField)
                _groupField = "CNT";
            recsValue.initColumn(new String[] {_groupField});
            recsValue.addRecord(new Object[] {_recsValue.getRowCount()});
            _recsValue = recsValue;
        }
        else
        {
            for(DBRecord rec : _recsValue.getRecords())
            {
                // 初始化字段名
                if(recsGroups[0] == null)
                {
                    recsGroups[0] = new DBRecords();
                    
                    if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                        recsGroups[0].initColumn(new String[] {noGroupField ? "CNT" :  _groupField});
                    else
                        recsGroups[0].initColumn(new String[] {_timeRange._timeField, noGroupField ? "CNT" :  _groupField});
                }
                
                // 获取原始值,忽略空值
                Object curValue = noGroupField ? 0 : convGroupTypeValue(_groupType, rec.getValue(_groupField));
                if(curValue == null)
                    continue;
                
                // 对齐时间
                Date time = alignGroupTime(timeGroupInfo, rec.getDate(_timeRange._timeField));
                Object orgValue = mapTime2Recs.get(time);
                
                // 进行统计计算
                switch(timeGroupInfo._op)
                {
                case MIN:
                    if(orgValue == null || compGroupTypeValue(_groupType, orgValue, curValue) > 0)
                        mapTime2Recs.put(time, curValue);
                    break;
                    
                case MAX:
                    if(orgValue == null || compGroupTypeValue(_groupType, orgValue, curValue) < 0)
                        mapTime2Recs.put(time, curValue);
                    break;    
                    
                case SUM:
                case AVG:
                case COUNT:
                    if(orgValue == null)
                    {
                        if(!noGroupField)
                            mapTime2Recs.put(time, curValue);
                        else
                            mapTime2Recs.put(time, 0);
                        mapTime2Count.put(time, 1);
                    }
                    else 
                    {
                        mapTime2Count.put(time, mapTime2Count.get(time) + 1);
                        
                        if(!noGroupField)
                        {
                            switch(_groupType)
                            {
                            case 'I':
                                mapTime2Recs.put(time, (int)orgValue + (int)curValue);
                                break;
                            case 'L':
                                mapTime2Recs.put(time, (long)orgValue + (long)curValue);
                                break;
                            case 'D':
                                mapTime2Recs.put(time, (double)orgValue + (double)curValue);
                                break;
                            }
                        }
                    }
                    break;
                    
                }
            }
                
    
            if(errors[0] != null)
                return errors[0];
            
            // 汇总成记录
            for(Entry<Date, Object> entry : mapTime2Recs.entrySet())
            {
                Object[] values = new Object[2];
                values[0] = entry.getKey();
                
                switch(timeGroupInfo._op)
                {
                case MIN:
                case MAX:
                case SUM:
                    values[1] = entry.getValue();
                    break;
                    
                case AVG:
                    {
                        int count = mapTime2Count.get(entry.getKey());
                        switch(_groupType)
                        {
                        case 'I':
                            values[1] = (int)((int)entry.getValue() / count);
                            break;
                        case 'L':
                            values[1] = (long)((long)entry.getValue() / count);
                            break;
                        case 'D':
                            values[1] = (double)((double)entry.getValue() / count);
                            break;
                        }
                    }
                    break;
                    
                case COUNT:
                    values[1] = mapTime2Count.get(entry.getKey());
                    break;
                    
                default:
                    break;
                }
                
                if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                    recsGroups[0].addRecord(new Object[] {values[1]});
                else
                    recsGroups[0].addRecord(values);
                    
            }
            
            if(recsGroups[0] == null)
            {
                recsGroups[0] = new DBRecords();
                
                if(r_isSummary[0] == ASTCubeRecsType.RECORD && timeGroupInfo._unit == GROUP_UNIT.NONE)
                    recsGroups[0].initColumn(new String[] {noGroupField ? "CNT" :  _groupField});
                else
                    recsGroups[0].initColumn(new String[] {_timeRange._timeField, noGroupField ? "CNT" :  _groupField});
                
                recsGroups[0].addRecord(new Object[] {0});
 
            }
            
            _recsValue = recsGroups[0];
        }
        
        return null;
 
    }
    
    public SMTJavaAIError diffValueRecords(String strDiffOP, ASTCubeRecsValue tagASTRecsValue) throws Exception
    {
        DIFF_OP diffOP;
        if("ADD".equals(strDiffOP))
            diffOP = DIFF_OP.ADD;
        else if("SUB".equals(strDiffOP))
            diffOP = DIFF_OP.SUB;
        else if("YOY".equals(strDiffOP))
            diffOP = DIFF_OP.YOY;
        else if("MOM".equals(strDiffOP))
            diffOP = DIFF_OP.YOY;
        else
            throw new Exception("未支持的差分:" + strDiffOP);
        
        if(_timeRange._startTime == null || tagASTRecsValue._timeRange._startTime == null)
            return new SMTJavaAIError("无延时数据可对比");
        
        if(SMTStatic.isNullOrEmpty(_groupField) || SMTStatic.isNullOrEmpty(tagASTRecsValue._groupField))
            return new SMTJavaAIError("无延时字段可对比");
        
        _timeRange.copyToTimeRange2(tagASTRecsValue._timeRange);
        
        // 计算时间偏差
        long subTime = tagASTRecsValue._timeRange._startTime.getTime() - this._timeRange._startTime.getTime();
        
        // 将目标延时数据转换成映射表
        HashMap<Date, Object> mapTime2Value = new HashMap<>();
        for(DBRecord recTag : tagASTRecsValue._recsValue.getRecords())
        {
            mapTime2Value.put(
                new Date(recTag.getDate(tagASTRecsValue._timeRange._timeField).getTime() - subTime), 
                recTag.getValue(tagASTRecsValue._groupField)
                );
        }
        
        // 创建新的结果集
        DBRecords recsDiff = new DBRecords();
        recsDiff.initColumn(new String[] {this._timeRange._timeField, this._groupField});
        
        // 扫描源表记录
        for(DBRecord recSrc : this._recsValue.getRecords())
        {
            Date   time = recSrc.getDate(this._timeRange._timeField);
            Object srcValue= recSrc.getValue(this._groupField);
            if(srcValue == null)
                continue;
            
            Object tagValue = mapTime2Value.get(time);
            if(tagValue == null)
                continue;
            
            Object diffValue = null;
            switch(diffOP)
            {
            case ADD:
                switch(_groupType)
                {
                case 'I':
                    diffValue = (int)srcValue + (int)tagValue;
                    break;
                case 'L':
                    diffValue = (long)srcValue + (long)tagValue;
                    break;
                case 'D':
                    diffValue = (double)srcValue + (double)tagValue;
                    break;
                }
                break;
                
            case SUB:
                switch(_groupType)
                {
                case 'I':
                    diffValue = (int)srcValue - (int)tagValue;
                    break;
                case 'L':
                    diffValue = (long)srcValue - (long)tagValue;
                    break;
                case 'D':
                    diffValue = (double)srcValue - (double)tagValue;
                    break;
                }
                break;
                
            case YOY:
                switch(_groupType)
                {
                case 'I':
                    diffValue = (((int)tagValue == 0) ? 0 : (double)((int)srcValue - (int)tagValue) / (int)tagValue);
                    break;
                case 'L':
                    diffValue = (((long)tagValue == 0) ? 0 : (double)((long)srcValue - (long)tagValue) / (long)tagValue);
                    break;
                case 'D':
                    diffValue = (((double)tagValue == 0) ? 0 : ((double)srcValue - (double)tagValue) / (double)tagValue);
                    break;
                }
                break;                
            }
            
            recsDiff.addRecord(new Object[] {time, diffValue});
        }
        
        this._recsValue = recsDiff;
        
        return null;
    }
}