Search in sources :

Example 1 with EdgeExtendedSummaryConfiguration

use of datawave.query.config.EdgeExtendedSummaryConfiguration in project datawave by NationalSecurityAgency.

the class DefaultExtendedEdgeQueryLogic method setupQuery.

@Override
public void setupQuery(GenericQueryConfiguration configuration) throws Exception {
    EdgeExtendedSummaryConfiguration localConf = (EdgeExtendedSummaryConfiguration) configuration;
    config = (EdgeExtendedSummaryConfiguration) configuration;
    prefilterValues = null;
    EdgeExtendedSummaryConfiguration.dateType dateFilterType = localConf.getDateRangeType();
    if (log.isTraceEnabled()) {
        log.trace("Performing edge table query: " + config.getQueryString());
    }
    // TODO check to see if overriding I/O necessary
    if (allowOverrideIO && localConf.isOverRideInput()) {
        this.summaryInputType = localConf.isSummaryInputType();
    }
    if (allowOverrideIO && localConf.isOverRideOutput()) {
        this.summaryOutputType = localConf.isAggregateResults();
    }
    boolean includeStats = localConf.includeStats();
    String queryString = config.getQueryString();
    MetadataHelper metadataHelper = super.prepareMetadataHelper(config.getConnector(), config.getModelTableName(), config.getAuthorizations());
    loadQueryModel(metadataHelper, config);
    // list of source values...no field names to translate
    if (this.summaryInputType == false) {
        queryString = applyQueryModel(queryString);
    }
    // set the modified queryString back into the config, for easy access
    config.setQueryString(queryString);
    String normalizedQuery = "";
    String statsNormalizedQuery = "";
    QueryData qData = configureRanges(queryString);
    setRanges(qData.getRanges());
    VisitationContext context = null;
    if (this.summaryInputType == false) {
        try {
            context = normalizeJexlQuery(queryString, false);
            normalizedQuery = context.getNormalizedQuery().toString();
            statsNormalizedQuery = context.getNormalizedStatsQuery().toString();
            if (log.isTraceEnabled()) {
                log.trace("Jexl after normalizing both vertices: " + normalizedQuery);
            }
        } catch (JexlException ex) {
            try {
                log.error("Error parsing user query.", ex);
            } catch (Exception ex2) {
                log.error("Exception thrown by logger (???)");
            }
        }
    }
    if ((null == normalizedQuery || normalizedQuery.equals("")) && qData.getRanges().size() < 1) {
        throw new IllegalStateException("Query string is empty after initial processing, no ranges or filters can be generated to execute.");
    }
    addIterators(qData, getDateBasedIterators(config.getBeginDate(), config.getEndDate(), currentIteratorPriority, dateFilterSkipLimit, dateFilterScanLimit, dateFilterType));
    if (!normalizedQuery.equals("")) {
        if (log.isTraceEnabled()) {
            log.trace("Query being sent to the filter iterator: " + normalizedQuery);
        }
        IteratorSetting edgeIteratorSetting = new IteratorSetting(currentIteratorPriority, EdgeFilterIterator.class.getSimpleName() + "_" + currentIteratorPriority, EdgeFilterIterator.class);
        edgeIteratorSetting.addOption(EdgeFilterIterator.JEXL_OPTION, normalizedQuery);
        edgeIteratorSetting.addOption(EdgeFilterIterator.PROTOBUF_OPTION, "TRUE");
        if (!statsNormalizedQuery.equals("")) {
            edgeIteratorSetting.addOption(EdgeFilterIterator.JEXL_STATS_OPTION, statsNormalizedQuery);
        }
        if (prefilterValues != null) {
            String value = serializePrefilter();
            edgeIteratorSetting.addOption(EdgeFilterIterator.PREFILTER_WHITELIST, value);
        }
        if (includeStats) {
            edgeIteratorSetting.addOption(EdgeFilterIterator.INCLUDE_STATS_OPTION, "TRUE");
        } else {
            edgeIteratorSetting.addOption(EdgeFilterIterator.INCLUDE_STATS_OPTION, "FALSE");
        }
        addIterator(qData, edgeIteratorSetting);
    }
    if (log.isTraceEnabled()) {
        log.trace("Configuring connection: tableName: " + config.getTableName() + ", auths: " + config.getAuthorizations());
    }
    BatchScanner scanner = createBatchScanner(config);
    if (log.isTraceEnabled()) {
        log.trace("Using the following ranges: " + qData.getRanges());
    }
    if (context != null && context.isHasAllCompleteColumnFamilies()) {
        for (Text columnFamily : context.getColumnFamilies()) {
            scanner.fetchColumnFamily(columnFamily);
        }
    }
    scanner.setRanges(qData.getRanges());
    addCustomFilters(qData, currentIteratorPriority);
    for (IteratorSetting setting : qData.getSettings()) {
        scanner.addScanIterator(setting);
    }
    this.scanner = scanner;
    iterator = scanner.iterator();
}
Also used : EdgeExtendedSummaryConfiguration(datawave.query.config.EdgeExtendedSummaryConfiguration) QueryData(datawave.webservice.query.configuration.QueryData) JexlException(org.apache.commons.jexl2.JexlException) BatchScanner(org.apache.accumulo.core.client.BatchScanner) Text(org.apache.hadoop.io.Text) ParseException(org.apache.commons.jexl2.parser.ParseException) JexlException(org.apache.commons.jexl2.JexlException) EdgeFilterIterator(datawave.query.iterator.filter.EdgeFilterIterator) MetadataHelper(datawave.query.util.MetadataHelper) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) VisitationContext(datawave.query.tables.edge.contexts.VisitationContext)

Example 2 with EdgeExtendedSummaryConfiguration

use of datawave.query.config.EdgeExtendedSummaryConfiguration in project datawave by NationalSecurityAgency.

the class DefaultExtendedEdgeQueryLogic method getSelectors.

@Override
public List<String> getSelectors(Query settings) throws IllegalArgumentException {
    EdgeExtendedSummaryConfiguration conf = (EdgeExtendedSummaryConfiguration) setUpConfig(settings);
    List<String> selectorList = null;
    SelectorExtractor selExtr;
    if (conf.isSummaryInputType()) {
        selExtr = listSelectorExtractor;
    } else {
        selExtr = selectorExtractor;
    }
    if (selExtr != null) {
        try {
            selectorList = selExtr.extractSelectors(settings);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage(), e);
        }
    }
    return selectorList;
}
Also used : EdgeExtendedSummaryConfiguration(datawave.query.config.EdgeExtendedSummaryConfiguration) SelectorExtractor(datawave.audit.SelectorExtractor) ParseException(org.apache.commons.jexl2.parser.ParseException) JexlException(org.apache.commons.jexl2.JexlException)

Aggregations

EdgeExtendedSummaryConfiguration (datawave.query.config.EdgeExtendedSummaryConfiguration)2 JexlException (org.apache.commons.jexl2.JexlException)2 ParseException (org.apache.commons.jexl2.parser.ParseException)2 SelectorExtractor (datawave.audit.SelectorExtractor)1 EdgeFilterIterator (datawave.query.iterator.filter.EdgeFilterIterator)1 VisitationContext (datawave.query.tables.edge.contexts.VisitationContext)1 MetadataHelper (datawave.query.util.MetadataHelper)1 QueryData (datawave.webservice.query.configuration.QueryData)1 BatchScanner (org.apache.accumulo.core.client.BatchScanner)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 Text (org.apache.hadoop.io.Text)1