[ https://issues.apache.org/jira/browse/QPID-8581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532795#comment-17532795 ]
ASF GitHub Bot commented on QPID-8581: -------------------------------------- dakirily commented on code in PR #121: URL: https://github.com/apache/qpid-broker-j/pull/121#discussion_r866737318 ########## broker-plugins/broker-query-engine/src/main/java/org/apache/qpid/server/query/engine/QueryEngine.java: ########## @@ -0,0 +1,129 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.query.engine; + +import java.math.BigDecimal; +import java.time.ZoneId; +import java.util.Map; +import java.util.Objects; + +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.port.HttpPort; +import org.apache.qpid.server.query.engine.cache.MaxSizeHashMap; +import org.apache.qpid.server.query.engine.evaluator.QueryEvaluator; +import org.apache.qpid.server.query.engine.evaluator.settings.QuerySettings; +import org.apache.qpid.server.query.engine.parsing.query.QueryExpression; + +/** + * Bridge class between broker configuration and query evaluator + */ +// sonar complains about underscores in variable names +@SuppressWarnings("java:S116") +public class QueryEngine +{ + /** + * Broker instance + */ + private final Broker<?> _broker; + + /** + * Cache holding queries + */ + private final Map<String, QueryExpression<?, ?>> _queryCache; + + /** + * Maximal allowed BigDecimal value. + * Is needed to prevent heap memory consumption when calculating very large numbers. + */ + private BigDecimal _maxBigDecimalValue = BigDecimal.valueOf(Double.MAX_VALUE).pow(4); + + /** + * Maximal amount of queries allowed caching + */ + private final int _maxQueryCacheSize; + + /** + * Maximal amount of query tree nodes allowed + */ + private int _maxQueryDepth; + + /** + * Zone id + */ + private ZoneId _zoneId; + + /** + * Constructor injects broker and retrieves default configuration values + * + * @param broker Broker instance + */ + // mutable broker instance is stored intentionally + @SuppressWarnings("findbugs:EI_EXPOSE_REP2") + public QueryEngine(final Broker<?> broker) + { + Objects.requireNonNull(broker, "Broker instance not provided for querying"); + _broker = broker; + final HttpPort<?> httpPort = broker.getPorts().stream() + .filter(port -> Objects.equals("HTTP", port.getType())) + .map(port -> (HttpPort<?>)port) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("HTTP port not found")); Review Comment: As the configuration was moved to http management, code fragment with iteration over ports and exception throwing was removed > [Broker-J] Broker-J Query REST API improvements > ----------------------------------------------- > > Key: QPID-8581 > URL: https://issues.apache.org/jira/browse/QPID-8581 > Project: Qpid > Issue Type: Improvement > Components: Broker-J > Affects Versions: qpid-java-broker-8.0.6 > Reporter: Daniil Kirilyuk > Priority: Minor > > Existing broker REST API (including broker query API) doesn’t support such > functions as aggregation, grouping and using nested logical operators, which > could be useful for gathering broker statistics and reporting. > We suggest to add a new POST method for the endpoint /api/latest/querybroker > and supply search criteria using JSON body. (Existing GET method > implementation should stay without changes for keeping backwards > compatibility and because of difficulties of parsing complicated search > conditions from URI parameters when using GET request method). > The new functionality should add > * logical OR operator (absent in current API) > * aggregation operators AVG, CNT, MAX, MIN, SUM > * grouping aggregation > * new numeric / datetime / string functions -- This message was sent by Atlassian Jira (v8.20.7#820007) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org