Skip to content

Commit 457b645

Browse files
committed
PHPC-165: Rename WriteBatch to BulkWrite
1 parent 4cf9536 commit 457b645

38 files changed

+296
-296
lines changed

bin/prep-release.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function get_files() {
8686
"src/libmongoc/src/mongoc/*.{c,h,def,defs}",
8787

8888
"tests/onnect/*.{phpt}",
89-
"tests/batch/*.{phpt}",
89+
"tests/bulk/*.{phpt}",
9090
"tests/bson/*.{phpt}",
9191
"tests/functional/*.{phpt}",
9292
"tests/generic/*.{phpt}",

config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ if test "$PHONGO" != "no"; then
180180
src/MongoDB/ReadPreference.c \
181181
src/MongoDB/Result.c \
182182
src/MongoDB/Server.c \
183-
src/MongoDB/WriteBatch.c \
183+
src/MongoDB/BulkWrite.c \
184184
src/MongoDB/WriteConcern.c \
185185
src/MongoDB/WriteConcernError.c \
186186
src/MongoDB/WriteError.c \

docs/batch.md renamed to docs/bulk.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ $jonpall = array(
1919
"citizen" => "Iceland",
2020
);
2121

22-
/* Ordered batch is executed in the same order as we add the operations to it.
22+
/* Ordered bulk is executed in the same order as we add the operations to it.
2323
* If operation fails the execution stops and no further operations executed.
24-
* For unordered batch, the operations can be executed in any order by the database
24+
* For unordered bulk, the operations can be executed in any order by the database
2525
* in an attempt to optimize its workload. An operation failure will not stop
2626
* the exection of the rest of the operations.
2727
* Default: true
2828
*/
2929
$ordered = true;
3030

31-
$batch = new MongoDB\Driver\WriteBatch($ordered);
31+
$bulk = new MongoDB\Driver\BulkWrite($ordered);
3232

3333
?>
3434
```
@@ -41,9 +41,9 @@ $batch = new MongoDB\Driver\WriteBatch($ordered);
4141
/* Argument#1 The document (array/object) to insert.
4242
* Returns the generated BSON\ObjectID if no _id was provided
4343
*/
44-
$hannes_id = $batch->insert($hannes);
45-
$hayley_id = $batch->insert($hayley);
46-
$jonpall_id = $batch->insert($jonpall);
44+
$hannes_id = $bulk->insert($hannes);
45+
$hayley_id = $bulk->insert($hayley);
46+
$jonpall_id = $bulk->insert($jonpall);
4747

4848
?>
4949
```
@@ -64,17 +64,17 @@ $jonpall_id = $batch->insert($jonpall);
6464
* true: Insert new document matching the criteria
6565
* false: Do not insert new document if no matches are found
6666
*/
67-
$batch->update(
67+
$bulk->update(
6868
array("_id" => $hayley_id),
6969
array('$set' => array("citizen" => "Iceland")),
7070
array("limit" => 1, "upsert" => false)
7171
);
72-
$batch->update(
72+
$bulk->update(
7373
array("citizen" => "Iceland"),
7474
array('$set' => array("viking" => true)),
7575
array("limit" => 0, "upsert" => false)
7676
);
77-
$batch->update(
77+
$bulk->update(
7878
array("name" => "Chuck Norris"),
7979
array('$set' => array("viking" => false)),
8080
array("limit" => 1, "upsert" => true)
@@ -95,7 +95,7 @@ $batch->update(
9595
* 0: Delete all matching documents
9696
* 1: Only delete the first matching document
9797
*/
98-
$batch->delete(array("_id" => $jonpall_id), array("limit" => 1));
98+
$bulk->delete(array("_id" => $jonpall_id), array("limit" => 1));
9999

100100
?>
101101
```
@@ -106,7 +106,7 @@ $batch->delete(array("_id" => $jonpall_id), array("limit" => 1));
106106
<?php
107107
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
108108
$wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY);
109-
$result = $manager->executeWriteBatch("db.collection", $batch, $wc);
109+
$result = $manager->executeBulkWrite("db.collection", $bulk, $wc);
110110

111111
printf("insertedCount: %d\n", $result->getInsertedCount());
112112
printf("matchedCount: %d\n", $result->getMatchedCount());
@@ -122,7 +122,7 @@ $query = new MongoDB\Driver\Query(array("viking" => false));
122122
$cursor = $manager->executeQuery("db.collection", $query);
123123
/* Note that var_dump()ing the $cursor will print out all sorts of debug information
124124
* about the cursor, such as ReadPreferences used, the query executed, namespace,
125-
* query flags, and the current batch information */
125+
* query flags, and the current bulk information */
126126
var_dump(iterator_to_array($cursor));
127127

128128
?>

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ theme: spacelab
44
pages:
55
- [index.md, Home]
66
- [crud.md, "CRUD", "Basic"]
7-
- [batch.md, "CRUD", "Batches"]
7+
- [bulk.md, "CRUD", "Bulks"]
88
- [commands.md, Commands]
99
- [ods.md, Object Document Serialization]
1010
extra_javascript:

php_phongo.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -492,60 +492,60 @@ bool phongo_split_namespace(char *namespace, char **dbname, char **cname) /* {{{
492492
return true;
493493
} /* }}} */
494494

495-
mongoc_bulk_operation_t *phongo_writebatch_init(zend_bool ordered) { /* {{{ */
495+
mongoc_bulk_operation_t *phongo_bulkwrite_init(zend_bool ordered) { /* {{{ */
496496
return mongoc_bulk_operation_new(ordered);
497497
} /* }}} */
498498

499499
int phongo_execute_single_insert(mongoc_client_t *client, char *namespace, bson_t *doc, mongoc_write_concern_t *write_concern, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
500500
{
501501
bool retval = false;
502-
mongoc_bulk_operation_t *batch;
502+
mongoc_bulk_operation_t *bulk;
503503

504-
batch = phongo_writebatch_init(true);
505-
mongoc_bulk_operation_insert(batch, doc);
504+
bulk = phongo_bulkwrite_init(true);
505+
mongoc_bulk_operation_insert(bulk, doc);
506506

507-
retval = phongo_execute_write(client, namespace, batch, write_concern, 0, return_value, return_value_used TSRMLS_CC);
508-
mongoc_bulk_operation_destroy(batch);
507+
retval = phongo_execute_write(client, namespace, bulk, write_concern, 0, return_value, return_value_used TSRMLS_CC);
508+
mongoc_bulk_operation_destroy(bulk);
509509

510510
return retval;
511511
} /* }}} */
512512

513513
int phongo_execute_single_update(mongoc_client_t *client, char *namespace, bson_t *query, bson_t *update, mongoc_write_concern_t *write_concern, mongoc_update_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
514514
{
515515
bool retval = false;
516-
mongoc_bulk_operation_t *batch;
516+
mongoc_bulk_operation_t *bulk;
517517

518-
batch = phongo_writebatch_init(true);
518+
bulk = phongo_bulkwrite_init(true);
519519
if (flags & MONGOC_UPDATE_MULTI_UPDATE) {
520-
mongoc_bulk_operation_update_one(batch, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
520+
mongoc_bulk_operation_update_one(bulk, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
521521
} else {
522-
mongoc_bulk_operation_update(batch, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
522+
mongoc_bulk_operation_update(bulk, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
523523
}
524-
retval = phongo_execute_write(client, namespace, batch, write_concern, 0, return_value, return_value_used TSRMLS_CC);
525-
mongoc_bulk_operation_destroy(batch);
524+
retval = phongo_execute_write(client, namespace, bulk, write_concern, 0, return_value, return_value_used TSRMLS_CC);
525+
mongoc_bulk_operation_destroy(bulk);
526526

527527
return retval;
528528
} /* }}} */
529529

530530
int phongo_execute_single_delete(mongoc_client_t *client, char *namespace, bson_t *query, mongoc_write_concern_t *write_concern, mongoc_delete_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
531531
{
532532
bool retval = false;
533-
mongoc_bulk_operation_t *batch;
533+
mongoc_bulk_operation_t *bulk;
534534

535-
batch = phongo_writebatch_init(true);
535+
bulk = phongo_bulkwrite_init(true);
536536
if (flags & MONGOC_DELETE_SINGLE_REMOVE) {
537-
mongoc_bulk_operation_remove_one(batch, query);
537+
mongoc_bulk_operation_remove_one(bulk, query);
538538
} else {
539-
mongoc_bulk_operation_remove(batch, query);
539+
mongoc_bulk_operation_remove(bulk, query);
540540
}
541541

542-
retval = phongo_execute_write(client, namespace, batch, write_concern, 0, return_value, return_value_used TSRMLS_CC);
543-
mongoc_bulk_operation_destroy(batch);
542+
retval = phongo_execute_write(client, namespace, bulk, write_concern, 0, return_value, return_value_used TSRMLS_CC);
543+
mongoc_bulk_operation_destroy(bulk);
544544

545545
return retval;
546546
} /* }}} */
547547

548-
bool phongo_execute_write(mongoc_client_t *client, char *namespace, mongoc_bulk_operation_t *batch, mongoc_write_concern_t *write_concern, int server_hint, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
548+
bool phongo_execute_write(mongoc_client_t *client, char *namespace, mongoc_bulk_operation_t *bulk, mongoc_write_concern_t *write_concern, int server_hint, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
549549
{
550550
bson_error_t error;
551551
bson_t reply;
@@ -558,18 +558,18 @@ bool phongo_execute_write(mongoc_client_t *client, char *namespace, mongoc_bulk_
558558
return false;
559559
}
560560

561-
mongoc_bulk_operation_set_database(batch, dbname);
562-
mongoc_bulk_operation_set_collection(batch, collname);
563-
mongoc_bulk_operation_set_client(batch, client);
564-
mongoc_bulk_operation_set_write_concern (batch, write_concern);
561+
mongoc_bulk_operation_set_database(bulk, dbname);
562+
mongoc_bulk_operation_set_collection(bulk, collname);
563+
mongoc_bulk_operation_set_client(bulk, client);
564+
mongoc_bulk_operation_set_write_concern (bulk, write_concern);
565565
efree(dbname);
566566
efree(collname);
567567

568568
if (server_hint) {
569-
mongoc_bulk_operation_set_hint(batch, server_hint);
569+
mongoc_bulk_operation_set_hint(bulk, server_hint);
570570
}
571571

572-
hint = mongoc_bulk_operation_execute(batch, &reply, &error);
572+
hint = mongoc_bulk_operation_execute(bulk, &reply, &error);
573573

574574
/* If there is no error then the command succeeded, but the write not */
575575
if (!hint && (error.code || error.domain)) {
@@ -1608,7 +1608,7 @@ PHP_MINIT_FUNCTION(phongo)
16081608
PHP_MINIT(ReadPreference)(INIT_FUNC_ARGS_PASSTHRU);
16091609
PHP_MINIT(Result)(INIT_FUNC_ARGS_PASSTHRU);
16101610
PHP_MINIT(Server)(INIT_FUNC_ARGS_PASSTHRU);
1611-
PHP_MINIT(WriteBatch)(INIT_FUNC_ARGS_PASSTHRU);
1611+
PHP_MINIT(BulkWrite)(INIT_FUNC_ARGS_PASSTHRU);
16121612
PHP_MINIT(WriteConcern)(INIT_FUNC_ARGS_PASSTHRU);
16131613
PHP_MINIT(WriteConcernError)(INIT_FUNC_ARGS_PASSTHRU);
16141614
PHP_MINIT(WriteError)(INIT_FUNC_ARGS_PASSTHRU);

php_phongo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ PHONGO_API zend_object_handlers *phongo_get_std_object_handlers(void);
102102

103103
void phongo_server_init (zval *return_value, int server_hint, mongoc_host_list_t *host TSRMLS_DC);
104104
bool phongo_query_init (php_phongo_query_t *query, zval *filter, zval *options TSRMLS_DC);
105-
mongoc_bulk_operation_t* phongo_writebatch_init (zend_bool ordered);
106-
bool phongo_execute_write (mongoc_client_t *client, char *namespace, mongoc_bulk_operation_t *batch, mongoc_write_concern_t *write_concern, int server_hint, zval *return_value, int return_value_used TSRMLS_DC);
105+
mongoc_bulk_operation_t* phongo_bulkwrite_init (zend_bool ordered);
106+
bool phongo_execute_write (mongoc_client_t *client, char *namespace, mongoc_bulk_operation_t *bulk, mongoc_write_concern_t *write_concern, int server_hint, zval *return_value, int return_value_used TSRMLS_DC);
107107
int phongo_execute_command (mongoc_client_t *client, char *db, bson_t *command, mongoc_read_prefs_t *read_preference, zval *return_value, int return_value_used TSRMLS_DC);
108108
int phongo_execute_query (mongoc_client_t *client, char *namespace, php_phongo_query_t *query, mongoc_read_prefs_t *read_preference, zval *return_value, int return_value_used TSRMLS_DC);
109109
int phongo_execute_single_insert(mongoc_client_t *client, char *namespace, bson_t *doc, mongoc_write_concern_t *write_concern, zval *return_value, int return_value_used TSRMLS_DC);

php_phongo_classes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ typedef struct {
101101

102102
typedef struct {
103103
zend_object std;
104-
mongoc_bulk_operation_t *batch;
105-
} php_phongo_writebatch_t;
104+
mongoc_bulk_operation_t *bulk;
105+
} php_phongo_bulkwrite_t;
106106

107107
typedef struct {
108108
zend_object std;
@@ -193,7 +193,7 @@ extern PHONGO_API zend_class_entry *php_phongo_query_ce;
193193
extern PHONGO_API zend_class_entry *php_phongo_readpreference_ce;
194194
extern PHONGO_API zend_class_entry *php_phongo_result_ce;
195195
extern PHONGO_API zend_class_entry *php_phongo_server_ce;
196-
extern PHONGO_API zend_class_entry *php_phongo_writebatch_ce;
196+
extern PHONGO_API zend_class_entry *php_phongo_bulkwrite_ce;
197197
extern PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
198198
extern PHONGO_API zend_class_entry *php_phongo_writeconcernerror_ce;
199199
extern PHONGO_API zend_class_entry *php_phongo_writeerror_ce;
@@ -234,7 +234,7 @@ PHP_MINIT_FUNCTION(Query);
234234
PHP_MINIT_FUNCTION(ReadPreference);
235235
PHP_MINIT_FUNCTION(Result);
236236
PHP_MINIT_FUNCTION(Server);
237-
PHP_MINIT_FUNCTION(WriteBatch);
237+
PHP_MINIT_FUNCTION(BulkWrite);
238238
PHP_MINIT_FUNCTION(WriteConcern);
239239
PHP_MINIT_FUNCTION(WriteConcernError);
240240
PHP_MINIT_FUNCTION(WriteError);

0 commit comments

Comments
 (0)