Search in sources :

Example 6 with EmptyObjectException

use of datawave.webservice.query.exception.EmptyObjectException in project datawave by NationalSecurityAgency.

the class DocumentTransformerSupport method extractMetrics.

protected void extractMetrics(Document document, Key documentKey) {
    Map<String, Attribute<? extends Comparable<?>>> dictionary = document.getDictionary();
    Attribute<? extends Comparable<?>> timingMetadataAttribute = dictionary.get(LogTiming.TIMING_METADATA);
    if (timingMetadataAttribute != null && timingMetadataAttribute instanceof TimingMetadata) {
        TimingMetadata timingMetadata = (TimingMetadata) timingMetadataAttribute;
        long currentSourceCount = timingMetadata.getSourceCount();
        long currentNextCount = timingMetadata.getNextCount();
        long currentSeekCount = timingMetadata.getSeekCount();
        long currentYieldCount = timingMetadata.getYieldCount();
        String host = timingMetadata.getHost();
        sourceCount += currentSourceCount;
        nextCount += currentNextCount;
        seekCount += currentSeekCount;
        yieldCount += currentYieldCount;
        Map<String, Long> stageTimers = timingMetadata.getStageTimers();
        if (stageTimers.containsKey(QuerySpan.Stage.DocumentSpecificTree.toString())) {
            docRanges++;
        } else if (stageTimers.containsKey(QuerySpan.Stage.FieldIndexTree.toString())) {
            fiRanges++;
        }
        if (logTimingDetails || log.isTraceEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("retrieved document from host:").append(host).append(" at key:").append(documentKey.toStringNoTime()).append(" stageTimers:").append(stageTimers);
            sb.append(" sourceCount:").append(currentSourceCount).append(" nextCount:").append(currentNextCount).append(" seekCount:").append(currentSeekCount).append(" yieldCount:").append(currentYieldCount);
            if (log.isTraceEnabled()) {
                log.trace(sb.toString());
            } else {
                log.info(sb.toString());
            }
        }
        if (dictionary.size() == 1) {
            // this document contained only timing metadata
            throw new EmptyObjectException();
        }
    }
}
Also used : Attribute(datawave.query.attributes.Attribute) EmptyObjectException(datawave.webservice.query.exception.EmptyObjectException) TimingMetadata(datawave.query.attributes.TimingMetadata)

Aggregations

EmptyObjectException (datawave.webservice.query.exception.EmptyObjectException)6 Key (org.apache.accumulo.core.data.Key)4 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)3 Document (datawave.query.attributes.Document)2 ResultsPage (datawave.webservice.query.cache.ResultsPage)2 BaseQueryResponse (datawave.webservice.result.BaseQueryResponse)2 IOException (java.io.IOException)2 JAXBException (javax.xml.bind.JAXBException)2 Value (org.apache.accumulo.core.data.Value)2 Attribute (datawave.query.attributes.Attribute)1 TimingMetadata (datawave.query.attributes.TimingMetadata)1 TermFrequencyKeyValue (datawave.query.table.parser.TermFrequencyKeyValueFactory.TermFrequencyKeyValue)1 DefaultEvent (datawave.webservice.query.result.event.DefaultEvent)1 DefaultField (datawave.webservice.query.result.event.DefaultField)1 EventBase (datawave.webservice.query.result.event.EventBase)1 FacetsBase (datawave.webservice.query.result.event.FacetsBase)1 Metadata (datawave.webservice.query.result.event.Metadata)1 Mutation (org.apache.accumulo.core.data.Mutation)1 NullWritable (org.apache.hadoop.io.NullWritable)1