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();
}
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;
}
Aggregations