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
package com.smtaiserver.smtaiserver.javaai.duckdb;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
 
import com.smtaiserver.smtaiserver.javaai.ast.ASTDimFilter;
import com.smtaiserver.smtaiserver.javaai.ast.ASTTimeRange;
import com.smtaiserver.smtaiserver.javaai.metrics.base.SMTDuckTimeGroupName;
 
 
public class DuckCubeRecs
{
    public enum DuckCubeRecsType
    {
        VALUE,
        SUMMARY,
        RECORD
    }
    
    public static class DuckCubeColTitle
    {
        public String                    _title;
        public boolean                    _isGroup;
        public boolean                    _isCount;
        
        public DuckCubeColTitle(String title, boolean isGroup, boolean isCount)
        {
            _title = title;
            _isGroup = isGroup;
            _isCount = isCount;
        }
    }
    
    public boolean                             _isRawRS = false;
    public DuckCubeRecsType                    _recsType = DuckCubeRecsType.VALUE;
    public String                            _title;
    public String                            _chartUnit;
    public String                            _chartTitle;
    public String                            _posXName;
    public String                            _posYName;
    public String                            _devKeyName;
    public Map<String, DuckCubeColTitle>    _mapCol2Title = new HashMap<>();
    public int                                _colKeyCount = 0;
    public List<String>                        _dimNames = new ArrayList<>();
    public List<ASTDimFilter>                _listDimFilter = null;
    public String                            _chartType = null;
    public ASTTimeRange                        _timeRange = null;
    public String                            _tableName;
    public String[]                            _orderCol;
    public List<SMTDuckTimeGroupName>        _listGroupNameInfo;
 
    
    public DuckCubeRecs cloneCubeRecs()
    {
        DuckCubeRecs newCubeRecs = new DuckCubeRecs();
        newCubeRecs._recsType = this._recsType;
        newCubeRecs._title = this._title;
        newCubeRecs._posXName = _posXName;
        newCubeRecs._posYName = _posYName;
        newCubeRecs._devKeyName = _devKeyName;
        newCubeRecs._colKeyCount = _colKeyCount;
        newCubeRecs._isRawRS = _isRawRS;
        newCubeRecs._chartType = this._chartType;
        newCubeRecs._title = this._title;
        newCubeRecs._chartTitle = this._chartTitle;
        newCubeRecs._chartUnit = this._chartUnit;
        newCubeRecs._orderCol = this._orderCol;
        newCubeRecs._listGroupNameInfo = _listGroupNameInfo;
 
        if(_timeRange != null)
            newCubeRecs._timeRange = _timeRange.cloneTimeRange();
        
        for(String dimName : _dimNames)
        {
            newCubeRecs._dimNames.add(dimName);
        }
        
        for(Entry<String, DuckCubeColTitle> entry : _mapCol2Title.entrySet())
        {
            newCubeRecs._mapCol2Title.put(entry.getKey(), entry.getValue());
        }
        
        return newCubeRecs;
    }
    
    public boolean isSameStartTime(Date checkTime, Date[] r_curTime)
    {
        Date curTime = _timeRange._startTime;
        
        if(r_curTime != null)
            r_curTime[0] = curTime;
        
        if(checkTime == null || curTime == null)
        {
            return (checkTime == null && curTime == null);
        }
        else
        {
            return checkTime.equals(curTime);
        }
    }
}