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

Newparser #9

Merged
merged 3 commits into from
Jun 22, 2015
Merged

Newparser #9

merged 3 commits into from
Jun 22, 2015

Conversation

sbromberger
Copy link
Contributor

This is a fix-all with a new parsing structure that takes advantage of Redis' CRLF line terminators. No more readavailable required, since we know when the Redis output is finished.

(In particular, this includes fixes for #1, #6, #7, and #8.)

@@ -221,7 +221,7 @@ end
@redisfunction "shutdown" String
@redisfunction "shutdown" String option
@redisfunction "slaveof" String host port
@redisfunction "time" Array
@redisfunction "_time" Array
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 did this as a proof of concept to show that we can cast Redis output to Julia types if we need to. time seemed like an obvious first choice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind moving this part into another pr for discussion? There's probably value in doing this, but I'd like to keep things consistent in the mean time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries. give me a few mins.

@sbromberger
Copy link
Contributor Author

Phew! I think that might do it, no?

@jkaye2012
Copy link
Collaborator

Looks pretty good to me. Let me pull it down quickly to run the tests, then I'll merge away.

Thanks for taking the time to help out on this!

@sbromberger
Copy link
Contributor Author

Absolutely my pleasure. I have grand plans for Redis + LightGraphs.

@sbromberger
Copy link
Contributor Author

Also, if you wouldn't mind tagging a new version, that way I can add this as a dependency in a project I've got going on.

PS: I took the liberty of creating a PR on Redis.io to change their "clients" page to point here for the Julia client. They don't currently have anything for Julia there.

@sbromberger
Copy link
Contributor Author

PPS: I didn't make any changes to (or do any testing with) PubSub, so I don't know whether this impacts it.

@jkaye2012
Copy link
Collaborator

Sure, I'll tag the version once I merge it.

I think this change might break v0.3 compatibility though. When I run the tests, get fails with this message:

ERROR: type cannot be constructed
in map at abstractarray.jl:1328
in parse_bulk_string at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:26
in parseline at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:58
in execute_command at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:85
in get at /Users/jkaye/.julia/v0.3/Redis/src/client.jl:70

Perhaps we can just require v0.4+ or something. Thoughts?

@sbromberger
Copy link
Contributor Author

Ah. Yes. This is a @compat thing, I think. Could you test the latest commit to see whether that fixes things? (I don't have 0.3 to test with at the moment.)

@jkaye2012
Copy link
Collaborator

Getting closer. A new one with Vector{Any}

ERROR: type cannot be constructed
in parse_array at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:35
in parseline at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:58
in execute_command at /Users/jkaye/.julia/v0.3/Redis/src/parser.jl:85
in keys at /Users/jkaye/.julia/v0.3/Redis/src/client.jl:70

@sbromberger
Copy link
Contributor Author

Yup, this is JuliaLang/Compat.jl#105. Let me fix it. You'll want to change this once the Compat fix is in, though.

throw exceptions instead of error
@sbromberger
Copy link
Contributor Author

Can you retest with 0.3 now?

@jkaye2012
Copy link
Collaborator

Okay, pretty sure this will be the last problem we find.

Subscription is broken because of this line https://github.com/jkaye2012/Redis.jl/blob/master/src/client.jl#L49

Just have to plug the new parsing in there and everything should work. This would also be broken on v0.4; after it's fixed just run a local Redis server (with data that you don't care about - it will run flushall) and run julia test/redis_tests.jl to see if everything is good to go.

@jkaye2012
Copy link
Collaborator

Also, this highlights another problem, which is that the Travis-CI build isn't properly running the tests right now because runtests.jl doesn't have anything in it, so I will have to fix that at some point.

I'm pretty sure this commit actually breaks parser_tests.jl as well now that I think of it.

@sbromberger
Copy link
Contributor Author

Okay, pretty sure this will be the last problem we find.

Hah - you've just guaranteed that it won't be. :)

Thanks for the testing instructions. I'd been doing Pkg.test() without realizing that runtests was empty :)

@jkaye2012
Copy link
Collaborator

Yeah.. it's kinda goofy because redis_tests.jl is really the one you need to know that everything is working, but it's really an integration test and not a unit test.

@sbromberger
Copy link
Contributor Author

OK, I'm having anxiety about pubsub here, since SubscriptionMessage relies on a Reply type that I'm not using.

@jkaye2012
Copy link
Collaborator

That reply was being used for the old parsing. If I'm not mistaken, subscription only uses the actual result, so you should be able to just pass the result of your new parsing into SubscriptionMessage and everything should be fine.

The way it works is that the subscription sends an array response to the client. Your parsing will turn that into an array of strings, which the SubscriptionMessage will parse for use by the frontend.

@sbromberger
Copy link
Contributor Author

function SubscriptionMessage(reply)
        notification = reply.response

The new parser just returns an int, string, or array depending on the result of the command. There's no structure with a response attribute.

@jkaye2012
Copy link
Collaborator

Yeah, so you can remove the notification = reply.response and just use reply directly (which will be an array - the same that reply.response used to be)

@sbromberger
Copy link
Contributor Author

Ah, I got it. pubsub is always an array, with the first element being the notification type. OK. stand by...

@sbromberger
Copy link
Contributor Author

I kept this commit separate (unsquashed).

@sbromberger
Copy link
Contributor Author

tests not working: specifically,

@test x == ["hello, world!"]

@jkaye2012
Copy link
Collaborator

@sbromberger
Copy link
Contributor Author

Gah, of course. (it's my code; I should've caught that. Sorry!)

tests run now, though there are deprecation warnings, and I had a quick bugfix for an error in the script.

ETA: This bug should really be fixed by importing Base.keys.

@jkaye2012
Copy link
Collaborator

Let's fix those in another commit. For now, this looks good on v0.3 and v0.4 so I'll go ahead and merge it once the build passes.

@sbromberger
Copy link
Contributor Author

Just to be clear: I fixed the test script (by changing keys to Redis.keys) in this PR. I'll follow up on merge with a "real" fix.

jkaye2012 added a commit that referenced this pull request Jun 22, 2015
@jkaye2012 jkaye2012 merged commit e1409e0 into JuliaDatabases:master Jun 22, 2015
@sbromberger
Copy link
Contributor Author

Thanks. Stand by for the fix for testing script.

@sbromberger
Copy link
Contributor Author

See #11. BTW, thanks so much for your prompt review/feedback on this flurry of changes. :)

@sbromberger sbromberger deleted the newparser branch June 22, 2015 16:32
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