Skip to content

Issue 265: Remove filterKeysByType step when getting data from redis #266

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 8 commits into from
Sep 11, 2020

Conversation

mayankasthana
Copy link
Contributor

#265

Instead of filtering keys by type beforehand, assume all keys are of the expected type and ignore exceptions later if we encounter a wrong type.

Instead of filtering keys by type beforehand, assume all keys
are of the expected type and handle exceptions later if we encounter
a wrong type.
@mayankasthana mayankasthana force-pushed the 265-remove-filter-by-key branch from 6f51d87 to bc4be3f Compare September 3, 2020 22:35
@mayankasthana mayankasthana changed the title [WIP] Issue 265: Remove filterKeysByType step when getting data from redis Issue 265: Remove filterKeysByType step when getting data from redis Sep 3, 2020
@gkorland gkorland requested a review from fe2s September 3, 2020 22:48
// Throw any other JedisDataException we encounter
case (_, e: JedisDataException) => throw e
// Throw any other Exception we encounter
case (_, e: Throwable) => throw e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fe2s changed this. Please review this change again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mayankasthana . Can we please also extract this parsing into the ParseUtils? I would keep this logic together in a single class, so it will easier to make any changes in future. Other than that it looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// Throw any other JedisDataException we encounter
case (_, e: JedisDataException) => throw e
// Throw any other Exception we encounter
case (_, e: Throwable) => throw e
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mayankasthana . Can we please also extract this parsing into the ParseUtils? I would keep this logic together in a single class, so it will easier to make any changes in future. Other than that it looks good.

@mayankasthana mayankasthana force-pushed the 265-remove-filter-by-key branch from 25311de to 01cc519 Compare September 9, 2020 20:41
val res = stringKeys.zip(response).iterator.asInstanceOf[Iterator[(String, String)]]

val res = nodeKeys.zip(response)
.view
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mayankasthana for the changes!
One minor question - what is the reason we need view here?

Copy link
Contributor Author

@mayankasthana mayankasthana Sep 10, 2020

Choose a reason for hiding this comment

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

We don't explicitly need it. We are doing two flatMap operations, so I think it is creating two full collections, and we don't really need the intermediate collection. I was trying to make it lazy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can we replace .view with .iterator and remove .iterator from the last line?

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 can do that.
But now that I think about it, I think I changed the semantics. Earlier we used to give out an Iterator of a strict collection and I changed it to become lazy. I think doing .force.iterator or .collect.iterator at the end is better, so that we evaluate the whole collection before giving out the Iterator. This way, we also throw any exceptions immediately and not need to wait for .next to be called by the caller.

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 just removed the view thing to not make things complicated.

@fe2s fe2s merged commit 7223a63 into RedisLabs:master Sep 11, 2020
@mayankasthana
Copy link
Contributor Author

Yay! Thanks @fe2s!

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