You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/12/04 17:48:51 UTC

[07/50] lucene-solr:jira/solr-11458-2: SOLR-11569: Add support for distance matrices to the distance Stream Evaluator

SOLR-11569: Add support for distance matrices to the distance Stream Evaluator


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/17078019
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/17078019
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/17078019

Branch: refs/heads/jira/solr-11458-2
Commit: 17078019e2266ac18abdd7c26b522d8b44b62e7f
Parents: 9b85b57
Author: Joel Bernstein <jb...@apache.org>
Authored: Wed Nov 22 18:30:39 2017 -0500
Committer: Joel Bernstein <jb...@apache.org>
Committed: Wed Nov 22 18:31:08 2017 -0500

----------------------------------------------------------------------
 .../org/apache/solr/handler/StreamHandler.java  |   2 +-
 .../io/eval/CanberraDistanceEvaluator.java      |  56 -------
 .../client/solrj/io/eval/DistanceEvaluator.java | 154 +++++++++++++++++
 .../io/eval/EarthMoversDistanceEvaluator.java   |  56 -------
 .../io/eval/ManhattanDistanceEvaluator.java     |  56 -------
 .../solrj/io/stream/StreamExpressionTest.java   | 166 ++++++++++++++-----
 6 files changed, 282 insertions(+), 208 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
index 834dab5..652048d 100644
--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
@@ -205,7 +205,7 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
         .withFunctionName("cov", CovarianceEvaluator.class)
         .withFunctionName("corr", CorrelationEvaluator.class)
         .withFunctionName("describe", DescribeEvaluator.class)
-        .withFunctionName("distance", EuclideanDistanceEvaluator.class)
+        .withFunctionName("distance", DistanceEvaluator.class)
         .withFunctionName("manhattanDistance", ManhattanDistanceEvaluator.class)
         .withFunctionName("earthMoversDistance", EarthMoversDistanceEvaluator.class)
         .withFunctionName("canberraDistance", CanberraDistanceEvaluator.class)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/CanberraDistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/CanberraDistanceEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/CanberraDistanceEvaluator.java
deleted file mode 100644
index 2271a34..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/CanberraDistanceEvaluator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.eval;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.commons.math3.ml.distance.CanberraDistance;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class CanberraDistanceEvaluator extends RecursiveNumericEvaluator implements TwoValueWorker {
-  protected static final long serialVersionUID = 1L;
-
-  public CanberraDistanceEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
-    super(expression, factory);
-  }
-
-  @Override
-  public Object doWork(Object first, Object second) throws IOException{
-    if(null == first){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
-    }
-    if(null == second){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
-    }
-    if(!(first instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the first value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-    if(!(second instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-
-    CanberraDistance distance = new CanberraDistance();
-    return distance.compute(
-        ((List)first).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray(),
-        ((List)second).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray()
-    );
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DistanceEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DistanceEvaluator.java
new file mode 100644
index 0000000..96712da
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DistanceEvaluator.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.math3.linear.Array2DRowRealMatrix;
+import org.apache.commons.math3.linear.RealMatrix;
+import org.apache.commons.math3.ml.distance.CanberraDistance;
+import org.apache.commons.math3.ml.distance.DistanceMeasure;
+import org.apache.commons.math3.ml.distance.EarthMoversDistance;
+import org.apache.commons.math3.ml.distance.EuclideanDistance;
+import org.apache.commons.math3.ml.distance.ManhattanDistance;
+
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class DistanceEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker {
+  protected static final long serialVersionUID = 1L;
+
+  public enum DistanceType {euclidean, manhattan, canberra, earthMovers}
+  private DistanceType type;
+
+  public DistanceEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    List<StreamExpressionNamedParameter> namedParams = factory.getNamedOperands(expression);
+    if(namedParams.size() > 0) {
+      if (namedParams.size() > 1) {
+        throw new IOException("distance function expects only one named parameter 'type'.");
+      }
+
+      StreamExpressionNamedParameter namedParameter = namedParams.get(0);
+      String name = namedParameter.getName();
+      if (!name.equalsIgnoreCase("type")) {
+        throw new IOException("distance function expects only one named parameter 'type'.");
+      }
+
+      String typeParam = namedParameter.getParameter().toString().trim();
+      this.type= DistanceType.valueOf(typeParam);
+    } else {
+      this.type = DistanceType.euclidean;
+    }
+  }
+
+  @Override
+  public Object doWork(Object ... values) throws IOException{
+
+    if(values.length == 2) {
+      Object first = values[0];
+      Object second = values[1];
+
+      if (null == first) {
+        throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - null found for the first value", toExpression(constructingFactory)));
+      }
+      if (null == second) {
+        throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - null found for the second value", toExpression(constructingFactory)));
+      }
+      if (!(first instanceof List<?>)) {
+        throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - found type %s for the first value, expecting a list of numbers", toExpression(constructingFactory), first.getClass().getSimpleName()));
+      }
+      if (!(second instanceof List<?>)) {
+        throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - found type %s for the second value, expecting a list of numbers", toExpression(constructingFactory), first.getClass().getSimpleName()));
+      }
+
+      if (type.equals(DistanceType.euclidean)) {
+        EuclideanDistance euclideanDistance = new EuclideanDistance();
+        return euclideanDistance.compute(
+            ((List) first).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray(),
+            ((List) second).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray()
+        );
+      } else if (type.equals(DistanceType.manhattan)) {
+        ManhattanDistance manhattanDistance = new ManhattanDistance();
+        return manhattanDistance.compute(
+            ((List) first).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray(),
+            ((List) second).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray()
+        );
+
+      } else if (type.equals(DistanceType.canberra)) {
+        CanberraDistance canberraDistance = new CanberraDistance();
+        return canberraDistance.compute(
+            ((List) first).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray(),
+            ((List) second).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray()
+        );
+      } else if (type.equals(DistanceType.earthMovers)) {
+        EarthMoversDistance earthMoversDistance = new EarthMoversDistance();
+        return earthMoversDistance.compute(
+            ((List) first).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray(),
+            ((List) second).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray()
+        );
+      } else {
+        return null;
+      }
+    } else if(values.length == 1) {
+      if(values[0] instanceof Matrix) {
+        Matrix matrix = (Matrix)values[0];
+        if (type.equals(DistanceType.euclidean)) {
+          EuclideanDistance euclideanDistance = new EuclideanDistance();
+          return distance(euclideanDistance, matrix);
+        } else if (type.equals(DistanceType.canberra)) {
+          CanberraDistance canberraDistance = new CanberraDistance();
+          return distance(canberraDistance, matrix);
+        } else if (type.equals(DistanceType.manhattan)) {
+          ManhattanDistance manhattanDistance = new ManhattanDistance();
+          return distance(manhattanDistance, matrix);
+        } else if (type.equals(DistanceType.earthMovers)) {
+          EarthMoversDistance earthMoversDistance = new EarthMoversDistance();
+          return distance(earthMoversDistance, matrix);
+        } else {
+          return null;
+        }
+      } else {
+        throw new IOException("distance function operates on either two numeric arrays or a single matrix as parameters.");
+      }
+    } else {
+      throw new IOException("distance function operates on either two numeric arrays or a single matrix as parameters.");
+    }
+  }
+
+  private Matrix distance(DistanceMeasure distanceMeasure, Matrix matrix) {
+    double[][] data = matrix.getData();
+    RealMatrix realMatrix = new Array2DRowRealMatrix(data);
+    realMatrix = realMatrix.transpose();
+    data = realMatrix.getData();
+    double[][] distanceMatrix = new double[data.length][data.length];
+    for(int i=0; i<data.length; i++) {
+      double[] row = data[i];
+      for(int j=0; j<data.length; j++) {
+        double[] row2 = data[j];
+        double dist = distanceMeasure.compute(row, row2);
+        distanceMatrix[i][j] = dist;
+      }
+    }
+    return new Matrix(distanceMatrix);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EarthMoversDistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EarthMoversDistanceEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EarthMoversDistanceEvaluator.java
deleted file mode 100644
index 0769d20..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EarthMoversDistanceEvaluator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.eval;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.commons.math3.ml.distance.EarthMoversDistance;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class EarthMoversDistanceEvaluator extends RecursiveNumericEvaluator implements TwoValueWorker {
-  protected static final long serialVersionUID = 1L;
-
-  public EarthMoversDistanceEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
-    super(expression, factory);
-  }
-
-  @Override
-  public Object doWork(Object first, Object second) throws IOException{
-    if(null == first){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
-    }
-    if(null == second){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
-    }
-    if(!(first instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the first value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-    if(!(second instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-
-    EarthMoversDistance distance = new EarthMoversDistance();
-    return distance.compute(
-        ((List)first).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray(),
-        ((List)second).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray()
-    );
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ManhattanDistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ManhattanDistanceEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ManhattanDistanceEvaluator.java
deleted file mode 100644
index c0a8ed1..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ManhattanDistanceEvaluator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.eval;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.commons.math3.ml.distance.ManhattanDistance;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class ManhattanDistanceEvaluator extends RecursiveNumericEvaluator implements TwoValueWorker {
-  protected static final long serialVersionUID = 1L;
-
-  public ManhattanDistanceEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
-    super(expression, factory);
-  }
-
-  @Override
-  public Object doWork(Object first, Object second) throws IOException{
-    if(null == first){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
-    }
-    if(null == second){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
-    }
-    if(!(first instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the first value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-    if(!(second instanceof List<?>)){
-      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
-    }
-
-    ManhattanDistance distance = new ManhattanDistance();
-    return distance.compute(
-        ((List)first).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray(),
-        ((List)second).stream().mapToDouble(value -> ((BigDecimal)value).doubleValue()).toArray()
-    );
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/17078019/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
index c64b4d7..a2b6b58 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
@@ -5593,55 +5593,143 @@ public class StreamExpressionTest extends SolrCloudTestCase {
 
   @Test
   public void testDistance() throws Exception {
-    UpdateRequest updateRequest = new UpdateRequest();
-
-    int i=0;
-    while(i<50) {
-      updateRequest.add(id, "id_"+(++i),"test_dt", getDateString("2016", "5", "1"), "price_f", "400.00");
-    }
-
-    while(i<100) {
-      updateRequest.add(id, "id_"+(++i),"test_dt", getDateString("2015", "5", "1"), "price_f", "300.0");
-    }
-
-    while(i<150) {
-      updateRequest.add(id, "id_"+(++i),"test_dt", getDateString("2014", "5", "1"), "price_f", "500.0");
-    }
-
-    while(i<250) {
-      updateRequest.add(id, "id_"+(++i),"test_dt", getDateString("2013", "5", "1"), "price_f", "100.00");
-    }
-
-    updateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);
-
-    String expr = "timeseries("+COLLECTIONORALIAS+", q=\"*:*\", start=\"2013-01-01T01:00:00.000Z\", " +
-        "end=\"2016-12-01T01:00:00.000Z\", " +
-        "gap=\"+1YEAR\", " +
-        "field=\"test_dt\", " +
-        "count(*), sum(price_f), max(price_f), min(price_f))";
-
-    String cexpr = "let(a="+expr+", b=select("+expr+",mult(-1, count(*)) as nvalue), c=col(a, count(*)), d=col(b, nvalue), " +
-                   "tuple(colc=c, cold=d, cov=cov(c,d), dist=distance(c,d), " +
-                         "mdist=manhattanDistance(c,d), edist=earthMoversDistance(c, d), cdist=canberraDistance(c,d)," +
-                         "chdist=chebyshevDistance(c,d)))";
+    String cexpr = "let(echo=true, " +
+                       "a=array(1,2,3,4)," +
+                       "b=array(2,3,4,5), " +
+                       "c=array(3,4,5,6), " +
+                       "d=distance(a, b), " +
+                       "e=distance(a, c)," +
+                       "f=distance(b, c)," +
+                       "g=transpose(matrix(a, b, c))," +
+                       "h=distance(g)," +
+                       "i=distance(a, b, type=manhattan), " +
+                       "j=distance(a, c, type=manhattan)," +
+                       "k=distance(b, c, type=manhattan)," +
+                       "l=transpose(matrix(a, b, c))," +
+                       "m=distance(l, type=manhattan)," +
+                       "n=distance(a, b, type=canberra), " +
+                       "o=distance(a, c, type=canberra)," +
+                       "p=distance(b, c, type=canberra)," +
+                       "q=transpose(matrix(a, b, c))," +
+                       "r=distance(q, type=canberra)," +
+                       "s=distance(a, b, type=earthMovers), " +
+                       "t=distance(a, c, type=earthMovers)," +
+                       "u=distance(b, c, type=earthMovers)," +
+                       "w=transpose(matrix(a, b, c))," +
+                       "x=distance(w, type=earthMovers)," +
+                       ")";
 
     ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
     paramsLoc.set("expr", cexpr);
     paramsLoc.set("qt", "/stream");
-
     String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString()+"/"+COLLECTIONORALIAS;
     TupleStream solrStream = new SolrStream(url, paramsLoc);
-
     StreamContext context = new StreamContext();
     solrStream.setStreamContext(context);
     List<Tuple> tuples = getTuples(solrStream);
     assertTrue(tuples.size() == 1);
-    assertTrue(tuples.get(0).getDouble("cov").equals(-625.0D));
-    assertTrue(tuples.get(0).getDouble("dist").equals(264.5751311064591D));
-    assertTrue(tuples.get(0).getDouble("mdist").equals(500.0D));
-    assertTrue(tuples.get(0).getDouble("cdist").equals(4.0D));
-    assertTrue(tuples.get(0).getDouble("chdist").equals(200.0D));
-    assertTrue(tuples.get(0).getDouble("edist").equals(1400.0D));
+    Number d = (Number)tuples.get(0).get("d");
+    assertEquals(d.doubleValue(), 2.0, 0.0);
+    Number e = (Number)tuples.get(0).get("e");
+    assertEquals(e.doubleValue(), 4.0, 0.0);
+    Number f = (Number)tuples.get(0).get("f");
+    assertEquals(f.doubleValue(), 2.0, 0.0);
+
+    List<List<Number>> h = (List<List<Number>>)tuples.get(0).get("h");
+    assertEquals(h.size(), 3);
+    assertEquals(h.get(0).size(), 3);
+    List<Number> row0 = h.get(0);
+    assertEquals(row0.get(0).doubleValue(), 0, 0);
+    assertEquals(row0.get(1).doubleValue(), 2, 0);
+    assertEquals(row0.get(2).doubleValue(), 4, 0);
+
+    List<Number> row1 = h.get(1);
+    assertEquals(row1.get(0).doubleValue(), 2, 0);
+    assertEquals(row1.get(1).doubleValue(), 0, 0);
+    assertEquals(row1.get(2).doubleValue(), 2, 0);
+
+    List<Number> row2 = h.get(2);
+    assertEquals(row2.get(0).doubleValue(), 4, 0);
+    assertEquals(row2.get(1).doubleValue(), 2, 0);
+    assertEquals(row2.get(2).doubleValue(), 0, 0);
+
+    Number i = (Number)tuples.get(0).get("i");
+    assertEquals(i.doubleValue(), 4.0, 0.0);
+    Number j = (Number)tuples.get(0).get("j");
+    assertEquals(j.doubleValue(), 8.0, 0.0);
+    Number k = (Number)tuples.get(0).get("k");
+    assertEquals(k.doubleValue(), 4.0, 0.0);
+
+    List<List<Number>> m = (List<List<Number>>)tuples.get(0).get("m");
+    assertEquals(m.size(), 3);
+    assertEquals(m.get(0).size(), 3);
+    row0 = m.get(0);
+    assertEquals(row0.get(0).doubleValue(), 0, 0);
+    assertEquals(row0.get(1).doubleValue(), 4, 0);
+    assertEquals(row0.get(2).doubleValue(), 8, 0);
+
+    row1 = m.get(1);
+    assertEquals(row1.get(0).doubleValue(), 4, 0);
+    assertEquals(row1.get(1).doubleValue(), 0, 0);
+    assertEquals(row1.get(2).doubleValue(), 4, 0);
+
+    row2 = m.get(2);
+    assertEquals(row2.get(0).doubleValue(), 8, 0);
+    assertEquals(row2.get(1).doubleValue(), 4, 0);
+    assertEquals(row2.get(2).doubleValue(), 0, 0);
+
+    Number n = (Number)tuples.get(0).get("n");
+    assertEquals(n.doubleValue(), 0.787302, 0.0001);
+    Number o = (Number)tuples.get(0).get("o");
+    assertEquals(o.doubleValue(), 1.283333, 0.0001);
+    Number p = (Number)tuples.get(0).get("p");
+    assertEquals(p.doubleValue(), 0.544877, 0.0001);
+
+    List<List<Number>> r = (List<List<Number>>)tuples.get(0).get("r");
+    assertEquals(r.size(), 3);
+    assertEquals(r.get(0).size(), 3);
+    row0 = r.get(0);
+    assertEquals(row0.get(0).doubleValue(), 0, 0);
+    assertEquals(row0.get(1).doubleValue(), 0.787302, .0001);
+    assertEquals(row0.get(2).doubleValue(), 1.283333, .0001);
+
+    row1 = r.get(1);
+    assertEquals(row1.get(0).doubleValue(), 0.787302, .0001);
+    assertEquals(row1.get(1).doubleValue(), 0, 0);
+    assertEquals(row1.get(2).doubleValue(), 0.544877, .0001);
+
+    row2 = r.get(2);
+    assertEquals(row2.get(0).doubleValue(), 1.283333, .0001);
+    assertEquals(row2.get(1).doubleValue(), 0.544877, .0001);
+    assertEquals(row2.get(2).doubleValue(), 0, 0);
+
+
+    Number s = (Number)tuples.get(0).get("s");
+    assertEquals(s.doubleValue(), 10.0, 0);
+    Number t = (Number)tuples.get(0).get("t");
+    assertEquals(t.doubleValue(), 20.0, 0);
+    Number u = (Number)tuples.get(0).get("u");
+    assertEquals(u.doubleValue(), 10.0, 0);
+
+    List<List<Number>> x = (List<List<Number>>)tuples.get(0).get("x");
+    assertEquals(x.size(), 3);
+    assertEquals(x.get(0).size(), 3);
+    row0 = x.get(0);
+    assertEquals(row0.get(0).doubleValue(), 0, 0);
+    assertEquals(row0.get(1).doubleValue(), 10.0, 0);
+    assertEquals(row0.get(2).doubleValue(), 20, 0);
+
+    row1 = x.get(1);
+    assertEquals(row1.get(0).doubleValue(), 10, 0);
+    assertEquals(row1.get(1).doubleValue(), 0, 0);
+    assertEquals(row1.get(2).doubleValue(), 10, 0);
+
+    row2 = x.get(2);
+    assertEquals(row2.get(0).doubleValue(), 20, 0);
+    assertEquals(row2.get(1).doubleValue(), 10, 0);
+    assertEquals(row2.get(2).doubleValue(), 0, 0);
+
+
   }