incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [3/4] git commit: Small formatting changes and removal of unsued imports.
Date Tue, 19 Feb 2013 02:16:24 GMT
Small formatting changes and removal of unsued imports.


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

Branch: refs/heads/0.2-dev
Commit: ad440adf0c0cf80dda92691d83050e504cbd2710
Parents: f7a18ec
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Feb 18 21:15:19 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Feb 18 21:15:19 2013 -0500

----------------------------------------------------------------------
 .../org/apache/blur/analysis/BlurAnalyzer.java     |   33 +++++++--------
 .../org/apache/blur/analysis/BlurAnalyzerTest.java |   21 ++++-----
 2 files changed, 26 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ad440adf/src/blur-core/src/main/java/org/apache/blur/analysis/BlurAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/analysis/BlurAnalyzer.java b/src/blur-core/src/main/java/org/apache/blur/analysis/BlurAnalyzer.java
index de63673..32c4b12 100644
--- a/src/blur-core/src/main/java/org/apache/blur/analysis/BlurAnalyzer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/analysis/BlurAnalyzer.java
@@ -32,7 +32,6 @@ import javax.script.ScriptException;
 
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
-import org.apache.blur.server.BlurServer;
 import org.apache.blur.thrift.generated.AnalyzerSubType;
 import org.apache.blur.thrift.generated.AnalyzerType;
 import org.apache.blur.thrift.generated.ClassDefinition;
@@ -62,22 +61,22 @@ public final class BlurAnalyzer extends AnalyzerWrapper {
     _defaultAnalyzer = new StandardAnalyzer(LUCENE_VERSION);
     convert(analyzer);
   }
-  
+
   public Analyzer createAnalyzerFromJavascriptInitFunction(ClassDefinition classDefinition)
{
     String initFunction = classDefinition.getInitFunction();
-    Map<String,ByteBuffer> arguments = classDefinition.getArguments();
-    ScriptEngineManager manager = new ScriptEngineManager();  
-    ScriptEngine engine = manager.getEngineByName("JavaScript");  
+    Map<String, ByteBuffer> arguments = classDefinition.getArguments();
+    ScriptEngineManager manager = new ScriptEngineManager();
+    ScriptEngine engine = manager.getEngineByName("JavaScript");
     try {
       engine.eval(initFunction);
       Invocable inv = (Invocable) engine;
-      return (Analyzer)inv.invokeFunction("initAnalyzer", arguments );
+      return (Analyzer) inv.invokeFunction("initAnalyzer", arguments);
     } catch (ScriptException e) {
       throw new RuntimeException(e);
     } catch (NoSuchMethodException e) {
       LOG.error("Javascript function initAnalyzer not found.");
       throw new RuntimeException(e);
-    }  
+    }
   }
 
   private void convert(org.apache.blur.thrift.generated.Analyzer analyzer) {
@@ -96,15 +95,15 @@ public final class BlurAnalyzer extends AnalyzerWrapper {
           String analyzerClassName = analyzerClassDefinition.getClassName();
           String initFunction = analyzerClassDefinition.getInitFunction();
           Object analyzerClassObject;
-          if (initFunction != null){
+          if (initFunction != null) {
             analyzerClassObject = createAnalyzerFromJavascriptInitFunction(analyzerClassDefinition);
-            if (analyzerClassName != null){
-              LOG.warn("Analyzer class :: "+analyzerClassName+" ignored. Using javascript
init function to created Analyzer.");
+            if (analyzerClassName != null) {
+              LOG.warn("Analyzer class :: " + analyzerClassName + " ignored. Using javascript
init function to created Analyzer.");
             }
-          }else{
+          } else {
             analyzerClassObject = analyzerClassName == null ? null : Class.forName(analyzerClassName).newInstance();
           }
-          
+
           if (analyzerClassObject != null) {
             if (analyzerClassObject instanceof Analyzer) {
               _analyzers.put(indexName, (Analyzer) analyzerClassObject);
@@ -118,14 +117,14 @@ public final class BlurAnalyzer extends AnalyzerWrapper {
             for (AnalyzerSubType analyzerSubType : analyzerSubTypes) {
               String subIndexName = analyzerSubType.getSubFieldName();
               String subAnalyzerClassName = analyzerSubType.getClassDefinition().getClassName();
-              String sunInitFunction =  analyzerSubType.getClassDefinition().getInitFunction();
+              String sunInitFunction = analyzerSubType.getClassDefinition().getInitFunction();
               Object subAnalyzerClassObject;
-              if (sunInitFunction != null){
+              if (sunInitFunction != null) {
                 subAnalyzerClassObject = createAnalyzerFromJavascriptInitFunction(analyzerClassDefinition);
-                if (subAnalyzerClassName != null){
-                  LOG.warn("Sub Analyzer class :: "+subAnalyzerClassName+" ignored. Using
javascript init function to created Analyzer.");
+                if (subAnalyzerClassName != null) {
+                  LOG.warn("Sub Analyzer class :: " + subAnalyzerClassName + " ignored. Using
javascript init function to created Analyzer.");
                 }
-              }else{
+              } else {
                 subAnalyzerClassObject = subAnalyzerClassName == null ? null : Class.forName(subAnalyzerClassName).newInstance();
               }
               if (subAnalyzerClassObject != null) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ad440adf/src/blur-core/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java b/src/blur-core/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
index e4c5fe2..1e2226f 100644
--- a/src/blur-core/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
@@ -26,7 +26,6 @@ import java.util.Map;
 import javax.script.ScriptException;
 
 import org.apache.blur.thrift.generated.Analyzer;
-import org.apache.blur.thrift.generated.AnalyzerSubType;
 import org.apache.blur.thrift.generated.AnalyzerType;
 import org.apache.blur.thrift.generated.ClassDefinition;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -37,28 +36,28 @@ public class BlurAnalyzerTest {
 
   @Test
   public void testBlurAnalyzerForClassDefinition() throws IOException, ScriptException, NoSuchMethodException
{
-    
-    Map<String,ByteBuffer> arguments = new HashMap<String, ByteBuffer>();
-    arguments.put("StopWord1",null);
-    arguments.put("StopWord2",null);
-    
+
+    Map<String, ByteBuffer> arguments = new HashMap<String, ByteBuffer>();
+    arguments.put("StopWord1", null);
+    arguments.put("StopWord2", null);
+
     String initFunction = "function initAnalyzer(arguments) { args = new java.util.HashMap(arguments);
stopWordsSet = new org.apache.lucene.analysis.util.CharArraySet(org.apache.lucene.util.Version.LUCENE_40,
args.keySet(), true);return new org.apache.lucene.analysis.standard.StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_40,stopWordsSet);}";
     ClassDefinition classDefinition = new ClassDefinition();
     classDefinition.setArguments(arguments);
     classDefinition.setInitFunction(initFunction);
-    
+
     AnalyzerType analyzerType = new AnalyzerType();
     analyzerType.setFieldName("test");
     analyzerType.setClassDefinition(classDefinition);
-    
+
     Analyzer analyzer = new Analyzer();
     analyzer.setAnalyzerTypes(Arrays.asList(analyzerType));
-    
+
     BlurAnalyzer blurAnalyzer = new BlurAnalyzer(analyzer);
-    StandardAnalyzer createdAnalyzer = (StandardAnalyzer)blurAnalyzer.getWrappedAnalyzer("test");
+    StandardAnalyzer createdAnalyzer = (StandardAnalyzer) blurAnalyzer.getWrappedAnalyzer("test");
     blurAnalyzer.close();
     createdAnalyzer.getStopwordSet();
-    Assert.assertEquals(2,createdAnalyzer.getStopwordSet().size());
+    Assert.assertEquals(2, createdAnalyzer.getStopwordSet().size());
   }
 
 }


Mime
View raw message