Skip to content

Commit

Permalink
IGNITE-4259: Fixed a problem with geospatial indexes and BinaryMarsha…
Browse files Browse the repository at this point in the history
…ller.
  • Loading branch information
devozerov committed Nov 22, 2016
1 parent c34d274 commit 9d82f2c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -189,7 +190,8 @@ else if (useOptMarshaller)
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 " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
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;
Expand Down Expand Up @@ -357,7 +358,8 @@ public boolean mustDeserialize(Class cls) {
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.apache.ignite.testframework.GridTestUtils;

/**
*
* Geo-indexing test.
*/
public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest {
/** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -33,6 +34,7 @@ public static TestSuite suite() throws Exception {

// Geo.
suite.addTestSuite(GridH2IndexingGeoSelfTest.class);
suite.addTestSuite(GridBinaryH2IndexingGeoSelfTest.class);

return suite;
}
Expand Down

0 comments on commit 9d82f2c

Please sign in to comment.