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

Feature/674 improve properties #721

Merged
merged 57 commits into from
Apr 2, 2024
Merged

Conversation

pnoltes
Copy link
Contributor

@pnoltes pnoltes commented Jan 22, 2024

This PR add support for setting and getting string, bool, long, double and a version array list with properties.

Also:

  • Add support for only getting a property value if it is stored with a specific type (getLong, getDouble, etc)
  • Refactor filter to use the underlying property type when matching. This prevent the needed for memory allocation during filter match. The changed behavior should also more align with Properites and Filter matching in OSGi
  • Add logic so that a service registration will use the correct type for service.id, service.bundleid and service.version and if needed convert service.ranking and service.version properties (if set before a service registration call) to the correct types.
  • Add Properties / Filter intro documentation
  • Improve test coverage for Filter and Properties

Refactoring the Properties store and load to include properties value type information will be done in a follow up PR.

# Conflicts:
#	libs/utils/src/array_list.c
@PengZheng
Copy link
Contributor

PengZheng commented Jan 23, 2024

I noticed Codecov has stopped working for 3 days in a row. Fixed.

(cherry picked from commit 9b4501d)
@PengZheng PengZheng self-requested a review January 23, 2024 05:37
@pnoltes
Copy link
Contributor Author

pnoltes commented Mar 24, 2024

This PR has been updated so that celix array list types are used, which minimizes the celix properties functions needed for array list handling.
This PR can be reviewed again.

After this, I will dive into properties (JSON) serialization.

@pnoltes pnoltes requested a review from PengZheng March 24, 2024 16:00
Copy link
Contributor

@PengZheng PengZheng left a comment

Choose a reason for hiding this comment

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

I have reviewed the API parts, and leave some further remarks.
To make this PR easier to follow, I revised all previous remarks to close resolved ones.

Note that there are still remarks that need fix/discussion.

libs/utils/include/celix_properties.h Outdated Show resolved Hide resolved
} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) {
entry->value = celix_utils_longArrayListToString(entry->typed.arrayValue);
} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) {
entry->value = celix_utils_doubleArrayListToString(entry->typed.arrayValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

WIll a single celix_arrayListToString be enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

And we'll have a single StringToArrayList.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A single StringToArrayList implies that we should detect the types in the string. This is currently not implemented. I most worry about versions (1.2.3 is a valid version, but also 1.2).

This also triggered me. If we want a properties to (de)serializer to JSON. Do we also want to support / JSON mixed arrays. So something like: [true, 1, 2.3, "string", "1.2.3.qualified"] ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want to support / JSON mixed arrays. So something like: [true, 1, 2.3, "string", "1.2.3.qualified"] ?

As a dynamically typed language, JS can support heterogeneous arrays.
As a statically typed language, Java supports heterogeneous arrays via "the mother of all" Object.
Here we may need a generic "entry".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am still a a bit worried about JSON serialization and especially empty ([]) arrays, but I will see how we can tackle this a properties JSON serialization pull request.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am still a a bit worried about JSON serialization and especially empty ([]) arrays.

Yeah, this is an annoying case.

libs/utils/include/celix_array_list.h Outdated Show resolved Hide resolved
libs/utils/include/celix_array_list.h Outdated Show resolved Hide resolved
libs/utils/include/celix_array_list.h Outdated Show resolved Hide resolved
libs/utils/include/celix_array_list.h Show resolved Hide resolved
libs/utils/include/celix_properties.h Outdated Show resolved Hide resolved
PengZheng and others added 19 commits March 25, 2024 16:09
…cation.

When compiling a filter, it will try to parse arbitrary string as a version. The string length may exceed 64 bytes and thus will trigger unnecessary dynamic memory allocation.
…dle CELIX_ILLEGAL_ARGUMENT of addEntry callback.
…ests for filter.

Attributes were ignored when performing equality test between substring filters.
It also replaces celix_utils_stringEquals with cheaper celix_utils_isStringNullOrEmpty.
@PengZheng PengZheng self-requested a review April 1, 2024 14:20
@PengZheng
Copy link
Contributor

All issues have been addressed! 🚀
Please wait for a little last minute cleanup to be merged, which will happen tomorrow.

Copy link
Contributor

@PengZheng PengZheng left a comment

Choose a reason for hiding this comment

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

LGTM

Long awaited typing support of celix_properties_t finally arrives, together with improved filter. Really exciting improvement.

@@ -28,6 +28,14 @@
#include "celix_utils.h"
#include "celix_version.h"

#define STRING_VALUE_UNDEFINED_EL_TYPE "CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "Undefined"/"undefined" will have better readability than "CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED" as console output.

} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) {
entry->value = celix_utils_longArrayListToString(entry->typed.arrayValue);
} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) {
entry->value = celix_utils_doubleArrayListToString(entry->typed.arrayValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want to support / JSON mixed arrays. So something like: [true, 1, 2.3, "string", "1.2.3.qualified"] ?

As a dynamically typed language, JS can support heterogeneous arrays.
As a statically typed language, Java supports heterogeneous arrays via "the mother of all" Object.
Here we may need a generic "entry".

} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) {
entry->value = celix_utils_longArrayListToString(entry->typed.arrayValue);
} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) {
entry->value = celix_utils_doubleArrayListToString(entry->typed.arrayValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still a a bit worried about JSON serialization and especially empty ([]) arrays.

Yeah, this is an annoying case.

@pnoltes pnoltes merged commit cb38185 into master Apr 2, 2024
32 checks passed
@pnoltes pnoltes deleted the feature/674-improve-properties branch April 2, 2024 20:21
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.

3 participants