use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.
the class ElideStandaloneSettings method getQueryEngine.
/**
* Gets the QueryEngine for elide.
* @param metaDataStore MetaDataStore object.
* @param defaultConnectionDetails default DataSource Object and SQLDialect Object.
* @param dynamicConfiguration Optional dynamic config.
* @param dataSourceConfiguration DataSource Configuration.
* @param dbPasswordExtractor Password Extractor Implementation.
* @return QueryEngine object initialized.
*/
default QueryEngine getQueryEngine(MetaDataStore metaDataStore, ConnectionDetails defaultConnectionDetails, Optional<DynamicConfiguration> dynamicConfiguration, DataSourceConfiguration dataSourceConfiguration, DBPasswordExtractor dbPasswordExtractor) {
if (dynamicConfiguration.isPresent()) {
Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
dynamicConfiguration.get().getDatabaseConfigurations().forEach(dbConfig -> connectionDetailsMap.put(dbConfig.getName(), new ConnectionDetails(dataSourceConfiguration.getDataSource(dbConfig, dbPasswordExtractor), SQLDialectFactory.getDialect(dbConfig.getDialect()))));
Function<String, ConnectionDetails> connectionDetailsLookup = (name) -> {
if (StringUtils.isEmpty(name)) {
return defaultConnectionDetails;
}
return Optional.ofNullable(connectionDetailsMap.get(name)).orElseThrow(() -> new IllegalStateException("ConnectionDetails undefined for connection: " + name));
};
return new SQLQueryEngine(metaDataStore, connectionDetailsLookup, new HashSet<>(Arrays.asList(new AggregateBeforeJoinOptimizer(metaDataStore))), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
}
return new SQLQueryEngine(metaDataStore, (unused) -> defaultConnectionDetails);
}
Aggregations