incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twilli...@apache.org
Subject git commit: Update test to return an object that'll go over the wire:)
Date Wed, 24 Sep 2014 23:00:28 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 46279f4d4 -> f3fe13f69


Update test to return an object that'll go over the wire:)


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

Branch: refs/heads/master
Commit: f3fe13f69bf71646c36c839272d22c2ea0598d0e
Parents: 46279f4
Author: twilliams <twilliams@apache.org>
Authored: Wed Sep 24 18:58:54 2014 -0400
Committer: twilliams <twilliams@apache.org>
Committed: Wed Sep 24 18:58:54 2014 -0400

----------------------------------------------------------------------
 .../org/apache/blur/command/TermsCommand.java   | 21 ++++++--------
 .../apache/blur/command/TermsCommandTest.java   | 30 ++++++++++----------
 .../blur/command/TestCombiningContext.java      | 13 +++++----
 .../java/org/apache/blur/command/BlurArray.java |  6 +++-
 4 files changed, 36 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f3fe13f6/blur-command/src/main/java/org/apache/blur/command/TermsCommand.java
----------------------------------------------------------------------
diff --git a/blur-command/src/main/java/org/apache/blur/command/TermsCommand.java b/blur-command/src/main/java/org/apache/blur/command/TermsCommand.java
index 8e02fe6..503a662 100644
--- a/blur-command/src/main/java/org/apache/blur/command/TermsCommand.java
+++ b/blur-command/src/main/java/org/apache/blur/command/TermsCommand.java
@@ -35,8 +35,8 @@ import com.google.common.collect.Sets;
  * the License.
  */
 @SuppressWarnings("serial")
-public class TermsCommand extends Command implements ClusterCommand<List<String>>,
-    IndexReadCombiningCommand<List<String>, List<String>> {
+public class TermsCommand extends Command implements ClusterReadCombiningCommand<BlurArray>,
+    IndexReadCombiningCommand<BlurArray, BlurArray> {
   private static final String NAME = "terms";
   private static final String PARAMS = "params";
   private static final String P_SIZE = "size";
@@ -46,31 +46,26 @@ public class TermsCommand extends Command implements ClusterCommand<List<String>
   private static final short DEFAULT_SIZE = 10;
 
   @Override
-  public List<String> execute(IndexContext context) throws IOException {
+  public BlurArray execute(IndexContext context) throws IOException {
     BlurObject params = context.getArgs().get(PARAMS);
     short size = params.getShort(P_SIZE, DEFAULT_SIZE);
     String fieldName = params.get(P_FIELD);
     String startWith = params.getString(P_START, "");
 
-    return terms(context.getIndexReader(), fieldName, startWith, size);
+    return new BlurArray(terms(context.getIndexReader(), fieldName, startWith, size));
   }
 
   @Override
-  public List<String> combine(CombiningContext context, Map<? extends Location<?>,
List<String>> results)
+  public BlurArray combine(CombiningContext context, Map<? extends Location<?>,
BlurArray> results)
       throws IOException, InterruptedException {
     TreeSet<String> terms = Sets.newTreeSet();
 
-    for (List<String> t : results.values()) {
-      terms.addAll(t);
+    for (BlurArray t : results.values()) {
+      terms.addAll((List<String>)t.getList());
     }
     // TODO: Use default until we figure out the requested size from the
     // context.
-    return Lists.newArrayList(terms).subList(0, Math.min(DEFAULT_SIZE, terms.size()));
-  }
-
-  @Override
-  public List<String> clusterExecute(ClusterContext context) throws IOException {
-    return null;
+    return new BlurArray(Lists.newArrayList(terms).subList(0, Math.min(DEFAULT_SIZE, terms.size())));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f3fe13f6/blur-command/src/test/java/org/apache/blur/command/TermsCommandTest.java
----------------------------------------------------------------------
diff --git a/blur-command/src/test/java/org/apache/blur/command/TermsCommandTest.java b/blur-command/src/test/java/org/apache/blur/command/TermsCommandTest.java
index c106a05..c480f29 100644
--- a/blur-command/src/test/java/org/apache/blur/command/TermsCommandTest.java
+++ b/blur-command/src/test/java/org/apache/blur/command/TermsCommandTest.java
@@ -38,55 +38,55 @@ public class TermsCommandTest {
 
   @Test
   public void basicTermsShouldReturn() throws IOException {
-    List<String> returned = getExecuteResult(newContext("val", null, null));
-    List<String> expected = Lists.newArrayList("val");
+    BlurArray returned = getExecuteResult(newContext("val", null, null));
+    BlurArray expected = new BlurArray(Lists.newArrayList("val"));
 
     assertEquals(expected, returned);
   }
 
   @Test
   public void sizeOfTermsRequestShouldBeRespected() throws IOException {
-    List<String> returned = getExecuteResult(newContext("alpha", (short) 7, null));
-    List<String> expected = Lists.newArrayList("aa", "bb", "cc", "dd", "ee", "ff",
"gg");
+    BlurArray returned = getExecuteResult(newContext("alpha", (short) 7, null));
+    BlurArray expected = new BlurArray(Lists.newArrayList("aa", "bb", "cc", "dd", "ee", "ff",
"gg"));
 
     assertEquals(expected, returned);
   }
 
   @Test
   public void sizeShouldDefaultToTen() throws IOException {
-    List<String> returned = getExecuteResult(newContext("alpha", null, null));
-    List<String> expected = Lists.newArrayList("aa", "bb", "cc", "dd", "ee", "ff",
"gg", "hh", "ii", "jj");
+    BlurArray returned = getExecuteResult(newContext("alpha", null, null));
+    BlurArray expected = new BlurArray(Lists.newArrayList("aa", "bb", "cc", "dd", "ee", "ff",
"gg", "hh", "ii", "jj"));
 
     assertEquals(expected, returned);
   }
 
   @Test
   public void combineShouldBeCorrect() throws IOException, InterruptedException {
-    Map<Shard, List<String>> execResults = Maps.newHashMap();
-    execResults.put(new Shard("t1", "s1"), Lists.newArrayList("aa", "cc"));
-    execResults.put(new Shard("t1", "s2"), Lists.newArrayList("bb", "dd"));
+    Map<Shard, BlurArray> execResults = Maps.newHashMap();
+    execResults.put(new Shard("t1", "s1"), new BlurArray(Lists.newArrayList("aa", "cc")));
+    execResults.put(new Shard("t1", "s2"), new BlurArray(Lists.newArrayList("bb", "dd")));
     
-    List<String> expected = Lists.newArrayList("aa", "bb", "cc", "dd");
+    BlurArray expected = new BlurArray(Lists.newArrayList("aa", "bb", "cc", "dd"));
     
     TermsCommand cmd = new TermsCommand();
-    List<String> returned = cmd.combine(new TestCombiningContext(), execResults);
+    BlurArray returned = cmd.combine(new TestCombiningContext(), execResults);
     
     assertEquals(expected, returned);
   }
   
   @Test
   public void combineEmptyShouldGiveNiceEmptyList() throws IOException, InterruptedException
{
-    Map<Shard, List<String>> execResults = Maps.newHashMap();
-    List<String> expected = Lists.newArrayList();
+    Map<Shard, BlurArray> execResults = Maps.newHashMap();
+    BlurArray expected = new BlurArray(Lists.newArrayList());
     
     TermsCommand cmd = new TermsCommand();
-    List<String> returned = cmd.combine(new TestCombiningContext(), execResults);
+    BlurArray returned = cmd.combine(new TestCombiningContext(), execResults);
     
     assertEquals(expected, returned);
   }
   
   
-  private List<String> getExecuteResult(IndexContext context) throws IOException {
+  private BlurArray getExecuteResult(IndexContext context) throws IOException {
     TermsCommand cmd = new TermsCommand();
     return cmd.execute(context);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f3fe13f6/blur-command/src/test/java/org/apache/blur/command/TestCombiningContext.java
----------------------------------------------------------------------
diff --git a/blur-command/src/test/java/org/apache/blur/command/TestCombiningContext.java
b/blur-command/src/test/java/org/apache/blur/command/TestCombiningContext.java
index 909bcc8..84f481f 100644
--- a/blur-command/src/test/java/org/apache/blur/command/TestCombiningContext.java
+++ b/blur-command/src/test/java/org/apache/blur/command/TestCombiningContext.java
@@ -22,23 +22,26 @@ import org.apache.blur.server.TableContext;
  * limitations under the License.
  */
 public class TestCombiningContext extends CombiningContext {
-
+  private Args args = new Args();
+  
+  public TestCombiningContext() {}
+  
+  public TestCombiningContext(Args a) {
+    this.args = a;
+  }
   
   @Override
   public Args getArgs() {
-    // TODO Auto-generated method stub
-    return null;
+    return args;
   }
 
   @Override
   public TableContext getTableContext(String table) throws IOException {
-    // TODO Auto-generated method stub
     return null;
   }
 
   @Override
   public BlurConfiguration getBlurConfiguration(String table) throws IOException {
-    // TODO Auto-generated method stub
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f3fe13f6/blur-core/src/main/java/org/apache/blur/command/BlurArray.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/command/BlurArray.java b/blur-core/src/main/java/org/apache/blur/command/BlurArray.java
index 88c7aa0..198fe70 100644
--- a/blur-core/src/main/java/org/apache/blur/command/BlurArray.java
+++ b/blur-core/src/main/java/org/apache/blur/command/BlurArray.java
@@ -31,7 +31,11 @@ public class BlurArray {
     _values.addAll(array._values);
   }
 
-  public List<Object> getList() {
+  public BlurArray(List<? extends Object> vals) {
+    _values .addAll(vals);
+  }
+  
+  public List<? extends Object> getList() {
     return _values;
   }
 


Mime
View raw message