ïŒA.S.ããŒã·ãã³ïŒ
ãããTwitterã®æçš¿ã§ããã°ãã CachéObjectScriptããã°ã©ããŒïŒ Cyrillic3ã®ä»£ããã«Cyrillic4ã䜿çšããŠãã ããïŒ ãã ããããããã§ãHabrãããã¯æèãåºããå¿ èŠããã-ç«ã®äžã§æè¿ã
Cachéã®ãã¹ãŠã¯ã°ããŒãã«ã«ä¿åãããŸãã ããŒã¿ãã¡ã¿ããŒã¿ãã¯ã©ã¹ãããã°ã©ã ã ã°ããŒãã«ããŒãã¯æ·»ãåã®å€ã§ãœãŒããããæ¿å ¥ãããé åºã§ã¯ãªããã¯ã€ãã¯æ€çŽ¢ã®ããã«ãœãŒããããŠãã£ã¹ã¯ã«ä¿åãããŸãã
USER>set ^a(10)="" USER>set ^a("")="" USER>set ^a("")="" USER>set ^a(2)="" USER>zwrite ^a ^a(2)="" ^a(10)="" ^a("")="" ^a("")=""
䞊ã¹æ¿ãããšããCachéã¯æ°åãšæååãåºå¥ããŸã-2ã¯æ°åãšèŠãªããã10ããåã«äžŠã¹æ¿ããããŸããzwriteã³ãã³ããš$ Orderããã³$ Queryé¢æ°ã¯ãã°ããŒãã«ã€ã³ããã¯ã¹ããã£ã¹ã¯ã«æ ŒçŽãããŠããé åºã§è¡šç€ºããŸããæåã¯ç©ºã®æååã次ã«è² ã®æ°åãæ£ã®æ°ã次ã«ç §åããŒãã«ã«ãã£ãŠæ±ºå®ãããé åºã®è¡ã
æãåçŽãªå ŽåããœãŒãããŒãã«ã¯åæåãšã·ãŒã±ã³ã¹çªå·ãç §åããŸãã 次ã«ã䞊ã¹æ¿ãããŒãã«ã䞊ã¹æ¿ããŸãã
Cachéã®æšæºãœãŒãã¯ãCachéæšæºãšåŒã°ããŸãã åæåãUnicodeã³ãŒãã«ãããã³ã°ããŸãã
çŸåšã®ããã»ã¹ã§ããŒã«ã«é åãäœæããããœãŒãã¯ããã±ãŒã«ïŒç®¡çããŒã¿ã«>ã·ã¹ãã 管ç>æ§æ>ååœèªã®ãµããŒãã®èšå®ïŒã«ãã£ãŠæ±ºå®ãããŸãã ãã·ã¢ã®CachéUnicodeã€ã³ã¹ããŒã«ã®ãã·ã¢èªãã±ãŒã«ã®ruswã®å Žåãæ¢å®ã®äžŠã¹æ¿ãããŒãã«ã¯Cyrillic3ã§ãã ruswã§å¯èœãªãã®ä»ã®ãœãŒãã¯ãCachéæšæºãCyrillic1ãCyrillic3ãCyrillic4ãUkrainian1ã§ãã
##ã¯ã©ã¹ïŒïŒ CollatââeïŒ.SetLocalNameïŒïŒã¡ãœããã¯ãçŸåšã®ããã»ã¹ã®ããŒã«ã«é åã®ãœãŒããå€æŽããŸãã
USER>write ##class(%Collate).GetLocalName() Cyrillic3 USER>write ##class(%Collate).SetLocalName("Cache standard") 1 USER>write ##class(%Collate).GetLocalName() Cache standard USER>write ##class(%Collate).SetLocalName("Cyrillic3") 1 USER>write ##class(%Collate).GetLocalName() Cyrillic3
åãœãŒãã«ã¯ãæ°å€ãæååãšããŠãœãŒãããããã¢ããããŸãã ãã®ãããªãã¢ãœãŒãã®ååã¯ãå ã®ãœãŒãã®ååã«ãstringããè¿œå ããããšã«ãã£ãŠååŸãããŸãã
USER>write ##class(%Collate).SetLocalName("Cache standard string") 1 USER>kill test USER>set test(10) = "", test(2) = "", test("") = "", test("") = "" USER>zwrite test test(10)="" test(2)="" test("")="" test("")="" USER>write ##class(%Collate).SetLocalName("Cache standard") 1 USER>kill test USER>set test(10) = "", test(2) = "", test("") = "", test("") = "" USER>zwrite test test(2)="" test(10)="" test("")="" test("")=""
Cachéæšæºããã³Cyrillic3
Cachéæšæºã§ã¯ãæåã¯Unicodeã³ãŒãã®é ã«ãœãŒããããŸãã
write ##class(%Library.Collate).SetLocalName("Cache standard"),! write ##class(%Library.Collate).GetLocalName(),! set letters = "" set letters = letters _ $zconvert(letters,"U") kill test // test for i=1:1:$Length(letters) { set test($Extract(letters,i)) = "" } // test set l = "", cnt = 0 for { set l = $Order(test(l)) quit:l="" write l, " ", $Ascii(l),"," set cnt = cnt + 1 write:cnt#8=0 ! }
USER>do ^testcol 1 Cache standard 1025, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1105,
æåããã³exceptãé€ããã¹ãŠã®æåãé 眮ãããŠããŸãã Unicodeã®ã³ãŒãã¯äžè¬çãªé åºããå€ããŠããŸãã ãããã£ãŠããã·ã¢èªãã±ãŒã«ã®å Žåãç¬èªã®äžŠã¹æ¿ãããŒãã«Cyrillic3ãå¿ èŠã§ãããCyrillic3ã§ã¯ãæåã¯ãã·ã¢èªã®ã¢ã«ãã¡ããããšåãé åºã«ãªããŸãã
USER>do ^testcol 1 Cyrillic3 1040, 1041, 1042, 1043, 1044, 1045, 1025, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1105, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1097, 1098, 1099, 1100, 1101, 1102, 1103,
CachéObjectScriptã«ã¯ãç¹å¥ãªãã€ããªæŒç®å]]]-ããœãŒãåŸãããããŸãã é åã€ã³ããã¯ã¹å ã§å·ŠåŒæ°ãå³åŒæ°ã®åŸã«é 眮ãããå Žåã¯1ãè¿ãããã以å€ã®å Žåã¯0ãè¿ããŸãã
USER>write ##class(%Library.Collate).SetLocalName("Cache standard"),! 1 USER>write "" ]] "" 1 USER>write ##class(%Library.Collate).SetLocalName("Cyrillic3"),! 1 USER>write "" ]] "" 0
ã°ããŒãã«ãšãœãŒãããŒãã«
åãããŒã¿ããŒã¹å ã®ç°ãªãã°ããŒãã«ã¯ãç°ãªããœãŒããæã€ããšãã§ããŸãã åããŒã¿ããŒã¹ã«ã¯èšå®ããããŸã-æ°ããã°ããŒãã«ã®ãœãŒãã ã€ã³ã¹ããŒã«çŽåŸã USERãé€ããã¹ãŠã®ããŒã¿ããŒã¹ã®å Žåãæ°ããã°ããŒãã«ã®æ¢å®ã®äžŠã¹æ¿ãã¯Cachéæšæºã§ãã USERã®å Žåãã€ã³ã¹ããŒã«ãã±ãŒã«ã«ãã£ãŠç°ãªããŸãã ruswã®å Žå -ããªã«æå3ã
ãã®ããŒã¿ããŒã¹ã®ããã©ã«ãã®ãœãŒããšã¯ç°ãªããœãŒãã§ã°ããŒãã«ãäœæããŸãã
USER>kill ^a USER>write ##class(%GlobalEdit).Create(,"a",##class(%Collate).DisplayToLogical("Cache standard"))
管çããŒã¿ã«ã®ã°ããŒãã«ã®ãªã¹ãïŒ[ã·ã¹ãã ãã©ãŠã¶ãŒ]> [ã°ããŒãã«]ïŒã«ã¯ãåã°ããŒãã«ã®ãœãŒãã衚瀺ãããŸãïŒ4åç®ïŒã
æ¢åã®ã°ããŒãã«ã®ãœãŒããå€æŽããããšã¯ã§ããŸããã æ°ãããœãŒãã§ã°ããŒãã«ãäœæããmergeã³ãã³ãã§å€ãã°ããŒãã«ããããŒã¿ãã³ããŒããå¿ èŠããããŸãã ##ã¯ã©ã¹ïŒSYS.DatabaseïŒ.CopyïŒïŒã¡ãœããã䜿çšããŠãããçš®é¡ããå¥ã®çš®é¡ãžã®ã°ããŒãã«ã®äžæ¬å€æãå®è¡ã§ããŸãã
Cyrillic4ãCyrillic3ããŠã ã©ãŠã
Cyrillic3ã®æäœäžã«ãããã¹ãã€ã³ããã¯ã¹ããå éšåœ¢åŒãžã®å€æã«ã¯Cachéæšæºã®ãœãŒããããæéãããããããCyrillic3ãœãŒãã䜿çšããã°ããŒãã«ïŒãŸãã¯ããŒã«ã«é åïŒã®æ¿å ¥ãšããã²ãŒããé ãããšãããããŸããã ããŒãžã§ã³2014.1ããå©çšå¯èœãªæ°ããCyrillic4ç §åãäœæãããŸããã ãã®äžã®ããªã«æåã®é åºã¯ããªã«æå3ãšåãã§ãããããªã«æå4ã¯èããé«éã§ãã
for collation="Cyrillic3","Cyrillic4","Cache standard","Cyrillic1" { write ##class(%Library.Collate).SetLocalName(collation),! write ##class(%Library.Collate).GetLocalName(),! do test(100000) } quit test(C) set letters = "" set letters = letters _ $zconvert(letters,"U") kill test write "test insert: " // test set z1=$zh for c=1:1:C { for i=1:1:$Length(letters) { set test($Extract(letters,i)_" " _ $Extract(letters,i)) = "" } } write $zh-z1,! // test write "test $Order: " set z1=$zh for c=1:1:C { set l = "" for { set l = $Order(test(l)) quit:l="" } } write $zh-z1,!
USER>do ^testcol 1 Cache standard test insert: 1.520673 test $Order: 2.062228 1 Cyrillic3 test insert: 3.541697 test $Order: 5.938042 1 Cyrillic4 test insert: 1.925205 test $Order: 2.834399
Cyrillic4ã¯ãŸã ruswãã±ãŒã«ã®ããã©ã«ãã®äžŠã¹æ¿ãã§ã¯ãããŸããããruswã«åºã¥ããŠç¬èªã®ãã±ãŒã«ãäœæããããšã«ãããCyrillic4ãããŒã«ã«é åã®ããã©ã«ãã®äžŠã¹æ¿ããšããŠæå®ã§ããŸãã ãŸãã¯ãããŒã¿ããŒã¹èšå®ã§æ°ããã°ããŒãã«ã®ããã©ã«ãç §åãšããŠCyrillic4ãæå®ããŸãã
Cyrillic3ã¯ãCachéæšæºããã³Cyrillic4ãããäœéã§ããããã¯ãCyrillic3ã¯ããããã®è¡ã®å¯Ÿå¿ããæåã®ã³ãŒãã«å¿ããŠ2è¡ããœãŒããããããäžè¬çãªã¢ã«ãŽãªãºã ã«åºã¥ããŠããããã§ãã
ãã€ãèªã§ã¯ã䞊ã¹æ¿ãããšãã æåÃã¯ssãšããŠè§£éãããå¿ èŠããããŸã ã ããã¯ãCachéã§ã®åäœã§ãã
USER>write ##class(%Collate).GetLocalName() German3 USER>set test("StraÃer")=1 USER>set test("Strasser")=1 USER>set test("Straster")=1 USER>zwrite test test("Strasser")=1 test("StraÃer")=1 test("Straster")=1
è¡ã®é åºã«æ³šæããŠãã ããã ã€ãŸããæåã®è¡ã®æåã®4æåããStrasãã次ã«ãStraÃãããããŠåã³ãStrasãã§ãããšããããšã§ãã åæåãäœããã®ã³ãŒãã«é¢é£ä»ããããŠããå Žåããã®é åºã¯å®çŸã§ããŸããã
ãã·ã¢èªã«ã¯å¹žéã§ã-ããšãã°ãã£ã³ã©ã³ãèªã®vãwã®ããã«ãåãæ¹æ³ã§ãœãŒãã§ãããŠã ã©ãŠããæåã¯ãããŸããã ãã·ã¢èªã§ã¯ãåæåã«çªå·ãä»ãã察å¿ããäœçœ®ã®æåçªå·ã«åŸã£ãŠè¡ãæ¯èŒããã ãã§ååã§ãã ãã®ãããCyrillic4ã§é床ãåäžããããšãå€æããŸããã
䞊ã¹æ¿ããšSQLããŒãã«
ã°ããŒãã«ã®ç §åããŒãã«ãšSQLã®åã®ç §åïŒç §åãïŒãæ··åããªãã§ãã ããã 2çªç®ã®äžŠã¹æ¿ãã¯ãå€ãã€ã³ããã¯ã¹ã°ããŒãã«ã«é 眮ããããå¥ã®å€ãšæ¯èŒããåã«å€ã«é©çšãããå€æã§ãã CachéSQLã§ã¯ãè¡ã®æ¢å®ã®ç §åã¯SQLUPPERã§ãã ãã®å€æã¯ããã¹ãŠã®æåã倧æåã«å€æããæ«å°Ÿã®ç©ºçœãåé€ããè¡ã®å é ã«ã¹ããŒã¹ã1ã€è¿œå ããŸãã ä»ã®3ã€ã®SQLãœãŒãïŒ EXACT ã SQLSTRING ã TRUNCATE ïŒã¯ã ããã¥ã¡ã³ãã«èšèŒãããŠããŸã ã
ããçšåºŠã®ã¹ãã«ãããã°ãããŒã¿ããŒã¹å ã®ç°ãªãã°ããŒãã«ã«ç°ãªã䞊ã¹æ¿ãããããããŒã«ã«ã¢ã¬ã€ã«3çªç®ã®äžŠã¹æ¿ããããå Žåãæ··ä¹±ãåŒãèµ·ããããšã¯é£ãããããŸããã å éšçãªããŒãºã®ããã«ãSQLã¯CACHETEMPããŒã¹ã䜿çšããŸããã°ããŒãã«ã®äžŠã¹æ¿ãã¯ãçŸåšã®ãã±ãŒã«ã®ããã©ã«ãã®äžŠã¹æ¿ããšãç°ãªãå ŽåããããŸãã
åºæ¬çãªã«ãŒã«ã¯1ã€ã§ãããããã£ãŠãSQLã¯ãšãªã®ORDER BYã¯æåŸ ãããé åºã§è¡ãè¿ããããã¯ãšãªã«åå ããããŒãã«ã®ããŒã¿ãšã€ã³ããã¯ã¹ãæ ŒçŽãããã°ããŒãã«ã®äžŠã¹æ¿ãã¯ã CACHETEMPããŒã¿ããŒã¹ã®ããã©ã«ãã®äžŠã¹æ¿ããšããŒã«ã«é åã®äžŠã¹æ¿ããšåãã§ããå¿ èŠããããŸãã 詳现ã«ã€ããŠã¯ã SQLããã³NLSç §åã®ããã¥ã¡ã³ãã®æ®µèœãåç §ããŠãã ããã
ãã¹ãã¯ã©ã¹ãäœæããŸãã
Class Habr.test Extends %Persistent { Property Name As %String; Property Surname As %String; Index SurInd On Surname; ClassMethod populate() { do ..%KillExtent() set t = ..%New() set t.Name = "", t.Surname = "" write t.%Save() set t = ..%New() set t.Name = "", t.Surname = "" write t.%Save() set t = ..%New() set t.Name = "", t.Surname = "" write t.%Save() } }
ããŒã¿ãå ¥åããŸãïŒãã®åŸããã€ãèªã®äŸããååãæååã«å€æŽã§ããŸãïŒã
USER>do ##class(Habr.test).populate()
ãªã¯ãšã¹ããå®è¡ããŸãïŒ
çµæã¯äºæ³å€ã§ãã äž»ãªè³ªåã¯ãååã®ã¢ã«ãã¡ãããé ïŒããŒã«ãããŒã¿ãŒãããã³ãŒã«ïŒã§ã¯ãªãã®ã¯ãªãã§ããïŒ ãªã¯ãšã¹ããã©ã³ã確èªããŸãã
ãã®ç¹ã§ã®ããŒã¯ãŒãã¯ãpopulates temp-fileãã§ãã ã¯ãšãªãå®è¡ããããã«ãSQLãªããã£ãã€ã¶ãŒã¯ãçŸåšã®ããã»ã¹ïŒããã»ã¹ãã©ã€ããŒãã°ããŒãã«ïŒã®ã¿ã«è¡šç€ºãããã°ããŒãã«ïŒå Žåã«ãã£ãŠã¯ããŒã«ã«é åïŒã®äžææ§é ïŒtemp-fileïŒã䜿çšããããšã決å®ããŸããã å€ã¯ãã®ã°ããŒãã«ã®ã€ã³ããã¯ã¹ã«é 眮ããããœãŒããããé åºã§è¡šç€ºãããŸãã äžæã°ããŒãã«ã¯CACHETEMPããŒã¿ããŒã¹ã«æ ŒçŽãããCachéæšæºã®æ°ããã°ããŒãã«ã«ãœãŒããããŸãã ãããããªããeããæåŸã§ã¯ãªãæåã«ããã®ã§ããããïŒ äžæã°ããŒãã«ã®ã€ã³ããã¯ã¹ã§ã¯ãååãã£ãŒã«ãã®å€ã¯ãããã倧æåã«çž®å°ããïŒ SQLUPPERã¯æååã®ããã©ã«ãã®å€æã§ã ïŒãæåEãå é ã«ä»ããŸãã
èªåå€æïŒ ïŒ Exacté¢æ°ïŒããã£ã³ã»ã«ãããšããŸã æ£ãããªãããå°ãªããšãäºæ³ãããé åº-ã-ãã¯ãã¹ãŠã®æåã®åŸã«ãœãŒãããã
CACHETEMPã®ãœãŒãããŒãã«ã¯ãŸã ä¿®æ£ããŸãã -å§ã®ã¯ãšãªããã§ãã¯ããŸãã çµå±ããã®åã«ã¯^ Habr.TestI globalã«ã€ã³ããã¯ã¹ããããŸãã ãã®ã°ããŒãã«ã®äžŠã¹æ¿ãã¯Cyrillic3ã§ãããããè¡ã®é åºã¯ã¢ã«ãã¡ãããé ã«ããå¿ èŠããããŸãã
åã³ããã§ã¯ãããŸããã ç§ãã¡ã¯èšç»ãèŠãŸãïŒ
å ã®åœ¢åŒã§å§ã衚瀺ããã«ã¯ïŒããã©ã«ãã§SurIndã€ã³ããã¯ã¹èŠçŽ ã«é©çšãããSQLUPPERå€æã®åïŒãã€ã³ããã¯ã¹ããŒã¿ã®ã¿ãå°ãããããŒãã«ã«ã¢ã¯ã»ã¹ããå¿ èŠããããããSQLãªããã£ãã€ã¶ãŒã¯ããŒãã«ããçŽæ¥ããŒã¿ãååŸããŠäžæå€æ°ã«äžŠã¹æ¿ããããšã決å®ããŸããååã®å Žåã
ãªã¯ãšã¹ãã§å€§æåãé©åã§ãããšæå®ããå Žåãé åºã¯æ£ãããªããŸããçµå±ãããŒã¿ã¯ã€ã³ããã¯ã¹global ^ Habr.testIããçŽæ¥ååŸãããŸãã
äºæ³ããããªã¯ãšã¹ããã©ã³ïŒ
ããŠã以åã«ãããªããã°ãªããªãã£ãããšãããŸããã-CACHETEMPããŒã¿ããŒã¹ã®æ°ããã°ããŒãã«ã®ããã©ã«ãã®ãœãŒããCyrillic3ïŒãŸãã¯Cyrillic4ïŒã«å€æŽããŸãã
äžææ§é ã䜿çšããã¯ãšãªã¯ãæ£ããé åºã§è¡ãåºåããããã«ãªããŸããã
çµè«
- æåwithã®ããŒã¿ã衚瀺ãããé åºãæ°ã«ããªãå Žåã¯ãCachéæšæºç §åããŒãã«ã䜿çšããŸãã
- Cyrillic3ã䜿çšããŠããå ŽåãCyrillic4ç §åããŒãã«ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ããã¹ãããŸãã ã¢ããªã±ãŒã·ã§ã³ã¯ããé«éã«ãªããŸãã
- åã䞊ã¹æ¿ãããŒãã«ãCACHETEMPããŒã¿ããŒã¹ã éçšããŒã¿ããŒã¹ãããã³ãã±ãŒã«èšå®ã«ããããšã確èªããŸãã