[
https://issues.apache.org/jira/browse/GEODE-8147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17111355#comment-17111355
]
ASF GitHub Bot commented on GEODE-8147:
---------------------------------------
dschneider-pivotal commented on a change in pull request #5128:
URL: https://github.com/apache/geode/pull/5128#discussion_r427457278
##########
File path:
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommandsFunctionExecutor.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.redis.internal.ByteArrayWrapper;
+import org.apache.geode.redis.internal.RedisCommandType;
+import org.apache.geode.redis.internal.RedisData;
+
+public class RedisKeyCommandsFunctionExecutor implements RedisKeyCommands {
+ private Region<ByteArrayWrapper, RedisData> region;
+
+ public RedisKeyCommandsFunctionExecutor(
+ Region<ByteArrayWrapper, RedisData> region) {
+ this.region = region;
+ }
+
+ @Override
+ public boolean del(ByteArrayWrapper key) {
+ return (boolean) CommandFunction.execute(RedisCommandType.DEL, key, new
Object[] {}, region);
Review comment:
Something I find slightly confusing on CommandFunction is that is has a
static method named execute. When looking at a Function I tend to look for its
"instance" method named execute. Something we could consider is having all our
*FunctionExecutor classes, subclass a common class that has the code from the
static CommandFunction execute. I think that could also simplify how much we
need to pass to this method (we would no longer need to pass the region since
we could access it from the instance). Let me know what you think. No need to
do this on this PR
##########
File path:
geode-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
##########
@@ -218,21 +216,16 @@ public boolean removeKey(ByteArrayWrapper key,
RedisDataType type, boolean cance
if (!typeStoresDataInKeyRegistrar(type)) {
keyRegistrar.unregister(key);
}
+ RedisKeyCommands redisKeyCommands = new
RedisKeyCommandsFunctionExecutor(dataRegion);
try {
if (type == RedisDataType.REDIS_STRING) {
Review comment:
consider converting this if/elseif chain to a switch statement
##########
File path:
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
##########
@@ -20,22 +20,19 @@
import org.apache.geode.redis.internal.Coder;
import org.apache.geode.redis.internal.Command;
import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisConstants.ArityDef;
public class ExistsExecutor extends AbstractExecutor {
@Override
public void executeCommand(Command command, ExecutionHandlerContext context)
{
List<ByteArrayWrapper> commandElems =
command.getProcessedCommandWrappers();
- if (commandElems.size() < 2) {
-
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(),
ArityDef.EXISTS));
- return;
- }
+ RedisKeyCommands redisKeyCommands =
+ new
RedisKeyCommandsFunctionExecutor(context.getRegionProvider().getDataRegion());
long existsCount = commandElems
.subList(1, commandElems.size())
.stream()
- .filter(key -> context.getKeyRegistrar().isRegistered(key))
+ .filter(key -> redisKeyCommands.exists(key))
Review comment:
This makes me happy that we didn't pass the key to the
RedisKeyCommandsFunctionExecutor constructor
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> key commands implement Function-Delta
> -------------------------------------
>
> Key: GEODE-8147
> URL: https://issues.apache.org/jira/browse/GEODE-8147
> Project: Geode
> Issue Type: New Feature
> Reporter: Murtuza Boxwala
> Priority: Major
>
> DELETE
> EXISTS
> RENAME
> should all implement function-delta
--
This message was sent by Atlassian Jira
(v8.3.4#803005)