You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by mh...@apache.org on 2019/12/19 20:42:38 UTC
[geode] branch release/1.11.0 updated: GEODE-7593: Force index to
use Strings instead of PdxStrings when eviction is enabled on region
(#4500)
This is an automated email from the ASF dual-hosted git repository.
mhanson pushed a commit to branch release/1.11.0
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/release/1.11.0 by this push:
new a36eadc GEODE-7593: Force index to use Strings instead of PdxStrings when eviction is enabled on region (#4500)
a36eadc is described below
commit a36eadca6c08078e089cb4942225498ac64cb947
Author: Jason Huynh <hu...@gmail.com>
AuthorDate: Thu Dec 19 09:38:05 2019 -0800
GEODE-7593: Force index to use Strings instead of PdxStrings when eviction is enabled on region (#4500)
(cherry picked from commit 1beec9e3930a071031b960f045874fb337e72e7c)
---
.../index/AbstractIndexMaintenanceIntegrationTest.java | 18 ++++++++++++++++++
.../cache/query/internal/index/AbstractIndex.java | 3 ++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
index 9917dd1..53a9d9d 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/AbstractIndexMaintenanceIntegrationTest.java
@@ -22,6 +22,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.EvictionAttributes;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.query.CacheUtils;
import org.apache.geode.cache.query.IndexExistsException;
@@ -116,6 +117,23 @@ public abstract class AbstractIndexMaintenanceIntegrationTest {
statusIndex.removeIndexMapping(entry, IndexProtocol.OTHER_OP);
}
+ @Test
+ public void indexKeysShouldBeStringIfRegionHasEvictionEnabled() throws Exception {
+ CacheUtils.startCache();
+ Cache cache = CacheUtils.getCache();
+ LocalRegion region =
+ (LocalRegion) cache.createRegionFactory(RegionShortcut.REPLICATE)
+ .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes())
+ .create("portfolios");
+ QueryService qs = cache.getQueryService();
+ AbstractIndex statusIndex =
+ createIndex(qs, "statusIndex", "value.status", "/portfolios.entrySet()");
+
+ statusIndex.setPdxStringFlag(new PdxString("IndexKey"));
+ assertFalse(statusIndex.isIndexOnPdxKeys());
+ }
+
+
protected abstract AbstractIndex createIndex(final QueryService qs, String name,
String indexExpression, String regionPath)
throws IndexNameConflictException, IndexExistsException, RegionNotFoundException;
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 98f7a91..bec7fb6 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
@@ -2024,7 +2024,8 @@ public abstract class AbstractIndex implements IndexProtocol {
return;
}
if (!this.isIndexedPdxKeys) {
- if (key instanceof PdxString && this.region.getAttributes().getCompressor() == null) {
+ if (region.getAttributes().getEvictionAttributes().isNoEviction() == true
+ && key instanceof PdxString && this.region.getAttributes().getCompressor() == null) {
this.isIndexedPdxKeys = true;
}
}