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

GridFS 2015 #100

Closed
wants to merge 34 commits into from
Closed

GridFS 2015 #100

wants to merge 34 commits into from

Conversation

rozza
Copy link
Owner

@rozza rozza commented Jul 30, 2015

Had to update codenarc as it couldn't parse the GridFS Smoke test.
As the yml tests are being refactored I paused work on that until they have been updated.

Review on Reviewable

@@ -191,4 +191,19 @@
*/
void createCollection(String collectionName, CreateCollectionOptions createCollectionOptions);

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think that MongoDatabase should be a factory for GridFSBucket instances. GridFS is an application on top of MongoDB, and therefore GridFSBucket should depend on MongoDatabase, not the other way around.

The advantage of this approach is that we don't have to expose a concrete implementation of GridFSBucket, but I still think it's a mistake.

How about

public class GridFSBuckets {
     public static GridFSBucket create(MongoDatabase);
}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nice - that also means I can move all the code under com.mongodb.client.gridfs

* @return the GridFS find iterable interface
* @mongodb.driver.manual tutorial/query-documents/ Find
*/
GridFSFindIterable find();
Copy link

Choose a reason for hiding this comment

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

In the CRUD spec we specifically decided that filters are mandatory.

Why this overload here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is inline with MongoCollection. A {} filter will be used underneath.

Done.

Copy link

Choose a reason for hiding this comment

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

So MongoCollection doesn't follow the CRUD spec?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It follows a version of it - when it was allowed ;)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Perhaps its more appropriate to say it is a superset of the CRUD spec.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done. (no action as is consistent with what we have).

if (fileInfo == null) {
throw new MongoGridFSException(format("No file found with the id: %s", id));
}
return new GridFSDownloadStreamImpl(fileInfo, chunksCollection);
Copy link

Choose a reason for hiding this comment

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

Does the constructor open the stream? (If so, is it a good idea to throw exceptions from constructors?)

Or do we need to call open on the stream before returning it?

Copy link
Owner Author

Choose a reason for hiding this comment

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

There is no stream is opened as such - this just initiates a class that extends the abstract InputStream class.

Copy link

Choose a reason for hiding this comment

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

So who opens the Stream?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no open method on Java streams. They are implicitly open on construction.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

@rozza rozza mentioned this pull request Aug 7, 2015
@rozza
Copy link
Owner Author

rozza commented Aug 7, 2015

@jyemin updated based on comments, also merged in the docs.

Regarding the abort() clean ups - this can be done with JAVA-1920 - I've copied in your comment to the ticket, so the context isn't lost.

@rozza rozza mentioned this pull request Aug 25, 2015
@jyemin
Copy link
Collaborator

jyemin commented Aug 31, 2015

This got a bit long and sat for a while due to my absence, but I don't see any more open issues. If you can confirm that, then LGTM.

if (buffer != null) {
chunkToCheck += 1;
}
Document chunk = getChunk(chunkToCheck);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this bit of code (lines 87 - 90) while reviewing #109. Can you explain the intention?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, at EOF we must validate there are no extra chunks OR that if there is an extra chunk it is empty. Prior to the change we didnt check but that was in breach of the spec.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Acknowledged

@rozza
Copy link
Owner Author

rozza commented Sep 1, 2015

Rebased, Squashed and merged

@rozza rozza closed this Sep 1, 2015
@rozza rozza deleted the j1713 branch September 1, 2015 15:49
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.

4 participants