#include <bson.h>
|
#include <mongoc.h>
|
#include <stdio.h>
|
|
int
|
main (int argc,
|
char *argv[])
|
{
|
mongoc_client_t *client;
|
mongoc_collection_t *collection;
|
mongoc_cursor_t *cursor;
|
const bson_t *doc;
|
bson_t *query;
|
char *str;
|
int64_t count = 0;
|
int64_t got = 0;
|
|
mongoc_init ();
|
|
client = mongoc_client_new ("mongodb://localhost:27017/");
|
collection = mongoc_client_get_collection (client, "enron_mail", "messages");
|
query = bson_new ();
|
count = mongoc_collection_count (collection, MONGOC_QUERY_NONE, query, 0, 0, NULL, NULL);
|
cursor = mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 100000, 0, query, NULL, NULL);
|
|
while (mongoc_cursor_next (cursor, &doc)) {
|
got++;
|
}
|
printf("Got in total: %ld documents, out of %ld\n", got, count);
|
|
bson_destroy (query);
|
mongoc_cursor_destroy (cursor);
|
mongoc_collection_destroy (collection);
|
mongoc_client_destroy (client);
|
|
return 0;
|
}
|
}
|
Got in total: 2035 documents, out of 501513
|
|