incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: These commit were apart of patch in the previous commit.
Date Mon, 22 Jun 2015 14:11:53 GMT
These commit were apart of patch in the previous commit.


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

Branch: refs/heads/master
Commit: 0dac7d0068144ed6f2b94cc53f47d47679019ed4
Parents: 4be05f7
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Jun 22 10:11:15 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Jun 22 10:11:15 2015 -0400

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java     | 15 ++++++++++++---
 .../apache/blur/analysis/FieldTypeDefinition.java | 18 +++++++++++++++++-
 ...sivePrefixTreeStrategyFieldTypeDefinition.java |  5 +++++
 ...ueryPrefixTreeStrategyFieldTypeDefinition.java |  6 ++++++
 4 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0dac7d00/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index 1cba196..acd473a 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLongArray;
 
 import org.apache.blur.analysis.FieldManager;
+import org.apache.blur.analysis.FieldTypeDefinition;
 import org.apache.blur.concurrent.Executors;
 import org.apache.blur.index.AtomicReaderUtil;
 import org.apache.blur.index.ExitableReader;
@@ -981,6 +982,11 @@ public class IndexManager {
       LOG.error("Unknown error while trying to fetch index readers.", e);
       throw new BException(e.getMessage(), e);
     }
+
+    TableContext tableContext = getTableContext(table);
+    FieldManager fieldManager = tableContext.getFieldManager();
+    // TODO: isn't there a util or something available to concat these?
+    final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily
+ "." + columnName);
     return ForkJoin.execute(_executor, blurIndexes.entrySet(),
         new ParallelCall<Entry<String, BlurIndex>, List<String>>() {
           @Override
@@ -988,7 +994,7 @@ public class IndexManager {
             BlurIndex index = input.getValue();
             IndexSearcherCloseable searcher = index.getIndexSearcher();
             try {
-              return terms(searcher.getIndexReader(), columnFamily, columnName, startWith,
size);
+              return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName,
startWith, size);
             } finally {
               // this will allow for closing of index
               searcher.close();
@@ -1013,8 +1019,8 @@ public class IndexManager {
     return reader.docFreq(getTerm(columnFamily, columnName, value));
   }
 
-  public static List<String> terms(IndexReader reader, String columnFamily, String
columnName, String startWith,
-      short size) throws IOException {
+  public static List<String> terms(IndexReader reader, FieldTypeDefinition typeDef,
String columnFamily,
+      String columnName, String startWith, short size) throws IOException {
     if (startWith == null) {
       startWith = "";
     }
@@ -1037,6 +1043,9 @@ public class IndexManager {
     BytesRef currentTermText = termEnum.term();
     do {
       terms.add(currentTermText.utf8ToString());
+      String readTerm = typeDef.readTerm(currentTermText);
+      if (readTerm != null)
+        terms.add(readTerm);
       if (terms.size() >= size) {
         return terms;
       }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0dac7d00/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
index 101ef62..0cae0d6 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
@@ -28,6 +28,7 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.util.BytesRef;
 
 public abstract class FieldTypeDefinition {
 
@@ -259,11 +260,26 @@ public abstract class FieldTypeDefinition {
   }
 
   /**
-   * If true this will allow the same alternate field name(s) across instances of the same
{@link FieldTypeDefinition}.
+   * If true this will allow the same alternate field name(s) across instances
+   * of the same {@link FieldTypeDefinition}.
+   * 
    * @return booelan.
    */
   public boolean isAlternateFieldNamesSharedAcrossInstances() {
     return false;
   }
 
+  /**
+   * Method that will convert whatever internal lucene format a term was stored
+   * into something that could be used as a type-ahead or term listing for a
+   * given field. (by default numeric fields are not readable with a simple
+   * toUtf8String())
+   * 
+   * @param byteRef
+   *          the term that need converting into human readable form
+   * @return String representation of the BytesRef or null if the term is not a
+   *         real term (ie, a numeric offset for range querying)
+   */
+  public abstract String readTerm(BytesRef byteRef);
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0dac7d00/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
index c43664a..29b4475 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
@@ -28,6 +28,7 @@ import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.query.SpatialOperation;
+import org.apache.lucene.util.BytesRef;
 
 import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.shape.Shape;
@@ -83,4 +84,8 @@ public class SpatialRecursivePrefixTreeStrategyFieldTypeDefinition extends
BaseS
     return super.getCustomQuery(text);
   }
 
+  @Override
+  public String readTerm(BytesRef byteRef) {
+    return byteRef.utf8ToString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0dac7d00/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
index 933821c..ab1e247 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
@@ -28,6 +28,7 @@ import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.query.SpatialOperation;
+import org.apache.lucene.util.BytesRef;
 
 import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.shape.Point;
@@ -79,4 +80,9 @@ public class SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition extends
BaseS
     }
     return super.getCustomQuery(text);
   }
+
+  @Override
+  public String readTerm(BytesRef byteRef) {
+    return byteRef.utf8ToString();
+  }
 }


Mime
View raw message