You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by mm...@apache.org on 2022/05/24 12:56:45 UTC
[ignite-extensions] branch master updated: IGNITE-17021 Move ignite-geospatial to the Ignite Extensions (#143)
This is an automated email from the ASF dual-hosted git repository.
mmuzaf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new 66bef7a IGNITE-17021 Move ignite-geospatial to the Ignite Extensions (#143)
66bef7a is described below
commit 66bef7a85649bb8937807dd779554447608adef2
Author: Maxim Muzafarov <ma...@gmail.com>
AuthorDate: Tue May 24 15:56:40 2022 +0300
IGNITE-17021 Move ignite-geospatial to the Ignite Extensions (#143)
---
modules/geospatial-ext/examples/README.md | 34 ++
.../examples/README.txt | 2 +-
.../examples/config/example-default.xml | 76 +++
.../examples/config/example-ignite.xml | 31 +
.../core/src/test/config/examples.properties | 25 +
.../modules/core/src/test/config/log4j-test.xml | 97 +++
.../modules/core/src/test/config/tests.properties | 19 +
.../examples/pom-standalone-lgpl.xml | 120 ++++
modules/geospatial-ext/examples/pom-standalone.xml | 123 ++++
modules/geospatial-ext/examples/pom.xml | 199 ++++++
.../examples/datagrid/SpatialQueryExample.java | 107 ++++
.../SpatialQueryExampleMultiNodeSelfTest.java | 34 ++
.../examples/SpatialQueryExampleSelfTest.java | 35 ++
.../IgniteGeospatialLgplExamplesSelfTestSuite.java | 46 ++
modules/geospatial-ext/geospatial/README.txt | 46 ++
.../geospatial/licenses/apache-2.0.txt | 202 ++++++
.../core/src/test/config/examples.properties | 25 +
.../modules/core/src/test/config/log4j-test.xml | 97 +++
.../modules/core/src/test/config/tests.properties | 19 +
modules/geospatial-ext/geospatial/pom.xml | 135 ++++
.../query/h2/opt/GeoSpatialClientIndex.java | 85 +++
.../h2/opt/GeoSpatialClientIndexDefinition.java | 75 +++
.../query/h2/opt/GeoSpatialClientIndexFactory.java | 39 ++
.../processors/query/h2/opt/GeoSpatialIndex.java | 65 ++
.../query/h2/opt/GeoSpatialIndexDefinition.java | 70 +++
.../query/h2/opt/GeoSpatialIndexFactory.java | 69 +++
.../query/h2/opt/GeoSpatialIndexImpl.java | 381 ++++++++++++
.../processors/query/h2/opt/GeoSpatialUtils.java | 98 +++
.../processors/query/h2/opt/GeometryIndexKey.java | 49 ++
.../query/h2/opt/GridH2SpatialBaseIndex.java | 65 ++
.../query/h2/opt/GridH2SpatialClientIndex.java | 91 +++
.../query/h2/opt/GridH2SpatialIndex.java | 141 +++++
.../query/h2/H2IndexesSystemViewTest.java | 119 ++++
.../query/h2/H2IndexingAbstractGeoSelfTest.java | 676 +++++++++++++++++++++
.../processors/query/h2/H2IndexingGeoSelfTest.java | 30 +
.../query/h2/H2IndexingSegmentedGeoSelfTest.java | 30 +
.../testsuites/GeoSpatialIndexingTestSuite.java | 36 ++
modules/geospatial-ext/pom.xml | 63 ++
modules/hibernate-ext/examples/README.txt | 2 +-
pom.xml | 1 +
40 files changed, 3655 insertions(+), 2 deletions(-)
diff --git a/modules/geospatial-ext/examples/README.md b/modules/geospatial-ext/examples/README.md
new file mode 100644
index 0000000..8d8a26b
--- /dev/null
+++ b/modules/geospatial-ext/examples/README.md
@@ -0,0 +1,34 @@
+# Apache Ignite Examples
+
+This module contains examples of how to run [Apache Ignite](ignite.apache.org) and [Apache Ignite](ignite.apache.org) with 3rd party components.
+
+Instructions on how to start examples can be found in [README.txt](README.txt).
+
+## Running examples on JDK 9/10/11
+
+Ignite uses proprietary SDK APIs that are not available by default. See also [How to run Ignite on JDK 9,10 and 11](https://ignite.apache.org/docs/latest/setup#running-ignite-with-java-11-or-later)
+
+To set up local IDE to easier access to examples, it is possible to add following options as default for all applications
+
+``--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
+ --add-exports=java.base/sun.nio.ch=ALL-UNNAMED
+ --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
+ --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
+ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
+ --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
+ --illegal-access=permit``
+
+For example, for IntelliJ IDEA it is possible to use Application Templates.
+
+Use 'Run' -> 'Edit Configuration' menu.
+
+<img src="https://docs.google.com/drawings/d/e/2PACX-1vQFgjhrPsLPUmic8CA_s1YpjVwA2vQITxNsLrAKOecZxIQEZSb1Ps2XKh0QEn8z9vtYiUofnGek_cag/pub?w=960&h=720"/>
+
+## Contributing to Examples
+
+*Notice* When updating classpath of examples and in case any modifications required in [pom.xml](pom.xml)
+please make sure that corresponding changes were applied to
+ * [pom-standalone.xml](pom-standalone.xml),
+ * [pom-standalone-lgpl.xml](pom-standalone-lgpl.xml).
+
+ These pom files are finalized during release and placed to the `examples` folder with these examples code.
diff --git a/modules/hibernate-ext/examples/README.txt b/modules/geospatial-ext/examples/README.txt
similarity index 93%
copy from modules/hibernate-ext/examples/README.txt
copy to modules/geospatial-ext/examples/README.txt
index 8e3bce0..33281f3 100644
--- a/modules/hibernate-ext/examples/README.txt
+++ b/modules/geospatial-ext/examples/README.txt
@@ -20,7 +20,7 @@ at https://ignite.apache.org/download.cgi#sources.
There is a way to gain required libs from sources:
-Run "./mvnw clean install -DskipTests " at Apache Ignite sources.
+Run "mvn clean install -DskipTests " at Apache Ignite sources.
This case will install lgpl-based libs to local maven repository.
Required libs will also appear at /target/release-package/libs/optional sub-folders.
diff --git a/modules/geospatial-ext/examples/config/example-default.xml b/modules/geospatial-ext/examples/config/example-default.xml
new file mode 100644
index 0000000..e6c359d
--- /dev/null
+++ b/modules/geospatial-ext/examples/config/example-default.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!--Task execution events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!--Cache events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
diff --git a/modules/geospatial-ext/examples/config/example-ignite.xml b/modules/geospatial-ext/examples/config/example-ignite.xml
new file mode 100644
index 0000000..a3e7e22
--- /dev/null
+++ b/modules/geospatial-ext/examples/config/example-ignite.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <!-- Imports default Ignite configuration -->
+ <import resource="example-default.xml"/>
+
+ <bean parent="ignite.cfg"/>
+</beans>
diff --git a/modules/geospatial-ext/examples/modules/core/src/test/config/examples.properties b/modules/geospatial-ext/examples/modules/core/src/test/config/examples.properties
new file mode 100644
index 0000000..b1b8bc1
--- /dev/null
+++ b/modules/geospatial-ext/examples/modules/core/src/test/config/examples.properties
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ScalarCacheAffinityExample1=examples/config/example-ignite.xml
+ScalarCacheAffinityExample2=examples/config/example-ignite.xml
+ScalarCacheAffinitySimpleExample=examples/config/example-ignite.xml
+ScalarCacheExample=examples/config/example-ignite.xml
+ScalarCacheQueryExample=examples/config/example-ignite.xml
+ScalarCountGraphTrianglesExample=examples/config/example-ignite.xml
+ScalarPopularNumbersRealTimeExample=examples/config/example-ignite.xml
+DataRegionEexample=examples/config/example-data-regions.xml
\ No newline at end of file
diff --git a/modules/geospatial-ext/examples/modules/core/src/test/config/log4j-test.xml b/modules/geospatial-ext/examples/modules/core/src/test/config/log4j-test.xml
new file mode 100755
index 0000000..b78fa9c
--- /dev/null
+++ b/modules/geospatial-ext/examples/modules/core/src/test/config/log4j-test.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"
+ "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
+<!--
+ Log4j configuration.
+-->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <!--
+ Logs System.out messages to console.
+ -->
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <!-- Log to STDOUT. -->
+ <param name="Target" value="System.out"/>
+
+ <!-- Log from DEBUG and higher. -->
+ <param name="Threshold" value="DEBUG"/>
+
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+
+ <!-- Do not log beyond INFO level. -->
+ <filter class="org.apache.log4j.varia.LevelRangeFilter">
+ <param name="levelMin" value="DEBUG"/>
+ <param name="levelMax" value="INFO"/>
+ </filter>
+ </appender>
+
+ <!--
+ Logs all System.err messages to console.
+ -->
+ <appender name="CONSOLE_ERR" class="org.apache.log4j.ConsoleAppender">
+ <!-- Log to STDERR. -->
+ <param name="Target" value="System.err"/>
+
+ <!-- Log from WARN and higher. -->
+ <param name="Threshold" value="WARN"/>
+
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!--
+ Logs all output to specified file.
+ -->
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="Threshold" value="DEBUG"/>
+ <param name="File" value="${IGNITE_HOME}/work/log/ignite.log"/>
+ <param name="Append" value="true"/>
+ <param name="MaxFileSize" value="10MB"/>
+ <param name="MaxBackupIndex" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Disable all open source debugging. -->
+ <category name="org">
+ <level value="INFO"/>
+ </category>
+
+ <category name="org.eclipse.jetty">
+ <level value="INFO"/>
+ </category>
+
+ <!-- Default settings. -->
+ <root>
+ <!-- Print at info by default. -->
+ <level value="INFO"/>
+
+ <!-- Append to file and console. -->
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="CONSOLE_ERR"/>
+ </root>
+</log4j:configuration>
diff --git a/modules/geospatial-ext/examples/modules/core/src/test/config/tests.properties b/modules/geospatial-ext/examples/modules/core/src/test/config/tests.properties
new file mode 100644
index 0000000..7bdcbed
--- /dev/null
+++ b/modules/geospatial-ext/examples/modules/core/src/test/config/tests.properties
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Local address to bind to.
+local.ip=127.0.0.1
diff --git a/modules/geospatial-ext/examples/pom-standalone-lgpl.xml b/modules/geospatial-ext/examples/pom-standalone-lgpl.xml
new file mode 100644
index 0000000..f019d70
--- /dev/null
+++ b/modules/geospatial-ext/examples/pom-standalone-lgpl.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ POM file.
+-->
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <lgpl.folder>src/main/java</lgpl.folder>
+ </properties>
+
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial-ext-examples</artifactId>
+ <version>1.0.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-geospatial-ext</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>config</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${lgpl.folder}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/modules/geospatial-ext/examples/pom-standalone.xml b/modules/geospatial-ext/examples/pom-standalone.xml
new file mode 100644
index 0000000..21cb10c
--- /dev/null
+++ b/modules/geospatial-ext/examples/pom-standalone.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <lgpl.folder>src/main/java</lgpl.folder>
+ </properties>
+
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial-ext-examples</artifactId>
+ <version>1.0.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-log4j2</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-kubernetes</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-geospatial-ext</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>config</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${lgpl.folder}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/modules/geospatial-ext/examples/pom.xml b/modules/geospatial-ext/examples/pom.xml
new file mode 100644
index 0000000..5a762e0
--- /dev/null
+++ b/modules/geospatial-ext/examples/pom.xml
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial-parent-ext</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ignite-geospatial-ext-examples</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>${javax.cache.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <!--Remove exclusion while upgrading ignite-spring version to 5.0-->
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!--Remove spring-core and spring-beans dependencies while upgrading ignite-spring version to 5.0-->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-calcite</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>${javassist.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-geospatial</artifactId>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <lgpl.folder>src/main/java</lgpl.folder>
+ <lgpl.test.folder>src/test/java</lgpl.test.folder>
+ </properties>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${lgpl.folder}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>config</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${lgpl.folder}</source>
+ </sources>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>add-tests</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${lgpl.test.folder}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+
+ <configuration>
+ <additionalDependencies>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ </additionalDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/modules/geospatial-ext/examples/src/main/java/org/apache/ignite/examples/datagrid/SpatialQueryExample.java b/modules/geospatial-ext/examples/src/main/java/org/apache/ignite/examples/datagrid/SpatialQueryExample.java
new file mode 100644
index 0000000..8f7ce09
--- /dev/null
+++ b/modules/geospatial-ext/examples/src/main/java/org/apache/ignite/examples/datagrid/SpatialQueryExample.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.datagrid;
+
+import java.util.Collection;
+import java.util.Random;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.io.WKTReader;
+
+/**
+ * This examples shows the usage of geospatial queries and indexes in Apache Ignite.
+ * For more information please refer to the following technical documentation:
+ * http://apacheignite.readme.io/docs/geospatial-queries
+ */
+public class SpatialQueryExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = SpatialQueryExample.class.getSimpleName();
+
+ /** */
+ static final String MODULE_PATH = System.getProperty("user.dir");
+
+ /**
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws Exception {
+ // Starting Ignite node.
+ try (Ignite ignite = Ignition.start(MODULE_PATH + "/config/example-ignite.xml")) {
+ // Preparing the cache configuration.
+ CacheConfiguration<Integer, MapPoint> cc = new CacheConfiguration<>(CACHE_NAME);
+
+ // Setting the indexed types.
+ cc.setIndexedTypes(Integer.class, MapPoint.class);
+
+ // Starting the cache.
+ try (IgniteCache<Integer, MapPoint> cache = ignite.createCache(cc)) {
+ Random rnd = new Random();
+
+ WKTReader r = new WKTReader();
+
+ // Adding geometry points into the cache.
+ for (int i = 0; i < 1000; i++) {
+ int x = rnd.nextInt(10000);
+ int y = rnd.nextInt(10000);
+
+ Geometry geo = r.read("POINT(" + x + " " + y + ")");
+
+ cache.put(i, new MapPoint(geo));
+ }
+
+ // Query to fetch the points that fit into a specific polygon.
+ SqlQuery<Integer, MapPoint> query = new SqlQuery<>(MapPoint.class, "coords && ?");
+
+ // Selecting points that fit into a specific polygon.
+ for (int i = 0; i < 10; i++) {
+ // Defining the next polygon boundaries.
+ Geometry cond = r.read("POLYGON((0 0, 0 " + rnd.nextInt(10000) + ", " +
+ rnd.nextInt(10000) + " " + rnd.nextInt(10000) + ", " +
+ rnd.nextInt(10000) + " 0, 0 0))");
+
+ // Executing the query.
+ Collection<Cache.Entry<Integer, MapPoint>> entries = cache.query(query.setArgs(cond)).getAll();
+
+ // Printing number of points that fit into the area defined by the polygon.
+ System.out.println("Fetched points [cond=" + cond + ", cnt=" + entries.size() + ']');
+ }
+ }
+ }
+ }
+
+ /**
+ * MapPoint with indexed coordinates.
+ */
+ private static class MapPoint {
+ /** Coordinates. */
+ @QuerySqlField(index = true)
+ private Geometry coords;
+
+ /**
+ * @param coords Coordinates.
+ */
+ private MapPoint(Geometry coords) {
+ this.coords = coords;
+ }
+ }
+}
diff --git a/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleMultiNodeSelfTest.java b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleMultiNodeSelfTest.java
new file mode 100644
index 0000000..fcfe507
--- /dev/null
+++ b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleMultiNodeSelfTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples;
+
+import org.apache.ignite.examples.datagrid.SpatialQueryExample;
+
+/**
+ * * Tests {@link SpatialQueryExample} in the multi node mode.
+ */
+public class SpatialQueryExampleMultiNodeSelfTest extends SpatialQueryExampleSelfTest {
+ /** */
+ static final String MODULE_PATH = System.getProperty("user.dir");
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ for (int i = 0; i < RMT_NODES_CNT; i++)
+ startGrid("node-" + i, MODULE_PATH + "/config/example-ignite.xml");
+ }
+}
diff --git a/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java
new file mode 100644
index 0000000..ea88cff
--- /dev/null
+++ b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples;
+
+import org.apache.ignite.examples.datagrid.SpatialQueryExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+import org.junit.Test;
+
+/**
+ * Tests {@link SpatialQueryExample}.
+ */
+public class SpatialQueryExampleSelfTest extends GridAbstractExamplesTest {
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testSpatialQueryExample() throws Exception {
+ SpatialQueryExample.main(EMPTY_ARGS);
+ }
+}
diff --git a/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteGeospatialLgplExamplesSelfTestSuite.java b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteGeospatialLgplExamplesSelfTestSuite.java
new file mode 100644
index 0000000..97b81ec
--- /dev/null
+++ b/modules/geospatial-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteGeospatialLgplExamplesSelfTestSuite.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import org.apache.ignite.examples.SpatialQueryExampleMultiNodeSelfTest;
+import org.apache.ignite.examples.SpatialQueryExampleSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite. <p> Contains only Spring ignite examples tests.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ SpatialQueryExampleSelfTest.class,
+
+ // Multi-node.
+ SpatialQueryExampleMultiNodeSelfTest.class
+})
+public class IgniteGeospatialLgplExamplesSelfTestSuite {
+ /** */
+ @BeforeClass
+ public static void init() {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(IgniteGeospatialLgplExamplesSelfTestSuite.class));
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/README.txt b/modules/geospatial-ext/geospatial/README.txt
new file mode 100644
index 0000000..d8d70fd
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/README.txt
@@ -0,0 +1,46 @@
+Apache Ignite Geospatial Module
+-----------------------------
+
+Apache Ignite geospatial module provides capabilities to geospatial index cache type.
+
+To enable geospatial module when starting a standalone node, move 'optional/ignite-geospatial' folder to
+'libs' folder before running 'ggstart.{sh|bat}' script. The content of the module folder will
+be added to classpath in this case.
+Note! This module can be used only when Ignite indexing module is enabled.
+
+Importing geospatial Module In Maven Project
+------------------------------------------
+
+If you are using Maven to manage dependencies of your project, you can add geospatial module
+dependency like this (replace '${ignite.version}' with actual Ignite version you are
+interested in):
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ ...
+ <dependencies>
+ ...
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial-ext</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+
+
+LGPL dependencies
+-----------------
+
+Ignite includes the following optional LGPL dependencies:
+ - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
+
+Apache binary releases cannot include LGPL dependencies. If you would like include
+optional LGPL dependencies into your release, you should download the source release
+from Ignite website and do the build with the following maven command:
+
+mvn clean package -DskipTests
diff --git a/modules/geospatial-ext/geospatial/licenses/apache-2.0.txt b/modules/geospatial-ext/geospatial/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/modules/geospatial-ext/geospatial/modules/core/src/test/config/examples.properties b/modules/geospatial-ext/geospatial/modules/core/src/test/config/examples.properties
new file mode 100644
index 0000000..b1b8bc1
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/modules/core/src/test/config/examples.properties
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ScalarCacheAffinityExample1=examples/config/example-ignite.xml
+ScalarCacheAffinityExample2=examples/config/example-ignite.xml
+ScalarCacheAffinitySimpleExample=examples/config/example-ignite.xml
+ScalarCacheExample=examples/config/example-ignite.xml
+ScalarCacheQueryExample=examples/config/example-ignite.xml
+ScalarCountGraphTrianglesExample=examples/config/example-ignite.xml
+ScalarPopularNumbersRealTimeExample=examples/config/example-ignite.xml
+DataRegionEexample=examples/config/example-data-regions.xml
\ No newline at end of file
diff --git a/modules/geospatial-ext/geospatial/modules/core/src/test/config/log4j-test.xml b/modules/geospatial-ext/geospatial/modules/core/src/test/config/log4j-test.xml
new file mode 100755
index 0000000..b78fa9c
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/modules/core/src/test/config/log4j-test.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"
+ "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
+<!--
+ Log4j configuration.
+-->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <!--
+ Logs System.out messages to console.
+ -->
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <!-- Log to STDOUT. -->
+ <param name="Target" value="System.out"/>
+
+ <!-- Log from DEBUG and higher. -->
+ <param name="Threshold" value="DEBUG"/>
+
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+
+ <!-- Do not log beyond INFO level. -->
+ <filter class="org.apache.log4j.varia.LevelRangeFilter">
+ <param name="levelMin" value="DEBUG"/>
+ <param name="levelMax" value="INFO"/>
+ </filter>
+ </appender>
+
+ <!--
+ Logs all System.err messages to console.
+ -->
+ <appender name="CONSOLE_ERR" class="org.apache.log4j.ConsoleAppender">
+ <!-- Log to STDERR. -->
+ <param name="Target" value="System.err"/>
+
+ <!-- Log from WARN and higher. -->
+ <param name="Threshold" value="WARN"/>
+
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!--
+ Logs all output to specified file.
+ -->
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="Threshold" value="DEBUG"/>
+ <param name="File" value="${IGNITE_HOME}/work/log/ignite.log"/>
+ <param name="Append" value="true"/>
+ <param name="MaxFileSize" value="10MB"/>
+ <param name="MaxBackupIndex" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Disable all open source debugging. -->
+ <category name="org">
+ <level value="INFO"/>
+ </category>
+
+ <category name="org.eclipse.jetty">
+ <level value="INFO"/>
+ </category>
+
+ <!-- Default settings. -->
+ <root>
+ <!-- Print at info by default. -->
+ <level value="INFO"/>
+
+ <!-- Append to file and console. -->
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="CONSOLE_ERR"/>
+ </root>
+</log4j:configuration>
diff --git a/modules/geospatial-ext/geospatial/modules/core/src/test/config/tests.properties b/modules/geospatial-ext/geospatial/modules/core/src/test/config/tests.properties
new file mode 100644
index 0000000..7bdcbed
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/modules/core/src/test/config/tests.properties
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Local address to bind to.
+local.ip=127.0.0.1
diff --git a/modules/geospatial-ext/geospatial/pom.xml b/modules/geospatial-ext/geospatial/pom.xml
new file mode 100644
index 0000000..f071166
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/pom.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial-parent-ext</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ignite-geospatial-ext</artifactId>
+
+ <url>https://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.locationtech.jts</groupId>
+ <artifactId>jts-core</artifactId>
+ <version>1.15.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ignite-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>lgpl</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle.
+ This bundle is a fragment attached to the ignite-core bundle, as it contains and exports classes in
+ the org.apache.ignite.internal.processors.query.h2.opt in the same manner as ignite-indexing, thus
+ leading to a split package situation in OSGi.
+ -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Fragment-Host>${project.groupId}.ignite-core</Fragment-Host>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndex.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndex.java
new file mode 100644
index 0000000..847ed88
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndex.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.processors.query.h2.index.client.AbstractClientIndex;
+import org.apache.ignite.internal.util.lang.GridCursor;
+import org.h2.table.IndexColumn;
+import org.h2.table.TableFilter;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * Mock for client nodes to support Geo-Spatial indexes.
+ */
+public class GeoSpatialClientIndex extends AbstractClientIndex implements GeoSpatialIndex {
+ /** Index unique ID. */
+ private final UUID id = UUID.randomUUID();
+
+ /** */
+ private final GeoSpatialClientIndexDefinition def;
+
+ /**
+ * @param def Index definition.
+ */
+ public GeoSpatialClientIndex(GeoSpatialClientIndexDefinition def) {
+ this.def = def;
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return def.idxName().idxName();
+ }
+
+ /** */
+ public GridH2Table tbl() {
+ return def.tbl();
+ }
+
+ /** */
+ public List<IndexColumn> cols() {
+ return def.cols();
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCursor<IndexRow> find(int seg, TableFilter filter) {
+ throw unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCursor<IndexRow> findFirstOrLast(int seg, boolean first) {
+ throw unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long totalCount() {
+ throw unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCursor<IndexRow> findByGeometry(int seg, TableFilter filter, Geometry intersection) {
+ throw unsupported();
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexDefinition.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexDefinition.java
new file mode 100644
index 0000000..dc03d37
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexDefinition.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.apache.ignite.internal.cache.query.index.IndexDefinition;
+import org.apache.ignite.internal.cache.query.index.IndexName;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition;
+import org.h2.table.IndexColumn;
+
+/**
+ * Definition of Geo-Spatial client index.
+ */
+public class GeoSpatialClientIndexDefinition implements IndexDefinition {
+ /** */
+ private final LinkedHashMap<String, IndexKeyDefinition> keyDefs;
+
+ /** */
+ private final IndexName idxName;
+
+ /** */
+ private final GridH2Table tbl;
+
+ /** */
+ private final List<IndexColumn> cols;
+
+ /** */
+ public GeoSpatialClientIndexDefinition(
+ GridH2Table tbl,
+ IndexName idxName,
+ LinkedHashMap<String, IndexKeyDefinition> keyDefs,
+ List<IndexColumn> cols
+ ) {
+ this.idxName = idxName;
+ this.keyDefs = keyDefs;
+ this.tbl = tbl;
+ this.cols = cols;
+ }
+
+ /** */
+ public GridH2Table tbl() {
+ return tbl;
+ }
+
+ /** */
+ public List<IndexColumn> cols() {
+ return cols;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IndexName idxName() {
+ return idxName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public LinkedHashMap<String, IndexKeyDefinition> indexKeyDefinitions() {
+ return keyDefs;
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexFactory.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexFactory.java
new file mode 100644
index 0000000..e57f403
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialClientIndexFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import org.apache.ignite.internal.cache.query.index.Index;
+import org.apache.ignite.internal.cache.query.index.IndexDefinition;
+import org.apache.ignite.internal.cache.query.index.IndexFactory;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Index factory for creating Geo-Spatial indexes for client node.
+ */
+public class GeoSpatialClientIndexFactory implements IndexFactory {
+ /** Instance of the factory. */
+ public static final GeoSpatialClientIndexFactory INSTANCE = new GeoSpatialClientIndexFactory();
+
+ /** {@inheritDoc} */
+ @Override public Index createIndex(@Nullable GridCacheContext<?, ?> cctx, IndexDefinition definition) {
+ GeoSpatialClientIndexDefinition def = (GeoSpatialClientIndexDefinition)definition;
+
+ return new GeoSpatialClientIndex(def);
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndex.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndex.java
new file mode 100644
index 0000000..d29ae55
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndex.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.cache.query.index.Index;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.util.lang.GridCursor;
+import org.h2.table.TableFilter;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * Interface for geo spatial indexes.
+ */
+public interface GeoSpatialIndex extends Index {
+ /**
+ * Finds index rows in specifed segment with table filtering.
+ *
+ * @param segment Number of segment to find.
+ * @param filter Table filter.
+ * @return Cursor of found index rows.
+ */
+ public GridCursor<IndexRow> find(int segment, TableFilter filter);
+
+ /**
+ * Finds index rows in specifed segment with table filtering.
+ *
+ * @param segment Number of segment to find.
+ * @param filter Table filter.
+ * @param intersection Intersection geometry to find rows within it.
+ * @return Cursor of found index rows.
+ */
+ public GridCursor<IndexRow> findByGeometry(int segment, TableFilter filter, Geometry intersection);
+
+ /**
+ * Finds first or last index row for specified segment.
+ *
+ * @param firstOrLast if {@code true} then return first index row or otherwise last row.
+ * @param segment Number of segment to find.
+ * @return Cursor of found index rows.
+ */
+ public GridCursor<IndexRow> findFirstOrLast(int segment, boolean firstOrLast);
+
+ /**
+ * Counts index rows for all segments.
+ *
+ * @return total count of index rows.
+ */
+ public long totalCount() throws IgniteCheckedException;
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexDefinition.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexDefinition.java
new file mode 100644
index 0000000..83c6ed5
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexDefinition.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.LinkedHashMap;
+import org.apache.ignite.internal.cache.query.index.IndexDefinition;
+import org.apache.ignite.internal.cache.query.index.IndexName;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition;
+import org.apache.ignite.internal.processors.query.h2.index.QueryIndexRowHandler;
+
+/**
+ * Definition of geo spatial index.
+ */
+public class GeoSpatialIndexDefinition implements IndexDefinition {
+ /** */
+ private final QueryIndexRowHandler rowHnd;
+
+ /** */
+ private final LinkedHashMap<String, IndexKeyDefinition> keyDefs;
+
+ /** */
+ private final int segmentsCnt;
+
+ /** */
+ private final IndexName idxName;
+
+ /** */
+ public GeoSpatialIndexDefinition(IndexName idxName, LinkedHashMap<String, IndexKeyDefinition> keyDefs,
+ QueryIndexRowHandler rowHnd, int segmentsCnt) {
+ this.idxName = idxName;
+ this.rowHnd = rowHnd;
+ this.keyDefs = keyDefs;
+ this.segmentsCnt = segmentsCnt;
+ }
+
+ /** */
+ public QueryIndexRowHandler rowHandler() {
+ return rowHnd;
+ }
+
+ /** */
+ public int segmentsCnt() {
+ return segmentsCnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IndexName idxName() {
+ return idxName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public LinkedHashMap<String, IndexKeyDefinition> indexKeyDefinitions() {
+ return keyDefs;
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexFactory.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexFactory.java
new file mode 100644
index 0000000..f9223a2
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexFactory.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.List;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.cache.query.index.Index;
+import org.apache.ignite.internal.cache.query.index.IndexDefinition;
+import org.apache.ignite.internal.cache.query.index.IndexFactory;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.h2.message.DbException;
+import org.h2.result.SortOrder;
+import org.h2.table.IndexColumn;
+import org.h2.value.Value;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Index factory for creating geo spatial indexes.
+ */
+public class GeoSpatialIndexFactory implements IndexFactory {
+ /** Instance of the factory. */
+ public static final GeoSpatialIndexFactory INSTANCE = new GeoSpatialIndexFactory();
+
+ /** {@inheritDoc} */
+ @Override public Index createIndex(@Nullable GridCacheContext<?, ?> cctx, IndexDefinition definition) {
+ GeoSpatialIndexDefinition def = (GeoSpatialIndexDefinition)definition;
+
+ try {
+ List<IndexColumn> cols = def.rowHandler().getH2IdxColumns();
+
+ if (cols.size() > 1)
+ throw DbException.getUnsupportedException("can only do one column");
+
+ if ((cols.get(0).sortType & SortOrder.DESCENDING) != 0)
+ throw DbException.getUnsupportedException("cannot do descending");
+
+ if ((cols.get(0).sortType & SortOrder.NULLS_FIRST) != 0)
+ throw DbException.getUnsupportedException("cannot do nulls first");
+
+ if ((cols.get(0).sortType & SortOrder.NULLS_LAST) != 0)
+ throw DbException.getUnsupportedException("cannot do nulls last");
+
+ if (cols.get(0).column.getType() != Value.GEOMETRY) {
+ throw DbException.getUnsupportedException("spatial index on non-geometry column, " +
+ cols.get(0).column.getCreateSQL());
+ }
+
+ return new GeoSpatialIndexImpl(cctx, def);
+ }
+ catch (Exception e) {
+ throw new IgniteException("Failed to instantiate: GridH2SpatialIndex", e);
+ }
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexImpl.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexImpl.java
new file mode 100644
index 0000000..a4bf9b4
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialIndexImpl.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.cache.query.index.AbstractIndex;
+import org.apache.ignite.internal.cache.query.index.SingleCursor;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.apache.ignite.internal.processors.query.h2.H2Utils;
+import org.apache.ignite.internal.util.GridCursorIteratorWrapper;
+import org.apache.ignite.internal.util.lang.GridCursor;
+import org.apache.ignite.spi.indexing.IndexingQueryCacheFilter;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.h2.index.IndexLookupBatch;
+import org.h2.message.DbException;
+import org.h2.mvstore.MVStore;
+import org.h2.mvstore.rtree.MVRTreeMap;
+import org.h2.mvstore.rtree.SpatialKey;
+import org.h2.table.TableFilter;
+import org.jetbrains.annotations.Nullable;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * Spatial index implementation.
+ */
+public class GeoSpatialIndexImpl extends AbstractIndex implements GeoSpatialIndex {
+ /** Index unique ID. */
+ private final UUID id = UUID.randomUUID();
+
+ /** Cache context. */
+ private final GridCacheContext cctx;
+
+ /** */
+ final GeoSpatialIndexDefinition def;
+
+ /** */
+ private final ReadWriteLock lock = new ReentrantReadWriteLock();
+
+ /** */
+ private volatile long rowCnt;
+
+ /** */
+ private long rowIds;
+
+ /** */
+ private boolean closed;
+
+ /** */
+ private final MVRTreeMap<Long>[] segments;
+
+ /** */
+ private final Map<Long, IndexRow> idToRow = new HashMap<>();
+
+ /** */
+ private final Map<Object, Long> keyToId = new HashMap<>();
+
+ /** */
+ private final MVStore store;
+
+ /**
+ * @param cctx Cache context.
+ * @param def Index definition.
+ */
+ public GeoSpatialIndexImpl(GridCacheContext cctx, GeoSpatialIndexDefinition def) {
+ this.cctx = cctx;
+ this.def = def;
+
+ // Index in memory
+ store = MVStore.open(null);
+
+ segments = new MVRTreeMap[def.segmentsCnt()];
+
+ for (int i = 0; i < def.segmentsCnt(); i++)
+ segments[i] = store.openMap("spatialIndex-" + i, new MVRTreeMap.Builder<Long>());
+ }
+
+ /** */
+ IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
+ GridH2Table table = def.rowHandler().getTable();
+
+ if (table.isPartitioned()) {
+ assert filter > 0; // Lookup batch will not be created for the first table filter.
+
+ throw DbException.throwInternalError(
+ "Table with a spatial index must be the first in the query: " + table);
+ }
+
+ return null; // Support must be explicitly added.
+ }
+
+ /**
+ * Check closed.
+ */
+ private void checkClosed() {
+ if (closed)
+ throw DbException.throwInternalError();
+ }
+
+ /**
+ * @param rowId Row id.
+ * @return Envelope.
+ */
+ private SpatialKey getEnvelope(CacheDataRow row, long rowId) {
+ Geometry g = (Geometry)def.rowHandler().indexKey(0, row).key();
+
+ return getEnvelope(g, rowId);
+ }
+
+ /**
+ * @param rowId Row id.
+ * @return Envelope.
+ */
+ private SpatialKey getEnvelope(Geometry key, long rowId) {
+ Envelope env = key.getEnvelopeInternal();
+
+ return new SpatialKey(rowId,
+ (float)env.getMinX(), (float)env.getMaxX(),
+ (float)env.getMinY(), (float)env.getMaxY());
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return def.idxName().idxName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean canHandle(CacheDataRow row) throws IgniteCheckedException {
+ return cctx.kernalContext().query().belongsToTable(
+ cctx, def.idxName().cacheName(), def.idxName().tableName(), row.key(), row.value());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onUpdate(@Nullable CacheDataRow oldRow, @Nullable CacheDataRow newRow,
+ boolean prevRowAvailable) throws IgniteCheckedException {
+
+ Lock l = lock.writeLock();
+
+ l.lock();
+
+ try {
+ if (oldRow != null && prevRowAvailable)
+ remove(oldRow);
+
+ if (newRow != null)
+ put(newRow);
+ }
+ finally {
+ l.unlock();
+ }
+ }
+
+ /** */
+ private boolean put(CacheDataRow row) {
+ checkClosed();
+
+ Object key = def.rowHandler().key(row);
+
+ assert key != null;
+
+ final int seg = segmentForRow(row);
+
+ Long rowId = keyToId.get(key);
+
+ if (rowId != null) {
+ Long oldRowId = segments[seg].remove(getEnvelope(idToRow.get(rowId).cacheDataRow(), rowId));
+
+ assert rowId.equals(oldRowId);
+ }
+ else {
+ rowId = ++rowIds;
+
+ keyToId.put(key, rowId);
+ }
+
+ IndexRow old = idToRow.put(rowId, new IndexRowImpl(def.rowHandler(), row));
+
+ segments[seg].put(getEnvelope(row, rowId), rowId);
+
+ if (old == null)
+ rowCnt++; // No replace.
+
+ return old != null;
+ }
+
+ /** */
+ private boolean remove(CacheDataRow row) {
+ checkClosed();
+
+ Object key = def.rowHandler().key(row);
+
+ assert key != null;
+
+ Long rowId = keyToId.remove(key);
+
+ assert rowId != null;
+
+ IndexRow oldRow = idToRow.remove(rowId);
+
+ assert oldRow != null;
+
+ final int seg = segmentForRow(row);
+
+ if (!segments[seg].remove(getEnvelope(row, rowId), rowId))
+ throw DbException.throwInternalError("row not found");
+
+ rowCnt--;
+
+ return oldRow != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy(boolean softDelete) {
+ Lock l = lock.writeLock();
+
+ l.lock();
+
+ try {
+ closed = true;
+
+ store.close();
+ }
+ finally {
+ l.unlock();
+ }
+ }
+
+ /**
+ * @param filter Table filter.
+ * @return Cursor.
+ */
+ @Override public GridCursor<IndexRow> find(int seg, TableFilter filter) {
+ Lock l = lock.readLock();
+
+ l.lock();
+
+ try {
+ checkClosed();
+
+ final MVRTreeMap<Long> segment = segments[seg];
+
+ return rowIterator(segment.keySet().iterator(), filter);
+ }
+ finally {
+ l.unlock();
+ }
+ }
+
+ /**
+ * @param i Spatial key iterator.
+ * @param filter Table filter.
+ * @return Iterator over rows.
+ */
+ @SuppressWarnings("unchecked")
+ private GridCursor<IndexRow> rowIterator(Iterator<SpatialKey> i, TableFilter filter) {
+ if (!i.hasNext())
+ return IndexValueCursor.EMPTY;
+
+ long time = System.currentTimeMillis();
+
+ IndexingQueryFilter qryFilter = null;
+
+ QueryContext qctx = H2Utils.context(filter.getSession());
+
+ if (qctx != null)
+ qryFilter = qctx.filter();
+
+ IndexingQueryCacheFilter qryCacheFilter = qryFilter != null ?
+ qryFilter.forCache(def.rowHandler().getTable().cacheName()) : null;
+
+ List<IndexRow> rows = new ArrayList<>();
+
+ do {
+ IndexRow row = idToRow.get(i.next().getId());
+
+ CacheDataRow cacheRow = row.cacheDataRow();
+
+ assert row != null;
+
+ if (cacheRow.expireTime() != 0 && cacheRow.expireTime() <= time)
+ continue;
+
+ if (qryCacheFilter == null || qryCacheFilter.applyPartition(cacheRow.partition()))
+ rows.add(row);
+ }
+ while (i.hasNext());
+
+ return new GridCursorIteratorWrapper(rows.iterator());
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCursor<IndexRow> findFirstOrLast(int seg, boolean first) {
+ Lock l = lock.readLock();
+
+ l.lock();
+
+ try {
+ checkClosed();
+
+ if (!first)
+ throw DbException.throwInternalError("Spatial Index can only be fetch by ascending order");
+
+ final MVRTreeMap<Long> segment = segments[seg];
+
+ GridCursor<IndexRow> iter = rowIterator(segment.keySet().iterator(), null);
+
+ return new SingleCursor<>(iter.next() ? iter.get() : null);
+ }
+ catch (IgniteCheckedException e) {
+ throw DbException.convert(e);
+ }
+ finally {
+ l.unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public long totalCount() {
+ return rowCnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCursor<IndexRow> findByGeometry(int seg, TableFilter filter, Geometry intersection) {
+ Lock l = lock.readLock();
+
+ l.lock();
+
+ try {
+ if (intersection == null)
+ return find(seg, filter);
+
+ final MVRTreeMap<Long> segment = segments[seg];
+
+ return rowIterator(segment.findIntersectingKeys(getEnvelope(intersection, 0)), filter);
+ }
+ finally {
+ l.unlock();
+ }
+ }
+
+ /**
+ * @param row cache row.
+ * @return Segment ID for given key
+ */
+ public int segmentForRow(CacheDataRow row) {
+ return segments.length == 1 ? 0 : (def.rowHandler().partition(row) % segments.length);
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialUtils.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialUtils.java
new file mode 100644
index 0000000..bb09b98
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeoSpatialUtils.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.cache.query.index.Index;
+import org.apache.ignite.internal.cache.query.index.IndexDefinition;
+import org.apache.ignite.internal.cache.query.index.IndexName;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyTypeRegistry;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKeyFactory;
+import org.apache.ignite.internal.processors.query.h2.index.QueryIndexKeyDefinitionProvider;
+import org.apache.ignite.internal.processors.query.h2.index.QueryIndexRowHandler;
+import org.h2.table.IndexColumn;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * This class is entrypoint for creating Geo-Spatial index.
+ */
+public class GeoSpatialUtils {
+ /** Dummy key types. */
+ private static final IndexKeyTypeSettings DUMMY_SETTINGS = new IndexKeyTypeSettings();
+
+ static {
+ IndexKeyFactory.register(IndexKeyTypes.GEOMETRY, k -> new GeometryIndexKey((Geometry)k));
+ }
+
+ /** */
+ public static GridH2IndexBase createIndex(GridH2Table tbl, String idxName, List<IndexColumn> cols) {
+ try {
+ IndexName name = new IndexName(tbl.cacheName(), tbl.getSchema().getName(), tbl.getName(), idxName);
+
+ LinkedHashMap<String, IndexKeyDefinition> keyDefs = new QueryIndexKeyDefinitionProvider(tbl, cols).keyDefinitions();
+
+ if (tbl.cacheInfo().affinityNode())
+ return createIndex(tbl, name, keyDefs, cols);
+ else
+ return createClientIndex(tbl, name, keyDefs, cols);
+ }
+ catch (Exception e) {
+ throw new IgniteException("Failed to instantiate", e);
+ }
+ }
+
+ /** Creates index for server Ignite nodes. */
+ private static GridH2SpatialIndex createIndex(
+ GridH2Table tbl,
+ IndexName name,
+ LinkedHashMap<String, IndexKeyDefinition> keyDefs,
+ List<IndexColumn> cols
+ ) {
+ List<InlineIndexKeyType> idxKeyTypes = InlineIndexKeyTypeRegistry.types(keyDefs.values(), DUMMY_SETTINGS);
+
+ QueryIndexRowHandler rowHnd = new QueryIndexRowHandler(tbl, cols, keyDefs, idxKeyTypes, DUMMY_SETTINGS);
+
+ final int segments = tbl.rowDescriptor().cacheInfo().config().getQueryParallelism();
+
+ IndexDefinition def = new GeoSpatialIndexDefinition(name, keyDefs, rowHnd, segments);
+
+ Index idx = tbl.idxProc().createIndex(tbl.cacheContext(), GeoSpatialIndexFactory.INSTANCE, def);
+
+ return new GridH2SpatialIndex(idx.unwrap(GeoSpatialIndexImpl.class));
+ }
+
+ /** Creates index for client Ignite nodes. */
+ private static GridH2SpatialClientIndex createClientIndex(
+ GridH2Table tbl,
+ IndexName name,
+ LinkedHashMap<String, IndexKeyDefinition> keyDefs,
+ List<IndexColumn> cols
+ ) {
+ IndexDefinition def = new GeoSpatialClientIndexDefinition(tbl, name, keyDefs, cols);
+
+ Index idx = tbl.idxProc().createIndex(tbl.cacheContext(), GeoSpatialClientIndexFactory.INSTANCE, def);
+
+ return new GridH2SpatialClientIndex(idx.unwrap(GeoSpatialClientIndex.class));
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeometryIndexKey.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeometryIndexKey.java
new file mode 100644
index 0000000..0532d0c
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GeometryIndexKey.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey;
+import org.h2.value.ValueGeometry;
+import org.locationtech.jts.geom.Geometry;
+
+/** */
+public class GeometryIndexKey implements IndexKey {
+ /** */
+ private final ValueGeometry geometry;
+
+ /** */
+ public GeometryIndexKey(Geometry g) {
+ geometry = ValueGeometry.getFromGeometry(g);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object key() {
+ return geometry.getGeometry();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int type() {
+ return IndexKeyTypes.GEOMETRY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compare(IndexKey o) {
+ return geometry.compareTo(((GeometryIndexKey)o).geometry, null);
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialBaseIndex.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialBaseIndex.java
new file mode 100644
index 0000000..370ba2e
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialBaseIndex.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import java.util.HashSet;
+import org.h2.engine.Session;
+import org.h2.index.IndexType;
+import org.h2.index.SpatialIndex;
+import org.h2.index.SpatialTreeIndex;
+import org.h2.result.SearchRow;
+import org.h2.result.SortOrder;
+import org.h2.table.Column;
+import org.h2.table.IndexColumn;
+import org.h2.table.TableFilter;
+
+/** Base class for Geo-Spatial indexes to register in the H2 engine. */
+public abstract class GridH2SpatialBaseIndex extends GridH2IndexBase implements SpatialIndex {
+ /**
+ * Constructor.
+ *
+ * @param tbl Table.
+ * @param name Index name.
+ * @param cols Indexed columns.
+ * @param type Index type.
+ */
+ protected GridH2SpatialBaseIndex(GridH2Table tbl, String name, IndexColumn[] cols, IndexType type) {
+ super(tbl, name, cols, type);
+ }
+
+ /** {@inheritDoc} */
+ @Override public H2CacheRow put(H2CacheRow row) {
+ throw new IllegalStateException("Must not be invoked.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putx(H2CacheRow row) {
+ throw new IllegalStateException("Must not be invoked.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean removex(SearchRow row) {
+ throw new IllegalStateException("Must not be invoked.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter,
+ SortOrder sortOrder, HashSet<Column> cols) {
+ return SpatialTreeIndex.getCostRangeIndex(masks, columns) / 10d;
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialClientIndex.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialClientIndex.java
new file mode 100644
index 0000000..5712fef
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialClientIndex.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import org.apache.ignite.internal.processors.query.h2.index.client.AbstractClientIndex;
+import org.apache.ignite.spi.indexing.IndexingQueryCacheFilter;
+import org.h2.engine.Session;
+import org.h2.index.Cursor;
+import org.h2.index.IndexType;
+import org.h2.result.SearchRow;
+import org.h2.table.IndexColumn;
+import org.h2.table.TableFilter;
+
+/** Mock for registering Geo-Spatial indexes on client nodes in the H2 engine. */
+public class GridH2SpatialClientIndex extends GridH2SpatialBaseIndex {
+ /** */
+ private final AbstractClientIndex delegate;
+
+ /** */
+ public GridH2SpatialClientIndex(GeoSpatialClientIndex delegate) {
+ super(delegate.tbl(), delegate.name(), delegate.cols().toArray(new IndexColumn[0]),
+ IndexType.createNonUnique(false, false, true));
+
+ this.delegate = delegate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public H2CacheRow put(H2CacheRow row) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putx(H2CacheRow row) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean removex(SearchRow row) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int segmentsCount() {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long totalRowCount(IndexingQueryCacheFilter partsFilter) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor find(Session ses, SearchRow first, SearchRow last) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean canGetFirstOrLast() {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor findFirstOrLast(Session ses, boolean first) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getRowCount(Session ses) {
+ throw delegate.unsupported();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last, SearchRow intersection) {
+ throw delegate.unsupported();
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
new file mode 100644
index 0000000..6132323
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.opt;
+
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor;
+import org.apache.ignite.internal.processors.query.h2.H2Cursor;
+import org.apache.ignite.internal.processors.query.h2.H2Utils;
+import org.apache.ignite.internal.util.lang.GridCursor;
+import org.apache.ignite.spi.indexing.IndexingQueryCacheFilter;
+import org.h2.engine.Session;
+import org.h2.index.Cursor;
+import org.h2.index.IndexLookupBatch;
+import org.h2.index.IndexType;
+import org.h2.result.SearchRow;
+import org.h2.table.IndexColumn;
+import org.h2.table.TableFilter;
+import org.h2.value.Value;
+import org.h2.value.ValueGeometry;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ * H2 wrapper for a Geo-Spatial index.
+ */
+public class GridH2SpatialIndex extends GridH2SpatialBaseIndex {
+ /** */
+ private final GeoSpatialIndexImpl delegate;
+
+ /** */
+ public GridH2SpatialIndex(GeoSpatialIndexImpl idx) {
+ super(idx.def.rowHandler().getTable(),
+ idx.def.idxName().idxName(),
+ idx.def.rowHandler().getH2IdxColumns().toArray(new IndexColumn[0]),
+ IndexType.createNonUnique(false, false, true));
+
+ delegate = idx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
+ return delegate.createLookupBatch(filters, filter);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int segmentsCount() {
+ return delegate.def.segmentsCnt();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy(boolean rmIdx) {
+ delegate.destroy(!rmIdx);
+
+ super.destroy(rmIdx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor find(TableFilter filter, SearchRow first, SearchRow last) {
+ GridCursor<IndexRow> cursor = delegate.find(segment(H2Utils.context(filter.getSession())), filter);
+
+ GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
+
+ return new H2Cursor(h2cursor);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor find(Session ses, SearchRow first, SearchRow last) {
+ GridCursor<IndexRow> cursor = delegate.find(segment(H2Utils.context(ses)), null);
+
+ GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
+
+ return new H2Cursor(h2cursor);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean canGetFirstOrLast() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor findFirstOrLast(Session ses, boolean first) {
+ GridCursor<IndexRow> cursor = delegate.findFirstOrLast(H2Utils.context(ses).segment(), first);
+
+ GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
+
+ return new H2Cursor(h2cursor);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getRowCount(Session ses) {
+ return delegate.totalCount();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getRowCountApproximation() {
+ return delegate.totalCount();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long totalRowCount(IndexingQueryCacheFilter partsFilter) {
+ return delegate.totalCount();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last,
+ SearchRow intersection) {
+
+ Value v = intersection.getValue(columnIds[0]);
+ Geometry g = ((ValueGeometry)v.convertTo(Value.GEOMETRY)).getGeometry();
+
+ int seg = segmentsCount() == 1 ? 0 : H2Utils.context(filter.getSession()).segment();
+
+ GridCursor<IndexRow> cursor = delegate.findByGeometry(seg, filter, g);
+
+ GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
+
+ return new H2Cursor(h2cursor);
+ }
+
+ /** */
+ private H2Row mapIndexRow(IndexRow row) {
+ if (row == null)
+ return null;
+
+ return new H2CacheRow(rowDescriptor(), row.cacheDataRow());
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexesSystemViewTest.java b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexesSystemViewTest.java
new file mode 100644
index 0000000..35b5847
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexesSystemViewTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.ignite.internal.processors.query.h2;
+
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ * Test expose SPATIAL indexes through SQL system view INDEXES.
+ */
+public class H2IndexesSystemViewTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration() throws Exception {
+ return super.getConfiguration().setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME));
+ }
+
+ /**
+ * Test indexes system view.
+ *
+ * @throws Exception in case of failure.
+ */
+ @Test
+ public void testIndexesView() throws Exception {
+ IgniteEx srv = startGrid(getConfiguration());
+
+ IgniteEx client = startClientGrid(getConfiguration().setIgniteInstanceName("CLIENT"));
+
+ execSql("CREATE TABLE PUBLIC.AFF_CACHE (ID1 INT, ID2 INT, GEOM GEOMETRY, PRIMARY KEY (ID1))");
+
+ execSql("CREATE SPATIAL INDEX IDX_GEO_1 ON PUBLIC.AFF_CACHE(GEOM)");
+
+ String idxSql = "SELECT " +
+ " CACHE_ID," +
+ " CACHE_NAME," +
+ " SCHEMA_NAME," +
+ " TABLE_NAME," +
+ " INDEX_NAME," +
+ " INDEX_TYPE," +
+ " COLUMNS," +
+ " IS_PK," +
+ " IS_UNIQUE," +
+ " INLINE_SIZE" +
+ " FROM SYS.INDEXES ORDER BY TABLE_NAME, INDEX_NAME";
+
+ List<List<?>> srvNodeIndexes = execSql(srv, idxSql);
+
+ List<List<?>> clientNodeNodeIndexes = execSql(client, idxSql);
+
+ for (List<?> idx : clientNodeNodeIndexes)
+ assertTrue(srvNodeIndexes.contains(idx));
+
+ Object[][] expectedResults = {
+ {-825022849, "SQL_PUBLIC_AFF_CACHE", "PUBLIC", "AFF_CACHE", "IDX_GEO_1", "SPATIAL", "\"GEOM\" ASC", false, false, null},
+ {-825022849, "SQL_PUBLIC_AFF_CACHE", "PUBLIC", "AFF_CACHE", "__SCAN_", "SCAN", null, false, false, null},
+ {-825022849, "SQL_PUBLIC_AFF_CACHE", "PUBLIC", "AFF_CACHE", "_key_PK", "BTREE", "\"ID1\" ASC", true, true, 5},
+ {-825022849, "SQL_PUBLIC_AFF_CACHE", "PUBLIC", "AFF_CACHE", "_key_PK_hash", "HASH", "\"ID1\" ASC", false, true, null}
+ };
+
+ for (int i = 0; i < srvNodeIndexes.size(); i++) {
+ List<?> resRow = srvNodeIndexes.get(i);
+
+ Object[] expRow = expectedResults[i];
+
+ assertEquals(expRow.length, resRow.size());
+
+ for (int j = 0; j < expRow.length; j++)
+ assertEquals(expRow[j], resRow.get(j));
+ }
+ }
+
+ /**
+ * @param sql Sql.
+ * @param args Args.
+ */
+ private List<List<?>> execSql(String sql, Object... args) {
+ return execSql(grid(), sql, args);
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param sql Sql.
+ * @param args Args.
+ */
+ @SuppressWarnings("unchecked")
+ private List<List<?>> execSql(Ignite ignite, String sql, Object... args) {
+ IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
+
+ SqlFieldsQuery qry = new SqlFieldsQuery(sql);
+
+ if (args != null && args.length > 0)
+ qry.setArgs(args);
+
+ return cache.query(qry).getAll();
+ }
+
+}
diff --git a/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
new file mode 100644
index 0000000..5cd3de2
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -0,0 +1,676 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
+
+/**
+ * Geo-indexing test.
+ */
+@RunWith(Parameterized.class)
+public abstract class H2IndexingAbstractGeoSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final int CNT = 100;
+
+ /** */
+ private static final long DUR = 60000L;
+
+ /** Number of generated samples. */
+ public static final int ENEMYCAMP_SAMPLES_COUNT = 500;
+
+ /** Number of generated samples. */
+ public static final int ENEMY_SAMPLES_COUNT = 1000;
+
+ /** */
+ private static final int QRY_PARALLELISM_LVL = 7;
+
+ /** Segmented index flag. */
+ private final boolean segmented;
+
+ /** Node that creates a Geo-Spatial index. {@code true} for coordinator node, otherwise client node. */
+ @Parameterized.Parameter
+ public boolean crtNode;
+
+ /** Node that stars a query over a Geo-Spatial index. {@code true} for coordinator node, otherwise client node. */
+ @Parameterized.Parameter(1)
+ public boolean qryNode;
+
+ /** */
+ private IgniteEx cln;
+
+ /** */
+ private IgniteEx srv;
+
+ /** */
+ @Parameterized.Parameters(name = "crtNode={0}, qryNode={1}")
+ public static Collection<Object[]> parameters() {
+ List<Boolean> nodes = F.asList(false, true);
+
+ return GridTestUtils.cartesianProduct(nodes, nodes);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param segmented Segmented index flag.
+ */
+ protected H2IndexingAbstractGeoSelfTest(boolean segmented) {
+ this.segmented = segmented;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void beforeTest() throws Exception {
+ srv = startGrids(3);
+
+ cln = startClientGrid();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void afterTest() {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return DUR * 3;
+ }
+
+ /**
+ * Create cache.
+ *
+ * @param name Name.
+ * @param partitioned Partitioned flag.
+ * @param keyCls Key class.
+ * @param valCls Value class.
+ * @return Cache.
+ * @throws Exception If failed.
+ */
+ protected <K, V> IgniteCache<K, V> createCache(String name, boolean partitioned, Class<?> keyCls, Class<?> valCls)
+ throws Exception {
+ return createCache(name, partitioned, keyCls, valCls, false);
+ }
+
+ /**
+ * Create cache.
+ *
+ * @param name Name.
+ * @param partitioned Partitioned flag.
+ * @param keyCls Key class.
+ * @param valCls Value class.
+ * @param dynamicIdx Whether index should be created dynamically.
+ * @return Cache.
+ * @throws Exception If failed.
+ */
+ protected <K, V> IgniteCache<K, V> createCache(String name, boolean partitioned, Class<?> keyCls, Class<?> valCls,
+ boolean dynamicIdx) throws Exception {
+ CacheConfiguration<K, V> ccfg = cacheConfig(name, partitioned, keyCls, valCls);
+
+ IgniteEx crtIgn = crtNode ? srv : cln;
+
+ if (dynamicIdx) {
+ Collection<QueryEntity> entities = ccfg.getQueryEntities();
+
+ assertEquals(1, entities.size());
+
+ QueryEntity entity = entities.iterator().next();
+
+ Collection<QueryIndex> idxs = new ArrayList<>(entity.getIndexes());
+
+ entity.setIndexes(null);
+
+ crtIgn.context().cache().dynamicStartSqlCache(ccfg).get();
+
+ // Process indexes dynamically.
+ for (QueryIndex idx : idxs) {
+ QueryEntity normalEntity = QueryUtils.normalizeQueryEntity(grid(0).context(), entity, ccfg.isSqlEscapeAll());
+
+ createDynamicIndex(crtIgn.cache(name), normalEntity, idx);
+ }
+ }
+ else
+ crtIgn.getOrCreateCache(ccfg);
+
+ return (qryNode ? srv : cln).cache(name);
+ }
+
+ /**
+ * Create dynamic index.
+ *
+ * @param cache Cache.
+ * @param entity Entity.
+ * @param idx Index.
+ */
+ private void createDynamicIndex(IgniteCache<?, ?> cache, QueryEntity entity, QueryIndex idx) {
+ boolean spatial = idx.getIndexType() == QueryIndexType.GEOSPATIAL;
+
+ GridStringBuilder sb = new SB("CREATE ")
+ .a(spatial ? "SPATIAL " : "")
+ .a("INDEX ")
+ .a("\"" + idx.getName() + "\"")
+ .a(" ON ")
+ .a(QueryUtils.tableName(entity))
+ .a(" (");
+
+ boolean first = true;
+
+ for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
+ if (first)
+ first = false;
+ else
+ sb.a(", ");
+
+ String name = fieldEntry.getKey();
+ boolean asc = fieldEntry.getValue();
+
+ sb.a("\"" + name + "\"").a(" ").a(asc ? "ASC" : "DESC");
+ }
+
+ sb.a(')');
+
+ String sql = sb.toString();
+
+ cache.query(new SqlFieldsQuery(sql)).getAll();
+ }
+
+ /**
+ * @param name Cache name.
+ * @param partitioned Partition or replicated cache.
+ * @param keyCls Key class.
+ * @param valCls Value class.
+ * @return Cache configuration.
+ */
+ private <K, V> CacheConfiguration<K, V> cacheConfig(@NotNull String name, boolean partitioned, Class<?> keyCls,
+ Class<?> valCls) {
+ CacheConfiguration<K, V> ccfg = new CacheConfiguration<K, V>(name)
+ .setName(name)
+ .setCacheMode(partitioned ? CacheMode.PARTITIONED : CacheMode.REPLICATED)
+ .setAtomicityMode(CacheAtomicityMode.ATOMIC)
+ .setIndexedTypes(keyCls, valCls);
+
+ if (segmented)
+ ccfg.setQueryParallelism(partitioned ? QRY_PARALLELISM_LVL : 1);
+
+ return ccfg;
+ }
+
+ /**
+ * Destroy cache.
+ *
+ * @param cache Cache.
+ * @param grid Node.
+ * @param dynamic Dynamic flag.
+ */
+ private static void destroy(IgniteCache<?, ?> cache, IgniteEx grid, boolean dynamic) {
+ if (!dynamic)
+ cache.destroy();
+ else
+ grid.context().cache().dynamicDestroyCache(cache.getName(), true, true, false, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testPrimitiveGeometry() throws Exception {
+ IgniteCache<Long, Geometry> cache = createCache("geom", true, Long.class, Geometry.class);
+
+ try {
+ WKTReader r = new WKTReader();
+
+ for (long i = 0; i < 100; i++)
+ cache.put(i, r.read("POINT(" + i + " " + i + ")"));
+
+ String plan = cache.query(new SqlFieldsQuery("explain select _key from Geometry where _val && ?")
+ .setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))")))
+ .getAll().get(0).get(0).toString().toLowerCase();
+
+ assertTrue("__ explain: " + plan, plan.contains("_val_idx"));
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * Test geo-index (static).
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testGeo() throws Exception {
+ checkGeo(false);
+ }
+
+ /**
+ * Test geo-index (dynamic).
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testGeoDynamic() throws Exception {
+ checkGeo(true);
+ }
+
+ /**
+ * Check geo-index (dynamic).
+ *
+ * @param dynamic Whether index should be created dynamically.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings({"unchecked", "ConstantConditions"})
+ private void checkGeo(boolean dynamic) throws Exception {
+ IgniteCache<Integer, EnemyCamp> cache = createCache("camp", true, Integer.class, EnemyCamp.class, dynamic);
+
+ try {
+ WKTReader r = new WKTReader();
+
+ cache.getAndPut(0, new EnemyCamp(r.read("POINT(25 75)"), "A"));
+ cache.getAndPut(1, new EnemyCamp(r.read("POINT(70 70)"), "B"));
+ cache.getAndPut(2, new EnemyCamp(r.read("POINT(70 30)"), "C"));
+ cache.getAndPut(3, new EnemyCamp(r.read("POINT(75 25)"), "D"));
+
+ SqlQuery<Integer, EnemyCamp> qry = new SqlQuery(EnemyCamp.class, "coords && ?");
+
+ Collection<Cache.Entry<Integer, EnemyCamp>> res = cache.query(
+ qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll();
+
+ checkPoints(res, "A");
+
+ res = cache.query(
+ qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll();
+
+ checkPoints(res, "C", "D");
+
+ // Move B to the first polygon.
+ cache.getAndPut(1, new EnemyCamp(r.read("POINT(20 75)"), "B"));
+
+ res = cache.query(
+ qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll();
+
+ checkPoints(res, "A", "B");
+
+ // Move B to the second polygon.
+ cache.getAndPut(1, new EnemyCamp(r.read("POINT(30 30)"), "B"));
+
+ res = cache.query(
+ qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll();
+
+ checkPoints(res, "B", "C", "D");
+
+ // Remove B.
+ cache.getAndRemove(1);
+
+ res = cache.query(
+ qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll();
+
+ checkPoints(res, "A");
+
+ res = cache.query(
+ qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll();
+
+ checkPoints(res, "C", "D");
+
+ // Check explain request.
+ String plan = cache.query(new SqlFieldsQuery("explain select * from EnemyCamp " +
+ "where coords && 'POINT(25 75)'")).getAll().get(0).get(0).toString().toLowerCase();
+
+ assertTrue("__ explain: " + plan, plan.contains("coords_idx"));
+
+ if (dynamic)
+ cache.query(new SqlFieldsQuery("DROP INDEX \"EnemyCamp_coords_idx\"")).getAll();
+ }
+ finally {
+ destroy(cache, grid(0), dynamic);
+ }
+ }
+
+ /**
+ * Test geo indexing multithreaded.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testGeoMultithreaded() throws Exception {
+ checkGeoMultithreaded(false);
+ }
+
+ /**
+ * Test geo indexing multithreaded with dynamic index creation.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testGeoMultithreadedDynamic() throws Exception {
+ checkGeoMultithreaded(true);
+ }
+
+ /**
+ * Check geo indexing multithreaded with dynamic index creation.
+ *
+ * @param dynamic Whether index should be created dynamically.
+ * @throws Exception If failed.
+ */
+ private void checkGeoMultithreaded(boolean dynamic) throws Exception {
+ final IgniteCache<Integer, EnemyCamp> cache1 =
+ createCache("camp", true, Integer.class, EnemyCamp.class, dynamic);
+
+ final IgniteCache<Integer, EnemyCamp> cache2 = grid(1).cache("camp");
+ final IgniteCache<Integer, EnemyCamp> cache3 = grid(2).cache("camp");
+
+ try {
+ final String[] points = new String[CNT];
+
+ WKTReader r = new WKTReader();
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ for (int idx = 0; idx < CNT; idx++) {
+ int x = rnd.nextInt(1, 100);
+ int y = rnd.nextInt(1, 100);
+
+ cache1.getAndPut(idx, new EnemyCamp(r.read("POINT(" + x + " " + y + ")"), Integer.toString(idx)));
+
+ points[idx] = Integer.toString(idx);
+ }
+
+ Thread.sleep(200);
+
+ final AtomicBoolean stop = new AtomicBoolean();
+ final AtomicReference<Exception> err = new AtomicReference<>();
+
+ IgniteInternalFuture<?> putFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ WKTReader r = new WKTReader();
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (!stop.get()) {
+ int cacheIdx = rnd.nextInt(0, 3);
+
+ IgniteCache<Integer, EnemyCamp> cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3;
+
+ int idx = rnd.nextInt(CNT);
+ int x = rnd.nextInt(1, 100);
+ int y = rnd.nextInt(1, 100);
+
+ cache.getAndPut(idx, new EnemyCamp(r.read("POINT(" + x + " " + y + ")"), Integer.toString(idx)));
+
+ U.sleep(50);
+ }
+
+ return null;
+ }
+ }, Runtime.getRuntime().availableProcessors(), "put-thread");
+
+ IgniteInternalFuture<?> qryFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ @Override public Void call() {
+ WKTReader r = new WKTReader();
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (!stop.get()) {
+ try {
+ int cacheIdx = rnd.nextInt(0, 3);
+
+ IgniteCache<Integer, EnemyCamp> cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3;
+
+ SqlQuery<Integer, EnemyCamp> qry = new SqlQuery<>(
+ EnemyCamp.class, "coords && ?");
+
+ Collection<Cache.Entry<Integer, EnemyCamp>> res = cache.query(qry.setArgs(
+ r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))"))).getAll();
+
+ checkPoints(res, points);
+
+ U.sleep(5);
+ }
+ catch (Exception e) {
+ err.set(e);
+
+ stop.set(true);
+
+ break;
+ }
+ }
+
+ return null;
+ }
+ }, 4, "qry-thread");
+
+ U.sleep(6000L);
+
+ stop.set(true);
+
+ putFut.get();
+ qryFut.get();
+
+ Exception err0 = err.get();
+
+ if (err0 != null)
+ throw err0;
+ }
+ finally {
+ destroy(cache1, grid(0), dynamic);
+ }
+ }
+
+ /**
+ * Check whether result contains all required points.
+ *
+ * @param res Result.
+ * @param points Expected points.
+ */
+ private void checkPoints(Collection<Cache.Entry<Integer, EnemyCamp>> res, String... points) {
+ Set<String> set = new HashSet<>(Arrays.asList(points));
+
+ assertEquals(set.size(), res.size());
+
+ for (Cache.Entry<Integer, EnemyCamp> e : res)
+ assertTrue(set.remove(e.getValue().name));
+ }
+
+ /**
+ * Test segmented geo-index join on PARTITIONED cache.
+ *
+ * @throws Exception if fails.
+ */
+ @Test
+ public void testSegmentedGeoIndexJoinPartitioned() throws Exception {
+ checkSegmentedGeoIndexJoin(true, false);
+ }
+
+ /**
+ * Test segmented geo-index join on PARTITIONED cache with dynamically created index.
+ *
+ * @throws Exception if fails.
+ */
+ @Test
+ public void testSegmentedGeoIndexJoinPartitionedDynamic() throws Exception {
+ checkSegmentedGeoIndexJoin(true, true);
+ }
+
+ /**
+ * Test segmented geo-index join on REPLICATED cache.
+ *
+ * @throws Exception if fails.
+ */
+ @Test
+ public void testSegmentedGeoIndexJoinReplicated() throws Exception {
+ checkSegmentedGeoIndexJoin(false, false);
+ }
+
+ /**
+ * Test segmented geo-index join on REPLICATED cache with dynamically created index.
+ *
+ * @throws Exception if fails.
+ */
+ @Test
+ public void testSegmentedGeoIndexJoinReplicatedDynamic() throws Exception {
+ checkSegmentedGeoIndexJoin(false, true);
+ }
+
+ /**
+ * Check segmented geo-index join.
+ *
+ * @param partitioned Partitioned flag.
+ * @param dynamic Whether index should be created dynamically.
+ * @throws Exception If failed.
+ */
+ private void checkSegmentedGeoIndexJoin(boolean partitioned, boolean dynamic) throws Exception {
+ IgniteCache<Integer, Enemy> c1 = createCache("enemy", true, Integer.class, Enemy.class);
+ IgniteCache<Integer, EnemyCamp> c2 = createCache("camp", partitioned, Integer.class, EnemyCamp.class, dynamic);
+
+ try {
+ final ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ WKTReader r = new WKTReader();
+
+ for (int i = 0; i < ENEMYCAMP_SAMPLES_COUNT; i++) {
+ final String point = String.format("POINT(%d %d)", rnd.nextInt(100), rnd.nextInt(100));
+
+ c2.put(i, new EnemyCamp(r.read(point), "camp-" + i));
+ }
+
+ for (int i = 0; i < ENEMY_SAMPLES_COUNT; i++) {
+ int campID = 30 + rnd.nextInt(ENEMYCAMP_SAMPLES_COUNT + 10);
+
+ c1.put(i, new Enemy(campID, "enemy-" + i));
+ }
+
+ checkDistributedQuery();
+ }
+ finally {
+ destroy(c1, grid(0), dynamic);
+ destroy(c2, grid(0), dynamic);
+ }
+ }
+
+ /**
+ * Check distributed query.
+ *
+ * @throws ParseException If failed.
+ */
+ private void checkDistributedQuery() throws ParseException {
+ IgniteCache<Integer, Enemy> c1 = grid(0).cache("enemy");
+ IgniteCache<Integer, EnemyCamp> c2 = grid(0).cache("camp");
+
+ final Geometry lethalArea = new WKTReader().read("POLYGON((30 30, 30 70, 70 70, 70 30, 30 30))");
+
+ int expectedEnemies = 0;
+
+ for (Cache.Entry<Integer, Enemy> e : c1) {
+ final int campID = e.getValue().campId;
+
+ if (30 <= campID && campID < ENEMYCAMP_SAMPLES_COUNT) {
+ final EnemyCamp camp = c2.get(campID);
+
+ if (lethalArea.covers(camp.coords))
+ expectedEnemies++;
+ }
+ }
+
+ final SqlFieldsQuery qry = new SqlFieldsQuery("select e._val, c._val from \"enemy\".Enemy e, " +
+ "\"camp\".EnemyCamp c where e.campId = c._key and c.coords && ?").setArgs(lethalArea);
+
+ List<List<?>> result = c1.query(qry.setDistributedJoins(true)).getAll();
+
+ assertEquals(expectedEnemies, result.size());
+ }
+
+ /**
+ *
+ */
+ private static class Enemy {
+ /** */
+ @QuerySqlField(index = true)
+ int campId;
+
+ /** */
+ @QuerySqlField
+ String name;
+
+ /**
+ * @param campId Camp ID.
+ * @param name Name.
+ */
+ public Enemy(int campId, String name) {
+ this.campId = campId;
+ this.name = name;
+ }
+ }
+
+ /**
+ *
+ */
+ protected static class EnemyCamp implements Serializable {
+ /** */
+ @QuerySqlField(index = true)
+ final Geometry coords;
+
+ /** */
+ @QuerySqlField
+ private final String name;
+
+ /**
+ * @param coords Coordinates.
+ * @param name Name.
+ */
+ EnemyCamp(Geometry coords, String name) {
+ this.coords = coords;
+ this.name = name;
+ }
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
new file mode 100644
index 0000000..bda187a
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2;
+
+/**
+ * Geo-indexing test.
+ */
+public class H2IndexingGeoSelfTest extends H2IndexingAbstractGeoSelfTest {
+ /**
+ * Constructor.
+ */
+ public H2IndexingGeoSelfTest() {
+ super(false);
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
new file mode 100644
index 0000000..fbb5274
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2;
+
+/**
+ * Test for segmented geo index.
+ */
+public class H2IndexingSegmentedGeoSelfTest extends H2IndexingAbstractGeoSelfTest {
+ /**
+ * Constructor.
+ */
+ public H2IndexingSegmentedGeoSelfTest() {
+ super(true);
+ }
+}
diff --git a/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
new file mode 100644
index 0000000..f5cd296
--- /dev/null
+++ b/modules/geospatial-ext/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import org.apache.ignite.internal.processors.query.h2.H2IndexesSystemViewTest;
+import org.apache.ignite.internal.processors.query.h2.H2IndexingGeoSelfTest;
+import org.apache.ignite.internal.processors.query.h2.H2IndexingSegmentedGeoSelfTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Geospatial indexing tests.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ H2IndexingGeoSelfTest.class,
+ H2IndexingSegmentedGeoSelfTest.class,
+ H2IndexesSystemViewTest.class
+})
+public class GeoSpatialIndexingTestSuite {
+}
diff --git a/modules/geospatial-ext/pom.xml b/modules/geospatial-ext/pom.xml
new file mode 100644
index 0000000..073d0d6
--- /dev/null
+++ b/modules/geospatial-ext/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent-ext-internal</artifactId>
+ <version>1</version>
+ <relativePath>../../parent-internal/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ignite-geospatial-parent-ext</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <modules>
+ <module>geospatial</module>
+ <module>examples</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>flatten-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>flatten</id>
+ <inherited>false</inherited>
+ <phase/>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/modules/hibernate-ext/examples/README.txt b/modules/hibernate-ext/examples/README.txt
index 8e3bce0..33281f3 100644
--- a/modules/hibernate-ext/examples/README.txt
+++ b/modules/hibernate-ext/examples/README.txt
@@ -20,7 +20,7 @@ at https://ignite.apache.org/download.cgi#sources.
There is a way to gain required libs from sources:
-Run "./mvnw clean install -DskipTests " at Apache Ignite sources.
+Run "mvn clean install -DskipTests " at Apache Ignite sources.
This case will install lgpl-based libs to local maven repository.
Required libs will also appear at /target/release-package/libs/optional sub-folders.
diff --git a/pom.xml b/pom.xml
index a005212..f2c865a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
<module>modules/zookeeper-ip-finder-ext</module>
<module>modules/topology-validator-ext</module>
<module>modules/hibernate-ext</module>
+ <module>modules/geospatial-ext</module>
</modules>
<profiles>