Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core][android]Decouple offline storage vacuum and the deleteRegion API #15899

Merged
merged 6 commits into from
Nov 12, 2019

Conversation

pozdnyakov
Copy link
Contributor

@pozdnyakov pozdnyakov added the Core The cross-platform C++ core, aka mbgl label Nov 8, 2019
@pozdnyakov pozdnyakov self-assigned this Nov 8, 2019
@pozdnyakov pozdnyakov changed the title Decouple offline storage vacuum and the deleteRegion API [core][android]Decouple offline storage vacuum and the deleteRegion API Nov 8, 2019
@pozdnyakov pozdnyakov added the Android Mapbox Maps SDK for Android label Nov 8, 2019
@pozdnyakov pozdnyakov force-pushed the mikhail_offline_storage_pack branch 2 times, most recently from 3858797 to 5587da4 Compare November 8, 2019 15:57
@pozdnyakov
Copy link
Contributor Author

@LukasPaczos @tobrun could you pls 👀 at the android-related changes, especially OfflineRegion.deleteAndSkipPackDatabase API. Is this API shape quite appropriate for Android, would it be better to just add a flag to the existing OfflineRegion.delete() method (and thus save some binary size)?

* After this operation is complete, the database file does not shrink.
* Database file packing can be done later with `packDatabase()`.
*
* This method is useful optimization e.g. when several regions should be deleted in a row.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: is a useful

@@ -82,9 +82,9 @@ class DefaultFileSource::Impl {
}
}

void deleteRegion(OfflineRegion&& region, std::function<void (std::exception_ptr)> callback) {
void deleteRegion(OfflineRegion&& region, bool skipPack, std::function<void(std::exception_ptr)> callback) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just don't like the fact this is a double negative.

false here means doing pack. What about just doPack or pack?

Copy link
Contributor

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

@pozdnyakov I think that adding a separate method is fine 👍

@@ -429,6 +429,53 @@ public void run() {
}
}

/**
* Same as the method above but skipping database file packing for performance reasons.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you link the method instead with {@link com.mapbox.mapboxsdk.offline.OfflineRegion#delete(OfflineRegion.OfflineRegionDeleteCallback)}?

/**
* Same as the method above but skipping database file packing for performance reasons.
* <p>
* This method is useful optimization e.g. when several regions should be deleted in a row.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to highlight here that the database file size will not shrink and you need to call packDatabase to do it later (and link the method like above).

@pozdnyakov pozdnyakov force-pushed the mikhail_offline_storage_pack branch from a60333a to d6a194c Compare November 12, 2019 10:07
@pozdnyakov pozdnyakov marked this pull request as ready for review November 12, 2019 10:07
@pozdnyakov pozdnyakov force-pushed the mikhail_offline_storage_pack branch from d6a194c to 2318841 Compare November 12, 2019 10:11
@pozdnyakov
Copy link
Contributor Author

@LukasPaczos @tmpsantos Thanks for your comments! Fixed now in the latest patch set, PTAL.

Copy link
Contributor

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

LGTM

- introduce `OfflineDatabase::pack()` standing for incremental vacuum
- make pack optional at offline region deletion
- update `OfflineDatabase.DeleteRegion` test accordingly to the items above
@pozdnyakov pozdnyakov force-pushed the mikhail_offline_storage_pack branch from 2318841 to e9940b8 Compare November 12, 2019 13:47
*
* This method is a useful optimization e.g. when several regions should be deleted in a row.
*/
void deleteOfflineRegionSkipPackDatabase(OfflineRegion&&, std::function<void(std::exception_ptr)>);
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch!

@pozdnyakov pozdnyakov force-pushed the mikhail_offline_storage_pack branch from e9940b8 to 13ed8a8 Compare November 12, 2019 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants