geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [29/58] [abbrv] geode git commit: GEODE-3021: Any call after the first to setPdxStringFlag should no-op
Date Mon, 17 Jul 2017 18:06:38 GMT
GEODE-3021: Any call after the first to setPdxStringFlag should no-op

  * The flag isIndexedPdxKeysFlagSet is now checked before setting pdx string flag

(cherry picked from commit f34d04754f27ad8f577ba54d0d0f18880322eaf7)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d49e8796
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d49e8796
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d49e8796

Branch: refs/heads/master
Commit: d49e87969a6535e67b00c5ddbfba6915063e4f2e
Parents: 29be69b
Author: Jason Huynh <huynhja@gmail.com>
Authored: Thu Jun 1 13:52:41 2017 -0700
Committer: Jason Huynh <huynhja@gmail.com>
Committed: Fri Jun 9 16:32:22 2017 -0700

----------------------------------------------------------------------
 .../query/internal/index/AbstractIndex.java     |  7 +++-
 ...AbstractIndexMaintenanceIntegrationTest.java | 42 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d49e8796/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
index d9a4e2e..c0e7885 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
@@ -2002,7 +2002,8 @@ public abstract class AbstractIndex implements IndexProtocol {
    */
   synchronized void setPdxStringFlag(Object key) {
     // For Null and Undefined keys do not set the isIndexedPdxKeysFlagSet flag
-    if (key == null || key == IndexManager.NULL || key == QueryService.UNDEFINED) {
+    if (isIndexedPdxKeysFlagSet || key == null || key == IndexManager.NULL
+        || key == QueryService.UNDEFINED) {
       return;
     }
     if (!this.isIndexedPdxKeys) {
@@ -2080,4 +2081,8 @@ public abstract class AbstractIndex implements IndexProtocol {
   public void setPopulated(boolean isPopulated) {
     this.isPopulated = isPopulated;
   }
+
+  boolean isIndexOnPdxKeys() {
+    return isIndexedPdxKeys;
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/d49e8796/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
index 66ed117..5d12705 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.cache.query.internal.index;
 
+import static junit.framework.TestCase.assertFalse;
+import static org.apache.geode.internal.Assert.assertTrue;
+
+import org.apache.geode.pdx.internal.PdxString;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -40,6 +44,44 @@ public abstract class AbstractIndexMaintenanceIntegrationTest {
   }
 
   @Test
+  public void setPdxStringFlagWithAPdxStringShouldNotBeChangedAfterTheFirstCall() throws
Exception {
+    CacheUtils.startCache();
+    Cache cache = CacheUtils.getCache();
+    LocalRegion region =
+        (LocalRegion) cache.createRegionFactory(RegionShortcut.REPLICATE).create("portfolios");
+    QueryService qs = cache.getQueryService();
+    AbstractIndex statusIndex =
+        createIndex(qs, "statusIndex", "value.status", "/portfolios.entrySet()");
+
+    statusIndex.setPdxStringFlag("StringKey");
+    assertTrue(statusIndex.isIndexedPdxKeysFlagSet);
+    assertFalse(statusIndex.isIndexOnPdxKeys());
+
+    statusIndex.setPdxStringFlag(new PdxString("PdxString Key"));
+    assertTrue(statusIndex.isIndexedPdxKeysFlagSet);
+    assertFalse(statusIndex.isIndexOnPdxKeys());
+  }
+
+  @Test
+  public void setPdxStringFlagWithAStringShouldNotBeChangedAfterTheFirstCall() throws Exception
{
+    CacheUtils.startCache();
+    Cache cache = CacheUtils.getCache();
+    LocalRegion region =
+        (LocalRegion) cache.createRegionFactory(RegionShortcut.REPLICATE).create("portfolios");
+    QueryService qs = cache.getQueryService();
+    AbstractIndex statusIndex =
+        createIndex(qs, "statusIndex", "value.status", "/portfolios.entrySet()");
+
+    statusIndex.setPdxStringFlag(new PdxString("PdxString Key"));
+    assertTrue(statusIndex.isIndexedPdxKeysFlagSet);
+    assertTrue(statusIndex.isIndexOnPdxKeys());
+
+    statusIndex.setPdxStringFlag("PdxString Key");
+    assertTrue(statusIndex.isIndexedPdxKeysFlagSet);
+    assertTrue(statusIndex.isIndexOnPdxKeys());
+  }
+
+  @Test
   public void whenRemovingRegionEntryFromIndexIfEntryDestroyedIsThrownCorrectlyRemoveFromIndexAndNotThrowException()
       throws Exception {
     CacheUtils.startCache();


Mime
View raw message