-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add 1.1 binary reader support for decimals #757
Add 1.1 binary reader support for decimals #757
Conversation
src/lazy/binary/raw/v1_1/reader.rs
Outdated
// 0d3 | ||
0x61, 0x07, | ||
|
||
// -0 |
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.
// -0 | |
// -0d3 |
src/lazy/binary/raw/v1_1/reader.rs
Outdated
use crate::types::decimal::Decimal; | ||
|
||
#[rustfmt::skip] | ||
let data: Vec<u8> = vec![ |
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.
We should add additional test cases for op code 0xF7
and for over-padded exponents and coefficients. You can find a fairly complete set of test cases here and here, and I'd recommend using them rather than spending time coming up with your own.
Also, it would be nice if you could use #[rstest]
for a parameterized test here.
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.
Also, it would be nice if you could use #[rstest] for a parameterized test here.
I've been using the array-of-inputs approach a lot recently, largely because my IDE can't run #[rstest]
s natively. I wish the Rust test harness would let you programmatically define a test (for individual PASS/FAIL indications) or Intellij would support macro-generated tests. 🫤
src/lazy/binary/raw/v1_1/value.rs
Outdated
let coefficient = if coefficient_size > 0 { | ||
FixedInt::read( | ||
&value_bytes[exponent.size_in_bytes()..], | ||
coefficient_size, | ||
0, | ||
)? | ||
} else { | ||
0i64.into() | ||
}; |
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.
This makes me think that FixedInt::read
should return zero if the size is zero. This seems like something that could come up in other places, and rather than handle this condition everywhere, we should probably just move it to FixedInt::read
.
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.
Matt made this change in PR #762.
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 good. Please address Matt's unit test comment before merging.
src/lazy/binary/raw/v1_1/reader.rs
Outdated
use crate::types::decimal::Decimal; | ||
|
||
#[rustfmt::skip] | ||
let data: Vec<u8> = vec![ |
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.
Also, it would be nice if you could use #[rstest] for a parameterized test here.
I've been using the array-of-inputs approach a lot recently, largely because my IDE can't run #[rstest]
s natively. I wish the Rust test harness would let you programmatically define a test (for individual PASS/FAIL indications) or Intellij would support macro-generated tests. 🫤
src/lazy/binary/raw/v1_1/value.rs
Outdated
let coefficient = if coefficient_size > 0 { | ||
FixedInt::read( | ||
&value_bytes[exponent.size_in_bytes()..], | ||
coefficient_size, | ||
0, | ||
)? | ||
} else { | ||
0i64.into() | ||
}; |
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.
Matt made this change in PR #762.
1b4f4ed
to
6d55b88
Compare
f6ed2e4
to
14fa06a
Compare
Issue #, if available: #662
Description of changes:
Add support for decimals to the 1.1 binary raw reader.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.