geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [1/2] incubator-geode git commit: Fixing a bug in LuceneQueryResultsImpl with pageSize=0
Date Thu, 24 Sep 2015 00:00:28 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-11 3e743df86 -> 87e46d823


Fixing a bug in LuceneQueryResultsImpl with pageSize=0

When pageSize=0, the results should be returned as a single page.
Instead it was returning an empty page.


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

Branch: refs/heads/feature/GEODE-11
Commit: 218f705f83d5de94e1928b7183c947bac79dc69e
Parents: 3e743df
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Sep 23 16:55:57 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Sep 23 16:55:57 2015 -0700

----------------------------------------------------------------------
 .../lucene/internal/LuceneQueryResultsImpl.java |  2 +-
 .../LuceneQueryResultsImplJUnitTest.java        | 43 +++++++++++++-------
 2 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/218f705f/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImpl.java
b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImpl.java
index 93a7f9d..d77dbc5 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImpl.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImpl.java
@@ -46,7 +46,7 @@ public class LuceneQueryResultsImpl<K,V> implements LuceneQueryResults<K,V>
{
   public LuceneQueryResultsImpl(List<EntryScore> hits, Region<K,V> userRegion,
int pageSize) {
     this.hits = hits;
     this.userRegion = userRegion;
-    this.pageSize = pageSize;
+    this.pageSize = pageSize == 0 ? Integer.MAX_VALUE : pageSize;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/218f705f/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImplJUnitTest.java
b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImplJUnitTest.java
index 000c01e..7009255 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImplJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneQueryResultsImplJUnitTest.java
@@ -27,6 +27,7 @@ public class LuceneQueryResultsImplJUnitTest {
 
   private List<EntryScore> hits;
   private List<LuceneResultStruct> expected = new ArrayList<LuceneResultStruct>();
+  private Region<String, String> userRegion;
   
   @Before
   public void setUp() {
@@ -36,21 +37,8 @@ public class LuceneQueryResultsImplJUnitTest {
       hits.add(new EntryScore("key_" + i, i));
       expected.add(new LuceneResultStructImpl<String, String>("key_" + i, "value_"
+ i, i));
     }
-  }
-  
-  @Test
-  public void testMaxStore() {
-
-    hits.set(5, new EntryScore("key_5", 502));
     
-    LuceneQueryResultsImpl<String, String> results = new LuceneQueryResultsImpl<String,
String>(hits, null, 5);
-    
-    assertEquals(502, results.getMaxScore(), 0.1f);
-  }
-  
-  @Test
-  public void testPagination() {
-    Region<String, String> userRegion = Mockito.mock(Region.class);
+    userRegion = Mockito.mock(Region.class);
     
     Mockito.when(userRegion.getAll(Mockito.anyCollection())).thenAnswer(new Answer() {
 
@@ -65,8 +53,20 @@ public class LuceneQueryResultsImplJUnitTest {
         return results;
       }
     });
+  }
+  
+  @Test
+  public void testMaxStore() {
+
+    hits.set(5, new EntryScore("key_5", 502));
     
+    LuceneQueryResultsImpl<String, String> results = new LuceneQueryResultsImpl<String,
String>(hits, null, 5);
     
+    assertEquals(502, results.getMaxScore(), 0.1f);
+  }
+  
+  @Test
+  public void testPagination() {
     LuceneQueryResultsImpl<String, String> results = new LuceneQueryResultsImpl<String,
String>(hits, userRegion, 10);
     
     assertEquals(23, results.size());
@@ -88,5 +88,20 @@ public class LuceneQueryResultsImplJUnitTest {
     assertFalse(results.hasNextPage());
     assertNull(results.getNextPage());
   }
+  
+  @Test
+  public void testNoPagination() {
+    LuceneQueryResultsImpl<String, String> results = new LuceneQueryResultsImpl<String,
String>(hits, userRegion, 0);
+    
+    assertEquals(23, results.size());
+    
+    assertTrue(results.hasNextPage());
+    
+    List<LuceneResultStruct<String, String>> next  = results.getNextPage();
+    assertEquals(expected, next);
+    
+    assertFalse(results.hasNextPage());
+    assertNull(results.getNextPage());
+  }
 
 }


Mime
View raw message