IGNITE-4259: Fixed a problem with geospatial indexes and BinaryMarshaller.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9d82f2ca Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9d82f2ca Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9d82f2ca Branch: refs/heads/ignite-4242 Commit: 9d82f2ca06fa6069c1976cc75814874256b24f8c Parents: c34d274 Author: devozerov <[email protected]> Authored: Tue Nov 22 15:05:29 2016 +0300 Committer: devozerov <[email protected]> Committed: Tue Nov 22 15:05:29 2016 +0300 ---------------------------------------------------------------------- .../internal/binary/BinaryClassDescriptor.java | 6 ++-- .../ignite/internal/binary/BinaryContext.java | 4 ++- .../h2/GridBinaryH2IndexingGeoSelfTest.java | 35 ++++++++++++++++++++ .../query/h2/GridH2IndexingGeoSelfTest.java | 2 +- .../testsuites/GeoSpatialIndexingTestSuite.java | 2 ++ 5 files changed, 45 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/9d82f2ca/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java index d05ce71..b121337 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java @@ -41,6 +41,7 @@ import org.apache.ignite.binary.BinaryReflectiveSerializer; import org.apache.ignite.binary.BinarySerializer; import org.apache.ignite.binary.Binarylizable; import org.apache.ignite.internal.processors.cache.CacheObjectImpl; +import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -156,7 +157,7 @@ public class BinaryClassDescriptor { initialSerializer = serializer; // If serializer is not defined at this point, then we have to use OptimizedMarshaller. - useOptMarshaller = serializer == null; + useOptMarshaller = serializer == null || GridQueryProcessor.isGeometryClass(cls); // Reset reflective serializer so that we rely on existing reflection-based serialization. if (serializer instanceof BinaryReflectiveSerializer) @@ -189,7 +190,8 @@ public class BinaryClassDescriptor { mode = serializer != null ? BinaryWriteMode.BINARY : BinaryUtils.mode(cls); } - if (useOptMarshaller && userType && !U.isIgnite(cls) && !U.isJdk(cls)) { + if (useOptMarshaller && userType && !U.isIgnite(cls) && !U.isJdk(cls) && + !GridQueryProcessor.isGeometryClass(cls)) { U.warn(ctx.log(), "Class \"" + cls.getName() + "\" cannot be serialized using " + BinaryMarshaller.class.getSimpleName() + " because it either implements Externalizable interface " + "or have writeObject/readObject methods. " + OptimizedMarshaller.class.getSimpleName() + " will be " + http://git-wip-us.apache.org/repos/asf/ignite/blob/9d82f2ca/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java index a1ea3e9..cc18318 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java @@ -78,6 +78,7 @@ import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProces import org.apache.ignite.internal.processors.platform.PlatformJavaObjectFactoryProxy; import org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionData; import org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionLockResult; +import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.util.lang.GridMapEntry; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; @@ -357,7 +358,8 @@ public class BinaryContext { if (BinaryUtils.wrapTrees() && (cls == TreeMap.class || cls == TreeSet.class)) return false; - return marshCtx.isSystemType(cls.getName()) || serializerForClass(cls) == null; + return marshCtx.isSystemType(cls.getName()) || serializerForClass(cls) == null || + GridQueryProcessor.isGeometryClass(cls); } else return desc.useOptimizedMarshaller(); http://git-wip-us.apache.org/repos/asf/ignite/blob/9d82f2ca/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridBinaryH2IndexingGeoSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridBinaryH2IndexingGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridBinaryH2IndexingGeoSelfTest.java new file mode 100644 index 0000000..01071f9 --- /dev/null +++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridBinaryH2IndexingGeoSelfTest.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.internal.processors.query.h2; + +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.binary.BinaryMarshaller; + +/** + * Geo-indexing test for binary mode. + */ +public class GridBinaryH2IndexingGeoSelfTest extends GridH2IndexingGeoSelfTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setMarshaller(new BinaryMarshaller()); + + return cfg; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9d82f2ca/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java index b73a5c0..2843076 100644 --- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java +++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java @@ -41,7 +41,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; /** - * + * Geo-indexing test. */ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/9d82f2ca/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java index d3b8d01..1773894 100644 --- a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java +++ b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java @@ -18,6 +18,7 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.query.h2.GridBinaryH2IndexingGeoSelfTest; import org.apache.ignite.internal.processors.query.h2.GridH2IndexingGeoSelfTest; /** @@ -33,6 +34,7 @@ public class GeoSpatialIndexingTestSuite extends TestSuite { // Geo. suite.addTestSuite(GridH2IndexingGeoSelfTest.class); + suite.addTestSuite(GridBinaryH2IndexingGeoSelfTest.class); return suite; }
