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

[FLINK-2125][streaming] Delimiter change from char to string #1077

Closed
wants to merge 18 commits into from
Closed

[FLINK-2125][streaming] Delimiter change from char to string #1077

wants to merge 18 commits into from

Conversation

ogokal
Copy link

@ogokal ogokal commented Aug 30, 2015

I tried to change based on the previous comments. I hope it is sufficient enough.

SocketTextStreamFunction source = new SocketTextStreamFunction("", 0, '\n', 0);
Field field = SocketTextStreamFunction.class.getDeclaredField("isRunning");
field.setAccessible(true);
field.set(source, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think it is good to use reflection since I did something the same as you before and they told don`t do this.
Why not set up a socket server in your test?

@HuangWHWHW
Copy link
Contributor

Hi,
Generally this is a good idea to receive all buffer once instead get a char every time.
And you can see my PR:#992.
There will be some changes in SocketTextStreamFunctionTest.java.
And These changes is just "maybe".
I am not sure since that PR has not been merged yet.
Just provide you an info.

@ogokal
Copy link
Author

ogokal commented Aug 31, 2015

I changed unit tests as HuangWHWHW suggested, added a simple test server socket and refactored test methods.

private static final String[] fakeServerResponses = content.split("\\.");

private class TestServer implements Runnable{
private int port = 44444;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not suitable to use a static port since sometimes it will get failed if this port is already used.
You can call serverSocket = new ServerSocket(0); to set up a socket server with a free port.

@ogokal
Copy link
Author

ogokal commented Sep 1, 2015

I changed static port and added assertions for full content

@HuangWHWHW
Copy link
Contributor

Hi, sorry for reply late.
The file SocketTextStreamFunction.java has been changed recently.
Can you update the code and squash your commits into one for the CI re-running?
Since there was an issue in travis before.
And generally this is good from my side.
Maybe you need to @somecommiter to take a look.

@fhueske
Copy link
Contributor

fhueske commented Sep 10, 2015

@ogokal, please ping me when you have rebased and updated the PR and I will have a look.
Thanks

} else if (data != '\r') { // ignore carriage return
buffer.append((char) data);
buffer.append(charBuffer, 0, readCount);
String[] splits = buffer.toString().split(delimiter);
Copy link
Contributor

Choose a reason for hiding this comment

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

String.split() and String.replace() create new String objects which must be garbage collected. This adds quite some overhead, because these functions are called very often. The previous implementation was operating on a byte-level and avoiding the creation of new objects. It would be good if we could preserve this behavior.

@fhueske
Copy link
Contributor

fhueske commented Oct 6, 2015

Hi @ogokal, do you plan to update this PR? If not, could you please close it? Thank you.

@fhueske
Copy link
Contributor

fhueske commented Oct 15, 2015

OK, I will close this PR for now.
Please reopen if you would like to continue to work on this issue.
Thank you.

@asfgit asfgit closed this in c82ebbf Oct 15, 2015
cfmcgrady pushed a commit to cfmcgrady/flink that referenced this pull request Oct 23, 2015
lofifnc pushed a commit to lofifnc/flink that referenced this pull request Oct 23, 2015
This closes apache#1247

-- PRs closed due to inactivity
This closes apache#1077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants