Repository navigation
ARROW-2585: [C++] Add Decimal::FromBigEndian, which was formerly a static method in parquet-cpp/src/parquet/arrow/reader.cc - #2036
joshuastorck wants to merge 2 commits into
Conversation
pitrou
left a comment
There was a problem hiding this comment.
From an API point of view, there's a Decimal128 constructor from little-endian bytes that only takes a uint8_t* (without a length), and a static method factory from big-endian bytes that takes a pointer and a length. Shouldn't we have something more consistent?
There was a problem hiding this comment.
You shouldn't need std:: in front of int32_t.
There was a problem hiding this comment.
This is potentially doing an unaligned access, which is forbidden on some architectures (SPARC for example, perhaps others).
There was a problem hiding this comment.
Looks like for linux there's get_unaligned/put_unaligned. For MSVC, we could create a template function that creates a temporary struct and accesses a member.
There was a problem hiding this comment.
I don't think we need such complication. Just read the memory byte per byte. Or, if you really insist on doing a single int64_t read, use mempcy into an int64_t local variable. Most compilers will optimize that into an unaligned access if the platform allows for it.
There was a problem hiding this comment.
Resolved in latest version. Using memcpy at particular byte offset.
There was a problem hiding this comment.
Ideally you should also test non-trivial values (not one which only has only one bit set), and also negative values.
There was a problem hiding this comment.
Testing negative values and complements in the latest version.
Codecov Report
@@ Coverage Diff @@
## master #2036 +/- ##
==========================================
+ Coverage 86.28% 86.33% +0.04%
==========================================
Files 242 242
Lines 41041 41091 +50
==========================================
+ Hits 35412 35474 +62
+ Misses 5629 5617 -12
Continue to review full report at Codecov.
|
|
@joshuastorck, thanks for the test additions. What do you think about the API inconsistency? It would deserve fixing before doing it has a compatibility cost, IMO. |
|
Since we are using Status codes (I wish we were using exceptions) for errors and this function can return an error, I don't want the logic in the constructor because the only way to handle that error is to do what's being done in the constructor that takes a string, which is to log and abort. If we were using exceptions, I would advocate for the same approach, primarily because this is a primitive numeric type and users don't want to think about exceptions when they are using primitive numeric types. |
|
That makes sense. I think we can go with this, then. |
|
@joshuastorck, sorry, I forgot to mention: you should prefix this PR's title with the corresponding JIRA ticket number and category, like this: |
There was a problem hiding this comment.
By the way: since this helper is only used by FromBigEndian, it needn't be in the .h file. You can just make it a static non-member function.
…parquet-cpp/src/parquet/arrow/reader.cc
2001769 to
e970c87
Compare
|
@pitrou, I think I've resolved all of your concerns. Could you please merge? |
|
@joshuastorck I'll probably do it in a couple days. If there is any hurry, please tell me. |
|
It's not urgent, I just want to make sure that it makes it in so that I can
get the Travis tests working for this PR:
apache/parquet-cpp#462.
…On Fri, May 18, 2018 at 1:12 PM, Antoine Pitrou ***@***.***> wrote:
@joshuastorck <https://github.com/joshuastorck> I'll probably do it in a
couple days. If there is any hurry, please tell me.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2036 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA5SPYR2CJy4xdF58-k6iLBl0OWBjEXTks5tzwDtgaJpZM4T8qSW>
.
|
No description provided.