public class JsonRenderer extends com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
Modifier and Type | Class and Description |
---|---|
private static class |
JsonRenderer.FieldConsumer
Received callbacks when fields of hits are encountered.
|
private class |
JsonRenderer.TraceRenderer |
private static class |
JsonRenderer.TraceRenderWrapper |
Modifier and Type | Field and Description |
---|---|
private static String |
BUCKET_FROM |
private static String |
BUCKET_LIMITS |
private static String |
BUCKET_TO |
private static String |
CHILDREN |
private static String |
CONTINUATION |
private static String |
COVERAGE |
private static String |
COVERAGE_COVERAGE |
private static String |
COVERAGE_DEGRADE |
private static String |
COVERAGE_DEGRADE_ADAPTIVE_TIMEOUT |
private static String |
COVERAGE_DEGRADE_MATCHPHASE |
private static String |
COVERAGE_DEGRADE_TIMEOUT |
private static String |
COVERAGE_DEGRADED_NON_IDEAL_STATE |
private static String |
COVERAGE_DOCUMENTS |
private static String |
COVERAGE_FULL |
private static String |
COVERAGE_NODES |
private static String |
COVERAGE_RESULTS |
private static String |
COVERAGE_RESULTS_FULL |
private static com.yahoo.processing.request.CompoundName |
DEBUG_RENDERING_KEY |
private boolean |
debugRendering |
private static String |
ERROR_CODE |
private static String |
ERROR_MESSAGE |
private static String |
ERROR_SOURCE |
private static String |
ERROR_STACK_TRACE |
private static String |
ERROR_SUMMARY |
private static String |
ERRORS |
private JsonRenderer.FieldConsumer |
fieldConsumer |
private static String |
FIELDS |
private com.fasterxml.jackson.core.JsonGenerator |
generator |
private com.fasterxml.jackson.core.JsonFactory |
generatorFactory |
private static String |
GROUPING_VALUE |
private static String |
ID |
private static com.yahoo.processing.request.CompoundName |
JSON_CALLBACK |
private static String |
LABEL |
private static String |
QUERY_TIME |
private static String |
RELEVANCE |
private Deque<Integer> |
renderedChildren |
private static String |
ROOT |
private static String |
SEARCH_TIME |
private static String |
SOURCE |
private OutputStream |
stream |
private static String |
SUMMARY_FETCH_TIME |
private LongSupplier |
timeSource |
private static String |
TIMING |
private static String |
TOTAL_COUNT |
private static String |
TRACE |
private static String |
TRACE_CHILDREN |
private static String |
TRACE_MESSAGE |
private static String |
TRACE_TIMESTAMP |
private static String |
TYPES |
private static String |
VESPA_HIDDEN_FIELD_PREFIX |
Constructor and Description |
---|
JsonRenderer() |
JsonRenderer(Executor executor)
Creates a json renderer using a custom executor.
|
Modifier and Type | Method and Description |
---|---|
private void |
beginJsonCallback(OutputStream stream)
Adds JSONP (Json with padding) support.
|
void |
beginList(com.yahoo.processing.response.DataList<?> list) |
void |
beginResponse(OutputStream stream) |
private void |
childrenArray() |
protected static com.fasterxml.jackson.databind.ObjectMapper |
createJsonCodec()
Create the codec used for rendering instances of
TreeNode . |
void |
data(com.yahoo.processing.response.Data data) |
private void |
endJsonCallback() |
void |
endList(com.yahoo.processing.response.DataList<?> list) |
void |
endResponse() |
private static String |
getBucketFrom(BucketGroupId<?> id) |
private static String |
getBucketTo(BucketGroupId<?> id) |
private boolean |
getDebugRendering(Query q) |
String |
getEncoding() |
private static String |
getIdValue(ValueGroupId<?> id) |
private String |
getJsonCallback() |
String |
getMimeType() |
private Result |
getResult() |
void |
init() |
private void |
lessChildren() |
protected void |
moreChildren() |
private void |
renderAllFields(Hit hit) |
private void |
renderContinuations(Map<String,Continuation> continuations) |
private void |
renderCoverage() |
private void |
renderErrors(Set<ErrorMessage> errors) |
private void |
renderGroupingGroupSyntheticFields(Hit hit) |
private void |
renderGroupingListSyntheticFields(AbstractList a) |
private void |
renderGroupMetadata(GroupId id) |
private void |
renderHit(Hit hit) |
private void |
renderHitContents(Hit hit) |
private void |
renderHitGroupHead(HitGroup hitGroup) |
private void |
renderSpecialCasesForGrouping(Hit hit) |
private void |
renderStandardFields(Hit hit) |
private void |
renderTiming() |
private void |
renderTotalHitCount(Hit hit) |
private void |
renderTrace(com.yahoo.processing.execution.Execution.Trace trace) |
private void |
setGenerator(com.fasterxml.jackson.core.JsonGenerator generator,
boolean debugRendering) |
(package private) void |
setTimeSource(LongSupplier timeSource)
Only for testing.
|
private boolean |
shouldRender(Hit hit) |
private boolean |
shouldRenderJsonCallback() |
private void |
writeGroupingLabel(AbstractList a) |
clientClosed, deconstruct, getExecution, getRecursionLevel, getResponse, onClientClosed, render, renderBeforeHandover, setNetworkWiring
private static final com.yahoo.processing.request.CompoundName DEBUG_RENDERING_KEY
private static final com.yahoo.processing.request.CompoundName JSON_CALLBACK
private static final String BUCKET_LIMITS
private static final String BUCKET_TO
private static final String BUCKET_FROM
private static final String CHILDREN
private static final String CONTINUATION
private static final String COVERAGE
private static final String COVERAGE_COVERAGE
private static final String COVERAGE_DOCUMENTS
private static final String COVERAGE_DEGRADE
private static final String COVERAGE_DEGRADE_MATCHPHASE
private static final String COVERAGE_DEGRADE_TIMEOUT
private static final String COVERAGE_DEGRADE_ADAPTIVE_TIMEOUT
private static final String COVERAGE_DEGRADED_NON_IDEAL_STATE
private static final String COVERAGE_FULL
private static final String COVERAGE_NODES
private static final String COVERAGE_RESULTS
private static final String COVERAGE_RESULTS_FULL
private static final String ERRORS
private static final String ERROR_CODE
private static final String ERROR_MESSAGE
private static final String ERROR_SOURCE
private static final String ERROR_STACK_TRACE
private static final String ERROR_SUMMARY
private static final String FIELDS
private static final String ID
private static final String LABEL
private static final String RELEVANCE
private static final String ROOT
private static final String SOURCE
private static final String TOTAL_COUNT
private static final String TRACE
private static final String TRACE_CHILDREN
private static final String TRACE_MESSAGE
private static final String TRACE_TIMESTAMP
private static final String TIMING
private static final String QUERY_TIME
private static final String SUMMARY_FETCH_TIME
private static final String SEARCH_TIME
private static final String TYPES
private static final String GROUPING_VALUE
private static final String VESPA_HIDDEN_FIELD_PREFIX
private final com.fasterxml.jackson.core.JsonFactory generatorFactory
private com.fasterxml.jackson.core.JsonGenerator generator
private JsonRenderer.FieldConsumer fieldConsumer
private boolean debugRendering
private LongSupplier timeSource
private OutputStream stream
public JsonRenderer()
public JsonRenderer(Executor executor)
protected static com.fasterxml.jackson.databind.ObjectMapper createJsonCodec()
TreeNode
. This
method will be invoked when creating the first renderer instance, but not
for each fresh clone used by individual results.public void init()
init
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
public void beginResponse(OutputStream stream) throws IOException
beginResponse
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
IOException
private void renderTiming() throws IOException
IOException
private boolean getDebugRendering(Query q)
private void renderTrace(com.yahoo.processing.execution.Execution.Trace trace) throws IOException
IOException
public void beginList(com.yahoo.processing.response.DataList<?> list) throws IOException
beginList
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
IOException
protected void moreChildren() throws IOException
IOException
private void childrenArray() throws IOException
IOException
private void lessChildren() throws IOException
IOException
private void renderHitGroupHead(HitGroup hitGroup) throws IOException
IOException
private void renderErrors(Set<ErrorMessage> errors) throws IOException
IOException
private void renderCoverage() throws IOException
IOException
private void renderHit(Hit hit) throws IOException
IOException
private boolean shouldRender(Hit hit)
private void renderHitContents(Hit hit) throws IOException
IOException
private void renderAllFields(Hit hit) throws IOException
IOException
private void renderStandardFields(Hit hit)
private void renderSpecialCasesForGrouping(Hit hit) throws IOException
IOException
private void renderGroupingGroupSyntheticFields(Hit hit) throws IOException
IOException
private void renderGroupingListSyntheticFields(AbstractList a) throws IOException
IOException
private void writeGroupingLabel(AbstractList a) throws IOException
IOException
private void renderContinuations(Map<String,Continuation> continuations) throws IOException
IOException
private void renderGroupMetadata(GroupId id) throws IOException
IOException
private static String getIdValue(ValueGroupId<?> id)
private static String getBucketFrom(BucketGroupId<?> id)
private static String getBucketTo(BucketGroupId<?> id)
private void renderTotalHitCount(Hit hit) throws IOException
IOException
public void data(com.yahoo.processing.response.Data data) throws IOException
data
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
IOException
public void endList(com.yahoo.processing.response.DataList<?> list) throws IOException
endList
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
IOException
public void endResponse() throws IOException
endResponse
in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
IOException
public String getEncoding()
getEncoding
in class com.yahoo.processing.rendering.Renderer<Result>
public String getMimeType()
getMimeType
in class com.yahoo.processing.rendering.Renderer<Result>
private Result getResult()
private void beginJsonCallback(OutputStream stream) throws IOException
IOException
private void endJsonCallback() throws IOException
IOException
private boolean shouldRenderJsonCallback()
private String getJsonCallback()
private void setGenerator(com.fasterxml.jackson.core.JsonGenerator generator, boolean debugRendering)
void setTimeSource(LongSupplier timeSource)
Copyright © 2018. All rights reserved.