mirror of https://github.com/apache/lucene.git
SOLR-13625: Fix broken test cases
This commit is contained in:
parent
eb280c4808
commit
f6992a3a3b
|
@ -107,7 +107,6 @@ public class Lang {
|
||||||
|
|
||||||
// tuple manipulation operations
|
// tuple manipulation operations
|
||||||
.withFunctionName("replace", ReplaceOperation.class)
|
.withFunctionName("replace", ReplaceOperation.class)
|
||||||
.withFunctionName("concat", ConcatOperation.class)
|
|
||||||
|
|
||||||
// stream reduction operations
|
// stream reduction operations
|
||||||
.withFunctionName("group", GroupOperation.class)
|
.withFunctionName("group", GroupOperation.class)
|
||||||
|
@ -297,6 +296,7 @@ public class Lang {
|
||||||
.withFunctionName("double", DoubleEvaluator.class)
|
.withFunctionName("double", DoubleEvaluator.class)
|
||||||
.withFunctionName("long", LongEvaluator.class)
|
.withFunctionName("long", LongEvaluator.class)
|
||||||
.withFunctionName("dateTime", DateEvaluator.class)
|
.withFunctionName("dateTime", DateEvaluator.class)
|
||||||
|
.withFunctionName("concat", ConcatEvaluator.class)
|
||||||
|
|
||||||
// Boolean Stream Evaluators
|
// Boolean Stream Evaluators
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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.util.List;
|
||||||
|
|
||||||
|
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 ConcatEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
private String delim = "";
|
||||||
|
|
||||||
|
public ConcatEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
|
||||||
|
super(expression, factory);
|
||||||
|
|
||||||
|
List<StreamExpressionNamedParameter> namedParams = factory.getNamedOperands(expression);
|
||||||
|
|
||||||
|
for(StreamExpressionNamedParameter namedParam : namedParams){
|
||||||
|
if(namedParam.getName().equals("delim")){
|
||||||
|
this.delim = namedParam.getParameter().toString().trim();
|
||||||
|
} else {
|
||||||
|
throw new IOException("Unexpected named parameter:"+namedParam.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doWork(Object values[]) throws IOException {
|
||||||
|
|
||||||
|
StringBuilder buff = new StringBuilder();
|
||||||
|
|
||||||
|
for(Object o : values) {
|
||||||
|
if(buff.length() > 0) {
|
||||||
|
buff.append(delim);
|
||||||
|
}
|
||||||
|
String s = o.toString();
|
||||||
|
if(s.startsWith("\"") && s.endsWith("\"")) {
|
||||||
|
s = s.substring(1, s.length()-1);
|
||||||
|
}
|
||||||
|
buff.append(s.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return buff.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,27 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker
|
||||||
return new BigDecimal(value.toString());
|
return new BigDecimal(value.toString());
|
||||||
}
|
}
|
||||||
else if(value instanceof Collection){
|
else if(value instanceof Collection){
|
||||||
|
//Let's first check to see if we have a List of Strings.
|
||||||
|
//If we do let's try and convert to a list of doubles and see what happens
|
||||||
|
try {
|
||||||
|
List<Number> vector = new ArrayList();
|
||||||
|
boolean allDoubles = true;
|
||||||
|
for(Object o : (Collection)value) {
|
||||||
|
if(o instanceof String) {
|
||||||
|
Double d = Double.parseDouble(o.toString());
|
||||||
|
vector.add(d);
|
||||||
|
} else {
|
||||||
|
allDoubles = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(allDoubles) {
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return ((Collection<?>)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList());
|
return ((Collection<?>)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
else if(value.getClass().isArray()){
|
else if(value.getClass().isArray()){
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -46,12 +47,20 @@ public abstract class RecursiveNumericEvaluator extends RecursiveEvaluator {
|
||||||
}
|
}
|
||||||
else if(value instanceof BigDecimal){
|
else if(value instanceof BigDecimal){
|
||||||
return value;
|
return value;
|
||||||
|
} else if(value instanceof String) {
|
||||||
|
return new BigDecimal((String)value);
|
||||||
}
|
}
|
||||||
else if(value instanceof Number){
|
else if(value instanceof Number){
|
||||||
return new BigDecimal(value.toString());
|
return new BigDecimal(value.toString());
|
||||||
}
|
}
|
||||||
else if(value instanceof Collection){
|
else if(value instanceof Collection){
|
||||||
return ((Collection<?>)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList());
|
if(value instanceof List) {
|
||||||
|
if(((List)value).get(0) instanceof Number) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((Collection<?>) value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
else if(value.getClass().isArray()){
|
else if(value.getClass().isArray()){
|
||||||
Stream<?> stream = Stream.empty();
|
Stream<?> stream = Stream.empty();
|
||||||
|
|
|
@ -52,6 +52,8 @@ public abstract class RecursiveNumericListEvaluator extends RecursiveEvaluator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new BigDecimal(value.toString());
|
return new BigDecimal(value.toString());
|
||||||
|
} else if (value instanceof String) {
|
||||||
|
return new BigDecimal(value.toString());
|
||||||
}
|
}
|
||||||
else if(value instanceof BigDecimal){
|
else if(value instanceof BigDecimal){
|
||||||
return (BigDecimal)value;
|
return (BigDecimal)value;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.solr.client.solrj.io.eval;
|
package org.apache.solr.client.solrj.io.eval;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -39,8 +40,15 @@ public class SetColumnLabelsEvaluator extends RecursiveObjectEvaluator implement
|
||||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName()));
|
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName()));
|
||||||
} else {
|
} else {
|
||||||
Matrix matrix = (Matrix)value1;
|
Matrix matrix = (Matrix)value1;
|
||||||
List<String> colLabels = (List<String>)value2;
|
|
||||||
matrix.setColumnLabels(colLabels);
|
List colLabels = (List)value2;
|
||||||
|
//Convert numeric labels to strings.
|
||||||
|
List<String> strLabels = new ArrayList(colLabels.size());
|
||||||
|
for(Object o : colLabels) {
|
||||||
|
strLabels.add(o.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.setColumnLabels(strLabels);
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.solr.client.solrj.io.eval;
|
package org.apache.solr.client.solrj.io.eval;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -39,8 +40,17 @@ public class SetRowLabelsEvaluator extends RecursiveObjectEvaluator implements T
|
||||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName()));
|
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName()));
|
||||||
} else {
|
} else {
|
||||||
Matrix matrix = (Matrix)value1;
|
Matrix matrix = (Matrix)value1;
|
||||||
List<String> rowlabels = (List<String>)value2;
|
List rowlabels = (List)value2;
|
||||||
matrix.setRowLabels(rowlabels);
|
|
||||||
|
//Convert numeric labels to strings.
|
||||||
|
|
||||||
|
List<String> strLabels = new ArrayList(rowlabels.size());
|
||||||
|
|
||||||
|
for(Object o : rowlabels) {
|
||||||
|
strLabels.add(o.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.setRowLabels(strLabels);
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class UuidEvaluator extends SourceEvaluator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object evaluate(Tuple tuple) throws IOException {
|
public Object evaluate(Tuple tuple) throws IOException {
|
||||||
return UUID.randomUUID();
|
return UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -131,6 +131,7 @@ public class CsvStream extends TupleStream implements Expressible {
|
||||||
throw new IOException("Headers and lines must have the same number of fields [file:"+file+" line number:"+lineNumber+"]");
|
throw new IOException("Headers and lines must have the same number of fields [file:"+file+" line number:"+lineNumber+"]");
|
||||||
}
|
}
|
||||||
Tuple out = new Tuple(new HashMap());
|
Tuple out = new Tuple(new HashMap());
|
||||||
|
out.put("id", file+"_"+lineNumber);
|
||||||
for(int i=0; i<headers.length; i++) {
|
for(int i=0; i<headers.length; i++) {
|
||||||
if(fields[i] != null && fields[i].length() > 0) {
|
if(fields[i] != null && fields[i].length() > 0) {
|
||||||
out.put(headers[i], fields[i]);
|
out.put(headers[i], fields[i]);
|
||||||
|
@ -147,7 +148,7 @@ public class CsvStream extends TupleStream implements Expressible {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] split(String line) {
|
protected String[] split(String line) {
|
||||||
String[] fields = line.split(",(?=([^\"]|\"[^\"]*\")*$)",-1);
|
String[] fields = line.split(",(?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)",-1);
|
||||||
for(int i=0; i<fields.length; i++) {
|
for(int i=0; i<fields.length; i++) {
|
||||||
String f = fields[i];
|
String f = fields[i];
|
||||||
if(f.startsWith("\"") && f.endsWith("\"")) {
|
if(f.startsWith("\"") && f.endsWith("\"")) {
|
||||||
|
|
|
@ -66,6 +66,9 @@ public class SolrStream extends TupleStream {
|
||||||
private String slice;
|
private String slice;
|
||||||
private long checkpoint = -1;
|
private long checkpoint = -1;
|
||||||
private CloseableHttpResponse closeableHttpResponse;
|
private CloseableHttpResponse closeableHttpResponse;
|
||||||
|
private boolean distrib = true;
|
||||||
|
private String user;
|
||||||
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param baseUrl Base URL of the stream.
|
* @param baseUrl Base URL of the stream.
|
||||||
|
@ -95,6 +98,11 @@ public class SolrStream extends TupleStream {
|
||||||
this.cache = context.getSolrClientCache();
|
this.cache = context.getSolrClientCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCredentials(String user, String password) {
|
||||||
|
this.user = user;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the stream to a single Solr instance.
|
* Opens the stream to a single Solr instance.
|
||||||
**/
|
**/
|
||||||
|
@ -261,6 +269,11 @@ public class SolrStream extends TupleStream {
|
||||||
query.setPath(p);
|
query.setPath(p);
|
||||||
query.setResponseParser(new InputStreamResponseParser(wt));
|
query.setResponseParser(new InputStreamResponseParser(wt));
|
||||||
query.setMethod(SolrRequest.METHOD.POST);
|
query.setMethod(SolrRequest.METHOD.POST);
|
||||||
|
|
||||||
|
if(user != null && password != null) {
|
||||||
|
query.setBasicAuthCredentials(user, password);
|
||||||
|
}
|
||||||
|
|
||||||
NamedList<Object> genericResponse = server.request(query);
|
NamedList<Object> genericResponse = server.request(query);
|
||||||
InputStream stream = (InputStream) genericResponse.get("stream");
|
InputStream stream = (InputStream) genericResponse.get("stream");
|
||||||
this.closeableHttpResponse = (CloseableHttpResponse)genericResponse.get("closeableResponse");
|
this.closeableHttpResponse = (CloseableHttpResponse)genericResponse.get("closeableResponse");
|
||||||
|
|
|
@ -209,6 +209,26 @@ public class MathExpressionTest extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConcat() throws Exception {
|
||||||
|
String expr = " select(list(tuple(field1=\"a\", field2=\"b\"), tuple(field1=\"c\", field2=\"d\")), concat(field1, field2, \"hello\", delim=\"-\") as field3)";
|
||||||
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||||
|
paramsLoc.set("expr", expr);
|
||||||
|
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);
|
||||||
|
assertEquals(tuples.size(), 2);
|
||||||
|
String s1= tuples.get(0).getString("field3");
|
||||||
|
assertEquals(s1, "a-b-hello");
|
||||||
|
String s2= tuples.get(1).getString("field3");
|
||||||
|
assertEquals(s2, "c-d-hello");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMemset() throws Exception {
|
public void testMemset() throws Exception {
|
||||||
String expr = "let(echo=\"b, c\"," +
|
String expr = "let(echo=\"b, c\"," +
|
||||||
|
@ -4461,6 +4481,103 @@ public class MathExpressionTest extends SolrCloudTestCase {
|
||||||
assertEquals(predictions.get(1).doubleValue(), 4, 0);
|
assertEquals(predictions.get(1).doubleValue(), 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDateTime() throws Exception {
|
||||||
|
String expr = "select(list(tuple(a=20001011:10:11:01), tuple(a=20071011:14:30:20)), dateTime(a, yyyyMMdd:kk:mm:ss) as date)";
|
||||||
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||||
|
paramsLoc.set("expr", expr);
|
||||||
|
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);
|
||||||
|
String date = (String)tuples.get(0).get("date");
|
||||||
|
assertEquals(date, "2000-10-11T10:11:01Z");
|
||||||
|
date = (String)tuples.get(1).get("date");
|
||||||
|
assertEquals(date, "2007-10-11T14:30:20Z");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDateTimeTZ() throws Exception {
|
||||||
|
String expr = "select(list(tuple(a=20001011), tuple(a=20071011)), dateTime(a, yyyyMMdd, UTC) as date, dateTime(a, yyyyMMdd, EST) as date1, dateTime(a, yyyyMMdd) as date2)";
|
||||||
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||||
|
paramsLoc.set("expr", expr);
|
||||||
|
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);
|
||||||
|
String date = (String)tuples.get(0).get("date");
|
||||||
|
String date1 = (String)tuples.get(0).get("date1");
|
||||||
|
String date2 = (String)tuples.get(0).get("date2");
|
||||||
|
|
||||||
|
assertEquals(date, "2000-10-11T00:00:00Z");
|
||||||
|
assertEquals(date1, "2000-10-11T05:00:00Z");
|
||||||
|
assertEquals(date2, "2000-10-11T00:00:00Z");
|
||||||
|
|
||||||
|
|
||||||
|
date = (String)tuples.get(1).get("date");
|
||||||
|
date1 = (String)tuples.get(1).get("date1");
|
||||||
|
date2 = (String)tuples.get(1).get("date2");
|
||||||
|
|
||||||
|
assertEquals(date, "2007-10-11T00:00:00Z");
|
||||||
|
assertEquals(date1, "2007-10-11T05:00:00Z");
|
||||||
|
assertEquals(date2, "2007-10-11T00:00:00Z");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleLong() throws Exception {
|
||||||
|
String expr = "select(tuple(d=\"1.1\", l=\"5000\"), double(d) as d, long(l) as l)";
|
||||||
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||||
|
paramsLoc.set("expr", expr);
|
||||||
|
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);
|
||||||
|
assertEquals(tuples.size(), 1);
|
||||||
|
assertTrue(tuples.get(0).get("d") instanceof Double);
|
||||||
|
assertTrue(tuples.get(0).get("l") instanceof Long);
|
||||||
|
|
||||||
|
assertEquals(tuples.get(0).getDouble("d"), 1.1D, 0);
|
||||||
|
assertEquals(tuples.get(0).getLong("l").longValue(), 5000L);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testDoubleArray() throws Exception {
|
||||||
|
String expr = "let(a=list(tuple(d=\"1.1\", l=\"5000\"), tuple(d=\"1.3\", l=\"7000\"))," +
|
||||||
|
" b=col(a, d)," +
|
||||||
|
" tuple(doubles=double(b)))";
|
||||||
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||||
|
paramsLoc.set("expr", expr);
|
||||||
|
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);
|
||||||
|
assertEquals(tuples.size(), 1);
|
||||||
|
|
||||||
|
List<Double> doubles = (List<Double>)tuples.get(0).get("doubles");
|
||||||
|
assertEquals(doubles.get(0), 1.1, 0);
|
||||||
|
assertEquals(doubles.get(1), 1.3, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGaussfit() throws Exception {
|
public void testGaussfit() throws Exception {
|
||||||
String cexpr = "let(echo=true, " +
|
String cexpr = "let(echo=true, " +
|
||||||
|
|
|
@ -3217,108 +3217,6 @@ public class StreamDecoratorTest extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDateTime() throws Exception {
|
|
||||||
String expr = "select(list(tuple(a=20001011:10:11:01), tuple(a=20071011:14:30:20)), dateTime(a, yyyyMMdd:kk:mm:ss) as date)";
|
|
||||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
|
||||||
paramsLoc.set("expr", expr);
|
|
||||||
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);
|
|
||||||
String date = (String)tuples.get(0).get("date");
|
|
||||||
assertEquals(date, "2000-10-11T10:11:01Z");
|
|
||||||
date = (String)tuples.get(1).get("date");
|
|
||||||
assertEquals(date, "2007-10-11T14:30:20Z");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDateTimeTZ() throws Exception {
|
|
||||||
String expr = "select(list(tuple(a=20001011), tuple(a=20071011)), dateTime(a, yyyyMMdd, UTC) as date, dateTime(a, yyyyMMdd, EST) as date1, dateTime(a, yyyyMMdd) as date2)";
|
|
||||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
|
||||||
paramsLoc.set("expr", expr);
|
|
||||||
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);
|
|
||||||
String date = (String)tuples.get(0).get("date");
|
|
||||||
String date1 = (String)tuples.get(0).get("date1");
|
|
||||||
String date2 = (String)tuples.get(0).get("date2");
|
|
||||||
|
|
||||||
assertEquals(date, "2000-10-11T00:00:00Z");
|
|
||||||
assertEquals(date1, "2000-10-11T05:00:00Z");
|
|
||||||
assertEquals(date2, "2000-10-11T00:00:00Z");
|
|
||||||
|
|
||||||
|
|
||||||
date = (String)tuples.get(1).get("date");
|
|
||||||
date1 = (String)tuples.get(1).get("date1");
|
|
||||||
date2 = (String)tuples.get(1).get("date2");
|
|
||||||
|
|
||||||
assertEquals(date, "2007-10-11T00:00:00Z");
|
|
||||||
assertEquals(date1, "2007-10-11T05:00:00Z");
|
|
||||||
assertEquals(date2, "2007-10-11T00:00:00Z");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleLong() throws Exception {
|
|
||||||
String expr = "select(tuple(d=\"1.1\", l=\"5000\"), double(d) as d, long(l) as l)";
|
|
||||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
|
||||||
paramsLoc.set("expr", expr);
|
|
||||||
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);
|
|
||||||
assertEquals(tuples.size(), 1);
|
|
||||||
assertTrue(tuples.get(0).get("d") instanceof Double);
|
|
||||||
assertTrue(tuples.get(0).get("l") instanceof Long);
|
|
||||||
|
|
||||||
assertEquals(tuples.get(0).getDouble("d"), 1.1D, 0);
|
|
||||||
assertEquals(tuples.get(0).getLong("l").longValue(), 5000L);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testDoubleLongArray() throws Exception {
|
|
||||||
String expr = "let(a=list(tuple(d=\"1.1\", l=\"5000\"), tuple(d=\"1.3\", l=\"7000\"))," +
|
|
||||||
" b=col(a, d)," +
|
|
||||||
" c=col(a, l)," +
|
|
||||||
" tuple(doubles=double(b)," +
|
|
||||||
" longs=long(c)))";
|
|
||||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
|
||||||
paramsLoc.set("expr", expr);
|
|
||||||
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);
|
|
||||||
assertEquals(tuples.size(), 1);
|
|
||||||
|
|
||||||
List<Double> doubles = (List<Double>)tuples.get(0).get("doubles");
|
|
||||||
List<Long> longs = (List<Long>)tuples.get(0).get("longs");
|
|
||||||
assertEquals(doubles.get(0), 1.1, 0);
|
|
||||||
assertEquals(doubles.get(1), 1.3, 0);
|
|
||||||
|
|
||||||
assertEquals(longs.get(0).longValue(), 5000L);
|
|
||||||
assertEquals(longs.get(1).longValue(), 7000L);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommitStream() throws Exception {
|
public void testCommitStream() throws Exception {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class AbsoluteValueEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("abs(a,b)");
|
factory.constructEvaluator("abs(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void absNoValue() throws Exception{
|
public void absNoValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public class AbsoluteValueEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void absNullValue() throws Exception{
|
public void absNullValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class AddEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertEquals(3.2D, result);
|
Assert.assertEquals(3.2D, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void addTwoFieldWithNulls() throws Exception{
|
public void addTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -79,7 +79,7 @@ public class AddEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void addTwoFieldsWithNull() throws Exception{
|
public void addTwoFieldsWithNull() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -103,7 +103,7 @@ public class AddEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void addTwoFieldsWithMissingField() throws Exception{
|
public void addTwoFieldsWithMissingField() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ArcCosineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("acos(a,b)");
|
factory.constructEvaluator("acos(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("acos(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("acos(a)");
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class ArcCosineEvaluatorTest extends SolrTestCase {
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ArcSineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("asin(a,b)");
|
factory.constructEvaluator("asin(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("asin(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("asin(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class ArcSineEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ArcTangentEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("atan(a,b)");
|
factory.constructEvaluator("atan(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("atan(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("atan(a)");
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class ArcTangentEvaluatorTest extends SolrTestCase {
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class CeilingEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("ceil(a,b)");
|
factory.constructEvaluator("ceil(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void ceilNoValue() throws Exception{
|
public void ceilNoValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class CeilingEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void ceilNullValue() throws Exception{
|
public void ceilNullValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)");
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class CosineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("cos(a,b)");
|
factory.constructEvaluator("cos(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("cos(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("cos(a)");
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class CosineEvaluatorTest extends SolrTestCase {
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class CubedRootEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("cbrt(a,b)");
|
factory.constructEvaluator("cbrt(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("cbrt(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("cbrt(a)");
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class CubedRootEvaluatorTest extends SolrTestCase {
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class DivideEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("div(a)");
|
factory.constructEvaluator("div(a)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void divTwoFieldWithNulls() throws Exception{
|
public void divTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class DivideEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void divTwoFieldsWithNullDenominator() throws Exception{
|
public void divTwoFieldsWithNullDenominator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class DivideEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void divTwoFieldsWithNullNumerator() throws Exception{
|
public void divTwoFieldsWithNullNumerator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class DivideEvaluatorTest extends SolrTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void divTwoFieldsWithMissingDenominator() throws Exception{
|
public void divTwoFieldsWithMissingDenominator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public class DivideEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void divTwoFieldsWithMissingNumerator() throws Exception{
|
public void divTwoFieldsWithMissingNumerator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,14 @@ public class FloorEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("floor(a,b)");
|
factory.constructEvaluator("floor(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void floorNoValue() throws Exception{
|
public void floorNoValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("floor(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("floor(a)");
|
||||||
|
|
||||||
values.clear();
|
values.clear();
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void floorNullValue() throws Exception{
|
public void floorNullValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("floor(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("floor(a)");
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class HyperbolicCosineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("cosh(a,b)");
|
factory.constructEvaluator("cosh(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("cosh(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("cosh(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class HyperbolicCosineEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class HyperbolicSineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("sinh(a,b)");
|
factory.constructEvaluator("sinh(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sinh(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sinh(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class HyperbolicSineEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class HyperbolicTangentEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("tanh(a,b)");
|
factory.constructEvaluator("tanh(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("tanh(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("tanh(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class HyperbolicTangentEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class ModuloEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("mod(a)");
|
factory.constructEvaluator("mod(a)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void modTwoFieldWithNulls() throws Exception{
|
public void modTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ModuloEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void modTwoFieldsWithNullDenominator() throws Exception{
|
public void modTwoFieldsWithNullDenominator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class ModuloEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void modTwoFieldsWithNullNumerator() throws Exception{
|
public void modTwoFieldsWithNullNumerator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class ModuloEvaluatorTest extends SolrTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void modTwoFieldsWithMissingDenominator() throws Exception{
|
public void modTwoFieldsWithMissingDenominator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public class ModuloEvaluatorTest extends SolrTestCase {
|
||||||
evaluator.evaluate(new Tuple(values));
|
evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void modTwoFieldsWithMissingNumerator() throws Exception{
|
public void modTwoFieldsWithMissingNumerator() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertEquals(6.5D, result);
|
Assert.assertEquals(6.5D, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void multTwoFieldWithNulls() throws Exception{
|
public void multTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -97,7 +97,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void multTwoFieldsWithNull() throws Exception{
|
public void multTwoFieldsWithNull() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -121,7 +121,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void multTwoFieldsWithMissingField() throws Exception{
|
public void multTwoFieldsWithMissingField() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class NaturalLogEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("log(a,b)");
|
factory.constructEvaluator("log(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void logNoValue() throws Exception{
|
public void logNoValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("log(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("log(a)");
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class NaturalLogEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void logNullValue() throws Exception{
|
public void logNullValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("log(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("log(a)");
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class PowerEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("pow(a)");
|
factory.constructEvaluator("pow(a)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void powTwoFieldWithNulls() throws Exception{
|
public void powTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("pow(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("pow(a,b)");
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class RoundEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("round(a,b)");
|
factory.constructEvaluator("round(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("round(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("round(a)");
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class RoundEvaluatorTest extends SolrTestCase {
|
||||||
Object result = evaluator.evaluate(new Tuple(values));
|
Object result = evaluator.evaluate(new Tuple(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class SineEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("sin(a,b)");
|
factory.constructEvaluator("sin(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sin(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sin(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class SineEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class SquareRootEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("sqrt(a,b)");
|
factory.constructEvaluator("sqrt(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sqrt(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sqrt(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class SquareRootEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class SubtractEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("sub(a)");
|
factory.constructEvaluator("sub(a)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void subTwoFieldWithNulls() throws Exception{
|
public void subTwoFieldWithNulls() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -84,7 +84,7 @@ public class SubtractEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void subTwoFieldsWithNull() throws Exception{
|
public void subTwoFieldsWithNull() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
@ -108,7 +108,7 @@ public class SubtractEvaluatorTest extends SolrTestCase {
|
||||||
Assert.assertNull(result);
|
Assert.assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void subTwoFieldsWithMissingField() throws Exception{
|
public void subTwoFieldsWithMissingField() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
|
||||||
Object result;
|
Object result;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TangentEvaluatorTest extends SolrTestCase {
|
||||||
factory.constructEvaluator("tan(a,b)");
|
factory.constructEvaluator("tan(a,b)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void noValue() throws Exception{
|
public void noValue() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("tan(a)");
|
StreamEvaluator evaluator = factory.constructEvaluator("tan(a)");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class TangentEvaluatorTest extends SolrTestCase {
|
||||||
assertNull(result);
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void nullValue() throws Exception{
|
public void nullValue() throws Exception{
|
||||||
test(null);
|
test(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,12 @@ public class UuidEvaluatorTest extends SolrTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isUuidType() throws Exception{
|
public void testUuid() throws Exception{
|
||||||
StreamEvaluator evaluator = factory.constructEvaluator("uuid()");
|
StreamEvaluator evaluator = factory.constructEvaluator("uuid()");
|
||||||
|
Assert.assertTrue(evaluator.evaluate(null) instanceof String);
|
||||||
Assert.assertTrue(evaluator.evaluate(null) instanceof UUID);
|
String uuid = (String)evaluator.evaluate(null);
|
||||||
Assert.assertTrue(evaluator.evaluate(new Tuple(values)) instanceof UUID);
|
assertEquals(uuid.split("-").length, 5);
|
||||||
|
String uuid1 = (String)evaluator.evaluate(new Tuple(values));
|
||||||
|
assertNotEquals(uuid, uuid1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue