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

JNI interface to opening ZIM archives (including embedded ones) by fd #429

Merged
merged 10 commits into from
Feb 26, 2021

Conversation

veloman-yunkan
Copy link
Collaborator

@veloman-yunkan veloman-yunkan commented Nov 29, 2020

Will fix #423

This PR exposes in the libkiwix java wrapper the functionality introduced by openzim/libzim#449.

The changes were tested in native_mixed build mode via the src/wrapper/java/org/kiwix/testing/compile_and_run_test.sh script. Achieving successful compilation in that mode required some tweaks. In particular,

  • (cd BUILD_native_mixed/INSTALL/; ln -s ../../BUILD_native_static/INSTALL/include)
  • (cd BUILD_native_mixed/INSTALL/; meson configure -Dwrapper=java)
  • The fatal error: jni.h: No such file or directory compilation error was worked around as follows (I realize that it is just a hack but it worked):
cp -s /usr/lib/jvm/java-11-openjdk-amd64/include/jni.h BUILD_native_mixed/INSTALL/include
cp -s /usr/lib/jvm/java-11-openjdk-amd64/include/linux/jni_md.h BUILD_native_mixed/INSTALL/include

Java unit tests were run as follows:

cd SOURCE/kiwix-lib
src/wrapper/java/org/kiwix/testing/compile_and_run_test.sh ../../BUILD_native_mixed/kiwix-lib/src/wrapper/java/kiwixlib.jar ../../BUILD_native_mixed/kiwix-lib/src

All changes in c++ code are covered via the java unit tests which are not run by the CI, hence the failure of the codecov/patch check.

Base automatically changed from libzim_next to master December 3, 2020 08:11
@veloman-yunkan veloman-yunkan force-pushed the open_zimfile_by_fd branch 2 times, most recently from d96433c to e1736b0 Compare December 5, 2020 20:25
@stale
Copy link

stale bot commented Dec 20, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label Dec 20, 2020
@mhutti1
Copy link
Contributor

mhutti1 commented Jan 14, 2021

This looks like it is working for me on the Android side. Is it ready to merge and publish?

@stale stale bot removed the stale label Jan 14, 2021
@kelson42
Copy link
Collaborator

@veloman-yunkan Can we merge the two PRs in libzim and libkiwix soon? Before libzim 7.0.0 release?

@veloman-yunkan
Copy link
Collaborator Author

@veloman-yunkan Can we merge the two PRs in libzim and libkiwix soon? Before libzim 7.0.0 release?

Yes. I will submit both PRs for review over the weekend.

@stale
Copy link

stale bot commented Jan 23, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label Jan 23, 2021
@kelson42
Copy link
Collaborator

kelson42 commented Feb 3, 2021

@veloman-yunkan Do you have still a lot to do on this PR (now that the libzim sibling PR has been merged)?

@stale stale bot removed the stale label Feb 3, 2021
@veloman-yunkan
Copy link
Collaborator Author

@veloman-yunkan Do you have still a lot to do on this PR (now that the libzim sibling PR has been merged)?

I don't think so

@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #429 (839fc10) into master (971374e) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #429      +/-   ##
==========================================
- Coverage   59.73%   59.62%   -0.12%     
==========================================
  Files          50       50              
  Lines        3410     3418       +8     
  Branches     1732     1736       +4     
==========================================
+ Hits         2037     2038       +1     
- Misses       1370     1377       +7     
  Partials        3        3              
Impacted Files Coverage Δ
include/entry.h 100.00% <ø> (ø)
include/reader.h 100.00% <ø> (ø)
src/reader.cpp 47.01% <0.00%> (-1.36%) ⬇️
src/tools/stringTools.cpp 61.65% <0.00%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 971374e...839fc10. Read the comment docs.

@kelson42
Copy link
Collaborator

kelson42 commented Feb 5, 2021

@veloman-yunkan meson.build needs to be updated to require libzim7.0.0+

@veloman-yunkan veloman-yunkan force-pushed the open_zimfile_by_fd branch 3 times, most recently from 0974192 to fdb4e9c Compare February 7, 2021 11:15
@veloman-yunkan veloman-yunkan changed the title [WIP] Open zimfile by fd JNI interface to opening ZIM archives (including embedded ones) by fd Feb 7, 2021
@veloman-yunkan veloman-yunkan marked this pull request as ready for review February 7, 2021 11:39
@veloman-yunkan
Copy link
Collaborator Author

@veloman-yunkan meson.build needs to be updated to require libzim7.0.0+

@kelson42 Done, but we better bring it into master via a separate PR.

@kelson42
Copy link
Collaborator

kelson42 commented Feb 7, 2021

@veloman-yunkan Thx, up to you, you might be right. Fell free to open a new PR. Just wanted that it does not get forgotten.

@veloman-yunkan
Copy link
Collaborator Author

@veloman-yunkan Thx, up to you, you might be right. Fell free to open a new PR. Just wanted that it does not get forgotten.

@kelson42 Version bump moved into a separate PR #452

The kiwixlib java wrapper unit test can be run manually via the
src/wrapper/java/org/kiwix/testing/compile_test.sh script.

The test ZIM files in src/wrapper/java/org/kiwix/testing were created
using the create_test_zimfiles. They must be updated/re-generated and
committed in git whenever their source data or the create_test_zimfiles
script changes. Note: small.zim.embedded is not used at this point, it
was created for testing the enhancement coming in a few commits.
@kelson42
Copy link
Collaborator

We have to bump to a major release name. I have rebased on origin/master.

@kelson42
Copy link
Collaborator

@mgautierfr We are expecting your review here to carry on.

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

We are good.

As we will merge this before #446, we must not remove the srand(time(nullptr));. But we need to remove it in #446 (which was missing).

{

/* initialize random seed: */
srand(time(nullptr));
Copy link
Member

Choose a reason for hiding this comment

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

Now that we implement random in libzim (openzim/libzim#476) this may be not necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see some inconsistency here. #446 doesn't drop the call to srand() in the other (pre-existing) constructor of kiwix::Reader. If that was an omission, then #446 can be amended for all three constructors of kiwix::Reader. Otherwise, if one constructor of kiwix::Reader contains that code, the others should do the same.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, see my global comment in the PR. We should remove it in #446.

@mgautierfr
Copy link
Member

We have to bump to a major release name

Yes, it is a pity that a change in the wrapper (Pair->DirectAccessInformation) force us to dump the major version of the whole kiwix-lib but we have to.
(Moving the wrapper in a separated repository as describe in #430 would help here)

@kelson42
Copy link
Collaborator

I guess we could merge that one now?

@veloman-yunkan
Copy link
Collaborator Author

I guess we could merge that one now?

In fact, I was wondering why it wasn't merged

@kelson42 kelson42 merged commit d3f2e08 into master Feb 26, 2021
@kelson42 kelson42 deleted the open_zimfile_by_fd branch February 26, 2021 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open ZIM file by filehandler
4 participants