MCPcopy Create free account
hub / github.com/iovisor/bcc / print_json_hist

Method print_json_hist

src/python/bcc/table.py:687–721  ·  view source on GitHub ↗

print_json_hist(val_type="value", section_header="Bucket ptr", section_print_fn=None, bucket_fn=None, bucket_sort_fn=None): Prints a table as a json histogram. The table must be stored as log2. The

(self, val_type="value", section_header="Bucket ptr",
                        section_print_fn=None, bucket_fn=None, bucket_sort_fn=None)

Source from the content-addressed store, hash-verified

685 buckets.append(bucket)
686
687 def print_json_hist(self, val_type="value", section_header="Bucket ptr",
688 section_print_fn=None, bucket_fn=None, bucket_sort_fn=None):
689 """print_json_hist(val_type="value", section_header="Bucket ptr",
690 section_print_fn=None, bucket_fn=None,
691 bucket_sort_fn=None):
692
693 Prints a table as a json histogram. The table must be stored as
694 log2. The val_type argument is optional, and is a column header.
695 If the histogram has a secondary key, the dictionary will be split by secondary key
696 If section_print_fn is not None, it will be passed the bucket value
697 to format into a string as it sees fit. If bucket_fn is not None,
698 it will be used to produce a bucket value for the histogram keys.
699 If bucket_sort_fn is not None, it will be used to sort the buckets
700 before iterating them, and it is useful when there are multiple fields
701 in the secondary key.
702 The maximum index allowed is log2_index_max (65), which will
703 accommodate any 64-bit integer in the histogram.
704 """
705 if isinstance(self.Key(), ct.Structure):
706 tmp = {}
707 buckets = []
708 self.decode_c_struct(tmp, buckets, bucket_fn, bucket_sort_fn)
709 for bucket in buckets:
710 vals = tmp[bucket]
711 if section_print_fn:
712 section_bucket = (section_header, section_print_fn(bucket))
713 else:
714 section_bucket = (section_header, bucket)
715 print(_get_json_hist(vals, val_type, section_bucket))
716
717 else:
718 vals = [0] * log2_index_max
719 for k, v in self.items():
720 vals[k.value] = v.value
721 print(_get_json_hist(vals, val_type))
722
723 def print_log2_hist(self, val_type="value", section_header="Bucket ptr",
724 section_print_fn=None, bucket_fn=None, strip_leading_zero=None,

Callers 1

biolatency.pyFile · 0.80

Calls 3

decode_c_structMethod · 0.95
itemsMethod · 0.95
_get_json_histFunction · 0.85

Tested by

no test coverage detected