Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary hashtable increments. Fixes #1742 #1897

Merged

Conversation

javierhonduco
Copy link
Contributor

Right now incrementing some datastructure's values like maps or histograms can
be done with some boilerplate[1] or with increment which increments a value
by 1.

This patch allows a second optional parameter to use as the increment.

  • [1]:
u64 zero = 0, *val;
val = map.lookup_or_init(&key, &zero);
(*val) += inc;

Notes:

  • Some lines in the documentation where changed because of trailing spaces
    deletion
  • The test is quite simple right now
  • Will update the tools to use increment in another PR

Right now incrementing some datastructure's values like maps or histograms can
be done with some boilerplate[1] or with `increment` which increments a value
by 1.

This patch allows a second optional parameter to use as the increment.

- [1]:
```
u64 zero = 0, *val;
val = map.lookup_or_init(&key, &zero);
(*val) += inc;
```

Notes:
- Some lines in the documentation where changed because of trailing spaces
deletion
- The test is quite simple right now
- Will update the tools to use `increment` in another PR
@yonghong-song
Copy link
Collaborator

The implementation looks good. Could you move the test to the test_clang.py. The current test is not triggered for ctest or make test, and it is also too small in functionality to have a separate test file. Thanks!

@yonghong-song
Copy link
Collaborator

[buildbot, ok to test]

Copy link
Collaborator

@yonghong-song yonghong-song left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. thanks!

@yonghong-song yonghong-song merged commit 230c9c0 into iovisor:master Jul 27, 2018
@javierhonduco javierhonduco deleted the hashtable-arbitrary-increments branch July 27, 2018 16:57
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
* Allow arbitrary hashtable increments. Fixes iovisor#1742

Right now incrementing some datastructure's values like maps or histograms can
be done with some boilerplate[1] or with `increment` which increments a value
by 1.

This patch allows a second optional parameter to use as the increment.

- [1]:
```
u64 zero = 0, *val;
val = map.lookup_or_init(&key, &zero);
(*val) += inc;
```

Notes:
- Some lines in the documentation where changed because of trailing spaces
deletion
- The test is quite simple right now
- Will update the tools to use `increment` in another PR

* CR changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants