Skip to content
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

Merged
merged 12 commits into from
May 3, 2016
Merged

Conversation

kneth
Copy link
Contributor

@kneth kneth commented Apr 26, 2016

Closes #833

Current status: ready to be merged

@kneth kneth self-assigned this Apr 26, 2016
@@ -111,7 +111,6 @@ static jlong getDistinctViewWithHandover
switch (table->get_column_type(S(columnIndex))) {
case type_Bool:
case type_Int:
case type_DateTime:
Copy link
Contributor

@bmunkholm bmunkholm Apr 26, 2016

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.

Copy link
Contributor Author

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.");
Copy link
Contributor

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

Copy link
Contributor Author

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;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline

@cmelchior
Copy link
Contributor

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?

@kneth
Copy link
Contributor Author

kneth commented Apr 28, 2016

@cmelchior We should definitely investigate our coverage to see if important methods are not tested. But in the case of the TableView setters, the conclusion might be that we should remove them.

@cmelchior
Copy link
Contributor

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
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor

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()}.");
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@cmelchior
Copy link
Contributor

Done with review. Mostly minor stuff, but there seems to be a bunch of FIXME's around find_all_date/find_first_date. I am not sure we even use those in the public API, so maybe something we should consider removing all together? Don't have to be in this PR though.

@@ -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);

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.

Copy link
Contributor Author

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.

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!

@AndyDentFree
Copy link

👍 preferably with those exception strings fixed to restore the word sorting

@cmelchior
Copy link
Contributor

cmelchior commented May 3, 2016

👍 , 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)

@kneth
Copy link
Contributor Author

kneth commented May 3, 2016

@cmelchior An exception is thrown (#2679 (comment))

And I have created #2722.

@cmelchior
Copy link
Contributor

👍

@kneth kneth merged commit fc23cfc into master May 3, 2016
@kneth kneth deleted the kg/switching-to-timestamp branch May 3, 2016 11:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants