-
Notifications
You must be signed in to change notification settings - Fork 10
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
DOCSP-43072: GridFS #60
DOCSP-43072: GridFS #60
Conversation
✅ Deploy Preview for docs-c ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! Some suggestions and questions
source/write/gridfs.txt
Outdated
View the following diagram to see how GridFS splits the files when uploaded to | ||
a bucket: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S:
View the following diagram to see how GridFS splits the files when uploaded to | |
a bucket: | |
The following diagram shows how GridFS splits files when they are | |
uploaded to a bucket: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! nice work.
source/includes/write/gridfs.c
Outdated
bson_oid_t oid; | ||
bson_oid_init_from_string (&oid, "66fb1b8ea0f84a74ee099e71"); | ||
bson_value_t file_id; | ||
file_id.value_type = BSON_TYPE_OID; | ||
memcpy(&file_id.value.v_oid, &oid, sizeof(bson_oid_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to tech reviewer: this seems like an overly complicated way to pass a file ID, so let me know if there's a better way (same with the next example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be valid to omit the temporary oid
:
bson_oid_t oid; | |
bson_oid_init_from_string (&oid, "66fb1b8ea0f84a74ee099e71"); | |
bson_value_t file_id; | |
file_id.value_type = BSON_TYPE_OID; | |
memcpy(&file_id.value.v_oid, &oid, sizeof(bson_oid_t)); | |
bson_value_t file_id; | |
file_id.value_type = BSON_TYPE_OID; | |
bson_oid_init_from_string (&file_id.value.v_oid, "66fb1b8ea0f84a74ee099e71"); |
(Same suggestion on other occurrences.)
Hi @vector-of-bool, just bumping this last PR review for the C standardization epic! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with minor comments on example code.
source/includes/write/gridfs.c
Outdated
bson_oid_t oid; | ||
bson_oid_init_from_string (&oid, "66fb1b8ea0f84a74ee099e71"); | ||
bson_value_t file_id; | ||
file_id.value_type = BSON_TYPE_OID; | ||
memcpy(&file_id.value.v_oid, &oid, sizeof(bson_oid_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be valid to omit the temporary oid
:
bson_oid_t oid; | |
bson_oid_init_from_string (&oid, "66fb1b8ea0f84a74ee099e71"); | |
bson_value_t file_id; | |
file_id.value_type = BSON_TYPE_OID; | |
memcpy(&file_id.value.v_oid, &oid, sizeof(bson_oid_t)); | |
bson_value_t file_id; | |
file_id.value_type = BSON_TYPE_OID; | |
bson_oid_init_from_string (&file_id.value.v_oid, "66fb1b8ea0f84a74ee099e71"); |
(Same suggestion on other occurrences.)
source/includes/write/gridfs.c
Outdated
bson_t opts; | ||
bson_init(&opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer BSON_INITIALIZER
bson_t opts; | |
bson_init(&opts); | |
bson_t opts = BSON_INITIALIZER; |
source/includes/write/gridfs.c
Outdated
if (upload_stream == NULL) { | ||
fprintf (stderr, "Failed to create upload stream: %s\n", error.message); | ||
} | ||
const char *data = "Data to store"; | ||
mongoc_stream_write (upload_stream, data, strlen(data), -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Should not try to use the stream on failure.
if (upload_stream == NULL) { | |
fprintf (stderr, "Failed to create upload stream: %s\n", error.message); | |
} | |
const char *data = "Data to store"; | |
mongoc_stream_write (upload_stream, data, strlen(data), -1); | |
if (upload_stream == NULL) { | |
fprintf (stderr, "Failed to create upload stream: %s\n", error.message); | |
} else { | |
const char *data = "Data to store"; | |
mongoc_stream_write (upload_stream, data, strlen(data), -1); | |
} |
Or show the example aborting/goto fail
/etc.
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-43072
Staging - https://deploy-preview-60--docs-c.netlify.app/write/gridfs/
Self-Review Checklist