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
Modifier and TypeClassDescriptionstatic class
Received callbacks when fields of hits are encountered. -
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
ConstructorDescriptionJsonRenderer
(Executor executor) Creates a json renderer using a custom executor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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
void
init()
protected void
protected void
renderAllFields
(Hit hit) protected void
renderContinuations
(Map<String, Continuation> continuations) protected void
protected void
renderErrors
(Set<ErrorMessage> errors) protected void
protected void
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
Methods inherited from class com.yahoo.processing.rendering.Renderer
clone, render
Methods inherited from class com.yahoo.component.AbstractComponent
compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
-
Constructor Details
-
JsonRenderer
public JsonRenderer() -
JsonRenderer
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 Details
-
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
- Specified by:
beginResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
renderTrace
- Throws:
IOException
-
beginList
- Specified by:
beginList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
moreChildren
- Throws:
IOException
-
renderHitGroupHead
- Throws:
IOException
-
renderErrors
- Throws:
IOException
-
renderCoverage
- Throws:
IOException
-
renderHit
- Throws:
IOException
-
shouldRender
-
renderHitContents
- Throws:
IOException
-
renderAllFields
- Throws:
IOException
-
renderContinuations
- Throws:
IOException
-
renderGroupMetadata
- Throws:
IOException
-
renderTotalHitCount
- Throws:
IOException
-
data
- Specified by:
data
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
endList
- Specified by:
endList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
endResponse
- Specified by:
endResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
IOException
-
getEncoding
- Specified by:
getEncoding
in classcom.yahoo.processing.rendering.Renderer<Result>
-
getMimeType
- Specified by:
getMimeType
in classcom.yahoo.processing.rendering.Renderer<Result>
-
createFieldConsumer
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.
-