-
Notifications
You must be signed in to change notification settings - Fork 125
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
Debugging API: get size of a stream to read #503
Conversation
|
7f45229
to
cf573c5
Compare
private | ||
|
||
def read_scope(spec) | ||
raise RubyEventStore::ReservedInternalName if spec.stream.name.eql?(EventRepository::SERIALIZED_GLOBAL_STREAM_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a part of read_scope
, please move it back to read
@@ -81,6 +81,12 @@ def read(specification) | |||
@events.read(specification) | |||
end | |||
|
|||
def count(specification) | |||
raise ReservedInternalName if specification.stream.name.eql?(@stream_entries.stream_entries.class::SERIALIZED_GLOBAL_STREAM_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a part of count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should count
allow for reserved name used in stream specification? maybe this check should be in Specification
class (via SpecificationReader
where we know repository)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, if count
omits read
than it can check for reserved name (reminder that name will no longer be reserved after #312 materializes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should remove that check in #312 or after.
|
||
if specification.batched? | ||
reader = ->(offset, limit) do | ||
query_builder(query, offset: offset, limit: limit).to_ary | ||
end | ||
BatchEnumerator.new(specification.batch_size, limit || Float::INFINITY, reader).each | ||
BatchEnumerator.new(specification.batch_size, specification.limit, reader).each |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed change from a different commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope - just simplification.
Was:
limit = specification.limit if specification.limit?
and later as argument: limit || Float::INFINITY
but that's not needed because specification.limit
is Float::INFINITY
if limit has not been specified.
Please rebase with master and |
def count(specification) | ||
query = read_scope(specification) | ||
limit = specification.limit if specification.limit? | ||
query = query_builder(query, limit: limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpraglowski I would say just do query = query.take(limit) if specification.limit?
and skip query_builder
because it does some combining of association data and entity mapping that you don't need to get the count
…ecification build up to this point
bdee7fc
to
7d52c25
Compare
When you have read specification like:
you could get a size of result set by using new API method:
scope.count
before you read all data from the stream byscope.each { .... }
orscope.to_a
.