{"id":269986,"date":"2015-12-09T16:43:02","date_gmt":"2015-12-09T13:43:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=269986"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=269986","title":{"rendered":"\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 \u0421\u0423\u0411\u0414 Cach\u00e9"},"content":{"rendered":"<p>       <a href=\"http:\/\/habrahabr.ru\/post\/272689\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6c7\/a54\/754\/6c7a547547284690aaf4668949b8b29e.jpg\" title=\"\u041d\u0438\u043a\u043e\u043b\u0430\u0439 \u0417\u0430\u0433\u0440\u0435\u043a\u043e\u0432 \u2014 \u041a\u0440\u0435\u0441\u0442\u044c\u044f\u043d\u0438\u043d \u0441 \u043a\u043e\u0441\u043e\u0439\" align=\"left\"\/><\/a><br \/>  \u0412 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0421\u0423\u0411\u0414 Cach\u00e9 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0435, <a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=GSQL_indices#GSQL_indices_bitmap\">bitmap<\/a> \u0438 <a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=GSQL_indices#GSQL_indices_bitslice\">bitslice<\/a>. \u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u044d\u0442\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2013.1 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c (\u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u043d\u0435 \u043f\u0443\u0433\u0430\u044e\u0442 \u0441\u043b\u043e\u0432\u0430 \u0442\u0438\u043f\u0430 \u043c\u0435\u0442\u043e\u0434-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u00ab\u0421\u0432\u043e\u0439 \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432\u00bb \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <i>%Library.FunctionalIndex<\/i> \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \/ \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. <\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>Property A As %String;  Property B As %String;  Index someind On (A,B) As CustomPackage.CustomIndex;<\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 <i>CustomPackage.CustomIndex<\/i> \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0435\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. <\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u0430-\u043a\u0432\u0430\u0434\u0440\u043e\u0434\u0435\u0440\u0435\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/intersystems\/blog\/267459\/\">\u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435<\/a> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u0410\u043d\u0434\u0440\u0435\u044f  <a href=\"http:\/\/habrahabr.ru\/users\/arechitsky\/\" class=\"user_link\">ARechitsky<\/a> \u0420\u0435\u0447\u0438\u0442\u0441\u043a\u043e\u0433\u043e, <a href=\"https:\/\/github.com\/APogrebnikov\">\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0430 \u041f\u043e\u0433\u0440\u0435\u0431\u043d\u0438\u043a\u043e\u0432\u0430<\/a> \u0438 \u0430\u0432\u0442\u043e\u0440\u0430 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u043e\u043a. \u0425\u0430\u043a\u0430\u0442\u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0435\u0436\u0435\u0433\u043e\u0434\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 InterSystems (\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u0435\u043b\u044e \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0430  <a href=\"http:\/\/habrahabr.ru\/users\/tsafin\/\" class=\"user_link\">tsafin<\/a>). \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0448\u043a\u043e\u043b\u044b, \u043a\u0441\u0442\u0430\u0442\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"http:\/\/www.intersystems.com\/ru\/who-we-are\/events\/event\/school-2015\/\">\u043d\u0430\u0448\u0435\u043c \u0441\u0430\u0439\u0442\u0435<\/a>.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043a\u0432\u0430\u0434\u0440\u043e\u0434\u0435\u0440\u0435\u0432\u043e \u0438 \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. <\/p>\n<p>  \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <i>%Library.FunctionalIndex<\/i> \u0434\u043b\u044f \u0438\u043c\u0435\u044e\u0449\u0435\u0439\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0432\u0430\u0434\u0440\u043e\u0434\u0435\u0440\u0435\u0432\u0430. \u0415\u0439 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u0410\u043d\u0434\u0440\u0435\u0439. \u0410\u043d\u0434\u0440\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 <i>SpatialIndex.Indexer<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u043b \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 <i>Insert(x, y, id)<\/i> \u0438 <i>Delete(x, y, id)<\/i>. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <i>SpatialIndex.Indexer<\/i> \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443\u0437\u0435\u043b \u0433\u043b\u043e\u0431\u0430\u043b\u0430, \u0432 \u043f\u043e\u0434\u0443\u0437\u043b\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u043b\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441. \u041c\u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <i>SpatialIndex.Index<\/i>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b <i>InsertIndex<\/i>, <i>UpdateIndex<\/i>, <i>DeleteIndex<\/i> \u0438 <i>PurgeIndex<\/i>. \u041f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 <i>Id<\/i> \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u0430\u043a \u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435, \u0433\u0434\u0435 \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, <i>pArg(1)<\/i> \u2014 <i>A<\/i>, <i>pArg(2)<\/i> \u2014 <i>B<\/i>.<\/p>\n<pre><code>Class SpatialIndex.Index Extends %Library.FunctionalIndex [ System = 3 ] {  ClassMethod InsertIndex(pID As %CacheString, pArg... As %Binary) [ CodeMode = generator, ServerOnly = 1 ] {     if %mode'=&quot;method&quot; { \/\/'    \t set IndexGlobal = ..IndexLocation(%class,%property)    \t $$$GENERATE($C(9)_&quot;set indexer = ##class(SpatialIndex.Indexer).%New($Name(&quot;_IndexGlobal_&quot;))&quot;)    \t $$$GENERATE($C(9)_&quot;do indexer.Insert(pArg(1),pArg(2),pID)&quot;)     } }  ClassMethod UpdateIndex(pID As %CacheString, pArg... As %Binary) [ CodeMode = generator, ServerOnly = 1 ] {     if %mode'=&quot;method&quot; { \/\/'    \t set IndexGlobal = ..IndexLocation(%class,%property)    \t $$$GENERATE($C(9)_&quot;set indexer = ##class(SpatialIndex.Indexer).%New($Name(&quot;_IndexGlobal_&quot;))&quot;)    \t $$$GENERATE($C(9)_&quot;do indexer.Delete(pArg(3),pArg(4),pID)&quot;)    \t $$$GENERATE($C(9)_&quot;do indexer.Insert(pArg(1),pArg(2),pID)&quot;)     } }  ClassMethod DeleteIndex(pID As %CacheString, pArg... As %Binary) [ CodeMode = generator, ServerOnly = 1 ] {     if %mode'=&quot;method&quot; { \/\/'    \t set IndexGlobal = ..IndexLocation(%class,%property)    \t $$$GENERATE($C(9)_&quot;set indexer = ##class(SpatialIndex.Indexer).%New($Name(&quot;_IndexGlobal_&quot;))&quot;)    \t $$$GENERATE($C(9)_&quot;do indexer.Delete(pArg(1),pArg(2),pID)&quot;)     } }  ClassMethod PurgeIndex() [ CodeMode = generator, ServerOnly = 1 ] {     if %mode'=&quot;method&quot; { \/\/'    \t set IndexGlobal = ..IndexLocation(%class,%property)    \t $$$GENERATE($C(9)_&quot;kill &quot; _ IndexGlobal)     } }  ClassMethod IndexLocation(className As %String, indexName As %String) As %String {     set storage = ##class(%Dictionary.ClassDefinition).%OpenId(className).Storages.GetAt(1).IndexLocation     quit $Name(@storage@(indexName)) }  }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>IndexLocation<\/i> \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0443\u0437\u043b\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0442\u0438\u043f\u0430 <i>SpatialIndex.Index<\/i>:<\/p>\n<pre><code>Class SpatialIndex.Test Extends %Persistent { Property Name As %String(MAXLEN = 300);  Property Latitude As %String;  Property Longitude As %String;  Index coord On (Latitude, Longitude) As SpatialIndex.Index; }<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <i>SpatialIndex.Test<\/i> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0442\u0438\u043f\u0430 <i>SpatialIndex.Index<\/i> \u0432 INT-\u043a\u043e\u0434\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code>zcoordInsertIndex(pID,pArg...) public {  \u00a0\u00a0\u00a0set indexer = ##class(SpatialIndex.Indexer).%New($Name(^SpatialIndex.TestI(&quot;coord&quot;)))  \u00a0\u00a0\u00a0do indexer.Insert(pArg(1),pArg(2),pID) } zcoordPurgeIndex() public {  \u00a0\u00a0\u00a0kill ^SpatialIndex.TestI(&quot;coord&quot;) } zcoordSegmentInsert(pIndexBuffer,pID,pArg...) public {  \u00a0\u00a0\u00a0do ..coordInsertIndex(pID, pArg...) } zcoordUpdateIndex(pID,pArg...) public {  \u00a0\u00a0\u00a0set indexer = ##class(SpatialIndex.Indexer).%New($Name(^SpatialIndex.TestI(&quot;coord&quot;)))  \u00a0\u00a0\u00a0do indexer.Delete(pArg(3),pArg(4),pID)  \u00a0\u00a0\u00a0do indexer.Insert(pArg(1),pArg(2),pID) }<\/code><\/pre>\n<p>  \u0410 \u043c\u0435\u0442\u043e\u0434\u044b <i>%SaveData<\/i>, <i>%DeleteData<\/i>, <i>%SQLInsert<\/i>, <i>%SQLUpdate<\/i>, <i>%SQLDelete<\/i> \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <i>%SaveData<\/i>:<\/p>\n<pre><code> if insert {  \u00a0\u00a0\u00a0\u00a0\/\/ ...  \u00a0\u00a0\u00a0\u00a0do ..coordInsertIndex(id,i%Latitude,i%Longitude,&quot;&quot;)  \u00a0\u00a0\u00a0\u00a0\/\/ ...  } else {  \u00a0\u00a0\u00a0\u00a0\/\/ ...  \u00a0\u00a0\u00a0\u00a0do ..coordUpdateIndex(id,i%Latitude,i%Longitude,zzc27v3,zzc27v2,&quot;&quot;)  \u00a0\u00a0\u00a0\u00a0\/\/ ...  }<\/code><\/pre>\n<p>  \u0412\u0435\u0441\u0435\u043b\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f <a href=\"https:\/\/github.com\/intersystems-ru\/spatialindex\/tree\/no-web-interface\">https:\/\/github.com\/intersystems-ru\/spatialindex\/tree\/no-web-interface<\/a>. \u042d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0432\u0435\u0442\u043a\u0443 \u0431\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0439\u0442\u0435 RuCut.zip \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code>do $system.OBJ.LoadDir(&quot;c:\\temp\\spatialindex&quot;,&quot;ck&quot;) do ##class(SpatialIndex.Test).load(&quot;c:\\temp\\rucut.txt&quot;) <\/code><\/pre>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 rucut.txt \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e 100\u2019000 \u043d\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445 \u0420\u043e\u0441\u0441\u0438\u0438 \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b. \u041c\u0435\u0442\u043e\u0434 <i>load<\/i> \u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <i>SpatialIndex.Test<\/i>. \u041f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u0435 <i>^SpatialIndex.TestI(\u00abcoord\u00bb)<\/i> \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0432\u0430\u0434\u0440\u043e\u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c <i>Latitude<\/i> \u0438 <i>Longitude<\/i>.<\/p>\n<h2>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/h2>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u2014 \u043f\u043e\u043b\u0434\u0435\u043b\u0430. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT * FROM SpatialIndex.Test WHERE %ID %FIND search_index(coord, 'window', 'minx=56,miny=56,maxx=57,maxy=57') <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c <i>%ID %FIND search_index<\/i> \u2014 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0451\u0442 \u0438\u043c\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <i>(&#8216;window&#8217;, &#8216;minx=56,miny=56,maxx=57,maxy=57)<\/i> \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 <i>Find<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 <i>SpatialIndex.Index<\/i>):<\/p>\n<pre><code>ClassMethod Find(queryType As %Binary, queryParams As %String) As %Library.Binary [ CodeMode = generator, ServerOnly = 1, SqlProc ] {     if %mode'=&quot;method&quot; { \/\/'    \t set IndexGlobal = ..IndexLocation(%class,%property)    \t set IndexGlobalQ = $$$QUOTE(IndexGlobal)    \t $$$GENERATE($C(9)_&quot;set result = ##class(SpatialIndex.SQLResult).%New()&quot;)    \t $$$GENERATE($C(9)_&quot;do result.PrepareFind($Name(&quot;_IndexGlobal_&quot;), queryType, queryParams)&quot;)    \t $$$GENERATE($C(9)_&quot;quit result&quot;)     } }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0434\u0432\u0430 \u2014 <i>queryType<\/i> \u0438 <i>queryParams<\/i>, \u043d\u043e \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435. <\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>Find<\/i> \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441 <i>SpatialIndex.Index<\/i>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <i>z&lt;IndexName&gt;Find<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code>zcoordFind(queryType,queryParams) public { Set:'$isobject($get(%sqlcontext)) %sqlcontext=##class(%Library.ProcedureContext).%New()  \u00a0\u00a0\u00a0set result = ##class(SpatialIndex.SQLResult).%New()  \u00a0\u00a0\u00a0do result.PrepareFind($Name(^SpatialIndex.TestI(&quot;coord&quot;)), queryType, queryParams)  \u00a0\u00a0\u00a0quit result } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>Find<\/i> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <i>%SQL.AbstractFind<\/i>. \u041c\u0435\u0442\u043e\u0434\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u2014 <i>NextChunk<\/i>, <i>PreviousChunk<\/i> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u043e 64000 \u0431\u0438\u0442. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c <i>ID<\/i> \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0431\u0438\u0442 (\u043d\u043e\u043c\u0435\u0440_\u043a\u0443\u0441\u043a\u0430 * 64000 + \u043d\u043e\u043c\u0435\u0440_\u043f\u043e\u0437\u0438\u0446\u0438\u0438_\u0432\u043d\u0443\u0442\u0440\u0438_\u043a\u0443\u0441\u043a\u0430) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 1.<\/p>\n<pre><code>Class SpatialIndex.SQLResult Extends %SQL.AbstractFind {  Property ResultBits [ MultiDimensional, Private ];  Method %OnNew() As %Status [ Private, ServerOnly = 1 ] {     kill i%ResultBits     kill qHandle     quit $$$OK }  Method PrepareFind(indexGlobal As %String, queryType As %String, queryParams As %Binary) As %Status {     if queryType = &quot;window&quot; {    \t for i = 1:1:4 {    \t\t set item = $Piece(queryParams, &quot;,&quot;, i)    \t\t set param = $Piece(item, &quot;=&quot;, 1)    \t\t set value = $Piece(item, &quot;=&quot; ,2)    \t\t set arg(param) = value    \t }          set qHandle(&quot;indexGlobal&quot;) = indexGlobal          do ##class(SpatialIndex.QueryExecutor).InternalFindWindow(.qHandle,arg(&quot;minx&quot;),arg(&quot;miny&quot;),arg(&quot;maxx&quot;),arg(&quot;maxy&quot;))          set id = &quot;&quot;          for  {    \t      set id = $O(qHandle(&quot;data&quot;, id),1,idd)    \t      quit:id=&quot;&quot;         \t set tChunk = (idd\\64000)+1, tPos=(idd#64000)+1         \t set $BIT(i%ResultBits(tChunk),tPos) = 1          }       }     quit $$$OK }  Method ContainsItem(pItem As %String) As %Boolean {     set tChunk = (pItem\\64000)+1, tPos=(pItem#64000)+1     quit $bit($get(i%ResultBits(tChunk)),tPos) }  Method GetChunk(pChunk As %Integer) As %Binary {     quit $get(i%ResultBits(pChunk)) }  Method NextChunk(ByRef pChunk As %Integer = &quot;&quot;) As %Binary {     set pChunk = $order(i%ResultBits(pChunk),1,tBits)     quit:pChunk=&quot;&quot; &quot;&quot;     quit tBits }  Method PreviousChunk(ByRef pChunk As %Integer = &quot;&quot;) As %Binary {     set pChunk = $order(i%ResultBits(pChunk),-1,tBits)     quit:pChunk=&quot;&quot; &quot;&quot;     quit tBits } } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>InternalFindWindow<\/i> \u043a\u043b\u0430\u0441\u0441\u0430 <i>SpatialIndex.QueryExecutor<\/i> \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u043e\u0447\u0435\u043a, \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a. \u0414\u0430\u043b\u044c\u0448\u0435, \u0432 \u0446\u0438\u043a\u043b\u0435 FOR, <i>ID<\/i> \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b.<\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435 \u0410\u043d\u0434\u0440\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043f\u043e\u0438\u0441\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0432\u0430\u043b\u0430:<\/p>\n<pre><code class=\"sql\">SELECT * FROM SpatialIndex.Test WHERE %ID %FIND search_index(coord,'radius','x=55,y=55,radiusX=2,radiusY=2') and name %StartsWith 'Z' <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0435 <i>%FIND<\/i><\/h2>\n<p>  \u0423 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <i>SIZE<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0443. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0431\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 <i>%FIND<\/i> \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <i>SpatialIndex.Test<\/i>:<\/p>\n<pre><code>Index ByName on Name;<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u044d\u0442\u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code>write ##class(SpatialIndex.Test).%BuildIndices($LB(&quot;ByName&quot;))<\/code><\/pre>\n<p>  \u0418, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c TuneTable:<\/p>\n<pre><code>do $system.SQL.TuneTable(&quot;SpatialIndex.Test&quot;, 1)<\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"sql\">SELECT * FROM SpatialIndex.Test WHERE name %startswith 'za' and %ID %FIND search_index(coord,'radius','x=55,y=55,radiusX=2,radiusY=2') size ((10))<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/987\/fdc\/7cd\/987fdc7cd70836888656dab1c8110eee.png\"\/><\/p>\n<p>  \u0418\u043d\u0434\u0435\u043a\u0441 coord \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0451\u0442 \u043c\u0430\u043b\u043e \u0441\u0442\u0440\u043e\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u043f\u043e\u043b\u044e <i>Name<\/i> \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0414\u0440\u0443\u0433\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"sql\">SELECT * FROM SpatialIndex.Test WHERE name %startswith 'za' and %ID %FIND search_index(coord,'radius','x=55,y=55,radiusX=2,radiusY=2') size ((1000))<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d11\/71a\/17e\/d1171a17e0ea659c3aff5195fc22e2c9.png\"\/><\/p>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u043f\u043e\u043b\u044e <i>Name<\/i> \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 <i>coord<\/i>, \u0435\u0441\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u043e\u043a\u043e\u043b\u043e 100\u2019000 \u0441\u0442\u0440\u043e\u043a, \u00a0\u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e:<\/p>\n<pre><code class=\"sql\">SELECT * FROM SpatialIndex.Test WHERE name %startswith 'za' and %ID %FIND search_index(coord,'radius','x=55,y=55,radiusX=2,radiusY=2') size ((100000))<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b9\/a61\/77a\/5b9a6177acadb2f304da394cee4bd95b.png\"\/><\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u043e\u0434\u0441\u043f\u043e\u0440\u044c\u0435\u043c \u043a\u0440\u043e\u043c\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435, \u0431\u0443\u0434\u0443\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <i>%Library.FunctionalIndex<\/i> \u0438 <i>%SQL.AbstractFind<\/i>. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u2014 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0432 \u0441\u0442\u0443\u0434\u0438\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0432 \u043c\u0435\u043d\u044e \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u041a\u043b\u0430\u0441\u0441 -&gt; \u0423\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0438:  <\/p>\n<ul>\n<li><a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=RSQL_find\">%FIND<\/a><\/li>\n<li><a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=RSQL_searchindex\">search_index<\/a><\/li>\n<li><a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/documatic\/%25CSP.Documatic.cls?PAGE=CLASS&amp;LIBRARY=%25SYS&amp;CLASSNAME=%25SQL.AbstractFind\">%SQL.AbstractFind<\/a><\/li>\n<li><a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/documatic\/%25CSP.Documatic.cls?PAGE=CLASS&amp;LIBRARY=%25SYS&amp;CLASSNAME=%25Library.FunctionalIndex\">%Library.FunctionIndex<\/a><\/li>\n<\/ul>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/272689\/\"> http:\/\/habrahabr.ru\/post\/272689\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <a href=\"http:\/\/habrahabr.ru\/post\/272689\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6c7\/a54\/754\/6c7a547547284690aaf4668949b8b29e.jpg\" title=\"\u041d\u0438\u043a\u043e\u043b\u0430\u0439 \u0417\u0430\u0433\u0440\u0435\u043a\u043e\u0432 \u2014 \u041a\u0440\u0435\u0441\u0442\u044c\u044f\u043d\u0438\u043d \u0441 \u043a\u043e\u0441\u043e\u0439\" align=\"left\"\/><\/a><br \/>  \u0412 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0421\u0423\u0411\u0414 Cach\u00e9 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0435, <a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=GSQL_indices#GSQL_indices_bitmap\">bitmap<\/a> \u0438 <a href=\"http:\/\/docs.intersystems.com\/cache20152\/csp\/docbook\/DocBook.UI.Page.cls?KEY=GSQL_indices#GSQL_indices_bitslice\">bitslice<\/a>. \u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u044d\u0442\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2013.1 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c (\u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u043d\u0435 \u043f\u0443\u0433\u0430\u044e\u0442 \u0441\u043b\u043e\u0432\u0430 \u0442\u0438\u043f\u0430 \u043c\u0435\u0442\u043e\u0434-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-269986","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=269986"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269986\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}