-
Notifications
You must be signed in to change notification settings - Fork 3
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
partial parsing #28
partial parsing #28
Conversation
@@ -147,7 +147,25 @@ end | |||
writer[] = x | |||
close(writer) | |||
reader = BSONReader(buf) | |||
reader[typeof(x)] == x | |||
@test reader[typeof(x)] == x |
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.
missing @test
?
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.
Looks like it
Codecov Report
@@ Coverage Diff @@
## master #28 +/- ##
==========================================
- Coverage 89.88% 88.84% -1.05%
==========================================
Files 13 13
Lines 811 753 -58
==========================================
- Hits 729 669 -60
- Misses 82 84 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
julia> struct S{T}
header::Int
payload::T
end
testf(reader) = reader[S{typeof(reader)}].header
buf = UInt8[]
writer = BSONWriter(buf)
writer[] = (; header = 1, payload = 45)
close(writer)
reader = BSONReader(buf)
@benchmark testf($reader)
BenchmarkTools.Trial: 10000 samples with 997 evaluations.
Range (min … max): 20.186 ns … 46.640 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 20.270 ns ┊ GC (median): 0.00%
Time (mean ± σ): 20.492 ns ± 0.879 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▄█▇▇▅▃▄▁ ▁▃▁▂▁ ▁ ▂▁ ▁▁ ▂
████████▅██▅██▄█████▇██▅▇▆▄▇▇▅▆█▆██▆██▇██▆█▇▅▆▅▄▄▅▃▆▅▁▃▄▁▁▃ █
20.2 ns Histogram: log(frequency) by time 22.7 ns <
Memory estimate: 0 bytes, allocs estimate: 0. |
Hi @ancapdev, |
@@ -147,7 +147,25 @@ end | |||
writer[] = x | |||
close(writer) | |||
reader = BSONReader(buf) | |||
reader[typeof(x)] == x | |||
@test reader[typeof(x)] == x |
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.
Looks like it
Been a little snowed under, but this looks good to me, just a tiny formatting change |
I'd like to be able to partially parse a document.
I would need to read a header before knowing the type I should use to parse the payload.
Partial parsing would allow me to avoid type instabillity.