-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Expanding time resolution into millisecs #2679
Conversation
@@ -111,7 +111,6 @@ static jlong getDistinctViewWithHandover | |||
switch (table->get_column_type(S(columnIndex))) { | |||
case type_Bool: | |||
case type_Int: | |||
case type_DateTime: |
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.
Does timestamp not support distinct? That's very breaking.
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.
I had to disable it as I got seg. faults. It has been fixed in core.
try { | ||
TableView* pTableView = new TableView( pTable->get_sorted_view(S(columnIndex), ascending != 0 ? true : false) ); | ||
return reinterpret_cast<jlong>(pTableView); | ||
} CATCH_STD() | ||
default: | ||
ThrowException(env, IllegalArgument, "Sort is currently only supported on integer, boolean, double, float, String, and Date columns."); | ||
ThrowException(env, IllegalArgument, "Invalid type - Only String, Date, boolean, short, int, long and their boxed variants are supported."); |
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.
boolean, byte
, short, int, long
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.
Indeed so
@@ -654,6 +655,7 @@ extern jmethodID java_lang_float_init; | |||
extern jclass java_lang_double; | |||
extern jmethodID java_lang_double_init; | |||
|
|||
|
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.
Remove newline
Done with a quick pass. Generally looks great. Like the internal renaming from Date to Timestamp. I am a bit concerned that some dividing by 1000 hasn't been caught by unit tests, which indicate our test coverage could be better? |
@cmelchior We should definitely investigate our coverage to see if important methods are not tested. But in the case of the |
Removing unused setters / getters seems like a good idea. We really shouldn't have unused code. Probably in another PR though. |
@@ -1523,42 +1521,44 @@ JNIEXPORT jdouble JNICALL Java_io_realm_internal_TableQuery_nativeAverageDouble( | |||
|
|||
|
|||
// date aggregates | |||
|
|||
JNIEXPORT jobject JNICALL Java_io_realm_internal_TableQuery_nativeMaximumDate( | |||
// FIXME: This is a rough workaround while waiting for https://github.com/realm/realm-core/issues/1720 to be solved |
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.
the issue you're pointing to is closed, are we still waiting for Core?
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.
I'll update the comment to be a link to realm/realm-core#1745
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.
Please update the link in the comment ☝️ 😄
@@ -201,7 +201,7 @@ task downloadCore(group: 'build setup', description: 'Download the latest versio | |||
throw new GradleException("Invalid checksum for file '" + | |||
"${project.coreArchiveFile.getName()}'. Expected " + | |||
"${project.coreSha256Hash.toLowerCase()} but got " + | |||
"${calculatedHash.toLowerCase()}."); | |||
"${calculatedHash.toLowerCase()}."); |
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.
Wrong indent?
@@ -254,6 +259,9 @@ JNIEXPORT void JNICALL Java_io_realm_internal_Table_nativeConvertColumnToNullabl | |||
case type_Table: | |||
// checked previously | |||
break; | |||
case type_OldDateTime: | |||
// not used |
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.
Throw exception instead? In case someone accidentally uses it?
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.
It should not be possible. All old Realm files are converted, and new Realm will only use Timestamp
.
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.
Then throwing an exception should be safe :) IMO I would much rather we threw exceptions in these cases as it will catch anyone accidentally using them in the future.
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.
If it's not possible - it should assert.
Done with review. Mostly minor stuff, but there seems to be a bunch of FIXME's around |
precision of Date fields.
@@ -217,7 +217,7 @@ JNIEXPORT jlong JNICALL Java_io_realm_internal_UncheckedRow_nativeGetLinkView | |||
if (!ROW_VALID(env, ROW(nativeRowPtr))) | |||
return 0; | |||
|
|||
LinkView* link_view_ptr = LangBindHelper::get_linklist_ptr( *ROW( nativeRowPtr ), S( columnIndex) ); | |||
LinkViewRef* link_view_ptr = const_cast<LinkViewRef*>(&(LangBindHelper::get_linklist_ptr(*ROW(nativeRowPtr), S(columnIndex)))); | |||
return reinterpret_cast<jlong>(link_view_ptr); |
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.
I don't understand how this ends up as a string and there's a lot of casting here. Unless we have a string buried as some kind of opaque type, this looks like a bug, which predates the change to Timestamp.
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.
I am not quite sure what you mean: no strings are involved there. With core 0.100.0, LangBindHelper::get_linklist_ptr()
has been changed to return a const LinkViewRef
(a shared_ptr<LinkView*>
. As we cannot use a shared_ptr
in Java, I have to store a pointer to shared_ptr
(returned as a jlong
). And I need to get rid of the constness too.
That gives us a double indirection which you can see in all the LinkView
methods.
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.
Sorry, scratch my comment - I was misinterpreting the github diff as the return type being a jstring - hadn't noticed the line number jump that it was a different method!
👍 preferably with those exception strings fixed to restore the word sorting |
👍 , but please create an issue with the overflow problem with dates coming from other platforms. As a minimum we need to document it somewhere instead of hiding it in a FIXME in the code. EDIT: This isn't addressed? #2679 (comment) |
@cmelchior An exception is thrown (#2679 (comment)) And I have created #2722. |
👍 |
Closes #833
Current status: ready to be merged