Skip to content

MINIFICPP-667: Add structural definitions to work out plan for C migr…#436

Closed
phrocker wants to merge 2 commits intoapache:masterfrom
phrocker:MINIFICPP-667
Closed

MINIFICPP-667: Add structural definitions to work out plan for C migr…#436
phrocker wants to merge 2 commits intoapache:masterfrom
phrocker:MINIFICPP-667

Conversation

@phrocker
Copy link
Contributor

…ation

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

@@ -0,0 +1,1073 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to place this file somewhere else, as it's not really part of core, but a 3rd party library we use. Could you add to a folder that implies this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks for calling this out. I have a more recent commit with a lot of changes, but didn't move this yet and probably would have forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have a third party dir in the main directory, which is where this should go.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not yet in nanofi :)
Guess this library is not going to be used in the C++ part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry CMAKE_SOURCE_DIR. It can go there and should. I think I updated the NOTICE and we direct people to the root source thirdparty, so we can probably just use that. No reason to create levels of thirdparty source dirs yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, fine for me. 👍 Happy to approve as it gets moved.

Copy link
Contributor Author

@phrocker phrocker Nov 15, 2018

Choose a reason for hiding this comment

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

As per the title this is to work out a plan so that it's out in the open on Apache. I won't be merging this quite yet.

*/

typedef struct{
char *key;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have this as const char *?
A bit better user experience if you can write something like

key_value.key = "some string" 

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 example code I took this from had this as char*, not sure we can do this. I'd have to look at the library.

Copy link
Contributor Author

@phrocker phrocker Nov 15, 2018

Choose a reason for hiding this comment

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

I'll add that I'm not against this, but the code pointer's management was a little different. Again, I'll take a look at if this makes sense. core will be things that don't reflect a user experience though. That is code that's not part of our public API.

In general with C APIs I either allow value and pointer to be changed or prevent both with const char * const key -- so I'll take a look in the recent commit what I've done. I don't recall as I'm working on a more pressing bug now.

// may have to translate port ID here in the future
// need reinterpret cast until we move to C for this module.
instance->port.port_id = reinterpret_cast<char*>(malloc(strlen(port->port_id) + 1));
instance->port.port_id = (char*)(malloc(strlen(port->port_id) + 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect this to fail linter, do we already have nanofi out of range of that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We won't be able to use the C++ linter on C files. I haven't pushed the recent commit, but I'm moving toward renaming this to nanofi.c

};

int API_INITIALIZER::initialized = initialize_api();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arpadboda I'm going to merge this PR since some of this has made it's way elsewhere and this was just a proof of concept; however, it may make sense to begin isolating the cpp layer a little more like this for the eventuality that we remote it entirely.

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean NOT going to merge?

Totally agree, my current site2site work introduces UT collections anyway to help working in C.

@phrocker
Copy link
Contributor Author

Was simply proof of concept to work out plan and visually see ideas in a diff. never intended to merge, so closing as it's OBE.

@phrocker phrocker closed this Jan 31, 2019
*/
typedef struct {
// structural definitions for moving way from C++
unsigned modified:1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arpadboda changes in cstructs were the only thing of merit here, where we have attributes...are you incorporating something like this into your site to site work?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, didn't touch C structures yet, I think I won't need to do either as there is C API to get attributes.

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