You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/05/18 14:20:59 UTC
[GitHub] [geode] prettyClouds opened a new pull request #5128: Key commands::DELETE
prettyClouds opened a new pull request #5128:
URL: https://github.com/apache/geode/pull/5128
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
- [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
- [ ] Is your initial contribution a single, squashed commit?
- [ ] Does `gradlew build` run cleanly?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
### Note:
Please ensure that once the PR is submitted, check Concourse for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal merged pull request #5128: GEODE-8147: DELETE and EXISTS implement Function-Delta
Posted by GitBox <gi...@apache.org>.
dschneider-pivotal merged pull request #5128:
URL: https://github.com/apache/geode/pull/5128
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [geode] prettyClouds commented on a change in pull request #5128: GEODE-8147: DELETE and EXISTS implement Function-Delta
Posted by GitBox <gi...@apache.org>.
prettyClouds commented on a change in pull request #5128:
URL: https://github.com/apache/geode/pull/5128#discussion_r427567548
##########
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:
yea, the static execute method looks a little weird to me as well.
I like the idea of having a simple interface other than the FunctionService to expose the function call, but the name `execute` is definitely confusing.
Some kind of code sharing in the *FunctionExecutor classes is a good idea.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [geode] prettyClouds commented on a change in pull request #5128: GEODE-8147: DELETE and EXISTS implement Function-Delta
Posted by GitBox <gi...@apache.org>.
prettyClouds commented on a change in pull request #5128:
URL: https://github.com/apache/geode/pull/5128#discussion_r427567684
##########
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:
lol...that would have been very passive aggressive
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [geode] prettyClouds commented on a change in pull request #5128: GEODE-8147: DELETE and EXISTS implement Function-Delta
Posted by GitBox <gi...@apache.org>.
prettyClouds commented on a change in pull request #5128:
URL: https://github.com/apache/geode/pull/5128#discussion_r427611753
##########
File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisDataInRegion.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.RedisData;
+import org.apache.geode.redis.internal.RegionProvider;
+
+class RedisDataInRegion {
Review comment:
made it RedisKeyInRegion
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal commented on a change in pull request #5128: GEODE-8147: DELETE and EXISTS implement Function-Delta
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal commented on a change in pull request #5128: Key commands::DELETE
Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #5128:
URL: https://github.com/apache/geode/pull/5128#discussion_r426728731
##########
File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
##########
@@ -32,24 +33,33 @@ public void executeCommand(Command command, ExecutionHandlerContext context) {
throw new UnsupportedOperationInTransactionException();
}
- List<byte[]> commandElems = command.getProcessedCommand();
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.DEL));
- return;
- }
-
- int numRemoved = 0;
+ List<ByteArrayWrapper> commandElems = command.getProcessedCommandWrappers();
- for (int i = 1; i < commandElems.size(); i++) {
- byte[] byteKey = commandElems.get(i);
- ByteArrayWrapper key = new ByteArrayWrapper(byteKey);
- RedisDataType type = context.getKeyRegistrar().getType(key);
- if (removeEntry(key, type, context)) {
- numRemoved++;
- }
- }
+ long numRemoved = commandElems
+ .subList(1, commandElems.size())
+ .stream()
+ .filter((key) -> new RedisKeyCommandsFunctionExecutor(
+ context.getRegionProvider().getDataRegion()).del(key))
+ .count();
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));
}
+ public interface RedisKeyCommands {
Review comment:
pull this out to its own file
##########
File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
##########
@@ -32,24 +33,33 @@ public void executeCommand(Command command, ExecutionHandlerContext context) {
throw new UnsupportedOperationInTransactionException();
}
- List<byte[]> commandElems = command.getProcessedCommand();
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.DEL));
- return;
- }
-
- int numRemoved = 0;
+ List<ByteArrayWrapper> commandElems = command.getProcessedCommandWrappers();
- for (int i = 1; i < commandElems.size(); i++) {
- byte[] byteKey = commandElems.get(i);
- ByteArrayWrapper key = new ByteArrayWrapper(byteKey);
- RedisDataType type = context.getKeyRegistrar().getType(key);
- if (removeEntry(key, type, context)) {
- numRemoved++;
- }
- }
+ long numRemoved = commandElems
+ .subList(1, commandElems.size())
+ .stream()
+ .filter((key) -> new RedisKeyCommandsFunctionExecutor(
+ context.getRegionProvider().getDataRegion()).del(key))
+ .count();
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));
}
+ public interface RedisKeyCommands {
+ boolean del(ByteArrayWrapper key);
+ }
+
+ public class RedisKeyCommandsFunctionExecutor implements RedisKeyCommands {
Review comment:
pull this out to its own file (if you keep it here make it static)
##########
File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/FlushAllExecutor.java
##########
@@ -37,7 +37,7 @@ public void executeCommand(Command command, ExecutionHandlerContext context) {
try {
ByteArrayWrapper skey = e.getKey();
RedisDataType type = e.getValue().getType();
Review comment:
no longer need to get type type
##########
File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisDataInRegion.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.RedisData;
+import org.apache.geode.redis.internal.RegionProvider;
+
+class RedisDataInRegion {
Review comment:
Think about making this classes name consistent with RedisKeyCommands. Should they both be "Key" or both be "Data"?
----------------------------------------------------------------
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:
users@infra.apache.org