Skip to content

Conversation

@hachikuji
Copy link
Contributor

Adds support for range queries over GRPC. We expose a new method Rs3Client.range which returns a blocking iterator. Internally in the iterator implementation, transient errors are caught and the operation is retried using the same exponential backoff we use for other operations.

}
}

interface Mapper<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe call this a Visitor instead? This looks like the classic visitor pattern to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's a visitor pattern, but I'm using it as a poor man's version of pattern matching to implement a map function. I thought using the Visitor name made its usage feel a little too vague. I don't feel strongly about it though..

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you - I felt the opposite 😛 . I was a bit confused at first and had to look at how it was used but it would've felt obvious if it was named Visitor. But that could just be me. We had the Visitor pattern drilled into us working on ksql syntax trees 😄

Copy link
Contributor

@rodesai rodesai left a comment

Choose a reason for hiding this comment

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

This looks great! My only question is about the queue implementation - why not just use the java BlockingQueue rather than rolling our own?

Copy link
Contributor

@rodesai rodesai left a comment

Choose a reason for hiding this comment

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

LGTM assuming the answer to my question about poll/peek is yes


public class GrpcMessageQueue<T> {
private final BlockingQueue<T> queue = new LinkedBlockingQueue<>();
private final AtomicReference<T> next = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be atomic? you can't do concurrent polls/peeks since taking the next item from the queue and setting next need to be synchronized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair enough.

}
}

T poll() {
Copy link
Contributor

Choose a reason for hiding this comment

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

multiple calls to poll/peek won't ever be done concurrently right?

@hachikuji hachikuji merged commit f410178 into main Apr 4, 2025
1 check passed
@hachikuji hachikuji deleted the rs3-range-query-support branch April 4, 2025 23:11
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.

3 participants