-
Notifications
You must be signed in to change notification settings - Fork 12
/
Person.cls
137 lines (113 loc) · 3.67 KB
/
Person.cls
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
Class isc.py.test.Person Extends (%Persistent, %Populate)
{
Property Name As %String;
Property DOB As %Date(MINVAL = 47117);
Property TS As %TimeStamp(MINVAL = "1970-01-01 00:00:00");
Property RandomTime As %Time;
Property AgeYears As %Integer;
Property AgeDecimal As %Decimal(SCALE = 2);
Property AgeDouble As %Double(SCALE = 4);
Property Bool As %Boolean;
/// Test data transfer methods
/// do ##class(isc.py.test.Person).Test()
ClassMethod Test(count As %Integer = 100)
{
if count {
do ..%KillExtent()
do ..Populate(count,,,,$$$NO)
}
write "Global structure:",!
zw ^isc.py.test.PersonD(1)
// Import now so it does not affect timings
set sc = ##class(isc.py.Main).ImportModule("pandas")
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
// All the ways to transfer data
set query = "SELECT * FROM isc_py_test.Person"
set class = "isc.py.test.Person"
set table = "isc_py_test.Person"
set global = "isc.py.test.PersonD"
// Common arguments
set variable = "df"
set type = "dataframe"
set start = 1
set end = $select(count>0:count, 1: $g(^isc.py.test.PersonD, 1))
// Approach 0: ExecuteGlobal without arguments
set t1 = $zh
set sc = ##class(isc.py.Main).ExecuteGlobal(global, variable _ 0, type)
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
set t2 = $zh
write !,"global auto time: ", t2-t1,!
write ##class(isc.py.util.BPEmulator).DescribeDataframe(variable _ 0),!
// Approach 1: ExecuteGlobal with arguments
// for global transfer labels are not calculated automatically
set labels = $lb("globalKey", "Name", "DOB", "TS", "RandomTime", "AgeYears", "AgeDecimal", "AgeDouble", "Bool")
// mask is 1 element shorter than labels because "globalKey" is global subscript label
// Here we want to skip %%CLASSNAME field
set mask = "-+dmt+++b"
set t1 = $zh
set sc = ##class(isc.py.Main).ExecuteGlobal(global, variable _ 1, type, start, end, mask, labels)
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
set t2 = $zh
write !,"global time: ", t2-t1,!
write ##class(isc.py.util.BPEmulator).DescribeDataframe(variable _ 1),!
// Approach 2: ExecuteClass
set t1 = $zh
set sc = ##class(isc.py.Main).ExecuteClass(class, variable _ 2, type, start, end)
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
set t2 = $zh
write !,"class time: ", t2-t1,!
write ##class(isc.py.util.BPEmulator).DescribeDataframe(variable _ 2),!
// Approach 3: ExecuteTable
set t1 = $zh
set sc = ##class(isc.py.Main).ExecuteTable(table, variable _ 3, type, start, end)
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
set t2 = $zh
write !,"table time: ", t2-t1,!
write ##class(isc.py.util.BPEmulator).DescribeDataframe(variable _ 3),!
// Approach 4: ExecuteTable
set t1 = $zh
set sc = ##class(isc.py.Main).ExecuteQuery(query, variable _ 4, type)
write:$$$ISERR(sc) $System.Status.GetErrorText(sc)
set t2 = $zh
write !,"query time: ", t2-t1,!
write ##class(isc.py.util.BPEmulator).DescribeDataframe(variable _ 4),!
}
Storage Default
{
<Data name="PersonDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>DOB</Value>
</Value>
<Value name="4">
<Value>TS</Value>
</Value>
<Value name="5">
<Value>RandomTime</Value>
</Value>
<Value name="6">
<Value>AgeYears</Value>
</Value>
<Value name="7">
<Value>AgeDecimal</Value>
</Value>
<Value name="8">
<Value>AgeDouble</Value>
</Value>
<Value name="9">
<Value>Bool</Value>
</Value>
</Data>
<DataLocation>^isc.py.test.PersonD</DataLocation>
<DefaultData>PersonDefaultData</DefaultData>
<IdLocation>^isc.py.test.PersonD</IdLocation>
<IndexLocation>^isc.py.test.PersonI</IndexLocation>
<StreamLocation>^isc.py.test.PersonS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}
}