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

Method mergeDataPoints

src/core/SaltScanner.java:398–454  ·  view source on GitHub ↗

Called once all of the scanners have reported back in to record our latency and merge the results into the spans map. If there was an exception stored then we'll return that instead.

()

Source from the content-addressed store, hash-verified

396 * stored then we'll return that instead.
397 */
398 private void mergeDataPoints() {
399 // Merge sorted spans together
400 final long merge_start = DateTime.nanoTime();
401 for (final List<KeyValue> kvs : kv_map.values()) {
402 if (kvs == null || kvs.isEmpty()) {
403 LOG.warn("Found a key value list that was null or empty");
404 continue;
405 }
406
407 for (final KeyValue kv : kvs) {
408 if (kv == null) {
409 LOG.warn("Found a key value item that was null");
410 continue;
411 }
412 if (kv.key() == null) {
413 LOG.warn("A key for a kv was null");
414 continue;
415 }
416
417 Span datapoints = spans.get(kv.key());
418 if (datapoints == null) {
419 datapoints = RollupQuery.isValidQuery(rollup_query) ?
420 new RollupSpan(tsdb, this.rollup_query) : new Span(tsdb);
421 spans.put(kv.key(), datapoints);
422 }
423
424 if (annotation_map.containsKey(kv.key())) {
425 for (final Annotation note: annotation_map.get(kv.key())) {
426 datapoints.getAnnotations().add(note);
427 }
428 annotation_map.remove(kv.key());
429 }
430 try {
431 datapoints.addRow(kv);
432 } catch (RuntimeException e) {
433 LOG.error("Exception adding row to span", e);
434 throw e;
435 }
436 }
437 }
438
439 kv_map.clear();
440
441 for (final byte[] key : annotation_map.keySet()) {
442 Span datapoints = spans.get(key);
443 if (datapoints == null) {
444 datapoints = new Span(tsdb);
445 spans.put(key, datapoints);
446 }
447
448 for (final Annotation note: annotation_map.get(key)) {
449 datapoints.getAnnotations().add(note);
450 }
451 }
452
453 annotation_map.clear();
454 }
455

Callers 1

mergeAndReturnResultsMethod · 0.95

Calls 13

nanoTimeMethod · 0.95
isValidQueryMethod · 0.95
getAnnotationsMethod · 0.95
addRowMethod · 0.95
isEmptyMethod · 0.80
putMethod · 0.80
errorMethod · 0.80
clearMethod · 0.80
valuesMethod · 0.65
keyMethod · 0.65
removeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected