Search in sources :

Example 1 with ContentQueryConfiguration

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

the class ContentQueryTable method setupQuery.

@Override
public void setupQuery(GenericQueryConfiguration genericConfig) throws Exception {
    if (!genericConfig.getClass().getName().equals(ContentQueryConfiguration.class.getName())) {
        throw new QueryException("Did not receive a ContentQueryConfiguration instance!!");
    }
    final ContentQueryConfiguration config = (ContentQueryConfiguration) genericConfig;
    try {
        final BatchScanner scanner = this.scannerFactory.newScanner(config.getTableName(), config.getAuthorizations(), this.queryThreads, config.getQuery());
        scanner.setRanges(config.getRanges());
        if (null != this.viewName) {
            final IteratorSetting cfg = new IteratorSetting(50, RegExFilter.class);
            cfg.addOption(RegExFilter.COLQ_REGEX, this.viewName);
            scanner.addScanIterator(cfg);
        }
        this.iterator = scanner.iterator();
        this.scanner = scanner;
    } catch (TableNotFoundException e) {
        throw new RuntimeException("Table not found: " + this.getTableName(), e);
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) QueryException(datawave.webservice.query.exception.QueryException) ContentQueryConfiguration(datawave.query.config.ContentQueryConfiguration) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) BatchScanner(org.apache.accumulo.core.client.BatchScanner)

Example 2 with ContentQueryConfiguration

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

the class ContentQueryTable method initialize.

@Override
public GenericQueryConfiguration initialize(final Connector connection, final Query settings, final Set<Authorizations> auths) throws Exception {
    // Initialize the config and scanner factory
    final ContentQueryConfiguration config = new ContentQueryConfiguration(this, settings);
    this.scannerFactory = new ScannerFactory(connection);
    config.setConnector(connection);
    config.setAuthorizations(auths);
    // Re-assign the view name if specified via params
    Parameter p = settings.findParameter(QueryParameters.CONTENT_VIEW_NAME);
    if (null != p && !StringUtils.isEmpty(p.getParameterValue())) {
        this.viewName = p.getParameterValue();
    }
    // Decide whether or not to include the content of child events
    String end;
    p = settings.findParameter(QueryParameters.CONTENT_VIEW_ALL);
    if ((null != p) && (null != p.getParameterValue()) && StringUtils.isNotBlank(p.getParameterValue())) {
        end = ALL;
    } else {
        end = PARENT_ONLY;
    }
    // Configure ranges
    final Collection<Range> ranges = this.createRanges(settings, end);
    config.setRanges(ranges);
    return config;
}
Also used : ContentQueryConfiguration(datawave.query.config.ContentQueryConfiguration) Parameter(datawave.webservice.query.QueryImpl.Parameter) ScannerFactory(datawave.query.tables.ScannerFactory) Range(org.apache.accumulo.core.data.Range)

Aggregations

ContentQueryConfiguration (datawave.query.config.ContentQueryConfiguration)2 ScannerFactory (datawave.query.tables.ScannerFactory)1 Parameter (datawave.webservice.query.QueryImpl.Parameter)1 QueryException (datawave.webservice.query.exception.QueryException)1 BatchScanner (org.apache.accumulo.core.client.BatchScanner)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 Range (org.apache.accumulo.core.data.Range)1