Parses a "tsuid=..." type query and adds it to the TSQuery. This will generate a TSSubQuery and add it to the TSQuery if successful @param query_string The value of the m query string parameter, i.e. what comes after the equals sign @param data_query The query we're building @throws BadRequestExcept
(final String query_string,
TSQuery data_query)
| 695 | * missing components |
| 696 | */ |
| 697 | private static void parseTsuidTypeSubQuery(final String query_string, |
| 698 | TSQuery data_query) { |
| 699 | if (query_string == null || query_string.isEmpty()) { |
| 700 | throw new BadRequestException("The tsuid query string was empty"); |
| 701 | } |
| 702 | |
| 703 | // tsuid queries are of the following forms: |
| 704 | // agg:[interval-agg:][rate:]tsuid[,s] |
| 705 | // where the parts in square brackets `[' .. `]' are optional. |
| 706 | final String[] parts = Tags.splitString(query_string, ':'); |
| 707 | int i = parts.length; |
| 708 | if (i < 2 || i > 5) { |
| 709 | throw new BadRequestException("Invalid parameter m=" + query_string + " (" |
| 710 | + (i < 2 ? "not enough" : "too many") + " :-separated parts)"); |
| 711 | } |
| 712 | |
| 713 | final TSSubQuery sub_query = new TSSubQuery(); |
| 714 | |
| 715 | // the aggregator is first |
| 716 | sub_query.setAggregator(parts[0]); |
| 717 | |
| 718 | i--; // Move to the last part (the metric name). |
| 719 | final List<String> tsuid_array = Arrays.asList(parts[i].split(",")); |
| 720 | sub_query.setTsuids(tsuid_array); |
| 721 | |
| 722 | // parse out the rate and downsampler |
| 723 | for (int x = 1; x < parts.length - 1; x++) { |
| 724 | if (parts[x].toLowerCase().startsWith("rate")) { |
| 725 | sub_query.setRate(true); |
| 726 | if (parts[x].indexOf("{") >= 0) { |
| 727 | sub_query.setRateOptions(QueryRpc.parseRateOptions(true, parts[x])); |
| 728 | } |
| 729 | } else if (Character.isDigit(parts[x].charAt(0))) { |
| 730 | sub_query.setDownsample(parts[x]); |
| 731 | } else if (parts[x].toLowerCase().startsWith("percentiles")) { |
| 732 | sub_query.setPercentiles(QueryRpc.parsePercentiles(parts[x])); |
| 733 | } else if (parts[x].toLowerCase().startsWith("show-histogram-buckets")) { |
| 734 | sub_query.setShowHistogramBuckets(true); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | if (data_query.getQueries() == null) { |
| 739 | final ArrayList<TSSubQuery> subs = new ArrayList<TSSubQuery>(1); |
| 740 | data_query.setQueries(subs); |
| 741 | } |
| 742 | data_query.getQueries().add(sub_query); |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * Parses the "rate" section of the query string and returns an instance |
no test coverage detected