| 53 | |
| 54 | template <class T> |
| 55 | void ReadIntArray(const StringPiece& sp, int expected_num_values, T* out) { |
| 56 | vector<StringPiece> counters = Split(sp, " ", SkipWhitespace()); |
| 57 | |
| 58 | // Something is wrong with the number of values that we read |
| 59 | if (expected_num_values > counters.size()) { |
| 60 | memset(out, 0, sizeof(*out)); |
| 61 | KLOG_EVERY_N_SECS(WARNING, 60) << "Failed to parse enough values: expected " |
| 62 | << expected_num_values << " but found " << counters.size() << ". Input was: " |
| 63 | << sp; |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | for (int i = 0; i < expected_num_values; ++i) { |
| 68 | int64_t* v = &(*out)[i]; |
| 69 | if (!safe_strto64(counters[i].as_string(), v)) { |
| 70 | KLOG_EVERY_N_SECS(WARNING, 60) << "Failed to parse value: " << *v; |
| 71 | *v = 0; |
| 72 | } |
| 73 | DCHECK_GE(*v, 0) << "Value " << i << ": " << *v; |
| 74 | } |
| 75 | } |
| 76 | } // anonymous namespace |
| 77 | |
| 78 | namespace impala { |
no test coverage detected