Skip to content

Conversation

@mgautierfr
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@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.

Few things to change.
Especially about the blob.

Comment on lines 435 to 437
cdef Blob blob = self.c_article.getData(<int> 0)
data = blob.data()[:blob.size()]
return data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you copying the content of the blob or creating a memory view ?
If you are copying the content, you shouldn't.
If you are creating a memory view, you must keep a copy of the blob somewhere to be sure the the content pointed by the blob (and so by the memoryview) is valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here the code is read to python to return it. What use case do you have in mind to avoid the copy?

self.zim_test_query = u"Einstein"

# Zim reader
self.zim_reader = ZimFileReader(self.zim_file_path)
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 line alone is not a problem. But it makes me think that it would be better to have a contextmanager for ZimFileReader:

with ZimFileReader.open(path) as zim_reader:
    ....

Copy link
Contributor

@jdcaballerov jdcaballerov Apr 28, 2020

Choose a reason for hiding this comment

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

What advantages or use case do you have in mind ? What to put in __enter__() and __exit__() ?

@mgautierfr mgautierfr force-pushed the reader branch 2 times, most recently from b6cc1fe to f9d850b Compare May 6, 2020 08:58
@mgautierfr mgautierfr merged commit 0df2e22 into master May 8, 2020
@mgautierfr mgautierfr deleted the reader branch May 8, 2020 14:48
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.

5 participants