MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / validate

Method validate

src/query/pojo/Query.java:103–173  ·  view source on GitHub ↗

Validates the query @throws IllegalArgumentException if one or more parameters were invalid

()

Source from the content-addressed store, hash-verified

101 * @throws IllegalArgumentException if one or more parameters were invalid
102 */
103 public void validate() {
104 if (time == null) {
105 throw new IllegalArgumentException("missing time");
106 }
107
108 validatePOJO(time, "time");
109
110 if (metrics == null || metrics.isEmpty()) {
111 throw new IllegalArgumentException("missing or empty metrics");
112 }
113
114 final Set<String> variable_ids = new HashSet<String>();
115 for (Metric metric : metrics) {
116 if (variable_ids.contains(metric.getId())) {
117 throw new IllegalArgumentException("duplicated metric id: "
118 + metric.getId());
119 }
120 variable_ids.add(metric.getId());
121 }
122
123 final Set<String> filter_ids = new HashSet<String>();
124
125 if (filters != null) {
126 for (Filter filter : filters) {
127 if (filter_ids.contains(filter.getId())) {
128 throw new IllegalArgumentException("duplicated filter id: "
129 + filter.getId());
130 }
131 filter_ids.add(filter.getId());
132 }
133 }
134
135 if (expressions != null) {
136 for (Expression expression : expressions) {
137 if (variable_ids.contains(expression.getId())) {
138 throw new IllegalArgumentException("Duplicated variable or expression id: "
139 + expression.getId());
140 }
141 variable_ids.add(expression.getId());
142 }
143 }
144
145 validateCollection(metrics, "metric");
146
147 if (filters != null) {
148 validateCollection(filters, "filter");
149 }
150
151 if (expressions != null) {
152 validateCollection(expressions, "expression");
153 }
154
155 validateFilters();
156
157 if (expressions != null) {
158 validateCollection(expressions, "expression");
159 for (final Expression exp : expressions) {
160 if (exp.getVariables() == null) {

Callers 13

invalidTimeMethod · 0.95
metricsIsNullMethod · 0.95
metricsIsEmptyMethod · 0.95
invalidMetricMethod · 0.95
invalidFilterMethod · 0.95
invalidExpressionMethod · 0.95
deserializeMethod · 0.95
duplicatedFilterIdMethod · 0.95
duplicatedMetricIdMethod · 0.95

Calls 10

validateFiltersMethod · 0.95
serializeToStringMethod · 0.95
validatePOJOMethod · 0.80
isEmptyMethod · 0.80
containsMethod · 0.80
validateCollectionMethod · 0.80
getVariablesMethod · 0.80
getExprMethod · 0.80
getIdMethod · 0.65
addMethod · 0.45

Tested by 13

invalidTimeMethod · 0.76
metricsIsNullMethod · 0.76
metricsIsEmptyMethod · 0.76
invalidMetricMethod · 0.76
invalidFilterMethod · 0.76
invalidExpressionMethod · 0.76
deserializeMethod · 0.76
duplicatedFilterIdMethod · 0.76
duplicatedMetricIdMethod · 0.76