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

Add a unique_list function #185

Merged
merged 1 commit into from Oct 10, 2018
Merged

Add a unique_list function #185

merged 1 commit into from Oct 10, 2018

Conversation

XaF
Copy link
Contributor

@XaF XaF commented Aug 7, 2018

The unique_list function takes a list as parameter, and returns
a list without any duplicated elements. The order of the elements
is maintained (i.e. if the first occurrence of an element appears in
the list before the first occurrence of another, the former will
precede the latter in the final list).

@hpcugentbot
Copy link

Can one of the admins verify this patch?

to_dict[escape(itemid)] = 1;
};
};
return(to_list);
Copy link
Member

Choose a reason for hiding this comment

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

remove the return, it makes an extra copy, (to_list; is enough)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not know that, will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed :)

@@ -218,3 +218,19 @@ function full_hostname_from_object = {
return (OBJECT);
};


@documentation{
desc = Function to deduplicate the content of a list, only the first occurence of each element in the list will be kept in the final list returned to the caller
Copy link
Member

Choose a reason for hiding this comment

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

line too long?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as for the other one. How do line break works for the desc field in @documentation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed :)

@documentation{
desc = Function to deduplicate the content of a list, only the first occurence of each element in the list will be kept in the final list returned to the caller
}
function unique_list = {
Copy link
Member

Choose a reason for hiding this comment

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

how often is this used? or how performance sensitive is this? the code below does a lot of copying and casting; if needed we can add this to panc (eg via supporting sets if you don't need the ordering)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The aim is to deduplicate a list of strings / long when generating the profile of a host, to manage a new entitlement structure (to be submitted later). The ordering is not important for us, so if this can be done a better & faster way, I'm all for it!

Copy link
Member

Choose a reason for hiding this comment

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

if you are up to it and if it is worth it, following doc sand example PR can show you what is needed: https://www.quattor.org/development/panc-internals-overview.html#adding-functionality (and example quattor/pan#118).

but just to be clear, i have no issue with getting this merged 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it will be worth the trouble... Maybe if this starts getting used heavily and becomes the bottleneck, but not sure this will! It's true that in Java it would just be a matter of doing a collection copy from the list to a set, and returning it as a list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Plus you would have to wait for a new panc release before you could use it, which would slow things down.

The unique_list function takes a list as parameter, and returns
a list without any duplicated elements. The order of the elements
is maintained (i.e. if the first occurrence of an element appears in
the list before the first occurrence of another, the former will
precede the latter in the final list).
@ned21
Copy link
Contributor

ned21 commented Aug 7, 2018

@hpcugentbot test this please

@XaF
Copy link
Contributor Author

XaF commented Sep 25, 2018

Seems that the commit failure comes from something else than my patch, looking at the test logs...

@jrha
Copy link
Member

jrha commented Oct 10, 2018

@hpcugentbot please test this please

@jrha jrha merged commit cd0c1d7 into quattor:master Oct 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants