-
Notifications
You must be signed in to change notification settings - Fork 626
Add Ml shared preferences for custom model storage #2104
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
Conversation
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (b0e24228) is created by Prow via merging commits: 844ff28 33eed38. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (b0e24228) is created by Prow via merging commits: 844ff28 33eed38. |
/retest |
1 similar comment
/retest |
*/ | ||
public CustomModel( | ||
@NonNull String name, long downloadId, long fileSize, @NonNull String modelHash) { | ||
this.modelHash = modelHash; |
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.
You could call the other constructor from here and assignments centralized in a single method.
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.
done.
@@ -76,18 +118,31 @@ public long getDownloadId() { | |||
return downloadId; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { |
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.
Override hashCode when overriding equals (Item 11 in Effective Java)
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.
thanks - added.
* model is present - this returns the details of that model, including local file path. If an | ||
* update of an existing model is in progress, the local model plus the download id for the new | ||
* upload is returned. To get only details related to the downloading model use | ||
* getDownloadingCustomModelDetails. If this is the initial download of a local file - the |
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.
* getDownloadingCustomModelDetails. If this is the initial download of a local file - the | |
* {@link #getDownloadingCustomModelDetails}. If this is the initial download of a local file - the |
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.
done
private static final CustomModel CUSTOM_MODEL_DOWNLOADING = | ||
new CustomModel(MODEL_NAME, 986, 100, MODEL_HASH); | ||
|
||
// private static final FirebaseApp FIREBASE_APP = FirebaseApp.initializeApp( |
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.
Can this code be removed?
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.
done.
String.format(LOCAL_MODEL_FILE_PATH_PATTERN, persistenceKey, modelName), filePath) | ||
.apply(); | ||
|
||
clearDownloadingModelDetails(customModel.getName()); |
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.
Would it be useful to do the clearing as part of the change above? If yes, then you can pass the editor to clearDownloadingModelDetails
and use it to add the remove statements in a single apply()
call.
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.
great idea.
.putLong( | ||
String.format(DOWNLOAD_BEGIN_TIME_MS_PATTERN, persistenceKey, modelName), | ||
SystemClock.elapsedRealtime()) | ||
.apply(); |
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.
apply()
only alters the in-memory contents of the SharedPreferences, and eventually writes to disk, which may fail silently, unlike commit()
that's synchronous. Just want to double check that this is an acceptable situation in this case.
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.
changed to commit
No description provided.