Skip to content

Commit a5203e1

Browse files
hanumantmkChristian Hergert
authored andcommitted
removal of aggregate_legacy + new cursor interface
o made aggregate work for wire_version 0 or 2 o Added in mongoc_cursor_interface_t and a synthetic cursor stub to handle the aggregate modes.
1 parent 92869ce commit a5203e1

16 files changed

+599
-323
lines changed

doc/mongoc_api.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

doc/mongoc_collection_aggregate.txt

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ mongoc_collection_aggregate(3)
44

55
NAME
66
----
7-
mongoc_collection_aggregate, mongoc_collection_aggregate_legacy - Execute an
8-
'aggregation' query
7+
mongoc_collection_aggregate - Execute an 'aggregation' query
98

109

1110
SYNOPSIS
@@ -17,14 +16,6 @@ mongoc_collection_aggregate (mongoc_collection_t *collection,
1716
mongoc_query_flags_t flags,
1817
const bson_t *pipeline,
1918
const mongoc_read_prefs_t *read_prefs)
20-
21-
bson_bool_t
22-
mongoc_collection_aggregate_legacy (mongoc_collection_t *collection,
23-
mongoc_query_flags_t flags,
24-
const bson_t *pipeline,
25-
const mongoc_read_prefs_t *read_prefs,
26-
bson_t *reply,
27-
bson_error_t *error);
2819
-----------------------
2920

3021

@@ -35,26 +26,23 @@ on the underlying 'collection'. The bson 'pipeline' is not validated, simply
3526
passed along as appropriate to the server. As such, compatibility and errors
3627
should be validated in the appropriate server documentation.
3728

38-
'flags' are the same as in linkmongoc:mongoc_collection_find[3].
29+
In the case of older server versions, < v2.5, the returned cursor is a
30+
synthetic iterator over the result set. This provides a limitation insofar as
31+
returned documents can be no larger than 16MB. When connecting to newer
32+
servers this limitation doesn't exist. The specific test is for wire_version >
33+
0.
3934

40-
The difference between _mongoc_collection_aggregate()_ and
41-
_mongoc_collection_aggregate_legacy()_ has to do with currenly non-discoverable
42-
changes in the aggegation api between mongodb 2.4 and 2.6. The legacy api
43-
returns values in 'reply', the non-legacy version returns a cursor.
35+
'flags' are the same as in linkmongoc:mongoc_collection_find[3].
4436

4537
RETURN VALUE
4638
------------
4739
The _mongoc_collection_aggregate()_ function returns a new
4840
linkmongoc:mongoc_cursor[7] if successful. It returns NULL in the event of
4941
failure.
5042

51-
The _mongoc_collection_aggregate_legacy()_ function returns true if successful
52-
and places the output value in 'reply'.
53-
5443
ERRORS
5544
------
56-
errors are detected through active use of the linkmongoc:mongoc_cursor[7] or
57-
through 'error'.
45+
errors are detected through active use of the linkmongoc:mongoc_cursor[7].
5846

5947

6048
SEE ALSO

doc/mongoc_collection_aggregate_legacy.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/mongoc_symbols.txt

Lines changed: 0 additions & 142 deletions
This file was deleted.

mongoc/Makefile.include

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ NOINST_H_FILES = \
5252
mongoc/mongoc-collection-private.h \
5353
mongoc/mongoc-counters-private.h \
5454
mongoc/mongoc-cursor-private.h \
55+
mongoc/mongoc-cursor-array-private.h \
56+
mongoc/mongoc-cursor-cursorid-private.h \
5557
mongoc/mongoc-cluster-private.h \
5658
mongoc/mongoc-database-private.h \
5759
mongoc/mongoc-init-private.h \
@@ -84,6 +86,8 @@ libmongoc_priv_la_SOURCES = \
8486
mongoc/mongoc-collection.c \
8587
mongoc/mongoc-counters.c \
8688
mongoc/mongoc-cursor.c \
89+
mongoc/mongoc-cursor-array.c \
90+
mongoc/mongoc-cursor-cursorid.c \
8791
mongoc/mongoc-database.c \
8892
mongoc/mongoc-init.c \
8993
mongoc/mongoc-gridfs.c \

mongoc/libmongoc.symbols

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mongoc_client_set_read_prefs
1818
mongoc_client_set_ssl_opts
1919
mongoc_client_set_write_concern
2020
mongoc_collection_aggregate
21-
mongoc_collection_aggregate_legacy
2221
mongoc_collection_command
2322
mongoc_collection_command_simple
2423
mongoc_collection_count

mongoc/mongoc-cluster.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444

4545
#define MIN_WIRE_VERSION 0
46-
#define MAX_WIRE_VERSION 0
46+
#define MAX_WIRE_VERSION 2
4747

4848

4949
#ifndef DEFAULT_SOCKET_TIMEOUT_MSEC
@@ -113,13 +113,15 @@ _mongoc_cluster_negotiate_wire_version (mongoc_cluster_t *cluster)
113113
for (i = 0; i < MONGOC_CLUSTER_MAX_NODES; i++) {
114114
node = &cluster->nodes[i];
115115

116-
if ((node->min_wire_version > max_wire_version) ||
117-
(node->max_wire_version < min_wire_version)) {
118-
RETURN (FALSE);
119-
}
116+
if (node->stream) {
117+
if ((node->min_wire_version > max_wire_version) ||
118+
(node->max_wire_version < min_wire_version)) {
119+
RETURN (FALSE);
120+
}
120121

121-
min_wire_version = MAX (min_wire_version, node->min_wire_version);
122-
max_wire_version = MIN (max_wire_version, node->max_wire_version);
122+
min_wire_version = MAX (min_wire_version, node->min_wire_version);
123+
max_wire_version = MIN (max_wire_version, node->max_wire_version);
124+
}
123125
}
124126

125127
BSON_ASSERT (min_wire_version <= max_wire_version);

0 commit comments

Comments
 (0)