add listval_filter method and corresponding tests
authorMatthias Bethke <matthias.bethke@financial.com>
Wed, 10 Sep 2014 17:34:50 +0000 (19:34 +0200)
committerMatthias Bethke <matthias.bethke@financial.com>
Wed, 10 Sep 2014 17:34:50 +0000 (19:34 +0200)
Rationale:
A frequent use case for LISTVAL is to retrieve a list of resources for a certain
host or host group that is not known in advance, such as when the hosts have
different disks installed. Using the existing listval() method,
Collectd::Unixsock retrieves the entire list, parses each entry into a hash and
returns the list, only to have the caller throw away the vast majority of
entries immediately. listval_filter() allows the caller to pass any attribute
that can be passed to getval() and filters the list of resources retrieved from
the socket before parsing it, resulting in a large speedup.
The current implemntation has some code duplication, although listval() could be
implemented as a small wrapper around listval_filter() with just a few percent
speed penalty due to the extra dynamically built regexp.


No differences found