use of com.yahoo.search.grouping.Continuation in project vespa by vespa-engine.
the class JsonRendererTestCase method testGrouping.
@Test
public void testGrouping() throws InterruptedException, ExecutionException, IOException {
String expected = "{\n" + " \"root\": {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"fields\": {\n" + " \"count()\": 7\n" + " },\n" + " \"value\": \"Jones\",\n" + " \"id\": \"group:string:Jones\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"next\": \"CCCC\",\n" + " \"prev\": \"BBBB\"\n" + " },\n" + " \"id\": \"grouplist:customer\",\n" + " \"label\": \"customer\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"this\": \"AAAA\"\n" + " },\n" + " \"id\": \"group:root:0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"fields\": {\n" + " \"totalCount\": 1\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " }\n" + "}\n";
Result r = newEmptyResult();
RootGroup rg = new RootGroup(0, new Continuation() {
@Override
public String toString() {
return "AAAA";
}
});
GroupList gl = new GroupList("customer");
gl.continuations().put("prev", new Continuation() {
@Override
public String toString() {
return "BBBB";
}
});
gl.continuations().put("next", new Continuation() {
@Override
public String toString() {
return "CCCC";
}
});
Group g = new Group(new StringId("Jones"), new Relevance(1.0));
g.setField("count()", Integer.valueOf(7));
gl.add(g);
rg.add(gl);
r.hits().add(rg);
r.setTotalHitCount(1L);
String summary = render(r);
assertEqualJson(expected, summary);
}
use of com.yahoo.search.grouping.Continuation in project vespa by vespa-engine.
the class JsonRendererTestCase method testGroupingWithBucket.
@Test
public void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
String expected = "{\n" + " \"root\": {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"fields\": {\n" + " \"something()\": 7\n" + " },\n" + " \"limits\": {\n" + " \"from\": \"1.0\",\n" + " \"to\": \"2.0\"\n" + " },\n" + " \"id\": \"group:double_bucket:1.0:2.0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"id\": \"grouplist:customer\",\n" + " \"label\": \"customer\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"continuation\": {\n" + " \"this\": \"AAAA\"\n" + " },\n" + " \"id\": \"group:root:0\",\n" + " \"relevance\": 1.0\n" + " }\n" + " ],\n" + " \"fields\": {\n" + " \"totalCount\": 1\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " }\n" + "}\n";
Result r = newEmptyResult();
RootGroup rg = new RootGroup(0, new Continuation() {
@Override
public String toString() {
return "AAAA";
}
});
GroupList gl = new GroupList("customer");
Group g = new Group(new DoubleBucketId(1.0, 2.0), new Relevance(1.0));
g.setField("something()", Integer.valueOf(7));
gl.add(g);
rg.add(gl);
r.hits().add(rg);
r.setTotalHitCount(1L);
String summary = render(r);
assertEqualJson(expected, summary);
}
use of com.yahoo.search.grouping.Continuation in project vespa by vespa-engine.
the class OffsetContinuationTestCase method requireThatEqualsIsImplemented.
@Test
public void requireThatEqualsIsImplemented() {
Continuation cnt = newOffset(1, 1, 2, 3);
assertFalse(cnt.equals(new Object()));
assertFalse(cnt.equals(newOffset(0, 1, 2, 3)));
assertFalse(cnt.equals(newOffset(1, 0, 2, 3)));
assertFalse(cnt.equals(newOffset(1, 1, 0, 3)));
assertFalse(cnt.equals(newOffset(1, 1, 2, 0)));
assertEquals(cnt, newOffset(1, 1, 2, 3));
}
use of com.yahoo.search.grouping.Continuation in project vespa by vespa-engine.
the class GroupingTransformTestCase method requireThatUnsupportedContinuationsCanNotBeAdded.
@Test
public void requireThatUnsupportedContinuationsCanNotBeAdded() {
GroupingTransform transform = newTransform();
try {
transform.addContinuation(new Continuation() {
});
fail();
} catch (UnsupportedOperationException e) {
}
}
Aggregations