use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class CubedRootEvaluatorTest method test.
private void test(Double value) throws IOException {
StreamEvaluator evaluator = factory.constructEvaluator("cbrt(a)");
values.clear();
values.put("a", value);
Object result = evaluator.evaluate(new Tuple(values));
if (null == value) {
Assert.assertNull(result);
} else {
Assert.assertTrue(result instanceof Double);
Assert.assertEquals(Math.cbrt(value), result);
}
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class CeilingEvaluatorTest method ceilingOneField.
@Test
public void ceilingOneField() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)");
Object result;
values.clear();
values.put("a", 1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Long);
Assert.assertEquals(1L, result);
values.clear();
values.put("a", 1.1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Long);
Assert.assertEquals(2L, result);
values.clear();
values.put("a", -1.1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Long);
Assert.assertEquals(-1L, result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class CoalesceEvaluatorTest method twoFieldsWithValues.
@Test
public void twoFieldsWithValues() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("coalesce(a,b)");
Object result;
values.clear();
values.put("a", null);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals(2, result);
values.clear();
values.put("a", 1.1);
values.put("b", null);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals(1.1D, result);
values.clear();
values.put("a", "foo");
values.put("b", 2.1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals("foo", result);
values.clear();
values.put("a", true);
values.put("b", 2.1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals(true, result);
values.clear();
values.put("a", null);
values.put("b", false);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals(false, result);
values.clear();
values.put("a", null);
values.put("b", null);
result = evaluator.evaluate(new Tuple(values));
Assert.assertNull(result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class CoalesceEvaluatorTest method manyFieldsWithSubcoalesces.
@Test
public void manyFieldsWithSubcoalesces() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("coalesce(a,b,coalesce(c,d))");
Object result;
values.clear();
values.put("a", 1);
values.put("b", null);
values.put("c", null);
values.put("d", 4);
result = evaluator.evaluate(new Tuple(values));
Assert.assertEquals(1, result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class AbsoluteValueEvaluatorTest method absNullValue.
@Test
public void absNullValue() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
values.clear();
values.put("a", null);
Object result = evaluator.evaluate(new Tuple(values));
assertNull(result);
}
Aggregations