You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/01/23 22:37:42 UTC
[GitHub] [incubator-pinot] harleyjj opened a new pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
harleyjj opened a new pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011
…ram for yaml/list
1) Makes dataset an optional param for returning a filtered list of detection yaml configurations
2) Adds some Swagger annotations for yaml/list endpoint
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] akshayrai commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
akshayrai commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371965339
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -904,15 +904,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = metricString != null && metricString.equals(metric);
+ }
+ // check dataset only if it was passed
+ if (dataset != null) {
+ // contains method should not be called on null
+ datasetMatch = datasetList != null && datasetList.contains(dataset);
+ }
+ // config should satisfy both filters
+ return metricMatch && datasetMatch;
+ }
+
/**
* List all yaml configurations as JSON enhanced with detection config id, isActive and createBy information.
+ * @param dataset the dataset to filter results by (optional)
+ * @param metric the metric to filter results by (optional)
* @return the yaml configuration converted in to JSON, with enhanced information from detection config DTO.
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> filterConfigsBy(y, dataset, metric))
+ .collect(Collectors.toList());
+ }
+ return yamls;
}
Review comment:
Although the legacy code doesn't follow the standards, I have some suggestions which we have been trying to follow for all the new apis.
1. If there is an exception thrown during the execution then we need to wrap it up and return a meaningful response to the caller along with the status codes.
2. Also consider adding some logging statements indicating how many configurations were returned for the params passed.
Refer example: https://github.com/apache/incubator-pinot/blob/master/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/api/user/dashboard/UserDashboardResource.java#L220
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r370435266
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,28 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List<String> thisYaml = (List)y.get("datasetNames");
Review comment:
I added metric as an optional param, as well. Would this comment still apply to the updated code?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r370742027
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,46 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List datasetList = (List) y.get("datasetNames");
+ String metricString = (String) y.get("metric");
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ if (metric != null ) {
+ if (metricString != null) {
+ metricMatch = metricString.equals(metric);
+ } else {
+ metricMatch = false;
+ }
+ }
+ if (dataset != null && datasetList != null) {
+ if (datasetList != null) {
+ datasetMatch = datasetList.contains(dataset);
+ } else {
+ datasetMatch = false;
+ }
+ }
+ return (metricMatch && datasetMatch);
+ })
Review comment:
The readability is bad. Let's rewrite this logic.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371436138
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,46 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List datasetList = (List) y.get("datasetNames");
+ String metricString = (String) y.get("metric");
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ if (metric != null ) {
+ if (metricString != null) {
+ metricMatch = metricString.equals(metric);
+ } else {
+ metricMatch = false;
+ }
+ }
+ if (dataset != null && datasetList != null) {
+ if (datasetList != null) {
+ datasetMatch = datasetList.contains(dataset);
+ } else {
+ datasetMatch = false;
+ }
+ }
+ return (metricMatch && datasetMatch);
+ })
Review comment:
I rewrote the logic in the method
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r372012082
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -904,15 +904,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = metricString != null && metricString.equals(metric);
+ }
+ // check dataset only if it was passed
+ if (dataset != null) {
+ // contains method should not be called on null
+ datasetMatch = datasetList != null && datasetList.contains(dataset);
+ }
+ // config should satisfy both filters
+ return metricMatch && datasetMatch;
+ }
+
/**
* List all yaml configurations as JSON enhanced with detection config id, isActive and createBy information.
+ * @param dataset the dataset to filter results by (optional)
+ * @param metric the metric to filter results by (optional)
* @return the yaml configuration converted in to JSON, with enhanced information from detection config DTO.
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> filterConfigsBy(y, dataset, metric))
+ .collect(Collectors.toList());
+ }
+ return yamls;
}
Review comment:
I made these changes. Please take a look.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r370397132
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,28 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List<String> thisYaml = (List)y.get("datasetNames");
Review comment:
variable "thisYaml" is not needed in this case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371459333
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -900,15 +900,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = (metricString != null) && metricString.equals(metric);
+ }
+ // check dataset only if it was passed
+ if (dataset != null) {
+ // contains method should not be called on null
+ datasetMatch = (datasetList != null) && datasetList.contains(dataset);
Review comment:
datasetMatch = datasetList != null && datasetList.contains(dataset);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371459220
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -900,15 +900,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = (metricString != null) && metricString.equals(metric);
+ }
+ // check dataset only if it was passed
+ if (dataset != null) {
+ // contains method should not be called on null
+ datasetMatch = (datasetList != null) && datasetList.contains(dataset);
+ }
+ // config should satisfy both filters
+ return (metricMatch && datasetMatch);
Review comment:
return metricMatch && datasetMatch;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371459410
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -900,15 +900,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = (metricString != null) && metricString.equals(metric);
Review comment:
metricMatch = metricString != null && metricString.equals(metric);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on issue #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on issue #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#issuecomment-579621137
One request not specific to this PR: Can we show error message in a separate panel? Currently it only shows as pop up window which is not very readable. @harleyjj
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
xiaohui-sun commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r370739427
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,46 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List datasetList = (List) y.get("datasetNames");
Review comment:
It is not good practice to put complicated logic inside lambda expressions.
Suggest to put it as a method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
harleyjj commented on a change in pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371435966
##########
File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -907,8 +907,46 @@ public Response toggleActivation(
*/
@GET
@Path("/list")
+ @ApiOperation("Get the list of all detection YAML configurations as JSON enhanced with additional information, optionally filtered.")
@Produces(MediaType.APPLICATION_JSON)
- public List<Map<String, Object>> listYamls() throws ExecutionException {
- return this.detectionConfigDAO.findAll().parallelStream().map(this.detectionConfigFormatter::format).collect(Collectors.toList());
+ public List<Map<String, Object>> listYamls(
+ @ApiParam("Dataset the detection configurations should be filtered by") @QueryParam("dataset") String dataset,
+ @ApiParam("Metric the detection configurations should be filtered by") @QueryParam("metric") String metric) throws ExecutionException {
+ List<Map<String, Object>> yamls;
+ if (dataset == null && metric == null) {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .collect(Collectors.toList());
+ } else {
+ yamls = this.detectionConfigDAO
+ .findAll()
+ .parallelStream()
+ .map(this.detectionConfigFormatter::format)
+ .filter(y -> {
+ List datasetList = (List) y.get("datasetNames");
Review comment:
Method added.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] akshayrai merged pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
Posted by GitBox <gi...@apache.org>.
akshayrai merged pull request #5011: [TE] endpoint - harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org