Skip to content

Conversation

@shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented May 21, 2020

Multimedia Changes -

  1. Adds a lazy Resource property
  2. Better classify MissingMediaException using MissingMediaExceptionType

cross-request: dimagi/commcare-android#2243

}

public Vector<Resource> getLazyResources() {
// todo
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this todo for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, left it by mistake

Copy link
Contributor

@ShivamPokhriyal ShivamPokhriyal left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@ctsims ctsims left a comment

Choose a reason for hiding this comment

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

Hey. Biggest feedback (well, for a small issue) is that I think we should be manually making the lazy flag metadata a string with a fixed set of static values rather than a Boolean object (and potentially the real value as well, potentially. We don't get much from making the metadata a boolean but it adds a lot of risk


private String descriptor;
protected String descriptor;
private boolean lazy;
Copy link
Member

Choose a reason for hiding this comment

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

I think this means we're also going to need to bump the appdb database version in formplayer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, noted.

case META_INDEX_VERSION:
return version;
case META_INDEX_LAZY:
return lazy;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little surprised to see this works with a boolean, btw. My intuition is that we should hard code an explicit string value here, and convert it to/from boolean. We've started making soft assumptions elsewhere that all metadata values are strings, and I'm worried that implicit conversions.

}

public Vector<Resource> getLazyResources() {
return storage.getRecordsForValues(new String[]{Resource.META_INDEX_LAZY}, new Boolean[]{true});
Copy link
Member

Choose a reason for hiding this comment

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

do we use this now that we're mostly iterating on ID's? This feels a bit like a potential bomb call, it'll grab a LOT of records.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This still gets used by the MM verification task here to skip any lazy resources during MM verification. I profiled a simialr call which gets all resources in the table for cas which was taking .1 - .2 secs for around ~1600 resources so didn't think it as a big deal for the one time MM verfication task. I can make a similar optimization here where we just collect the uris for all lazy resources by looping over the resources one by one. Though do you think if it's worth to optimize that way ?

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, no need to optimize for .1 / .2 seconds.

* @return A Vector of Externalizable objects e, such that the fields specified are equal to the corresponding values provided.
*
*/
Vector<E> getRecordsForValues(String[] metaFieldNames, Object[] values);
Copy link
Member

Choose a reason for hiding this comment

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

Is this the same signature as the custom implementations in Android AND formplayer? Is good to finally have it committed in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah!


public Resource(int version, String id, Vector<ResourceLocation> locations, String descriptor) {
this(version, id, locations, descriptor, false);
this(version, id, locations, descriptor, "false");
Copy link
Member

Choose a reason for hiding this comment

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

Can we make these static accessors? Lots of risk of typos.

@shubham1g5 shubham1g5 requested a review from ctsims June 11, 2020 17:12
@shubham1g5 shubham1g5 merged commit 72014dc into master Jun 11, 2020
@shubham1g5 shubham1g5 deleted the multimediaChanges branch June 11, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants