MCPcopy Create free account
hub / github.com/OpenTSDB/opentsdb / mergeDataPoints

Method mergeDataPoints

src/core/MultiGetQuery.java:899–963  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

897 }
898
899 private void mergeDataPoints() {
900 for (List<KeyValue> kvs : kvsmap.values()) {
901 if (kvs == null || kvs.isEmpty()) {
902 LOG.error("Found a key value list that was null or empty");
903 continue;
904 }
905 for (final KeyValue kv : kvs) {
906
907 if (kv == null) {
908 LOG.error("Found a key value item that was null");
909 continue;
910 }
911 if (kv.key() == null) {
912 LOG.error("A key for a kv was null");
913 continue;
914 }
915
916 Span datapoints = null;
917 try {
918 datapoints = spans.get(kv.key());
919 } catch (RuntimeException e) {
920 LOG.error("Failed to fetch the span", e);
921 }
922
923 // If this tsdb follows append logic, then there will not be any
924 // duplicates here. But if it is not, then there can be multiple
925 // non-compcated or out of order rows here
926 if (datapoints == null) {
927 datapoints = RollupQuery.isValidQuery(rollup_query)
928 ? new RollupSpan(tsdb, rollup_query)
929 : new Span(tsdb);
930 spans.put(kv.key(), datapoints);
931 }
932
933 if (annotMap.containsKey(kv.key())) {
934 for (Annotation note : annotMap.get(kv.key())) {
935 datapoints.getAnnotations().add(note);
936 }
937 annotMap.remove(kv.key());
938 }
939 try {
940 datapoints.addRow(kv);
941 } catch (RuntimeException e) {
942 LOG.error("Exception adding row to span", e);
943 }
944 }
945 }
946
947 kvsmap.clear();
948
949 for (byte[] key : annotMap.keySet()) {
950 Span datapoints = (Span) spans.get(key);
951
952 if (datapoints == null) {
953 datapoints = new Span(tsdb);
954 spans.put(key, datapoints);
955 }
956

Callers 1

mergeAndReturnResultsMethod · 0.95

Calls 12

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

Tested by

no test coverage detected