Skip to content

Remove simdjson_move_result #628

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

Merged
merged 18 commits into from
Mar 27, 2020
Merged

Conversation

jkeiser
Copy link
Member

@jkeiser jkeiser commented Mar 26, 2020

This uses the C++ lvalue operator to enforce moves in and out of simdjson_result, allowing us to use a single class for owned and non-owned things. We never call std::move() anymore, instead relying on forward to figure out whether to copy (in the case of references) or move (in the case of values).

Specifically:

  • tie() can only be done on an rvalue now (i.e. once you tie() you have to throw away the simdjson_result).
  • operator T is changed to operator T&& and requires the simdjson_result to be an rvalue.
  • The constructor always takes T&&, requiring the input to be an rvalue.

With that, we now use simdjson_result<padded_string> for load() and can remove simdjson_move_result entirely.

Fixes #622

@jkeiser
Copy link
Member Author

jkeiser commented Mar 26, 2020

(I was toying with this idea anyway, given that simdjson_result<document> doesn't exist anymore this was the last user.)

@jkeiser jkeiser force-pushed the jkeiser/remove-simdjson-move-result branch from f0ad8e7 to 3353df6 Compare March 26, 2020 19:01
@jkeiser jkeiser mentioned this pull request Mar 26, 2020
@jkeiser jkeiser force-pushed the jkeiser/remove-simdjson-move-result branch 2 times, most recently from cc34782 to ccee716 Compare March 26, 2020 19:46
@jkeiser jkeiser force-pushed the jkeiser/remove-simdjson-move-result branch from ccee716 to 56841bc Compare March 26, 2020 19:48
@lemire
Copy link
Member

lemire commented Mar 26, 2020

@jkeiser I am very, very confused .... why does jsonpointer (the tool) relies on deprecated functions?

That's wrong, right? Didn't you just update it?

@lemire
Copy link
Member

lemire commented Mar 26, 2020

@jkeiser Just so we have the same understanding...

The && ref-qualifier means that the instance must be an rvalue.

The & ref-qualifier means that the instance must be an lvalue.

If we agree with this... then I don't quite understand your comments... because you have added the && ref-qualifier to tie...

 void tie(T& t, error_code & e) && noexcept {

This means, as far as I can tell, that it can only be called on rvalues...

@jkeiser
Copy link
Member Author

jkeiser commented Mar 26, 2020

I am very, very confused .... why does jsonpointer (the tool) relies on deprecated functions?

That's wrong, right? Didn't you just update it?

I have explicitly not been changing the idiom of anything while deprecating stuff. All updates to the tools during deprecation have kept the same meaning (e.g. anything using ParsedJson::Iterator still uses it). Trying to keep separate things separate :)

This means, as far as I can tell, that it can only be called on rvalues...

@lemire You're right, but with one caveat: && is an rvalue reference. What this means, roughly, is "either a temporary value or a variable that will no longer be used." By passing you a reference with &&, the caller gives up all rights to use the object from that point on.

See this reference for a fairly enlightening explanation. That's how it clicked for me, and the way I'm using && is backed up by the theory in there.

It's new info to me, so please do tell me if you understand it differently after reading!

@lemire
Copy link
Member

lemire commented Mar 26, 2020

@jkeiser My understanding is the same, I think. However, here is how I would name things...

the ref qualifier & is for lvalues

the ref qualifier && is for rvalues

@lemire
Copy link
Member

lemire commented Mar 26, 2020

Ok. Freeze your PR as it stands, I will patch it so that it passes the tests.

@jkeiser
Copy link
Member Author

jkeiser commented Mar 26, 2020

Yeah, I think I got lvalues / rvalues wrong in my initial explanation. I've fixed the description. So do you feel && is in the right places, and will work well for users, based on your understanding of it?

@jkeiser
Copy link
Member Author

jkeiser commented Mar 26, 2020

(PR is frozen.)

@lemire
Copy link
Member

lemire commented Mar 26, 2020

@jkeiser I think that the code is correct and I now think that the description is correct.

@lemire
Copy link
Member

lemire commented Mar 26, 2020

I still have a way to go, but I think it is necessary for us to remove deprecated calls from our own tools.

@jkeiser
Copy link
Member Author

jkeiser commented Mar 26, 2020

I still have a way to go, but I think it is necessary for us to remove deprecated calls from our own tools.

I agree. We should also find a way to turn off the deprecation warnings for tests that are explicitly testing deprecated APIs, without turning them off for everything.

My suggestion: comment out the warnings-as-errors tests in this PR, and we can attack this problem separately and then enable them.

Either way, I think it needs to be deprecation-clean by 0.3.

@lemire
Copy link
Member

lemire commented Mar 27, 2020

@jkeiser

I have upgraded all of our tests and tools to the new API. I am now going to wait to see whether it runs without any warning in recent GCC compilers.

@lemire
Copy link
Member

lemire commented Mar 27, 2020

My suggestion: comment out the warnings-as-errors tests in this PR, and we can attack this problem separately and then enable them.

Too late. :-)

@lemire
Copy link
Member

lemire commented Mar 27, 2020

@jkeiser I suggest you have a look at my changes. I tweaked your API a bit.

@lemire
Copy link
Member

lemire commented Mar 27, 2020

@jkeiser This passes all tests now. Merge at will.

@jkeiser
Copy link
Member Author

jkeiser commented Mar 27, 2020

(Any and all of these comments can be cleaned up later, and I may do so before merging anyway.)

@jkeiser jkeiser force-pushed the jkeiser/remove-simdjson-move-result branch from 8d7ddd7 to f0f111b Compare March 27, 2020 16:07
jkeiser added 3 commits March 27, 2020 09:09
- Remove const char * variants for at_key(), string_view covers them
- Add at_key_case_insensitive variants on *_result
- Add at(), at_key(), at_key_case_insensitive() tests
@jkeiser
Copy link
Member Author

jkeiser commented Mar 27, 2020

@lemire if you could give a once-over on my last 4 commits (should be reasonably small), I'll merge this puppy (after tests of course).

@lemire
Copy link
Member

lemire commented Mar 27, 2020

@jkeiser I scanned everything new and I don't find anything objectionable. Merge at will.

@jkeiser
Copy link
Member Author

jkeiser commented Mar 27, 2020

CircleCI is painfully overloaded at the moment, most jobs are queued but not running.

@jkeiser jkeiser merged commit 47859f3 into master Mar 27, 2020
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.

GCC 9 complains about padded_string
2 participants