You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/07/08 18:21:26 UTC
[18/21] incubator-geode git commit: GEODE-1566: rename
GeodeRedisServer and repackage redis code into org.apache.geode
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
deleted file mode 100644
index 4e2a69e..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-public enum ListQuery {
-
- LINDEX {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
- }
- }, LRANGE {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
- }
- }, LREMG {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 AND key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $2";
- }
- }, LREML {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 AND key != 'head' AND key != 'tail' ORDER BY key desc LIMIT $2";
- }
- }, LREME {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 ORDER BY key asc";
- }
- }, LSET {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
- }
- }, LTRIM {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
- }
- };
-
- public abstract String getQueryString(String fullpath);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireAtExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireAtExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireAtExecutor.java
deleted file mode 100755
index 5deedc7..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireAtExecutor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class PExpireAtExecutor extends ExpireAtExecutor {
-
- @Override
- protected boolean timeUnitMillis() {
- return true;
- }
-
- @Override
- public String getArgsError() {
- return ArityDef.PEXPIREAT;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireExecutor.java
deleted file mode 100755
index 037f3fe..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PExpireExecutor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class PExpireExecutor extends ExpireExecutor {
-
- @Override
- protected boolean timeUnitMillis() {
- return true;
- }
-
- @Override
- public String getArgsError() {
- return ArityDef.PEXPIRE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PTTLExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PTTLExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PTTLExecutor.java
deleted file mode 100755
index af609a6..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PTTLExecutor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class PTTLExecutor extends TTLExecutor {
-
-
- @Override
- protected boolean timeUnitMillis() {
- return true;
- }
-
- @Override
- public String getArgsError() {
- return ArityDef.PTTL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
deleted file mode 100755
index f3bb686..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import java.util.List;
-
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class PersistExecutor extends AbstractExecutor {
-
- private final int TIMEOUT_REMOVED = 1;
-
- private final int KEY_NOT_EXIST_OR_NO_TIMEOUT = 0;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.PERSIST));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- boolean canceled = context.getRegionProvider().cancelKeyExpiration(key);
-
- if (canceled)
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), TIMEOUT_REMOVED));
- else
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), KEY_NOT_EXIST_OR_NO_TIMEOUT));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
deleted file mode 100755
index 828c74a..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-
-public class PingExecutor extends AbstractExecutor {
-
- private final String PING_RESPONSE = "PONG";
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), PING_RESPONSE));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
deleted file mode 100755
index 784676a..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants;
-
-public class QuitExecutor extends AbstractExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), RedisConstants.QUIT_RESPONSE));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
deleted file mode 100755
index f5ac4cb..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.redis.GemFireRedisServer;
-
-public class ScanExecutor extends AbstractScanExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SCAN));
- return;
- }
-
- String cursorString = command.getStringKey();
- int cursor = 0;
- Pattern matchPattern = null;
- String globMatchString = null;
- int count = DEFUALT_COUNT;
- try {
- cursor = Integer.parseInt(cursorString);
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_CURSOR));
- return;
- }
- if (cursor < 0) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_CURSOR));
- return;
- }
-
- if (commandElems.size() > 3) {
- try {
- byte[] bytes = commandElems.get(2);
- String tmp = Coder.bytesToString(bytes);
- if (tmp.equalsIgnoreCase("MATCH")) {
- bytes = commandElems.get(3);
- globMatchString = Coder.bytesToString(bytes);
- } else if (tmp.equalsIgnoreCase("COUNT")) {
- bytes = commandElems.get(3);
- count = Coder.bytesToInt(bytes);
- }
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
- }
-
- if (commandElems.size() > 5) {
- try {
- byte[] bytes = commandElems.get(4);
- String tmp = Coder.bytesToString(bytes);
- if (tmp.equalsIgnoreCase("COUNT")) {
- bytes = commandElems.get(5);
- count = Coder.bytesToInt(bytes);
- }
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
- }
-
- if (count < 0) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
-
- try {
- matchPattern = convertGlobToRegex(globMatchString);
- } catch (PatternSyntaxException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_ILLEGAL_GLOB));
- return;
- }
-
- @SuppressWarnings("unchecked")
- List<String> returnList = (List<String>) getIteration(context.getRegionProvider().metaKeySet(), matchPattern, count, cursor);
-
- command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected List<?> getIteration(Collection<?> list, Pattern matchPattern, int count, int cursor) {
- List<String> returnList = new ArrayList<String>();
- int size = list.size();
- int beforeCursor = 0;
- int numElements = 0;
- int i = -1;
- for (String key: (Collection<String>) list) {
- if (key.equals(GemFireRedisServer.REDIS_META_DATA_REGION) || key.equals(GemFireRedisServer.STRING_REGION) || key.equals(GemFireRedisServer.HLL_REGION))
- continue;
- i++;
- if (beforeCursor < cursor) {
- beforeCursor++;
- continue;
- } else if (numElements < count) {
- if (matchPattern != null) {
- if (matchPattern.matcher(key).matches()) {
- returnList.add(key);
- numElements++;
- }
- } else {
- returnList.add(key);
- numElements++;
- }
- } else
- break;
- }
-
- if (i == size - (NUM_DEFAULT_REGIONS + 1))
- returnList.add(0, String.valueOf(0));
- else
- returnList.add(0, String.valueOf(i));
- return returnList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ShutDownExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ShutDownExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ShutDownExecutor.java
deleted file mode 100755
index 3618768..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ShutDownExecutor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-
-public class ShutDownExecutor extends AbstractExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
deleted file mode 100644
index 0b1a9ed..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-public enum SortedSetQuery {
-
- ZCOUNTNINFI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score <= $1";
- }
- }, ZCOUNTNINF {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score < $1";
- }
- }, ZCOUNTPINFI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score >= $1";
- }
- }, ZCOUNTPINF {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score > $1";
- }
- }, ZCOUNTSTI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score >= $1 AND value.score < $2";
- }
- }, ZCOUNTSTISI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score >= $1 AND value.score <= $2";
- }
- }, ZCOUNTSI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score > $1 AND value.score <= $2";
- }
- }, ZCOUNT {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".values value WHERE value.score > $1 AND value.score < $2";
- }
- }, ZLEXCOUNTNINFI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) <= 0";
- }
- }, ZLEXCOUNTNINF {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) < 0";
- }
- }, ZLEXCOUNTPINFI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0";
- }
- }, ZLEXCOUNTPINF {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0";
- }
- }, ZLEXCOUNTSTI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0 AND key.compareTo($2) < 0";
- }
- }, ZLEXCOUNTSTISI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0 AND key.compareTo($2) <= 0";
- }
- }, ZLEXCOUNTSI {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0 AND key.compareTo($2) <= 0";
- }
- }, ZLEXCOUNT {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0 AND key.compareTo($2) < 0";
- }
- }, ZRANGEBYLEXNINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) <= 0 ORDER BY key asc LIMIT $2";
- }
- }, ZRANGEBYLEXNINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) < 0 ORDER BY key asc LIMIT $2";
- }
- }, ZRANGEBYLEXPINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0 ORDER BY key asc LIMIT $2";
- }
- }, ZRANGEBYLEXPINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0 ORDER BY key asc LIMIT $2";
- }
- }, ZRANGEBYLEXSTI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0 AND key.compareTo($2) < 0 ORDER BY key asc LIMIT $3";
- }
- }, ZRANGEBYLEXSTISI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) >= 0 AND key.compareTo($2) <= 0 ORDER BY key asc LIMIT $3";
- }
- }, ZRANGEBYLEXSI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0 AND key.compareTo($2) <= 0 ORDER BY key asc LIMIT $3";
- }
- }, ZRANGEBYLEX {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key.compareTo($1) > 0 AND key.compareTo($2) < 0 ORDER BY key asc LIMIT $3";
- }
- }, ZREMRANGEBYRANK {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry ORDER BY entry.value asc LIMIT $1";
- }
- }, ZRBSNINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score <= $1 ORDER BY entry.value asc LIMIT $2";
- }
- }, ZRBSNINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score < $1 ORDER BY entry.value asc LIMIT $2";
- }
- }, ZRBSPINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 ORDER BY entry.value asc LIMIT $2";
- }
- }, ZRBSPINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 ORDER BY entry.value asc LIMIT $2";
- }
- }, ZRBSSTISI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score <= $2 ORDER BY entry.value asc LIMIT $3";
- }
- }, ZRBSSTI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score < $2 ORDER BY entry.value asc LIMIT $3";
- }
- }, ZRBSSI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score <= $2 ORDER BY entry.value asc LIMIT $3";
- }
- }, ZRBS {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score < $2 ORDER BY entry.value asc LIMIT $3";
- }
- }, ZREVRBSNINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value <= $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
- }
- }, ZREVRBSNINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score < $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
- }
- }, ZREVRBSPINFI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
- }
- }, ZREVRBSPINF {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
- }
- }, ZREVRBSSTISI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score <= $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
- }
- }, ZREVRBSSTI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score < $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
- }
- }, ZREVRBSSI {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score <= $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
- }
- }, ZREVRBS {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score < $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
- }
- }, ZREVRANGE {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry ORDER BY entry.value asc, entry.key asc LIMIT $1";
- }
- }, ZRANGE {
- public String getQueryString(String fullpath) {
- return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry ORDER BY entry.value desc, entry.key desc LIMIT $1";
- }
- }, ZRANK {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE entry.value < $1 OR (entry.value = $2 AND entry.key.compareTo($3) < 0)";
- }
- }, ZREVRANK {
- public String getQueryString(String fullpath) {
- return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE entry.value > $1 OR (entry.value = $2 AND entry.key.compareTo($3) > 0)";
- }
- };
-
- public abstract String getQueryString(String fullpath);
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
deleted file mode 100755
index 630b8d0..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import java.util.List;
-
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.Extendable;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionProvider;
-
-public class TTLExecutor extends AbstractExecutor implements Extendable {
-
- private final int NOT_EXISTS = -2;
-
- private final int NO_TIMEOUT = -1;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
- RegionProvider rC = context.getRegionProvider();
- boolean exists = false;
- RedisDataType val = rC.getRedisDataType(key);
- if (val != null)
- exists = true;
-
- if (!exists) {
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));
- return;
- }
- long ttl = rC.getExpirationDelayMillis(key);
-
- if (ttl == 0L) {
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NO_TIMEOUT));
- return;
- }
-
- if(!timeUnitMillis())
- ttl = ttl / millisInSecond;
-
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), ttl));
- }
-
- protected boolean timeUnitMillis() {
- return false;
- }
-
- @Override
- public String getArgsError() {
- return ArityDef.TTL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TimeExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TimeExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TimeExecutor.java
deleted file mode 100755
index 59b8b17..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TimeExecutor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import io.netty.buffer.ByteBuf;
-
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-
-public class TimeExecutor extends AbstractExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- long timeStamp = System.currentTimeMillis();
- long seconds = timeStamp / 1000;
- long microSeconds = (timeStamp - (seconds * 1000)) * 1000;
- byte[] secAr = Coder.longToBytes(seconds);
- byte[] micAr = Coder.longToBytes(microSeconds);
-
- ByteBuf response = context.getByteBufAllocator().buffer(50);
- response.writeByte(Coder.ARRAY_ID);
- response.writeByte(50); // #2
- response.writeBytes(Coder.CRLFar);
- response.writeByte(Coder.BULK_STRING_ID);
- response.writeBytes(Coder.intToBytes(secAr.length));
- response.writeBytes(Coder.CRLFar);
- response.writeBytes(secAr);
- response.writeBytes(Coder.CRLFar);
- response.writeByte(Coder.BULK_STRING_ID);
- response.writeBytes(Coder.intToBytes(micAr.length));
- response.writeBytes(Coder.CRLFar);
- response.writeBytes(micAr);
- response.writeBytes(Coder.CRLFar);
- command.setResponse(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
deleted file mode 100755
index 7c8eded..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import java.util.List;
-
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-
-public class TypeExecutor extends AbstractExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.TYPE));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- RedisDataType type = context.getRegionProvider().getRedisDataType(key);
-
- if (type == null)
- command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), "none"));
- else
- command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), type.toString()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
deleted file mode 100755
index 1e92258..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor;
-
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants;
-
-public class UnkownExecutor extends AbstractExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_UNKOWN_COMMAND));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
deleted file mode 100755
index ccc8f4b..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HDelExecutor extends HashExecutor {
-
- private final int START_FIELDS_INDEX = 2;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HDEL));
- return;
- }
-
- int numDeleted = 0;
-
- ByteArrayWrapper key = command.getKey();
-
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeleted));
- return;
- }
-
-
- for (int i = START_FIELDS_INDEX; i < commandElems.size(); i++) {
- ByteArrayWrapper field = new ByteArrayWrapper(commandElems.get(i));
- Object oldValue = keyRegion.remove(field);
- if (oldValue != null)
- numDeleted++;
- }
- if (keyRegion.isEmpty()) {
- context.getRegionProvider().removeKey(key, RedisDataType.REDIS_HASH);
- }
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeleted));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HExistsExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HExistsExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HExistsExecutor.java
deleted file mode 100755
index e3bcee0..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HExistsExecutor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HExistsExecutor extends HashExecutor {
-
- private final int NOT_EXISTS = 0;
-
- private final int EXISTS = 1;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HEXISTS));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));
- return;
- }
-
- byte[] byteField = commandElems.get(FIELD_INDEX);
- ByteArrayWrapper field = new ByteArrayWrapper(byteField);
-
- boolean hasField = keyRegion.containsKey(field);
-
- if (hasField)
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), EXISTS));
- else
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
deleted file mode 100755
index 902422a..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-
-public class HGetAllExecutor extends HashExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HGETALL));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
- return;
- }
-
- Collection<Map.Entry<ByteArrayWrapper,ByteArrayWrapper>> entries = new ArrayList(keyRegion.entrySet()); // This creates a CopyOnRead behavior
-
- if (entries.isEmpty()) {
- command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
- return;
- }
-
- command.setResponse(Coder.getKeyValArrayResponse(context.getByteBufAllocator(), entries));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetExecutor.java
deleted file mode 100755
index b72d29c..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetExecutor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HGetExecutor extends HashExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HGET));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
- return;
- }
-
- byte[] byteField = commandElems.get(FIELD_INDEX);
- ByteArrayWrapper field = new ByteArrayWrapper(byteField);
-
- ByteArrayWrapper valueWrapper = keyRegion.get(field);
-
- if (valueWrapper != null) {
- command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), valueWrapper.toBytes()));
- } else
- command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByExecutor.java
deleted file mode 100755
index 8001d5e..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByExecutor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HIncrByExecutor extends HashExecutor {
-
- private final String ERROR_FIELD_NOT_USABLE = "The value at this field is not an integer";
-
- private final String ERROR_INCREMENT_NOT_USABLE = "The increment on this key must be numeric";
-
- private final String ERROR_OVERFLOW = "This incrementation cannot be performed due to overflow";
-
- private final int FIELD_INDEX = 2;
-
- private final int INCREMENT_INDEX = 3;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 4) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HINCRBY));
- return;
- }
-
- byte[] incrArray = commandElems.get(INCREMENT_INDEX);
- long increment;
-
- try {
- increment = Coder.bytesToLong(incrArray);
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_INCREMENT_NOT_USABLE));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getOrCreateRegion(context, key, RedisDataType.REDIS_HASH);
-
- byte[] byteField = commandElems.get(FIELD_INDEX);
- ByteArrayWrapper field = new ByteArrayWrapper(byteField);
-
- /*
- * Put incrememnt as value if field doesn't exist
- */
-
- ByteArrayWrapper oldValue = keyRegion.get(field);
-
- if (oldValue == null) {
- keyRegion.put(field, new ByteArrayWrapper(incrArray));
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), increment));
- return;
- }
-
- /*
- * If the field did exist then increment the field
- */
-
- long value;
-
- try {
- value = Long.parseLong(oldValue.toString());
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_FIELD_NOT_USABLE));
- return;
- }
-
- /*
- * Check for overflow
- */
- if ((value >= 0 && increment > (Long.MAX_VALUE - value)) || (value <= 0 && increment < (Long.MIN_VALUE - value))) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_OVERFLOW));
- return;
- }
-
- value += increment;
- //String newValue = String.valueOf(value);
-
- keyRegion.put(field, new ByteArrayWrapper(Coder.longToBytes(value)));
-
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), value));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByFloatExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByFloatExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByFloatExecutor.java
deleted file mode 100755
index c8c27b5..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HIncrByFloatExecutor.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HIncrByFloatExecutor extends HashExecutor {
-
- private final String ERROR_FIELD_NOT_USABLE = "The value at this field cannot be incremented numerically because it is not a float";
-
- private final String ERROR_INCREMENT_NOT_USABLE = "The increment on this key must be floating point numeric";
-
- private final int FIELD_INDEX = 2;
-
- private final int INCREMENT_INDEX = 3;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 4) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HINCRBYFLOAT));
- return;
- }
-
- byte[] incrArray = commandElems.get(INCREMENT_INDEX);
- Double increment;
-
- try {
- increment = Coder.bytesToDouble(incrArray);
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_INCREMENT_NOT_USABLE));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getOrCreateRegion(context, key, RedisDataType.REDIS_HASH);
-
- byte[] byteField = commandElems.get(FIELD_INDEX);
- ByteArrayWrapper field = new ByteArrayWrapper(byteField);
-
- /*
- * Put incrememnt as value if field doesn't exist
- */
-
- ByteArrayWrapper oldValue = keyRegion.get(field);
-
- if (oldValue == null) {
- keyRegion.put(field, new ByteArrayWrapper(incrArray));
- command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), increment));
- return;
- }
-
- /*
- * If the field did exist then increment the field
- */
- String valueS = oldValue.toString();
- if (valueS.contains(" ")) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_FIELD_NOT_USABLE));
- return;
- }
- Double value;
-
- try {
- value = Coder.stringToDouble(valueS);
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_FIELD_NOT_USABLE));
- return;
- }
-
- value += increment;
- keyRegion.put(field, new ByteArrayWrapper(Coder.doubleToBytes(value)));
- command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), value));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
deleted file mode 100755
index d7cf777..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-
-public class HKeysExecutor extends HashExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HKEYS));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
- return;
- }
-
- Set<ByteArrayWrapper> keys = new HashSet(keyRegion.keySet());
-
- if (keys.isEmpty()) {
- command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
- return;
- }
-
- // String response = getBulkStringArrayResponse(keys);
-
- command.setResponse(Coder.getBulkStringArrayResponse(context.getByteBufAllocator(), keys));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HLenExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HLenExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HLenExecutor.java
deleted file mode 100755
index b62f49f..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HLenExecutor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HLenExecutor extends HashExecutor {
-
- private final int NOT_EXISTS = 0;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 2) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HLEN));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
- checkDataType(key, RedisDataType.REDIS_HASH, context);
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));
- return;
- }
-
- final int regionSize = keyRegion.size();
-
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), regionSize));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMGetExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMGetExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMGetExecutor.java
deleted file mode 100755
index d8c7bbf..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMGetExecutor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HMGetExecutor extends HashExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HMGET));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key);
- checkDataType(key, RedisDataType.REDIS_HASH, context);
-
- if (keyRegion == null) {
- command.setResponse(Coder.getArrayOfNils(context.getByteBufAllocator(), commandElems.size() - 2));
- return;
- }
-
- ArrayList<ByteArrayWrapper> fields = new ArrayList<ByteArrayWrapper>();
- for (int i = 2; i < commandElems.size(); i++) {
- byte[] fieldArray = commandElems.get(i);
- ByteArrayWrapper field = new ByteArrayWrapper(fieldArray);
- fields.add(field);
- }
-
- Map<ByteArrayWrapper, ByteArrayWrapper> results = keyRegion.getAll(fields);
-
- ArrayList<ByteArrayWrapper> values = new ArrayList<ByteArrayWrapper>();
-
- /*
- * This is done to preserve order in the output
- */
- for (ByteArrayWrapper field : fields)
- values.add(results.get(field));
-
- command.setResponse(Coder.getBulkStringArrayResponse(context.getByteBufAllocator(), values));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMSetExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMSetExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMSetExecutor.java
deleted file mode 100755
index efb4d2a..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HMSetExecutor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-
-public class HMSetExecutor extends HashExecutor {
-
- private final String SUCCESS = "OK";
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3 || commandElems.size() % 2 == 1) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HMSET));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getOrCreateRegion(context, key, RedisDataType.REDIS_HASH);
-
- Map<ByteArrayWrapper, ByteArrayWrapper> map = new HashMap<ByteArrayWrapper, ByteArrayWrapper>();
- for (int i = 2; i < commandElems.size(); i += 2) {
- byte[] fieldArray = commandElems.get(i);
- ByteArrayWrapper field = new ByteArrayWrapper(fieldArray);
- byte[] value = commandElems.get(i +1);
- map.put(field, new ByteArrayWrapper(value));
- }
-
- keyRegion.putAll(map);
-
- command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
deleted file mode 100755
index 9e70a79..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisConstants;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.executor.AbstractScanExecutor;
-
-public class HScanExecutor extends AbstractScanExecutor {
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 3) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HSCAN));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
- @SuppressWarnings("unchecked")
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionProvider().getRegion(key);
- checkDataType(key, RedisDataType.REDIS_HASH, context);
- if (keyRegion == null) {
- command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), new ArrayList<String>()));
- return;
- }
- byte[] cAr = commandElems.get(2);
- String cursorString = Coder.bytesToString(cAr);
-
- int cursor = 0;
- Pattern matchPattern = null;
- String globMatchPattern = null;
- int count = DEFUALT_COUNT;
- try {
- cursor = Integer.parseInt(cursorString);
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_CURSOR));
- return;
- }
- if (cursor < 0) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_CURSOR));
- return;
- }
-
- if (commandElems.size() > 4) {
- try {
- byte[] bytes = commandElems.get(3);
- String tmp = Coder.bytesToString(bytes);
- if (tmp.equalsIgnoreCase("MATCH")) {
- bytes = commandElems.get(4);
- globMatchPattern = Coder.bytesToString(bytes);
- } else if (tmp.equalsIgnoreCase("COUNT")) {
- bytes = commandElems.get(4);
- count = Coder.bytesToInt(bytes);
- }
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
- }
-
- if (commandElems.size() > 6) {
- try {
- byte[] bytes = commandElems.get(5);
- String tmp = Coder.bytesToString(bytes);
- if (tmp.equalsIgnoreCase("MATCH")) {
- bytes = commandElems.get(6);
- globMatchPattern = Coder.bytesToString(bytes);
- } else if (tmp.equalsIgnoreCase("COUNT")) {
- bytes = commandElems.get(6);
- count = Coder.bytesToInt(bytes);
- }
- } catch (NumberFormatException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
- }
-
- if (count < 0) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_COUNT));
- return;
- }
-
- try {
- matchPattern = convertGlobToRegex(globMatchPattern);
- } catch (PatternSyntaxException e) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_ILLEGAL_GLOB));
- return;
- }
-
- List<Object> returnList = getIteration(new HashSet(keyRegion.entrySet()), matchPattern, count, cursor);
-
- command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected List<Object> getIteration(Collection<?> list, Pattern matchPattern, int count, int cursor) {
- List<Object> returnList = new ArrayList<Object>();
- int size = list.size();
- int beforeCursor = 0;
- int numElements = 0;
- int i = -1;
- for (Entry<ByteArrayWrapper, ByteArrayWrapper> entry: (Collection<Entry<ByteArrayWrapper, ByteArrayWrapper>>) list) {
- ByteArrayWrapper key = entry.getKey();
- ByteArrayWrapper value = entry.getValue();
- i++;
- if (beforeCursor < cursor) {
- beforeCursor++;
- continue;
- } else if (numElements < count) {
- if (matchPattern != null) {
- if (matchPattern.matcher(key.toString()).matches()) {
- returnList.add(key);
- returnList.add(value);
- numElements++;
- }
- } else {
- returnList.add(key);
- returnList.add(value);
- numElements++;
- }
- } else
- break;
- }
-
- if (i == size - 1)
- returnList.add(0, String.valueOf(0));
- else
- returnList.add(0, String.valueOf(i));
- return returnList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dfd481e0/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HSetExecutor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HSetExecutor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HSetExecutor.java
deleted file mode 100755
index 5216594..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HSetExecutor.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 com.gemstone.gemfire.internal.redis.executor.hash;
-
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
-import com.gemstone.gemfire.internal.redis.Coder;
-import com.gemstone.gemfire.internal.redis.Command;
-import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.Extendable;
-import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-
-public class HSetExecutor extends HashExecutor implements Extendable {
-
- private final int EXISTING_FIELD = 0;
-
- private final int NEW_FIELD = 1;
-
- private final int VALUE_INDEX = 3;
-
- @Override
- public void executeCommand(Command command, ExecutionHandlerContext context) {
- List<byte[]> commandElems = command.getProcessedCommand();
-
- if (commandElems.size() < 4) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
- return;
- }
-
- ByteArrayWrapper key = command.getKey();
-
- Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getOrCreateRegion(context, key, RedisDataType.REDIS_HASH);
-
- byte[] byteField = commandElems.get(FIELD_INDEX);
- ByteArrayWrapper field = new ByteArrayWrapper(byteField);
-
- byte[] value = commandElems.get(VALUE_INDEX);
-
- Object oldValue;
-
- if (onlySetOnAbsent())
- oldValue = keyRegion.putIfAbsent(field, new ByteArrayWrapper(value));
- else
- oldValue = keyRegion.put(field, new ByteArrayWrapper(value));
-
- if (oldValue == null)
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NEW_FIELD));
- else
- command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), EXISTING_FIELD));
-
- }
-
- protected boolean onlySetOnAbsent() {
- return false;
- }
-
- @Override
- public String getArgsError() {
- return ArityDef.HSET;
- }
-}