Github user galen-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/404#discussion_r104059948 --- Diff: geode-core/src/main/java/org/apache/geode/redis/internal/executor/hash/HashInterpreter.java --- @@ -0,0 +1,126 @@ +/* + * 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.geode.redis.internal.executor.hash; + +import java.util.Map; + +import org.apache.geode.cache.Region; +import org.apache.geode.redis.GeodeRedisServer; +import org.apache.geode.redis.internal.ByteArrayWrapper; +import org.apache.geode.redis.internal.Coder; +import org.apache.geode.redis.internal.ExecutionHandlerContext; +import org.apache.geode.redis.internal.RedisDataType; + +/** + * Utility class for interpreting and processing Redis Hash data structure + * + * + */ +public class HashInterpreter { + + /** + * <pre> + * The region:key separator. + * + * REGION_KEY_SEPERATOR = ":" + * + * See Hash section of <a href= + "https://redis.io/topics/data-types">https://redis.io/topics/data-types#Hashes</a> + * </pre> + */ + public static final String REGION_KEY_SEPERATOR = ":"; + + /** + * The default hash region name REGION_HASH_REGION = Coder.stringToByteArrayWrapper("ReDiS_HASH") + */ + public static final ByteArrayWrapper REGION_HASH_REGION = + Coder.stringToByteArrayWrapper(GeodeRedisServer.HASH_REGION); + + /** + * Return the region presenting the hash + * + * @param key the raw Redis command key that may contain the region:key formation + * @param context the exception handler context + * @return the region were the command's data will be processed + */ + @SuppressWarnings("unchecked") + public static Region<ByteArrayWrapper, Map<ByteArrayWrapper, ByteArrayWrapper>> getRegion( --- End diff -- I think the abstraction would be cleaner if the HashInterpreter implemented `setHash` and `getHash` (and `setHashKey` and `getHashKey`) methods, and callers didn't have to think about regions at all. It would also make it clearer where the single point of concern is for where and how hashes get stored.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---