use of datawave.query.config.EdgeQueryConfiguration in project datawave by NationalSecurityAgency.
the class EdgeQueryLogic method initialize.
@Override
public GenericQueryConfiguration initialize(Connector connection, Query settings, Set<Authorizations> auths) throws Exception {
currentIteratorPriority = super.getBaseIteratorPriority() + 30;
EdgeQueryConfiguration cfg = setUpConfig(settings);
cfg.setConnector(connection);
cfg.setAuthorizations(auths);
String queryString = settings.getQuery();
if (null == queryString) {
throw new IllegalArgumentException("Query cannot be null");
} else {
cfg.setQueryString(queryString);
}
cfg.setBeginDate(settings.getBeginDate());
cfg.setEndDate(settings.getEndDate());
scannerFactory = new ScannerFactory(connection);
return cfg;
}
use of datawave.query.config.EdgeQueryConfiguration in project datawave by NationalSecurityAgency.
the class EdgeQueryLogic method setupQuery.
@Override
public void setupQuery(GenericQueryConfiguration configuration) throws Exception {
config = (EdgeQueryConfiguration) configuration;
prefilterValues = null;
EdgeQueryConfiguration.dateType dateFilterType = ((EdgeQueryConfiguration) configuration).getDateRangeType();
log.debug("Performing edge table query: " + config.getQueryString());
boolean includeStats = ((EdgeQueryConfiguration) configuration).includeStats();
String queryString = config.getQueryString();
String normalizedQuery = null;
String statsNormalizedQuery = null;
queryString = fixQueryString(queryString);
QueryData qData = configureRanges(queryString);
setRanges(qData.getRanges());
VisitationContext context = null;
try {
context = normalizeJexlQuery(queryString, false);
normalizedQuery = context.getNormalizedQuery().toString();
statsNormalizedQuery = context.getNormalizedStatsQuery().toString();
log.debug("Jexl after normalizing SOURCE and SINK: " + normalizedQuery);
} catch (JexlException ex) {
log.error("Error parsing user query.", ex);
}
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("")) {
log.debug("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);
}
log.debug("Configuring connection: tableName: " + config.getTableName() + ", auths: " + config.getAuthorizations());
BatchScanner scanner = createBatchScanner(config);
log.debug("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();
}
Aggregations