Package com.yahoo.search.rendering
Class JsonRenderer
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.processing.rendering.Renderer<RESPONSE>
-
- com.yahoo.processing.rendering.AsynchronousRenderer<RESPONSE>
-
- com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
-
- com.yahoo.search.rendering.JsonRenderer
-
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,Cloneable
,Comparable<com.yahoo.component.Component>
public class JsonRenderer extends com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
JSON renderer for search results.- Author:
- Steinar Knutsen, bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonRenderer.FieldConsumer
Received callbacks when fields of hits are encountered.
-
Constructor Summary
Constructors Constructor Description JsonRenderer()
JsonRenderer(Executor executor)
Creates a json renderer using a custom executor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
beginList(com.yahoo.processing.response.DataList<?> list)
void
beginResponse(OutputStream stream)
protected JsonRenderer.FieldConsumer
createFieldConsumer(boolean debugRendering)
Override this method to use a customJsonRenderer.FieldConsumer
sub-class to render fieldsprotected JsonRenderer.FieldConsumer
createFieldConsumer(com.fasterxml.jackson.core.JsonGenerator generator, boolean debugRendering)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed in Vespa 8.protected static com.fasterxml.jackson.databind.ObjectMapper
createJsonCodec()
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed in Vespa 8.void
data(com.yahoo.processing.response.Data data)
void
endList(com.yahoo.processing.response.DataList<?> list)
void
endResponse()
String
getEncoding()
String
getMimeType()
void
init()
protected void
moreChildren()
protected void
renderAllFields(Hit hit)
protected void
renderContinuations(Map<String,Continuation> continuations)
protected void
renderCoverage()
protected void
renderErrors(Set<ErrorMessage> errors)
protected void
renderGroupMetadata(GroupId id)
protected void
renderHit(Hit hit)
protected void
renderHitContents(Hit hit)
protected void
renderHitGroupHead(HitGroup hitGroup)
protected void
renderTotalHitCount(Hit hit)
protected void
renderTrace(com.yahoo.processing.execution.Execution.Trace trace)
protected boolean
shouldRender(Hit hit)
-
Methods inherited from class com.yahoo.processing.rendering.AsynchronousSectionedRenderer
clientClosed, deconstruct, getExecution, getRecursionLevel, getResponse, onClientClosed, renderBeforeHandover, renderResponse, renderResponseBeforeHandover, setNetworkWiring
-
-
-
-
Constructor Detail
-
JsonRenderer
public JsonRenderer()
-
JsonRenderer
public JsonRenderer(Executor executor)
Creates a json renderer using a custom executor. Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
-
-
Method Detail
-
createJsonCodec
@Deprecated(forRemoval=true, since="7") protected static com.fasterxml.jackson.databind.ObjectMapper createJsonCodec()
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed in Vespa 8. Override the individual render methods ofJsonRenderer
to alter rendering behaviour. OverridecreateFieldConsumer(boolean)
and sub-classJsonRenderer.FieldConsumer
to alter rendering of hit fields.Create the codec used for rendering instances ofTreeNode
. This method will be invoked when creating the first renderer instance, but not for each fresh clone used by individual results.- Returns:
- an object mapper for the internal JsonFactory
-
init
public void init()
- Overrides:
init
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
-
beginResponse
public void beginResponse(OutputStream stream) throws IOException
- Specified by:
beginResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
renderTrace
protected void renderTrace(com.yahoo.processing.execution.Execution.Trace trace) throws IOException
- Throws:
IOException
-
beginList
public void beginList(com.yahoo.processing.response.DataList<?> list) throws IOException
- Specified by:
beginList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
moreChildren
protected void moreChildren() throws IOException
- Throws:
IOException
-
renderHitGroupHead
protected void renderHitGroupHead(HitGroup hitGroup) throws IOException
- Throws:
IOException
-
renderErrors
protected void renderErrors(Set<ErrorMessage> errors) throws IOException
- Throws:
IOException
-
renderCoverage
protected void renderCoverage() throws IOException
- Throws:
IOException
-
renderHit
protected void renderHit(Hit hit) throws IOException
- Throws:
IOException
-
shouldRender
protected boolean shouldRender(Hit hit)
-
renderHitContents
protected void renderHitContents(Hit hit) throws IOException
- Throws:
IOException
-
renderAllFields
protected void renderAllFields(Hit hit) throws IOException
- Throws:
IOException
-
renderContinuations
protected void renderContinuations(Map<String,Continuation> continuations) throws IOException
- Throws:
IOException
-
renderGroupMetadata
protected void renderGroupMetadata(GroupId id) throws IOException
- Throws:
IOException
-
renderTotalHitCount
protected void renderTotalHitCount(Hit hit) throws IOException
- Throws:
IOException
-
data
public void data(com.yahoo.processing.response.Data data) throws IOException
- Specified by:
data
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
endList
public void endList(com.yahoo.processing.response.DataList<?> list) throws IOException
- Specified by:
endList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
endResponse
public void endResponse() throws IOException
- Specified by:
endResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in classcom.yahoo.processing.rendering.Renderer<Result>
-
getMimeType
public String getMimeType()
- Specified by:
getMimeType
in classcom.yahoo.processing.rendering.Renderer<Result>
-
createFieldConsumer
protected JsonRenderer.FieldConsumer createFieldConsumer(boolean debugRendering)
Override this method to use a customJsonRenderer.FieldConsumer
sub-class to render fields
-
createFieldConsumer
@Deprecated(forRemoval=true, since="7") protected JsonRenderer.FieldConsumer createFieldConsumer(com.fasterxml.jackson.core.JsonGenerator generator, boolean debugRendering)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed in Vespa 8. UsecreateFieldConsumer(boolean)
instead.
-
-