geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [geode] branch feature/GEODE-3606 updated: GEODE-3606: add index as parameter for toDocuments()
Date Fri, 22 Sep 2017 16:39:31 GMT
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-3606
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-3606 by this push:
     new a2de0d2  GEODE-3606: add index as parameter for toDocuments()
a2de0d2 is described below

commit a2de0d22b3868864db6ba6b3da0c18a23c5925a1
Author: zhouxh <gzhou@pivotal.io>
AuthorDate: Fri Sep 22 09:38:36 2017 -0700

    GEODE-3606: add index as parameter for toDocuments()
---
 .../geode/cache/lucene/LuceneSerializer.java       |  4 +-
 .../lucene/internal/IndexRepositoryFactory.java    |  2 +-
 .../internal/LuceneIndexForPartitionedRegion.java  |  2 +-
 .../cache/lucene/internal/LuceneRawIndex.java      |  2 +-
 .../lucene/internal/RawIndexRepositoryFactory.java |  2 +-
 .../internal/repository/IndexRepositoryImpl.java   | 11 ++++--
 .../serializer/HeterogeneousLuceneSerializer.java  | 43 +++++++---------------
 .../repository/serializer/PdxLuceneSerializer.java |  3 +-
 .../repository/serializer/PrimitiveSerializer.java |  3 +-
 .../serializer/ReflectionLuceneSerializer.java     |  4 +-
 .../geode/cache/lucene/DummyLuceneSerializer.java  |  2 +-
 .../cache/lucene/LuceneIndexCreationDUnitTest.java |  3 +-
 .../LuceneIndexMaintenanceIntegrationTest.java     |  6 +--
 .../LuceneIndexCreationProfileJUnitTest.java       |  2 +-
 .../LuceneIndexRecoveryHAIntegrationTest.java      |  4 +-
 .../PartitionedRepositoryManagerJUnitTest.java     |  2 +-
 .../RawLuceneRepositoryManagerJUnitTest.java       |  2 +-
 .../distributed/DistributedScoringJUnitTest.java   |  7 +++-
 .../repository/IndexRepositoryImplJUnitTest.java   |  7 +++-
 .../IndexRepositoryImplPerformanceTest.java        |  2 +-
 .../HeterogeneousLuceneSerializerJUnitTest.java    |  8 ++--
 .../serializer/SerializerTestHelper.java           |  7 +++-
 .../cache/lucene/test/LuceneTestSerializer.java    |  3 +-
 23 files changed, 64 insertions(+), 67 deletions(-)

diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneSerializer.java
index f1c530d..363867d 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneSerializer.java
@@ -30,6 +30,8 @@ public interface LuceneSerializer extends Declarable {
 
   /**
    * Add the fields of the given value to a set of documents
+   * 
+   * @param index lucene index
    */
-  Collection<Document> toDocuments(Object value);
+  Collection<Document> toDocuments(LuceneIndex index, Object value);
 }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
index a863ddc..08ffaa9 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
@@ -83,7 +83,7 @@ public class IndexRepositoryFactory {
       IndexWriterConfig config = new IndexWriterConfig(indexForPR.getAnalyzer());
       IndexWriter writer = new IndexWriter(dir, config);
       repo = new IndexRepositoryImpl(fileAndChunkBucket, writer, serializer,
-          indexForPR.getIndexStats(), dataBucket, lockService, lockName);
+          indexForPR.getIndexStats(), dataBucket, lockService, lockName, indexForPR);
       success = true;
       return repo;
     } catch (IOException e) {
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 2fc714a..b383210 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -59,7 +59,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   protected RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer)
{
     LuceneSerializer mapper = luceneSerializer;
     if (mapper == null) {
-      mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+      mapper = new HeterogeneousLuceneSerializer();
     }
     PartitionedRepositoryManager partitionedRepositoryManager =
         new PartitionedRepositoryManager(this, mapper);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
index 7ee0ff5..7ecd5c2 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
@@ -29,7 +29,7 @@ public class LuceneRawIndex extends LuceneIndexImpl {
   protected RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer)
{
     HeterogeneousLuceneSerializer mapper = (HeterogeneousLuceneSerializer) luceneSerializer;
     if (mapper == null) {
-      mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+      mapper = new HeterogeneousLuceneSerializer();
     }
     RawLuceneRepositoryManager rawLuceneRepositoryManager =
         new RawLuceneRepositoryManager(this, mapper);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
index 9085ce0..f1f9cd3 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
@@ -58,6 +58,6 @@ public class RawIndexRepositoryFactory extends IndexRepositoryFactory {
     IndexWriter writer = new IndexWriter(dir, config);
 
     return new IndexRepositoryImpl(null, writer, serializer, indexForRaw.getIndexStats(),
-        dataBucket, null, "");
+        dataBucket, null, "", indexForRaw);
   }
 }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImpl.java
index 8698471..e772d49 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImpl.java
@@ -17,6 +17,7 @@ package org.apache.geode.cache.lucene.internal.repository;
 
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.repository.serializer.SerializerUtil;
 import org.apache.geode.distributed.DistributedLockService;
@@ -54,6 +55,7 @@ public class IndexRepositoryImpl implements IndexRepository {
   private DocumentCountSupplier documentCountSupplier;
   private final DistributedLockService lockService;
   private String lockName;
+  private LuceneIndex index;
 
   private static final Logger logger = LogService.getLogger();
 
@@ -61,12 +63,12 @@ public class IndexRepositoryImpl implements IndexRepository {
   IndexRepositoryImpl(Region<?, ?> region, IndexWriter writer, LuceneSerializer serializer,
       LuceneIndexStats stats, Region<?, ?> userRegion) throws IOException {
     this(region, writer, serializer, stats, userRegion,
-        ((DistributedRegion) region).getLockService(), "NoLockFile");
+        ((DistributedRegion) region).getLockService(), "NoLockFile", null);
   }
 
   public IndexRepositoryImpl(Region<?, ?> region, IndexWriter writer, LuceneSerializer
serializer,
       LuceneIndexStats stats, Region<?, ?> userRegion, DistributedLockService lockService,
-      String lockName) throws IOException {
+      String lockName, LuceneIndex index) throws IOException {
     this.region = region;
     this.userRegion = userRegion;
     this.writer = writer;
@@ -77,13 +79,14 @@ public class IndexRepositoryImpl implements IndexRepository {
     stats.addDocumentsSupplier(documentCountSupplier);
     this.lockService = lockService;
     this.lockName = lockName;
+    this.index = index;
   }
 
   @Override
   public void create(Object key, Object value) throws IOException {
     long start = stats.startUpdate();
     try {
-      Collection<Document> docs = serializer.toDocuments(value);
+      Collection<Document> docs = serializer.toDocuments(index, value);
       docs.forEach(doc -> SerializerUtil.addKey(key, doc));
       writer.addDocuments(docs);
     } finally {
@@ -95,7 +98,7 @@ public class IndexRepositoryImpl implements IndexRepository {
   public void update(Object key, Object value) throws IOException {
     long start = stats.startUpdate();
     try {
-      Collection<Document> docs = serializer.toDocuments(value);
+      Collection<Document> docs = serializer.toDocuments(index, value);
       docs.forEach(doc -> SerializerUtil.addKey(key, doc));
       Term keyTerm = SerializerUtil.toKeyTerm(key);
       writer.updateDocuments(keyTerm, docs);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
index 864b3b7..cd02ea3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.document.Document;
-
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.internal.logging.LogService;
@@ -34,11 +34,6 @@ import org.apache.geode.pdx.PdxInstance;
  */
 public class HeterogeneousLuceneSerializer implements LuceneSerializer {
   /**
-   * The set of indexed fields for this mapper
-   */
-  private String[] indexedFields;
-
-  /**
    * A mapper for converting a PDX object into a document
    */
   private LuceneSerializer pdxMapper;
@@ -53,36 +48,18 @@ public class HeterogeneousLuceneSerializer implements LuceneSerializer
{
 
   private static final Logger logger = LogService.getLogger();
 
-  public HeterogeneousLuceneSerializer(String[] indexedFields) {
-    this.indexedFields = indexedFields;
-    pdxMapper = new PdxLuceneSerializer(indexedFields);
-
-
-    addSerializersForPrimitiveValues();
-  }
-
-  /**
-   * Add serializers for the primitive value types (String, Number, etc.) if the user has
requested
-   * that the whole value be serialized
-   */
-  private void addSerializersForPrimitiveValues() {
-    if (Arrays.asList(indexedFields).contains(LuceneService.REGION_VALUE_FIELD)) {
-      final PrimitiveSerializer primitiveSerializer = new PrimitiveSerializer();
-      SerializerUtil.supportedPrimitiveTypes().stream()
-          .forEach(type -> mappers.put(type, primitiveSerializer));
-    }
-  }
+  public HeterogeneousLuceneSerializer() {}
 
   @Override
-  public Collection<Document> toDocuments(Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, Object value) {
 
     if (value == null) {
       return Collections.emptyList();
     }
 
-    LuceneSerializer mapper = getFieldMapper(value);
+    LuceneSerializer mapper = getFieldMapper(value, index.getFieldNames());
 
-    Collection<Document> docs = mapper.toDocuments(value);
+    Collection<Document> docs = mapper.toDocuments(null, value);
     if (logger.isDebugEnabled()) {
       logger.debug("HeterogeneousLuceneSerializer.toDocuments:" + docs);
     }
@@ -93,8 +70,16 @@ public class HeterogeneousLuceneSerializer implements LuceneSerializer
{
   /**
    * Get the field mapper based on the type of the given object.
    */
-  private LuceneSerializer getFieldMapper(Object value) {
+  private LuceneSerializer getFieldMapper(Object value, String[] indexedFields) {
+    if (Arrays.asList(indexedFields).contains(LuceneService.REGION_VALUE_FIELD)) {
+      final PrimitiveSerializer primitiveSerializer = new PrimitiveSerializer();
+      SerializerUtil.supportedPrimitiveTypes().stream()
+          .forEach(type -> mappers.put(type, primitiveSerializer));
+    }
     if (value instanceof PdxInstance) {
+      if (pdxMapper == null) {
+        pdxMapper = new PdxLuceneSerializer(indexedFields);
+      }
       return pdxMapper;
     } else {
       Class<?> clazz = value.getClass();
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PdxLuceneSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PdxLuceneSerializer.java
index f63a1b7..a18043a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PdxLuceneSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PdxLuceneSerializer.java
@@ -21,6 +21,7 @@ import org.apache.lucene.document.Document;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.pdx.PdxInstance;
@@ -39,7 +40,7 @@ class PdxLuceneSerializer implements LuceneSerializer {
   }
 
   @Override
-  public Collection<Document> toDocuments(Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, Object value) {
     Document doc = new Document();
     PdxInstance pdx = (PdxInstance) value;
     for (String field : indexedFields) {
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PrimitiveSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PrimitiveSerializer.java
index 159f18c..fddcb44 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PrimitiveSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/PrimitiveSerializer.java
@@ -17,6 +17,7 @@ package org.apache.geode.cache.lucene.internal.repository.serializer;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.LuceneService;
 
@@ -29,7 +30,7 @@ import org.apache.lucene.document.Document;
 public class PrimitiveSerializer implements LuceneSerializer {
 
   @Override
-  public Collection<Document> toDocuments(final Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, final Object value) {
     Document doc = new Document();
     SerializerUtil.addField(doc, LuceneService.REGION_VALUE_FIELD, value);
     return Collections.singleton(doc);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/ReflectionLuceneSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/ReflectionLuceneSerializer.java
index a9ef5d2..5b9298b 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/ReflectionLuceneSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/ReflectionLuceneSerializer.java
@@ -25,7 +25,7 @@ import java.util.Set;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.document.Document;
-
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.internal.logging.LogService;
 
@@ -63,7 +63,7 @@ class ReflectionLuceneSerializer implements LuceneSerializer {
   }
 
   @Override
-  public Collection<Document> toDocuments(Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, Object value) {
     Document doc = new Document();
     for (Field field : fields) {
       try {
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/DummyLuceneSerializer.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/DummyLuceneSerializer.java
index 2a31768..def03f7 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/DummyLuceneSerializer.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/DummyLuceneSerializer.java
@@ -22,7 +22,7 @@ import org.apache.lucene.document.Document;
 public class DummyLuceneSerializer implements LuceneSerializer {
 
   @Override
-  public Collection<Document> toDocuments(Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, Object value) {
     return Collections.emptyList();
   }
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java
index e41cf85..afd8c96 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationDUnitTest.java
@@ -506,8 +506,7 @@ public class LuceneIndexCreationDUnitTest extends LuceneDUnitTest {
     return () -> {
       LuceneService luceneService = LuceneServiceProvider.get(getCache());
       luceneService.createIndexFactory().setFields(new String[] {"field1", "field2"})
-          .setLuceneSerializer(new HeterogeneousLuceneSerializer(new String[] {"field1",
"field2"}))
-          .create(INDEX_NAME, REGION_NAME);
+          .setLuceneSerializer(new HeterogeneousLuceneSerializer()).create(INDEX_NAME, REGION_NAME);
     };
   }
 }
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
index 03921ee..1827f2a 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
@@ -109,10 +109,8 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
 
   @Test
   public void useSerializerToIndex() throws Exception {
-    luceneService.createIndexFactory().setFields("title", "name")
-        .setLuceneSerializer(
-            new HeterogeneousLuceneSerializer(new String[] {"title", "description"}))
-        .create(INDEX_NAME, REGION_NAME);
+    luceneService.createIndexFactory().setFields("title", "description")
+        .setLuceneSerializer(new HeterogeneousLuceneSerializer()).create(INDEX_NAME, REGION_NAME);
 
     Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION);
     region.put("object-1", new TestObject("title 1", "hello world"));
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
index c653c2f..5ecca42 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
@@ -97,7 +97,7 @@ public class LuceneIndexCreationProfileJUnitTest {
 
   private LuceneIndexCreationProfile getHeterogeneousLuceneSerializerCreationProfile() {
     return new LuceneIndexCreationProfile(INDEX_NAME, REGION_NAME, new String[] {"field1"},
-        new StandardAnalyzer(), null, new HeterogeneousLuceneSerializer(new String[] {"field1"}));
+        new StandardAnalyzer(), null, new HeterogeneousLuceneSerializer());
   }
 
   @Test
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
index b6b1d23..5adf823 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
@@ -43,7 +43,7 @@ import static org.junit.Assert.assertTrue;
 @Category(IntegrationTest.class)
 public class LuceneIndexRecoveryHAIntegrationTest {
   String[] indexedFields = new String[] {"txt"};
-  HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(indexedFields);
+  HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
   Analyzer analyzer = new StandardAnalyzer();
 
   Cache cache;
@@ -53,7 +53,7 @@ public class LuceneIndexRecoveryHAIntegrationTest {
   @Before
   public void setup() {
     indexedFields = new String[] {"txt"};
-    mapper = new HeterogeneousLuceneSerializer(indexedFields);
+    mapper = new HeterogeneousLuceneSerializer();
     analyzer = new StandardAnalyzer();
     LuceneServiceImpl.registerDataSerializables();
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
index deda987..20d0213 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
@@ -82,7 +82,7 @@ public class PartitionedRepositoryManagerJUnitTest {
     userDataStore = Mockito.mock(PartitionedRegionDataStore.class);
     when(userRegion.getDataStore()).thenReturn(userDataStore);
     when(cache.getRegion("/testRegion")).thenReturn(userRegion);
-    serializer = new HeterogeneousLuceneSerializer(new String[] {"a", "b"});
+    serializer = new HeterogeneousLuceneSerializer();
     DLockService lockService = mock(DLockService.class);
     when(lockService.lock(any(), anyLong(), anyLong())).thenReturn(true);
     DLockService.addLockServiceForTests(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME,
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
index ca4d170..26447ca 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
@@ -46,7 +46,7 @@ public class RawLuceneRepositoryManagerJUnitTest extends PartitionedRepositoryMa
     userDataStore = Mockito.mock(PartitionedRegionDataStore.class);
     when(userRegion.getDataStore()).thenReturn(userDataStore);
     when(cache.getRegion("/testRegion")).thenReturn(userRegion);
-    serializer = new HeterogeneousLuceneSerializer(new String[] {"a", "b"});
+    serializer = new HeterogeneousLuceneSerializer();
     createIndexAndRepoManager();
   }
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/DistributedScoringJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/DistributedScoringJUnitTest.java
index ee1c70f..ef6f44e 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/DistributedScoringJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/DistributedScoringJUnitTest.java
@@ -32,6 +32,7 @@ import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 import org.apache.geode.cache.lucene.internal.directory.RegionDirectory;
 import org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats;
@@ -43,7 +44,7 @@ import org.apache.geode.test.junit.categories.UnitTest;
 public class DistributedScoringJUnitTest {
 
   private String[] indexedFields = new String[] {"txt"};
-  private HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(indexedFields);
+  private HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
 
   private final StandardAnalyzer analyzer = new StandardAnalyzer();
   private Region<String, String> region;
@@ -135,8 +136,10 @@ public class DistributedScoringJUnitTest {
 
     IndexWriterConfig config = new IndexWriterConfig(analyzer);
     IndexWriter writer = new IndexWriter(dir, config);
+    LuceneIndex index = Mockito.mock(LuceneIndex.class);
+    Mockito.when(index.getFieldNames()).thenReturn(new String[] {"txt"});
 
-    return new IndexRepositoryImpl(region, writer, mapper, indexStats, null, null, "");
+    return new IndexRepositoryImpl(region, writer, mapper, indexStats, null, null, "", index);
   }
 
   private static class TestType {
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
index 23c2e9c..bac4c12 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplJUnitTest.java
@@ -42,6 +42,7 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 import org.apache.geode.cache.lucene.internal.directory.RegionDirectory;
 import org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats;
@@ -73,7 +74,7 @@ public class IndexRepositoryImplJUnitTest {
     IndexWriterConfig config = new IndexWriterConfig(analyzer);
     writer = new IndexWriter(dir, config);
     String[] indexedFields = new String[] {"s", "i", "l", "d", "f", "s2", "missing"};
-    mapper = new HeterogeneousLuceneSerializer(indexedFields);
+    mapper = new HeterogeneousLuceneSerializer();
     region = Mockito.mock(Region.class);
     userRegion = Mockito.mock(BucketRegion.class);
     BucketAdvisor bucketAdvisor = Mockito.mock(BucketAdvisor.class);
@@ -83,8 +84,10 @@ public class IndexRepositoryImplJUnitTest {
     Mockito.when(((BucketRegion) userRegion).getBucketAdvisor().isPrimary()).thenReturn(true);
     stats = Mockito.mock(LuceneIndexStats.class);
     Mockito.when(userRegion.isDestroyed()).thenReturn(false);
+    LuceneIndex index = Mockito.mock(LuceneIndex.class);
+    Mockito.when(index.getFieldNames()).thenReturn(new String[] {"s"});
     repo = new IndexRepositoryImpl(region, writer, mapper, stats, userRegion,
-        mock(DistributedLockService.class), "lockName");
+        mock(DistributedLockService.class), "lockName", index);
   }
 
   @Test
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplPerformanceTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplPerformanceTest.java
index 4b321a5..a591cd9 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplPerformanceTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/IndexRepositoryImplPerformanceTest.java
@@ -119,7 +119,7 @@ public class IndexRepositoryImplPerformanceTest {
         IndexWriterConfig config = new IndexWriterConfig(analyzer);
         writer = new IndexWriter(dir, config);
         String[] indexedFields = new String[] {"text"};
-        HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(indexedFields);
+        HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
         repo = new IndexRepositoryImpl(fileAndChunkRegion, writer, mapper, stats, null);
       }
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializerJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializerJUnitTest.java
index e7e95ba..684323f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializerJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializerJUnitTest.java
@@ -37,7 +37,7 @@ public class HeterogeneousLuceneSerializerJUnitTest {
   @Test
   public void testHeterogeneousObjects() {
     String[] fields = new String[] {"s", "i", "l", "d", "f", "s2", "missing"};
-    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(fields);
+    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
 
     Type1 t1 = new Type1("a", 1, 2L, 3.0, 4.0f);
 
@@ -78,8 +78,7 @@ public class HeterogeneousLuceneSerializerJUnitTest {
 
   @Test
   public void shouldIndexPrimitiveStringIfRequested() {
-    HeterogeneousLuceneSerializer mapper =
-        new HeterogeneousLuceneSerializer(new String[] {LuceneService.REGION_VALUE_FIELD});
+    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
     Document doc = SerializerTestHelper.invokeSerializer(mapper, "sample value");
     assertEquals(1, doc.getFields().size());
     assertEquals("sample value", doc.getField(LuceneService.REGION_VALUE_FIELD).stringValue());
@@ -87,8 +86,7 @@ public class HeterogeneousLuceneSerializerJUnitTest {
 
   @Test
   public void shouldIndexPrimitiveNumberIfRequested() {
-    HeterogeneousLuceneSerializer mapper =
-        new HeterogeneousLuceneSerializer(new String[] {LuceneService.REGION_VALUE_FIELD});
+    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
     Document doc = SerializerTestHelper.invokeSerializer(mapper, 53);
 
     assertEquals(1, doc.getFields().size());
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/SerializerTestHelper.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/SerializerTestHelper.java
index 3f5e8d7..61a5ad7 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/SerializerTestHelper.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/SerializerTestHelper.java
@@ -19,12 +19,15 @@ import static org.junit.Assert.assertEquals;
 import java.util.Collection;
 
 import org.apache.lucene.document.Document;
-
+import org.mockito.Mockito;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 
 public class SerializerTestHelper {
   static Document invokeSerializer(LuceneSerializer mapper, Object object) {
-    Collection<Document> docs = mapper.toDocuments(object);
+    LuceneIndex index = Mockito.mock(LuceneIndex.class);
+    Mockito.when(index.getFieldNames()).thenReturn(new String[] {"s", "i", "l", "d", "f",
"s2"});
+    Collection<Document> docs = mapper.toDocuments(index, object);
     assertEquals(1, docs.size());
     return docs.iterator().next();
   }
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/LuceneTestSerializer.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/LuceneTestSerializer.java
index 7466b7a..0f2e86c 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/LuceneTestSerializer.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/LuceneTestSerializer.java
@@ -15,6 +15,7 @@
 package org.apache.geode.cache.lucene.test;
 
 import org.apache.geode.cache.Declarable;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.internal.cache.xmlcache.Declarable2;
 import org.apache.lucene.document.Document;
@@ -59,7 +60,7 @@ public class LuceneTestSerializer implements LuceneSerializer {
   }
 
   @Override
-  public Collection<Document> toDocuments(Object value) {
+  public Collection<Document> toDocuments(LuceneIndex index, Object value) {
     return Collections.emptyList();
   }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message