incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [04/45] git commit: Adding MIN and MAX keywords for Numeric types.
Date Sat, 28 Sep 2013 02:11:50 GMT
Adding MIN and MAX keywords for Numeric types.


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

Branch: refs/heads/apache-blur-0.2
Commit: ffd701822fecb3d6408329007a3061a80ffbc41c
Parents: a906bc3
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Sep 14 18:24:35 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Sep 14 18:24:35 2013 -0400

----------------------------------------------------------------------
 .../type/DoubleFieldTypeDefinition.java         | 14 +++++++++++--
 .../analysis/type/FloatFieldTypeDefinition.java | 13 ++++++++++--
 .../analysis/type/IntFieldTypeDefinition.java   | 14 +++++++++++--
 .../analysis/type/LongFieldTypeDefinition.java  | 14 +++++++++++--
 .../type/NumericFieldTypeDefinition.java        |  3 +++
 docs/data-model.html                            | 22 +++++++++++++++++++-
 6 files changed, 71 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
index 3e2db14..bb6464e 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
@@ -69,9 +69,19 @@ public class DoubleFieldTypeDefinition extends NumericFieldTypeDefinition
{
 
   @Override
   public Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    double p1 = Double.parseDouble(part1);
-    double p2 = Double.parseDouble(part2);
+    double p1 = parseDouble(part1);
+    double p2 = parseDouble(part2);
     return NumericRangeQuery.newDoubleRange(field, _precisionStep, p1, p2, startInclusive,
endInclusive);
   }
+  
+  private double parseDouble(String number) {
+    if (number.toLowerCase().equals(MIN)) {
+      return Double.MIN_VALUE;
+    } else if (number.toLowerCase().equals(MAX)) {
+      return Double.MAX_VALUE;
+    } else {
+      return Double.parseDouble(number);
+    }
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
index 66567c8..730733b 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
@@ -69,9 +69,18 @@ public class FloatFieldTypeDefinition extends NumericFieldTypeDefinition
{
 
   @Override
   public Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    float p1 = Float.parseFloat(part1);
-    float p2 = Float.parseFloat(part2);
+    float p1 = parseFloat(part1);
+    float p2 = parseFloat(part2);
     return NumericRangeQuery.newFloatRange(field, _precisionStep, p1, p2, startInclusive,
endInclusive);
   }
 
+  private float parseFloat(String number) {
+    if (number.toLowerCase().equals(MIN)) {
+      return Float.MIN_VALUE;
+    } else if (number.toLowerCase().equals(MAX)) {
+      return Float.MAX_VALUE;
+    } else {
+      return Float.parseFloat(number);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
index f20694e..890d0c8 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
@@ -69,8 +69,18 @@ public class IntFieldTypeDefinition extends NumericFieldTypeDefinition
{
 
   @Override
   public Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    int p1 = Integer.parseInt(part1);
-    int p2 = Integer.parseInt(part2);
+    int p1 = parseInt(part1);
+    int p2 = parseInt(part2);
     return NumericRangeQuery.newIntRange(field, _precisionStep, p1, p2, startInclusive, endInclusive);
   }
+  
+  private int parseInt(String number) {
+    if (number.toLowerCase().equals(MIN)) {
+      return Integer.MIN_VALUE;
+    } else if (number.toLowerCase().equals(MAX)) {
+      return Integer.MAX_VALUE;
+    } else {
+      return Integer.parseInt(number);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
index d28b726..ec53927 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
@@ -69,9 +69,19 @@ public class LongFieldTypeDefinition extends NumericFieldTypeDefinition
{
 
   @Override
   public Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    long p1 = Long.parseLong(part1);
-    long p2 = Long.parseLong(part2);
+    long p1 = parseLong(part1);
+    long p2 = parseLong(part2);
     return NumericRangeQuery.newLongRange(field, _precisionStep, p1, p2, startInclusive,
endInclusive);
   }
 
+  private long parseLong(String number) {
+    if (number.toLowerCase().equals(MIN)) {
+      return Long.MIN_VALUE;
+    } else if (number.toLowerCase().equals(MAX)) {
+      return Long.MAX_VALUE;
+    } else {
+      return Long.parseLong(number);
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
index 2d0921e..008cf5f 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
@@ -25,6 +25,9 @@ import org.apache.lucene.util.NumericUtils;
 public abstract class NumericFieldTypeDefinition extends FieldTypeDefinition {
 
   protected static final String NUMERIC_PRECISION_STEP = "numericPrecisionStep";
+  
+  protected static final String MAX = "max";
+  protected static final String MIN = "min";
 
   protected int _precisionStep = NumericUtils.PRECISION_STEP_DEFAULT;
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ffd70182/docs/data-model.html
----------------------------------------------------------------------
diff --git a/docs/data-model.html b/docs/data-model.html
index 9aab6ba..f6c397c 100644
--- a/docs/data-model.html
+++ b/docs/data-model.html
@@ -244,6 +244,26 @@ To run a query to find all the rows that contain a column with a starting
value
 <pre><code class="json">docs.id:[12345 TO 54321]</code></pre>
 </p>
 
+<p>
+To run a query to find all the rows that contain a column with a value less than &quot;12345&quot;
where the family is &quot;docs&quot; and the column is &quot;id&quot;.
+<pre><code class="json">docs.id:[MIN TO 12345}</code></pre>
+</p>
+
+<p>
+To run a query to find all the rows that contain a column with a value less than or equal
to &quot;12345&quot; where the family is &quot;docs&quot; and the column is
&quot;id&quot;.
+<pre><code class="json">docs.id:[MIN TO 12345]</code></pre>
+</p>
+
+<p>
+To run a query to find all the rows that contain a column with a value great than to &quot;12345&quot;
where the family is &quot;docs&quot; and the column is &quot;id&quot;.
+<pre><code class="json">docs.id:{12345 TO MAX]</code></pre>
+</p>
+
+<p>
+To run a query to find all the rows that contain a column with a value great than or equal
to &quot;12345&quot; where the family is &quot;docs&quot; and the column is
&quot;id&quot;.
+<pre><code class="json">docs.id:[12345 TO MAX]</code></pre>
+</p>
+
 <h3 id="date_query">Date</h3>
 <p>Date types are basically a long field type with a date parser built-in.
 
@@ -464,4 +484,4 @@ To run a query to find all the rows that contain a location within 10
miles of g
     <script src="resources/js/respond.min.js"></script>
     <script src="resources/js/docs.js"></script>
   </body>
-</html>
+</html>


Mime
View raw message