Repository: ignite Updated Branches: refs/heads/ignite-1282 6ef7fb604 -> c6e117fe6
Renamed portable key mapper. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/784ea7cf Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/784ea7cf Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/784ea7cf Branch: refs/heads/ignite-1282 Commit: 784ea7cf5d878e7e9bffcb06cca1be863265845a Parents: 6ef7fb6 Author: Alexey Goncharuk <[email protected]> Authored: Sat Nov 28 16:11:35 2015 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Sat Nov 28 16:11:35 2015 +0300 ---------------------------------------------------------------------- .../CacheDefaultBinaryAffinityKeyMapper.java | 51 ++++++++++++++++++++ .../portable/CacheObjectPortableContext.java | 3 +- 2 files changed, 53 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/784ea7cf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheDefaultBinaryAffinityKeyMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheDefaultBinaryAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheDefaultBinaryAffinityKeyMapper.java new file mode 100644 index 0000000..efd38f7 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheDefaultBinaryAffinityKeyMapper.java @@ -0,0 +1,51 @@ +/* + * 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.cache; + +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.binary.BinaryObject; + +/** + * + */ +public class CacheDefaultBinaryAffinityKeyMapper extends GridCacheDefaultAffinityKeyMapper { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override public Object affinityKey(Object key) { + IgniteKernal kernal = (IgniteKernal)ignite; + + CacheObjectBinaryProcessorImpl proc = (CacheObjectBinaryProcessorImpl)kernal.context().cacheObjects(); + + try { + key = proc.toPortable(key); + } + catch (IgniteException e) { + U.error(log, "Failed to marshal key to portable: " + key, e); + } + + if (key instanceof BinaryObject) + return proc.affinityKey((BinaryObject)key); + else + return super.affinityKey(key); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/784ea7cf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java index c83c9af..719d0a9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.portable; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper; @@ -40,7 +41,7 @@ public class CacheObjectPortableContext extends CacheObjectContext { boolean storeVal, boolean portableEnabled, boolean depEnabled) { - super(kernalCtx, portableEnabled ? new CacheDefaultPortableAffinityKeyMapper() : + super(kernalCtx, portableEnabled ? new CacheDefaultBinaryAffinityKeyMapper() : new GridCacheDefaultAffinityKeyMapper(), cpyOnGet, storeVal, depEnabled); this.portableEnabled = portableEnabled;
