Core: Add setter for firstRowId in V4 metadata#16849
Conversation
|
Currently, there is no mechanism to set |
| } | ||
|
|
||
| void setFirstRowId(Long newFirstRowId) { | ||
| Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null"); |
There was a problem hiding this comment.
Why not just make the parameter long since it's required anyway?
There was a problem hiding this comment.
+1 to make the parameter to long.
There was a problem hiding this comment.
Good point! done
|
|
||
| void setFirstRowId(Long newFirstRowId) { | ||
| Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null"); | ||
| Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative"); |
There was a problem hiding this comment.
| Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative"); | |
| Preconditions.checkArgument( | |
| newFirstRowId >= 0, "Invalid first row ID: %s (must be >= 0)", newFirstRowId); |
| } | ||
|
|
||
| void setFirstRowId(Long newFirstRowId) { | ||
| Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null"); |
There was a problem hiding this comment.
+1 to make the parameter to long.
| } | ||
|
|
||
| @Test | ||
| public void testSettingFirstRowId() { |
There was a problem hiding this comment.
How about adding a test case for setFirstRowId(0L) to demonstrate the boundary of the >= 0 check?
There was a problem hiding this comment.
I changed one of the tests to use zero for input. Thx
fe964f0 to
a0b0ddd
Compare
gaborkaszab
left a comment
There was a problem hiding this comment.
Thanks for taking a look! I addressed all the comments. Additionally, there are 2 extra modifications I figured would make sense:
- Not allow to set first row id for ADDED entries. I think for these null is the desired value
- I also added a setter method to
TrackedFileStructfor convenience. With this the user doesn't have to be aware of the actual representation being inTrackingand can simply invokeTrackedFileStruct.setFirstRowId()without knowing how it is represented internally.
Let me know what you think!
| } | ||
|
|
||
| void setFirstRowId(Long newFirstRowId) { | ||
| Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null"); |
There was a problem hiding this comment.
Good point! done
|
|
||
| void setFirstRowId(Long newFirstRowId) { | ||
| Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null"); | ||
| Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative"); |
| } | ||
|
|
||
| @Test | ||
| public void testSettingFirstRowId() { |
There was a problem hiding this comment.
I changed one of the tests to use zero for input. Thx
a0b0ddd to
ab3b98a
Compare
No description provided.