incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twilli...@apache.org
Subject git commit: format/organize
Date Mon, 03 Mar 2014 23:52:05 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/apache-blur-0.2 885604e3b -> 9800bdee4


format/organize


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

Branch: refs/heads/apache-blur-0.2
Commit: 9800bdee416a3f8ca09faf161280558aba301944
Parents: 885604e
Author: twilliams <twilliams@apache.org>
Authored: Mon Mar 3 18:52:02 2014 -0500
Committer: twilliams <twilliams@apache.org>
Committed: Mon Mar 3 18:52:02 2014 -0500

----------------------------------------------------------------------
 .../org/apache/blur/slur/BlurQueryHelper.java   | 25 +++++++-------
 .../org/apache/blur/slur/BlurResultHelper.java  | 21 +++++-------
 .../org/apache/blur/slur/RowMutationHelper.java |  2 +-
 .../apache/blur/slur/SolrLookingBlurServer.java | 17 ++++------
 .../apache/blur/slur/BlurQueryHelperTest.java   | 35 ++++++++++----------
 .../apache/blur/slur/RowMutationHelperTest.java |  3 +-
 .../blur/slur/SolrLookingBlurServerTest.java    | 33 +++++++++---------
 7 files changed, 64 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurQueryHelper.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurQueryHelper.java b/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurQueryHelper.java
index bae9cde..27346a6 100644
--- a/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurQueryHelper.java
+++ b/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurQueryHelper.java
@@ -7,7 +7,6 @@ import java.util.Set;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.Query;
 import org.apache.blur.thrift.generated.Selector;
-import org.apache.commons.collections.map.HashedMap;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.SolrParams;
 
@@ -17,14 +16,14 @@ public class BlurQueryHelper {
 
   public static BlurQuery from(SolrParams p) {
     BlurQuery blurQuery = new BlurQuery();
-    
+
     Query query = new Query();
     query.setRowQuery(false);
-    
+
     maybeAddSelector(blurQuery, p);
-    
+
     query.setQuery(p.get(CommonParams.Q));
-    
+
     blurQuery.setQuery(query);
     return blurQuery;
   }
@@ -33,25 +32,25 @@ public class BlurQueryHelper {
     String fieldString = p.get(CommonParams.FL);
     Selector selector = new Selector();
     selector.setRecordOnly(true);
-    
-    if(fieldString != null) {
+
+    if (fieldString != null) {
       Map<String, Set<String>> famCols = Maps.newHashMap();
       String[] fields = fieldString.split(",");
-      
-      for(String field: fields) {
+
+      for (String field : fields) {
         String[] famCol = field.split("\\.");
-        
-        if(famCol.length != 2) {
+
+        if (famCol.length != 2) {
           throw new IllegalArgumentException("Fields must be in a family.column format["
+ field + "]");
         }
-        if(!famCols.containsKey(famCol[0])) {
+        if (!famCols.containsKey(famCol[0])) {
           famCols.put(famCol[0], new HashSet<String>());
         }
         Set<String> cols = famCols.get(famCol[0]);
         cols.add(famCol[1]);
       }
       selector.setColumnsToFetch(famCols);
-     
+
     }
     blurQuery.setSelector(selector);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurResultHelper.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurResultHelper.java b/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurResultHelper.java
index aab8482..eb3cd50 100644
--- a/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurResultHelper.java
+++ b/whiteboard/slur/src/main/java/org/apache/blur/slur/BlurResultHelper.java
@@ -6,9 +6,7 @@ import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.BlurResults;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.blur.thrift.generated.FetchRecordResult;
-import org.apache.blur.thrift.generated.FetchRowResult;
 import org.apache.blur.thrift.generated.Record;
-import org.apache.blur.thrift.generated.Row;
 import org.apache.blur.utils.BlurConstants;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
@@ -17,37 +15,36 @@ public class BlurResultHelper {
 
   public static SolrDocumentList from(BlurResults results) {
     SolrDocumentList docResults = new SolrDocumentList();
-    
+
     convertMetadata(results, docResults);
 
     convertRows(results.getResults(), docResults);
-    
+
     return docResults;
   }
 
   private static void convertRows(List<BlurResult> results, SolrDocumentList docResults)
{
-    for(BlurResult result: results) {      
+    for (BlurResult result : results) {
       docResults.add(convertRecord(result.getFetchResult().getRecordResult()));
     }
-    
+
   }
 
   private static SolrDocument convertRecord(FetchRecordResult recResult) {
     SolrDocument doc = new SolrDocument();
     Record record = recResult.getRecord();
-    
+
     doc.addField(BlurConstants.RECORD_ID, record.getRecordId());
-    
-    for(Column col: record.getColumns()) {
-      System.out.println("Adding[" + joinColumnFamily(record.getFamily(), col.getName())
+ "] val[" + col.getValue() + "]");
+
+    for (Column col : record.getColumns()) {
       doc.addField(joinColumnFamily(record.getFamily(), col.getName()), col.getValue());
     }
-    
+
     return doc;
   }
 
   private static String joinColumnFamily(String family, String name) {
-    if(family != null) {
+    if (family != null) {
       return family + "." + name;
     }
     return name;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/main/java/org/apache/blur/slur/RowMutationHelper.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/main/java/org/apache/blur/slur/RowMutationHelper.java b/whiteboard/slur/src/main/java/org/apache/blur/slur/RowMutationHelper.java
index 850ea96..44ac7a4 100644
--- a/whiteboard/slur/src/main/java/org/apache/blur/slur/RowMutationHelper.java
+++ b/whiteboard/slur/src/main/java/org/apache/blur/slur/RowMutationHelper.java
@@ -54,7 +54,7 @@ public class RowMutationHelper {
         validateAsRecord(child);
         recordMutations.add(createRecordMutation(child, extractRecordId(child)));
       }
-      
+
     }
     mutate.setRecordMutations(recordMutations);
     return mutate;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/main/java/org/apache/blur/slur/SolrLookingBlurServer.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/main/java/org/apache/blur/slur/SolrLookingBlurServer.java
b/whiteboard/slur/src/main/java/org/apache/blur/slur/SolrLookingBlurServer.java
index 193e390..204a1a1 100644
--- a/whiteboard/slur/src/main/java/org/apache/blur/slur/SolrLookingBlurServer.java
+++ b/whiteboard/slur/src/main/java/org/apache/blur/slur/SolrLookingBlurServer.java
@@ -20,18 +20,14 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.BlurClient;
-import org.apache.blur.thrift.BlurClientManager;
 import org.apache.blur.thrift.generated.Blur.Iface;
-import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurResults;
 import org.apache.blur.thrift.generated.RowMutation;
 import org.apache.blur.thrift.generated.RowMutationType;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
-import org.apache.solr.client.solrj.SolrResponse;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.StreamingResponseCallback;
@@ -40,7 +36,6 @@ import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.SolrPingResponse;
 import org.apache.solr.client.solrj.response.SolrResponseBase;
 import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
@@ -227,21 +222,21 @@ public class SolrLookingBlurServer extends SolrServer {
   public QueryResponse query(SolrParams params) throws SolrServerException {
     QueryResponse response = new QueryResponse();
     long start = System.currentTimeMillis();
-    
+
     try {
       BlurQuery blurQuery = BlurQueryHelper.from(params);
       BlurResults results = client().query(tableName, blurQuery);
       NamedList<Object> resp = new NamedList<Object>();
-        
+
       resp.add("response", BlurResultHelper.from(results));
-      
+
       response.setResponse(resp);
     } catch (Exception e) {
       throw new SolrServerException("Unable to complete query", e);
     }
-    
-    response.setElapsedTime((System.currentTimeMillis()-start));
-    
+
+    response.setElapsedTime((System.currentTimeMillis() - start));
+
     return response;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/test/java/org/apache/blur/slur/BlurQueryHelperTest.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/test/java/org/apache/blur/slur/BlurQueryHelperTest.java b/whiteboard/slur/src/test/java/org/apache/blur/slur/BlurQueryHelperTest.java
index 8f72c1f..566c489 100644
--- a/whiteboard/slur/src/test/java/org/apache/blur/slur/BlurQueryHelperTest.java
+++ b/whiteboard/slur/src/test/java/org/apache/blur/slur/BlurQueryHelperTest.java
@@ -1,6 +1,7 @@
 package org.apache.blur.slur;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
 import java.util.Set;
@@ -15,44 +16,44 @@ public class BlurQueryHelperTest {
   @Test
   public void simpleQueryString() {
     SolrParams p = new SolrQuery("foo");
-    
+
     BlurQuery query = BlurQueryHelper.from(p);
-    
+
     assertEquals("Should get our query string back.", "foo", query.getQuery().getQuery());
   }
-  
-  @Test(expected=IllegalArgumentException.class)
+
+  @Test(expected = IllegalArgumentException.class)
   public void fieldValuesMustFollowBlursFamilyColumnFormat() {
     SolrQuery p = new SolrQuery();
-    
+
     p.setFields("foo");
-    
+
     BlurQuery query = BlurQueryHelper.from(p);
   }
-  
+
   @Test
   public void fieldsShouldTranslateToSelector() {
     SolrQuery p = new SolrQuery();
-    
-    p.setFields("fam1.col1","fam1.col2","fam2.col1");
-    
+
+    p.setFields("fam1.col1", "fam1.col2", "fam2.col1");
+
     BlurQuery query = BlurQueryHelper.from(p);
-    
+
     Map<String, Set<String>> columns = query.getSelector().getColumnsToFetch();
-    
+
     assertTrue("Should have fam1 defined.", columns.containsKey("fam1"));
     assertTrue("Should have fam2 defined.", columns.containsKey("fam2"));
-    
+
     Set<String> fam1 = columns.get("fam1");
-    
+
     assertEquals("Should get all columns back.", 2, fam1.size());
     assertTrue("Should contain our column", fam1.contains("col1"));
     assertTrue("Should contain our column", fam1.contains("col2"));
-    
+
     Set<String> fam2 = columns.get("fam2");
     assertEquals("Should get all columns back.", 1, fam2.size());
     assertTrue("Should contain our column", fam2.contains("col1"));
-       
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/test/java/org/apache/blur/slur/RowMutationHelperTest.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/test/java/org/apache/blur/slur/RowMutationHelperTest.java
b/whiteboard/slur/src/test/java/org/apache/blur/slur/RowMutationHelperTest.java
index 7b9a843..6dc6aaa 100644
--- a/whiteboard/slur/src/test/java/org/apache/blur/slur/RowMutationHelperTest.java
+++ b/whiteboard/slur/src/test/java/org/apache/blur/slur/RowMutationHelperTest.java
@@ -16,13 +16,12 @@
  */
 package org.apache.blur.slur;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import java.util.List;
 
 import org.apache.blur.thrift.generated.Column;
 import org.apache.blur.thrift.generated.Record;
-import org.apache.blur.thrift.generated.RecordMutation;
 import org.apache.blur.thrift.generated.RowMutation;
 import org.apache.solr.common.SolrInputDocument;
 import org.junit.AfterClass;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9800bdee/whiteboard/slur/src/test/java/org/apache/blur/slur/SolrLookingBlurServerTest.java
----------------------------------------------------------------------
diff --git a/whiteboard/slur/src/test/java/org/apache/blur/slur/SolrLookingBlurServerTest.java
b/whiteboard/slur/src/test/java/org/apache/blur/slur/SolrLookingBlurServerTest.java
index 8e372d4..2ae8f17 100644
--- a/whiteboard/slur/src/test/java/org/apache/blur/slur/SolrLookingBlurServerTest.java
+++ b/whiteboard/slur/src/test/java/org/apache/blur/slur/SolrLookingBlurServerTest.java
@@ -17,8 +17,8 @@
 package org.apache.blur.slur;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
@@ -96,10 +96,10 @@ public class SolrLookingBlurServerTest {
   @Test
   public void childDocsShouldBecomeRecordsOfRow() throws Exception {
     String table = "childDocsShouldBecomeRecordsOfRow";
-    
+
     TestTableCreator.newTable(table)
-    .withRowCount(1).withRecordsPerRow(100)
-    .withRecordColumns("fam.value").create();
+        .withRowCount(1).withRecordsPerRow(100)
+        .withRecordColumns("fam.value").create();
 
     TableStats stats = client().tableStats(table);
 
@@ -142,9 +142,8 @@ public class SolrLookingBlurServerTest {
       TException {
     String table = "multipleDocumentsShouldBeIndexed";
     TestTableCreator.newTable(table)
-                          .withRowCount(100).withRecordsPerRow(1)
-                          .withRecordColumns("fam.value").create();
- 
+        .withRowCount(100).withRecordsPerRow(1)
+        .withRecordColumns("fam.value").create();
 
     assertTotalResults(table, "fam.value:value0-0", 1l);
     assertTotalResults(table, "fam.value:value1-0", 1l);
@@ -160,8 +159,9 @@ public class SolrLookingBlurServerTest {
   public void weShouldBeAbleToDeleteARowById() throws Exception,
       TException {
     String table = "weShouldBeAbleToDeleteARowById";
-    
-    SolrServer server = TestTableCreator.newTable(table).withRowCount(2).withRecordsPerRow(1).withRecordColumns("fam.value").create();
+
+    SolrServer server = TestTableCreator.newTable(table).withRowCount(2).withRecordsPerRow(1)
+        .withRecordColumns("fam.value").create();
 
     assertTotalResults(table, "rowid:0", 1l);
     assertTotalResults(table, "rowid:1", 1l);
@@ -178,9 +178,10 @@ public class SolrLookingBlurServerTest {
   public void weShouldBeAbleToDeleteARowByAListOfIds() throws Exception,
       TException {
     String table = "weShouldBeAbleToDeleteARowByAListOfIds";
-    
-    SolrServer server = TestTableCreator.newTable(table).withRowCount(20).withRecordsPerRow(1).withRecordColumns("fam.value").create();
-    
+
+    SolrServer server = TestTableCreator.newTable(table).withRowCount(20).withRecordsPerRow(1)
+        .withRecordColumns("fam.value").create();
+
     assertTotalResults(table, "rowid:1", 1l);
     assertTotalResults(table, "rowid:2", 1l);
     List<String> ids = Lists.newArrayList("1", "2", "3", "4", "5");
@@ -198,7 +199,7 @@ public class SolrLookingBlurServerTest {
     String table = "basicFullTextQuery";
     SolrServer server = TestTableCreator.newTable(table)
         .withRowCount(1).withRecordsPerRow(2)
-        .withRecordColumns("fam.value", "fam.mvf","fam.mvf").create();
+        .withRecordColumns("fam.value", "fam.mvf", "fam.mvf").create();
 
     SolrQuery query = new SolrQuery("value0-0");
 
@@ -225,8 +226,8 @@ public class SolrLookingBlurServerTest {
 
     String table = "fieldsRequestsShouldTurnIntoSelectors";
     SolrServer server = TestTableCreator.newTable(table)
-                          .withRowCount(1).withRecordsPerRow(2)
-                          .withRecordColumns("fam.value", "fam.mvf").create();
+        .withRowCount(1).withRecordsPerRow(2)
+        .withRecordColumns("fam.value", "fam.mvf").create();
 
     SolrQuery query = new SolrQuery("value0-0");
     query.setFields("fam.value");
@@ -376,7 +377,7 @@ public class SolrLookingBlurServerTest {
         for (int j = 0; j < recordsPerRow; j++) {
           SolrInputDocument child = new SolrInputDocument();
           child.addField(BlurConstants.RECORD_ID, j);
-          
+
           for (String colName : columns) {
             child.addField(colName, "value" + i + "-" + j);
           }


Mime
View raw message