Be already: UNC path not recognized
- Log in to post comments
Be already: UNC path not recognized
Here is my solution, which has a number of advantages:
See my article for details: Indexing of non-atomic attributes
Class dc.TSOrder Extends (%Persistent, %Populate)
{
Index Extent [ Extent, Type = bitmap ];
Index iSmartTS On (TS(KEYS), TS(ELEMENTS));
Index iTS On TS;
Property TS As %TimeStamp(MAXVAL = "2016-07-31 23:59:59.999999", MINVAL = "2016-07-01 00:00:00.000000");
Property Data As %String(MAXLEN = 200, MINLEN = 100);
ClassMethod TSBuildValueArray(
value,
ByRef array) As %Status
{
i value="" {
s array(0)=value
}else{
s date=$p(value," ",1),
time=$p(value," ",2),
array("date")=date,
array("time")=time,
array("ddhh")=$p(date,"-",3)_"-"_$p(time,":",1)
}
q $$$OK
}
/// d ##class(dc.TSOrder).Fill()
ClassMethod Fill(N = {30e6})
{
d ..%KillExtent(), ..Populate(N), $system.SQL.TuneTable($classname(),$$$YES), $system.OBJ.Compile($classname(),"cu-d")
}
}Results from SMP:
select distinct null from dc.TSOrder where TS between {ts '2016-07-01 00:00:00.00000'} AND {ts '2016-07-01 23:59:59.999999'}
Performance: 2.339 seconds 2109755 global references 14768692 lines executed
(the number of selected records is 968476, used the normal index)
select distinct null from dc.TSOrder where for some %element(TS) (%key='date' and %value = '2016-07-01')
Performance: 2.269 seconds 1936962 global references 15496098 lines executed
(the number of selected records is 968476, used the "smart" index)
select distinct null from dc.TSOrder where for some %element(TS) (%key='ddhh' and %value = '01-13')
Performance: 0.096 seconds 80488 global references 644270 lines executed
(the number of selected records is 40239, used the "smart" index)Try so:
<tabGroup ... onshowTab="zenThis.refreshContents(true);"> </tabGroup>
You can see the code examples and coding style in the sources of namespaces '%SYS' and/or 'SAMPLES'. But keep in mind that the style of classes written a long time ago differs significantly from style of classes written relatively recently, ex. [$ZT vs try/catch] or [%ResultSet vs %SQL.Statement]
For self - education is the best - documentation, for example:
Simple example:
Class dc.test Extends %ZEN.Component.page
{
Parameter DOMAIN = "DCTEST";
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
<radioSet id="lng"
label="Текущий язык"
layout="vertical"
displayList="Португальский,Русский"
valueList="pt-br,ru"
value="ru"
onchange="zenPage.changeLang(zenThis.value);"
/>
<form>
<text label="Описание" required="true" requiredMessage="обязательно." />
<submit caption="Сохранить"/>
</form>
</page>
}
/// User clicked to change preferred language.
ClientMethod changeLang(lng) [ Language = javascript ]
{
var ok = this.SrvChangeLang(lng);
self.document.location.reload();
}
/// Change preferred language for this session and page
ClassMethod SrvChangeLang(lng) As %Boolean [ ZenMethod ]
{
s %session.Language=lng
s %response.Language=lng
q $$$YES
}
Method %OnAfterCreatePage() As %Status
{
d ..%SetValueById("lng",%session.Language)
Quit $$$OK
}
}USER>d ##class(%MessageDictionary).ExportDomainList("messages_ru.xml","DCTEST","ru")
Result (messages_ru.xml):
<?xml version="1.0" encoding="UTF-8"?>
<MsgFile Language="ru">
<MsgDomain Domain="DCTEST">
<Message Id="358179803">Текущий язык</Message>
<Message Id="1805419696">Португальский,Русский</Message>
<Message Id="2153752096">Описание</Message>
<Message Id="2835101332">обязательно.</Message>
<Message Id="3683485237">Сохранить</Message>
</MsgDomain>
</MsgFile>
messages_pt-br.xml:
<?xml version="1.0" encoding="UTF-8"?>
<MsgFile Language="pt-br">
<MsgDomain Domain="DCTEST">
<Message Id="358179803">Idioma atual</Message>
<Message Id="1805419696">Português,Russo</Message>
<Message Id="2153752096">Descrição</Message>
<Message Id="2835101332">é obrigatório.</Message>
<Message Id="3683485237">Salvar</Message>
</MsgDomain>
</MsgFile>
USER>d ##class(%MessageDictionary).Import("messages_pt-br.xml")USER>w $zv Cache for Windows (x86-32) 2015.2 (Build 664_3U) Wed Aug 12 2015 12:29:34 EDT
The date is saved to the database correctly.
Class dc.A Extends %Persistent
{
Property DOB As %Date;
}
Class dc.MVC.A Extends %ZEN.DataModel.ObjectDataModel
{
Property DOB As %Date(ZENATTRS = "id:DOB|format:DMY|separator:/", ZENCONTROL = "dateText");
Method %OnNewSource(Output pSC As %Status = {$$$OK}) As %RegisteredObject
{
q ##class(dc.A).%New()
}
Method %OnOpenSource(
pID As %String,
pConcurrency As %Integer = -1,
Output pSC As %Status = {$$$OK}) As %RegisteredObject
{
q ##class(dc.A).%OpenId(pID,pConcurrency,.pSC)
}
Method %OnSaveSource(pSource As dc.A) As %Status
{
q pSource.%Save()
}
ClassMethod %OnDeleteSource(pID As %String) As %Status
{
q ##class(dc.A).%DeleteId(pID)
}
Method %OnLoadModel(pSource As dc.A) As %Status
{
s ..DOB = pSource.DOB
q $$$OK
}
Method %OnStoreModel(pSource As dc.A) As %Status
{
s pSource.DOB = ..DOB
q $$$OK
}
}
Class dc.test Extends %ZEN.Component.page
{
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
<dataController id="a-controller" modelClass="dc.MVC.A" modelId=""/>
<dynaForm id="a-form" controllerId="a-controller"/>
<button caption="Save" onclick="zen('a-form').save();" />
</page>
}
}Still can be so:
Class dc.test [ Abstract ]
{
ClassMethod Test(s = "#")
{
w "Test_",s
}
ClassMethod mac() [ ProcedureBlock = 0 ]
{
sub1(s=1)
w "sub1_",s
q
sub2(s=2)
w "sub2_",s
q
procPrivate(s=3) {
w "procPrivate_",s
}
procPublic(s=3) public {
w "procPublic_",s
}
}
}Result:
USER>d zTest^dc.test.1(1) Test_1 USER>d sub1^dc.test.1 sub1_1 USER>d sub2^dc.test.1 sub2_2 USER>d sub1^dc.test.1(10) sub1_10 USER>d sub2^dc.test.1(10) sub2_10 USER>d procPrivate^dc.test.1(10) D procPrivate^dc.test.1(10) ^USER>d procPublic^dc.test.1(10) procPublic_10 USER>
This can be done also in the CLS.
TEST(invar) [outvar] public {
}=>
ClassMethod TEST(invar) [PublicList=outvar] {
}
my code is disclosed above
Upd: 67
Upd: 72
My best result is 77726967 so far.
Class ITPlanet.Task4 [ Abstract ]
{
ClassMethod main(s As %Integer = 10)
{
f x=1:1:s w ! f y=1:1:s w $c(y#s<2!$lf($lb(1,s,y,s-y+1),x)*3+32)
}
ClassMethod length(
class = {$classname()},
method = "main") As %Integer [ CodeMode = expression ]
{
##class(%Dictionary.MethodDefinition).IDKEYOpen(class, method).Implementation.Size
}
}
USER>w ##class(ITPlanet.Task4).length()
67
USER>d ##class(ITPlanet.Task4).main(11)
###########
## ##
# # # #
# # # #
# # # #
# # #
# # # #
# # # #
# # # #
## ##
###########Make two changes to your code:
/// return json
Method infoJson() As %String [ WebMethod ]
{
set soapresponse=##class(webservice.SOAPResponse).%New()
set soapresponse.CustomerID="1"
set soapresponse.Name="2"
set soapresponse.Street="3"
set soapresponse.City="4"
set soapresponse.State="5"
set soapresponse.Zip="6"
set stream=##class(%Stream.TmpBinary).%New()
do ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(stream,soapresponse,,,$$$YES,"s")
quit stream.Read($$$MaxStringLength)
}/// write ##class(PRD.Test).test1()
ClassMethod test1() As %String
{
set soapresponse=##class(webservice.SOAPResponse).%New()
set soapresponse.CustomerID="1"
set soapresponse.Name="2"
set soapresponse.Street="3"
set soapresponse.City="4"
set soapresponse.State="5"
set soapresponse.Zip="6"
set stream=##class(%Stream.TmpBinary).%New()
do ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(stream,soapresponse,,,$$$YES,"s")
quit stream.Read($$$MaxStringLength)
}Fixed bugs/typos and added new types.
#include %PVA
types ; Show COS-Datatypes ; kav ; 2018-03-04
n array,i,bitstring
s $bit(bitstring,1) = 1
w "№",?4,"VALUE",?30,"JSON",?45,"$LISTBUILD",!,$TR($J("",55)," ","-"),!
s array=[
(bitstring),
($ZBITSET($ZBITSTR(4,1),2,0)),
($lb("")),
null,
true,
false,
(##class(%ZEN.proxyObject).%New()),
[],
{},
"abcd",
($wc(35222)),
"2",
2,
-2,
2.1,
-2.1,
($double(2.1))
]
s array."18"=2
s array."19"=-2
f i=0:1:array.%Size() {
w i,")",?4,array.%Get(i),?30,$$TypeOf1(.array,i),?45,$$TypeOf2(array.%Get(i)),!
}
// Return JSON datatype by the documented way
//
TypeOf1(&array,key)
{
s typ=array.%GetTypeCodeOf(key)
q typ_" "_$case(typ,
$$$PVVALUENULL:"null",
$$$PVVALUETRUE:"boolTrue",
$$$PVVALUEFALSE:"boolFalse",
$$$PVVALUEINTEGERPOS:"+int",
$$$PVVALUEINTEGERNEG:"-int",
$$$PVVALUEUNUSED1:"unused",
$$$PVVALUEARRAY:"array",
$$$PVVALUEOBJECT:"object",
$$$PVVALUETEXT:"text",
$$$PVVALUENUMBER:"number",
$$$PVVALUEOVERFLOW:"overflow",
$$$PVVALUECACHENUMERIC:"cacheNumeric",
$$$PVVALUEOREF:"oref",
$$$PVVALUEUNASSIGNED:"unassigned",
$$$PVVALUELONGPOS:"+long",
$$$PVVALUELONGNEG:"-long",
$$$PVVALUEBYTE:"byte[]",
$$$PVVALUEDATETIME:"dateTime",
$$$PVVALUEDOUBLE:"double",
$$$PVVALUESINGLE:"single",
$$$PVVALUEUTF8:"utf8",
$$$PVVALUENESTED:"nested",
$$$PVVALUEEOF:"eof",
:"unknown")
}
// Return datatype by the undocumented $LB() way
//
TypeOf2(val)
{
i $l(val)>253 {
s typ=$ziswide(val)+1
} else {
s typ=$a($lb(val),2)
}
q typ_" "_$case(typ
,1:"8bitString"
,2:"16bitString"
,4:"nonNegativeInteger"
,5:"negativeInteger"
,6:"nonNegativeFloat"
,7:"negativeFloat"
,8:"double"
, :"??? never seen before")
}Result:
USER>d ^types
№ VALUE JSON $LISTBUILD
-------------------------------------------------------
0) 8 text 1 8bitString
8 text 1 8bitString
2) 8 text 1 8bitString
3) 0 null 1 8bitString
4) 1 1 boolTrue 1 8bitString
5) 0 2 boolFalse 1 8bitString
6) 4@%ZEN.proxyObject 12 oref 1 8bitString
7) 2@%Library.DynamicArray 6 array 1 8bitString
8) 1@%Library.DynamicObject 7 object 1 8bitString
9) abcd 8 text 1 8bitString
10) 視 8 text 2 16bitString
11) 2 8 text 1 8bitString
12) 2 9 number 4 nonNegativeInteger
13) -2 9 number 5 negativeInteger
14) 2.1 9 number 6 nonNegativeFloat
15) -2.1 9 number 7 negativeFloat
16) 2.1000000000000000888 18 double 8 double
17) 13 unassigned 1 8bitString
18) 2 3 +int 4 nonNegativeInteger
19) -2 4 -int 5 negativeInteger
20) 31 eof 1 8bitStringOn my desktop quite other results.
n N,j,time
s N=1e8
f j=1,2/*,3,4,5*/ {
w j,") "
s time=$zh
d @("j"_j)(N)
w $zh-time," s.",!
}
q
j1(N) public {
f i=1:1:N {s (a,b,c,d,e,f)=0}
}
j2(N) public {
f i=1:1:N {s a=0,b=0,c=0,d=0,e=0,f=0}
}
j3(N) public {
f i=1:1:N {s a=0,b=1,c=2,d=3,e=4,f=5}
}
j4(N) public {
f i=1:1:N {s a=0 s b=1 s c=2 s d=3 s e=4 s f=5}
}
j5(N) public {
f i=1:1:N {s $lb(a,b,c,d,e,f)=$lb(0,1,2,3,4,5)}
}Results:
USER>d ^perf 1) 11.814189 s. 2) 4.683832 s.
As you can see the difference is almost 2.5 times.
I also want to note that
s (a,b,c)=0
is slower than
s a=0,b=0,c=0
Undefined variable and the variable contains "" (null) is two different situations, e.g. (see $DATA):
kill myObj write $data(myObj),! ; -> 0 set myObj=$$$NULLOREF write $data(myObj),! ; -> 1
In your case it would be better to use $IsObject:
kill myObj
write $IsObject(myObj),! ; -> 0
set d=$$$NULLOREF
write $IsObject(myObj),! ; -> 0
set myObj={}
write $IsObject(myObj),! ; -> 1Accordingly, should be do $$$AssertTrue('$IsObject(myObj), "myObj is null")
You are right, the macro $$$NULL present only in %sqlMigration.inc and this is not the file that developers often include to its project.
I prefer to use the macro $$$NULLOREF/$$$NULLOID from %occExtent.inc, which is available by default in the class that inherits from %Library.Base, and for routines is enough to include %systemInclude.inc.
Why so difficult?
This similarly following condition:
WHERE ( year(current_date) - year(DOB) ) >= 13
It Besides above was already indicated, why does not follow to use such a code, for example:
select datediff(year,
todate(to_char({d '1990-12-31'},'YYYY')||':1','YYYY:MM'), -- birthday
todate(to_char({d '2003-01-01'},'YYYY')||':1','YYYY:MM') -- report date
)This gives an incorrect result - 13, although it should be 12.
Here's another way (without PlaceAfter):
Class Macro.Child Extends Macro.Parent
{
ClassMethod %inc() [ Internal, Private ]
{
#include Child
}
ClassMethod Test()
{
write "Class: " , $classname() , ! , "Value: " , $$$name
}
}Class include is not required (and does not seem to affect anything) and can be omittedYeah, I just forgot to delete that line.
Then this:
Include Child
Class Macro.Child Extends Macro.Parent
{
ClassMethod first()
{
#include Child
}
ClassMethod Test() [ PlaceAfter = first ]
{
write "Class: " , $classname() , ! , "Value: " , $$$name
}
}or this:
ClassMethod Test()
{
#include Child
write "Class: " , $classname() , ! , "Value: " , $$$name
}