SlideShare a Scribd company logo
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
{
    "_id" : <unspecified>, //file      ID
    "length" : data_number, //          bytes
    "chunkSize" : data_number, //               :256KB
    "uploadDate" : data_date, //file
    "md5" : data_string //"filemd5"
}
{
    "filename" : data_string,
    "contentType" : data_string,
    "aliases" : data_array of data_string,
    "metadata" : data_object,
}
{
    "_id" : <unspecified>, //chunk           ID

    "files_id" : <unspecified>, //file            _id

    "n" : chunk_number, //0          chunk

        0,1,2...   chunk

    "data" : data_binary, // BSON

}
> db.fs.chunks.ensureIndex(
                    {files_id:1, n:1}, {unique: true});




> db.fs.chunks.findOne({files_id: myFileID, n: 0});
➜ ~ mongofiles --help
usage: mongofiles [options] command [gridfs filename]
command:
  one of (list|search|put|get)
  list - file
 search - file
 put - file
 get - file
 delete - file
➜ ~ mongofiles list
connected to: 127.0.0.1

➜ ~ mongofiles put ByeForNow.mp3
connected to: 127.0.0.1
added file: { _id: ObjectId('4df17f8d9d47ba5c0247e72e'),
filename: "ByeForNow.mp3", chunkSize: 262144, uploadDate:
new Date(1307672462538), md5:
"9ee9472200a2e18bf376ce622c3b0055", length: 11183104 }
done!

➜   ~   mongofiles list -v // -v
Fri Jun 10 11:21:05 creating new connection to:127.0.0.1
Fri Jun 10 11:21:05 BackgroundJob starting:
connected to: 127.0.0.1
ByeForNow.mp3   11183104
➜ ~ mongofiles put Maria.mp3
connected to: 127.0.0.1
added file: { _id: ObjectId('4df181fc5e354129e833193f'),
filename: "Maria.mp3", chunkSize: 262144, uploadDate: new
Date(1307673086293), md5:
"9d4f424fa1843711e196e502d8a00183", length: 12225353 }
done!
➜ ~ mongofiles list
connected to: 127.0.0.1
ByeForNow.mp3   11183104
Maria.mp3       12225353
➜ ~ mongofiles list M
connected to: 127.0.0.1
Maria.mp3       12225353
➜ ~ mongofiles search .mp3
connected to: 127.0.0.1
ByeForNow.mp3   11183104
Maria.mp3       12225353
➜   ~   mkdir tmp //      get
➜ ~ cd tmp
➜ mongofiles get Maria.mp3
connected to: 127.0.0.1
done write to: Maria.mp3
➜ ls
Maria.mp3
➜ mongofiles get Bye
ERROR: file not found
➜ mongofiles get ByeForNow.mp3
done write to: ByeForNow.mp3
➜ md5 Maria.mp3
MD5 (Maria.mp3) = 9d4f424fa1843711e196e502d8a00183
➜ md5 ../Maria.mp3
MD5 (../Maria.mp3) = 9d4f424fa1843711e196e502d8a00183
> db.fs.files.find().forEach(printjson)
{
        "_id" : ObjectId("4df17f8d9d47ba5c0247e72e"),
        "filename" : "ByeForNow.mp3",
        "chunkSize" : 262144,
        "uploadDate" : ISODate("2011-06-10T02:21:02.538Z"),
        "md5" : "9ee9472200a2e18bf376ce622c3b0055",
        "length" : 11183104
}
{
        "_id" : ObjectId("4df181fc5e354129e833193f"),
        "filename" : "Maria.mp3",
        "chunkSize" : 262144,
        "uploadDate" : ISODate("2011-06-10T02:31:26.293Z"),
        "md5" : "9d4f424fa1843711e196e502d8a00183",
        "length" : 12225353
}
> db.fs.chunks.findOne(
     {n:0,files_id:ObjectId("4df181fc5e354129e833193f")})
{
  "_id" : ObjectId("4df181fcd40994ca1de28d09"),
  "files_id" : ObjectId("4df181fc5e354129e833193f"),
  "n" : 0,
  "data" : BinData(0,"SUQzAwAAAABQdlRSQ0sAAAACAAAAM1RJVDIA
AAAHAAAAg32DioNBVUZJRAAAAGYAAGh0dHA6Ly93d3cuY2RkYi5jb20vaWQ
zL3RhZ2luZm8xLmh0bWwAM0NEM00xMTBRMjA3NTYwOTc4VjY4MTBCQTlBNj
UzN0JCQUQ1QTgyOUE4NTRCRkQ2QTdBRjNQOAAAAAAAAAAAAEdFT0IAACNgA
AAAYXBwbGljYX...)
}
>   db.fs.chunks.ensureIndex({files_id: 1});
>   db.runCommand({ shardcollection : "test.fs.chunks", key :
{   files_id : 1 }})
{   "collectionsharded" : "test.fs.chunks", "ok" : 1 }
MongoDB   GridFS
Replace Amazon S3 with MongoDB GridFS and Grails
MongoDB全機能解説2
MongoDB全機能解説2
{   loc   :   [   50 , 30 ] }
{   loc   :   {   x : 50 , y : 30 } }
{   loc   :   {   foo : 50 , y : 30 } }
{   loc   :   {   long : 40.739037, lat: 73.992964 } }
db.places.ensureIndex( { loc : "2d" } )
db.places.ensureIndex( { loc : "2d" } , { min : -500 , max : 500 } )
db.places.find( { loc : [50,50] } )




db.places.find( { loc : { $near : [50,50] } } )
db.places.find( { loc : { $near : [50,50] } } ).limit(20)
db.places.find( { loc : { $near : [50,50] ,
                          $maxDistance : 5 } } ).limit(20)
//
> box = [[40.73083, -73.99756], [40.741404, -73.988135]]
> db.places.find({"loc" : {"$within" : {"$box" : box}}})

//
> center = [50, 50]
> radius = 10
> db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}})

// v1.9
> polygonA = [ [ 10, 20 ], [   10, 40 ], [ 30, 40 ], [ 30, 20 ] ]
> polygonB = { a : { x : 10,   y : 20 }, b : { x : 15, y : 25 }, c : { x :
20, y : 20 } }
> db.places.find({ "loc" : {   "$within" : { "$polygon" : polygonA } } })
> db.places.find({ "loc" : {   "$within" : { "$polygon" : polygonB } } })
> db.runCommand( { geoNear : "places" , near : [ 50 , 50 ], num : 10,
query : { type : "museum" } } );
{
       "ns" : "test.places",
       "near" : "1100110000001111110000001111110000001111110000001111",
       "results" : [
               {
                       "dis" : 69.29646421910687,
                       "obj" : {
                               "_id" : ObjectId("4b8bd6b93b83c574d8760280"),
                               "y" : [
                                       1,
                                       1
                               ],
                               "category" : "Coffee"
                       }
               },
               {
                       "dis" : 69.29646421910687,
                       "obj" : {
                               "_id" : ObjectId("4b8bd6b03b83c574d876027f"),
                                       1
...}
MongoDB
MongoDB全機能解説2
> db.points.insert({ pos : { long : 30, lat : 30 } })
> db.points.insert({ pos : { long : -10, lat : -20 } })
> db.points.ensureIndex({ pos : "2d" })

> db.points.find({ pos: { $nearSphere: [0,0], $maxDistance : 0.4 } })
{ "_id" : ObjectId("4df11e47b8e84370f84afdd3"), "pos" : { "long" : -10,
"lat" : -20 } }
> var earthRadius = 6378 // km
> var range = 3000 // km
> distances = db.runCommand({ geoNear : "points", near : [0, 0], spherical :
true, maxDistance : range / earthRadius }).results
[
        {
                "dis" : 0.3886630122897946, //
                "obj" : {
                        "_id" : ObjectId("4df11e47b8e84370f84afdd3"),
                        "pos" : {
                                "long" : -10,
                                "lat" : -20
                        }
                }
        }
]
> pointDistance = distances[0].dis * earthRadius
2478.89269238431 // km
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
http://www.slideshare.net/doryokujin/mongo-sharding
MongoDB全機能解説2
MongoDB全機能解説2
~   mkdir    -p   shard/shard00
~   mkdir    -p   shard/shard01
~   mkdir    -p   shard/shard02
~   mkdir    -p   shard/config




~   mongod   --shardsvr --port 27017 --dbpath    shard/shard00
~   mongod   --shardsvr --port 27018 --dbpath    shard/shard01
~   mongod   --shardsvr --port 27019 --dbpath    shard/shard02
~   mongod   --configsvr --port 27020 --dbpath   shard/config
~   mongos   --configdb localhost:27020 --port   27021
➜   ~    mongo localhost:27021 // mongos

MongoDB shell version: 1.8.0
connecting to: localhost:27021/test
> show dbs
config    0.1875GB // sharding

> db.adminCommand( { addshard: "localhost:27017", name: "shard00" } )
{ "shardAdded" : "shard00", "ok" : 1 }
> db.adminCommand( { addshard: "localhost:27018", name: "shard01" } )
{ "shardAdded" : "shard01", "ok" : 1 }
> db.adminCommand( { addshard: "localhost:27019", name: "shard02" } )
{ "shardAdded" : "shard02", "ok" : 1 }
//       mongos

> db.adminCommand( { enablesharding : "test" } )
{ "ok" : 1 }
> db.adminCommand( { moveprimary : "test", to : "shard02" } );
{ "primary " : "shard02:localhost:27019", "ok" : 1 }
> db.adminCommand( { shardcollection : "test.myshard", key : { n : 1 } } )
{ "collectionsharded" : "test.myshard", "ok" : 1 }
//       mongos

> db.adminCommand({split : "test.myshard", middle : { n: 0 } } )
{ "ok" : 1 }
> db.adminCommand({split : "test.myshard", middle : { n: 1 } } )
{ "ok" : 1 }
> db.adminCommand({split : "test.myshard", middle : { n: 2 } } )
{ "ok" : 1 }
> db.printShardingStatus() //

--- Sharding Status ---
  sharding version: { "_id" : 1, "version" : 3 }
  shards:
      { "_id" : "shard00", "host" : "localhost:27017" }
      { "_id" : "shard01", "host" : "localhost:27018" }
      { "_id" : "shard02", "host" : "localhost:27019" }
  databases:
        { "_id" : "admin", "partitioned" : false, "primary" : "config" }
        { "_id" : "test", "partitioned" : true, "primary" : "shard02" }
        test.myshard chunks:
            shard02 4
 { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "t" : 1000, "i" : 1 }
 { "n" : 0 } -->> { "n" : 1 } on : shard02 { "t" : 1000, "i" : 3 }
 { "n" : 1 } -->> { "n" : 2 } on : shard02 { "t" : 1000, "i" : 5 }
 { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "t" : 1000, "i" : 6 }
//       mongos

> db.adminCommand({moveChunk: "test.myshard", find: { n: 0 }, to: "shard00" });
{ "millis" : 1051, "ok" : 1 }
> db.adminCommand({moveChunk: "test.myshard", find: { n: 1 }, to: "shard01" });
{ "millis" : 1046, "ok" : 1 }
> db.adminCommand({moveChunk :"test.myshard", find: { n: 2 }, to: "shard02" });
{ "ok" : 0, "errmsg" : "that chunk is already on that shard" }
> db.printShardingStatus()
--- Sharding Status ---
  sharding version: { "_id" : 1, "version" : 3 }
  shards:
      { "_id" : "shard00", "host" : "localhost:27017" }
      { "_id" : "shard01", "host" : "localhost:27018" }
      { "_id" : "shard02", "host" : "localhost:27019" }
  databases:
        { "_id" : "admin", "partitioned" : false, "primary" : "config" }
        { "_id" : "test", "partitioned" : true, "primary" : "shard02" }
        test.myshard chunks:
               shard02 2
               shard00 1
               shard01 1
   { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "t" : 3000, "i" : 1 }
   { "n" : 0 } -->> { "n" : 1 } on : shard00 { "t" : 2000, "i" : 0 }
   { "n" : 1 } -->> { "n" : 2 } on : shard01 { "t" : 3000, "i" : 0 }
   { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "t" : 1000, "i" : 6 }
//         mongos

> for(var m=0; m<100; m++){ db.myshard.insert({n: m % 3}) } // n =0,1,2,0,1,...


> printShardingSizes()      // Shard

     ...
     test.myshard chunks:
     { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "estimate" :
false, "size" : 0, "numObjects" : 0 }
     { "n" : 0 } -->> { "n" : 1 } on : shard00 { "estimate" : false, "size" :
1224, "numObjects" : 34 }
     { "n" : 1 } -->> { "n" : 2 } on : shard01 { "estimate" : false, "size" :
1188, "numObjects" : 33 }
     { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "estimate" :
false, "size" : 1188, "numObjects" : 33 }
➜    ~   mongo localhost:27017
> db.myshard.count()
34
> db.myshard.distinct("n")
[ 0 ]
➜    ~   mongo localhost:27018
> db.myshard.count()
33
> db.myshard.distinct("n")
[ 1 ]
➜    ~   mongo localhost:27019
> db.myshard.count()
33
> db.myshard.distinct("n")
[ 2 ]
MongoDB全機能解説2
MongoDB全機能解説2
> db.adminCommand( { addshard: "set00/delta1:27017,delta2:27017", name:
"shard00" } )
{ "shardAdded" : "shard00", "ok" : 1 }
> db.adminCommand( { addshard: "set01/delta3:27018,delta4:27018", name:
"shard01" } )
{ "shardAdded" : "shard01", "ok" : 1 }
> db.adminCommand( { addshard: "set02/delta5:27019,delta6:27019", name:
"shard02" } )
{ "shardAdded" : "shard02", "ok" : 1 }
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
MongoDB全機能解説2
Map-Reduce on Mongo
MongoDB全機能解説2
MongoDB全機能解説2
db.mycoll.mapReduce(
 map : <map                >,

 reduce : <reduce                >

 [, finalize : <finalize             >]

 [, query : <                        >]

 [, sort : <

     reduce                                       >]

 [, out : <                     >]

 [, scope : <object where fields go into javascript global scope >]

);
db.people.insert({userId:1,   age:24, type:"A"})
db.people.insert({userId:2,   age:47, type:"B"})
db.people.insert({userId:3,   age:34, type:"C"})
db.people.insert({userId:4,   age:4,   type:"B"})
db.people.insert({userId:5,   age:14, type:"A"})
db.people.insert({userId:6,   age:29, type:"C"})
db.people.insert({userId:7,   age:39, type:"C"})
db.people.insert({userId:8,   age:42, type:"B"})
db.people.insert({userId:9,   age:56, type:"A"})
db.people.insert({userId:10, age:12, type:"A"})
m = function() {
  emit(this.type, { age: this.age, num: 1 } );
}
r = function(key, values) {
    var result = { age: 0, num: 0 };
    values.forEach( function(value){
        result.age += value.age; // age
        result.num += value.num; //
    } );
    return result;
}
r = function(key, values) {
    var num = 0;
    var sum = 0;
    values.forEach( function(value){
        sum += value.age; // age
        num += value.num; //
    } );
    return sum/num;
}
m = function() {
  emit(this.type, { age: this.age, num: 1 } );
}
r = function(key, values) {
    var result = { age: 0, num: 0 };
    values.forEach( function(value){
        result.age += value.age; // age
        result.num += value.num; //
    } );
    return result;
}
m = function() {
  emit(this.type, { age: this.age, num: 1 } );
}
r = function(key, values) {
    var result = { age: 0, num: 0 };
    values.forEach( function(value){
        result.age += value.age; //
        result.num += value.num; //
    } );
    return result;
}
f = function( key, result ){
    result.avg = result.age / result.num;
    return result;
}
> res = db.people.mapReduce( m , r ,
        { finalize : f , out : "mr_out", verbose: true });
{
        "result" : "mr_out", //
        "timeMillis" : 18,     //
        "timing" : {
                "mapTime" : NumberLong(1),
                "emitLoop" : 12,
                "total" : 18
        },
        "counts" : {
                "input" : 10, // 10
                "emit" : 10,        // 10   emit
                "output" : 3        // 3
        },
        "ok" : 1,
}
> db.mr_out.find()
{ "_id" : "A",
  "value" : { "age" : 106, "num" : 4, "avg" : 26.5 } }
{ "_id" : "B",
  "value" : { "age" : 93, "num" : 3, "avg" : 31 } }
{ "_id" : "C",
  "value" : { "age" : 102, "num" : 3, "avg" : 34 } }
> res = db.people.mapReduce( m , r ,
  { finalize : f , out : "mr_out", query: { age: { $gte: 20 } } });
{
         "result" : "mr_out",
         "timeMillis" : 35,
         "counts" : {
                 "input" : 7, // 3
                "emit" : 7,
                "output" : 3
        },
        "ok" : 1,
}
> db.mr_out.find() //

{ "_id" : "A",
  "value" : { "age" : 80, "num" : 2, "avg" : 40 } }
{ "_id" : "B",
  "value" : { "age" : 89, "num" : 2, "avg" : 44.5 } }
{ "_id" : "C",
  "value" : { "age" : 102, "num" : 3, "avg" : 34 } }
MongoDB全機能解説2
MongoDB全機能解説2
db.items.insert({ date: "2011-06-01", item: "apple", price: 100 })
db.items.insert({ date: "2011-06-01", item: "banana", price: 200 })
db.items.insert({ date: "2011-06-01", item: "apple" , price :100})
db.items.insert({ date: "2011-06-02", item: "orange", price: 50 })
db.items.insert({ date: "2011-06-02", item: "orange", price: 50 })
db.items.insert({ date: "2011-06-02", item: "apple", price: 100 })
m = function() { emit(this.item, this.price); }
r = function(key,values) {
      var result = 0;
      values.forEach( function(value){ result += value } );
      return result;
}
> res = db.items.mapReduce( m, r, { query: {date: "2011-06-01"} ,
out: {replace: "mr_out2"}} );
{
        "result" : "mr_out2",
        "timeMillis" : 10,
        "counts" : {
                "input" : 3,
                "emit" : 3,
                "output" : 2
        },
        "ok" : 1,
}
>db.mr_out2.find()
{ "_id" : "apple", "value" : 200 }
{ "_id" : "banana", "value" : 200 }
> res = db.items.mapReduce( m, r,
  { query: {date: "2011-06-02"} , out: {reduce: "mr_out2"}} );
{
        "result" : "mr_out2",
        "timeMillis" : 23,
        "counts" : {
                "input" : 3,
                "emit" : 3,
                "output" : 3
        },
        "ok" : 1,
}
> db.mr_out2.find()
{ "_id" : "apple", "value" : 300 } //
{ "_id" : "banana", "value" : 200 } //
{ "_id" : "orange", "value" : 100 } //
MongoDB全機能解説2
MongoDB全機能解説2
Ad

More Related Content

What's hot (20)

MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
Alexander Rubin
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 
Litebox
LiteboxLitebox
Litebox
meli media
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
Julie Sommerville
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
Puneet Behl
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
Ke Wei Louis
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifiers
zarigatongy
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
MongoDB
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
Eugene Zharkov
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
erwanl
 
Mongo db dla administratora
Mongo db dla administratoraMongo db dla administratora
Mongo db dla administratora
Łukasz Jagiełło
 
Embedding a language into string interpolator
Embedding a language into string interpolatorEmbedding a language into string interpolator
Embedding a language into string interpolator
Michael Limansky
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
Harun Yardımcı
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzenAndreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
DevDay Dresden
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
MongoDB Aggregation Framework in action !
MongoDB Aggregation Framework in action !MongoDB Aggregation Framework in action !
MongoDB Aggregation Framework in action !
Sébastien Prunier
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
Alexander Rubin
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
Puneet Behl
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
Ke Wei Louis
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifiers
zarigatongy
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
MongoDB
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
erwanl
 
Embedding a language into string interpolator
Embedding a language into string interpolatorEmbedding a language into string interpolator
Embedding a language into string interpolator
Michael Limansky
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzenAndreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
DevDay Dresden
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
MongoDB Aggregation Framework in action !
MongoDB Aggregation Framework in action !MongoDB Aggregation Framework in action !
MongoDB Aggregation Framework in action !
Sébastien Prunier
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 

Viewers also liked (7)

Mongo dbのgridfsについて
Mongo dbのgridfsについてMongo dbのgridfsについて
Mongo dbのgridfsについて
Masahiro Saito
 
MongoDBざっくり解説
MongoDBざっくり解説MongoDBざっくり解説
MongoDBざっくり解説
知教 本間
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
Takahiro Inoue
 
Mongo DBを半年運用してみた
Mongo DBを半年運用してみたMongo DBを半年運用してみた
Mongo DBを半年運用してみた
Masakazu Matsushita
 
MongoDB全機能解説1
MongoDB全機能解説1MongoDB全機能解説1
MongoDB全機能解説1
Takahiro Inoue
 
イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱
Fumio SAGAWA
 
MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介
Koji Iwazaki
 
Mongo dbのgridfsについて
Mongo dbのgridfsについてMongo dbのgridfsについて
Mongo dbのgridfsについて
Masahiro Saito
 
MongoDBざっくり解説
MongoDBざっくり解説MongoDBざっくり解説
MongoDBざっくり解説
知教 本間
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
Takahiro Inoue
 
Mongo DBを半年運用してみた
Mongo DBを半年運用してみたMongo DBを半年運用してみた
Mongo DBを半年運用してみた
Masakazu Matsushita
 
MongoDB全機能解説1
MongoDB全機能解説1MongoDB全機能解説1
MongoDB全機能解説1
Takahiro Inoue
 
イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱
Fumio SAGAWA
 
MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介
Koji Iwazaki
 
Ad

Similar to MongoDB全機能解説2 (20)

Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
Uwe Printz
 
MongoDB With Style
MongoDB With StyleMongoDB With Style
MongoDB With Style
Gabriele Lana
 
Couchdb
CouchdbCouchdb
Couchdb
Саги Усаги
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
Books
BooksBooks
Books
flaglio
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
rogerbodamer
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
Karel Minarik
 
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
Latinoware
LatinowareLatinoware
Latinoware
kchodorow
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 LinkMongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
Shuai Liu
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
LearningTech
 
Geospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDBGeospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
Sensmon couchdb
Sensmon couchdbSensmon couchdb
Sensmon couchdb
Motokazu Nishimura
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
iammutex
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
Uwe Printz
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB .local Houston 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
rogerbodamer
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
Karel Minarik
 
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 LinkMongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
Shuai Liu
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
LearningTech
 
Geospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDBGeospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
iammutex
 
Ad

More from Takahiro Inoue (20)

Treasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC DemoTreasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC Demo
Takahiro Inoue
 
トレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティングトレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティング
Takahiro Inoue
 
Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界
Takahiro Inoue
 
トレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解するトレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解する
Takahiro Inoue
 
20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション
Takahiro Inoue
 
トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方
Takahiro Inoue
 
オンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータオンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータ
Takahiro Inoue
 
事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612
Takahiro Inoue
 
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
Takahiro Inoue
 
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
Takahiro Inoue
 
Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!
Takahiro Inoue
 
Hadoop and the Data Scientist
Hadoop and the Data ScientistHadoop and the Data Scientist
Hadoop and the Data Scientist
Takahiro Inoue
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
Takahiro Inoue
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
Takahiro Inoue
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
Takahiro Inoue
 
An Introduction to Neo4j
An Introduction to Neo4jAn Introduction to Neo4j
An Introduction to Neo4j
Takahiro Inoue
 
The Definition of GraphDB
The Definition of GraphDBThe Definition of GraphDB
The Definition of GraphDB
Takahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)
Takahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)
Takahiro Inoue
 
Advanced MongoDB #1
Advanced MongoDB #1Advanced MongoDB #1
Advanced MongoDB #1
Takahiro Inoue
 
Treasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC DemoTreasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC Demo
Takahiro Inoue
 
トレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティングトレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティング
Takahiro Inoue
 
Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界
Takahiro Inoue
 
トレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解するトレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解する
Takahiro Inoue
 
20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション
Takahiro Inoue
 
トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方
Takahiro Inoue
 
オンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータオンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータ
Takahiro Inoue
 
事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612
Takahiro Inoue
 
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
Takahiro Inoue
 
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
Takahiro Inoue
 
Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!
Takahiro Inoue
 
Hadoop and the Data Scientist
Hadoop and the Data ScientistHadoop and the Data Scientist
Hadoop and the Data Scientist
Takahiro Inoue
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
Takahiro Inoue
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
Takahiro Inoue
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
Takahiro Inoue
 
An Introduction to Neo4j
An Introduction to Neo4jAn Introduction to Neo4j
An Introduction to Neo4j
Takahiro Inoue
 
The Definition of GraphDB
The Definition of GraphDBThe Definition of GraphDB
The Definition of GraphDB
Takahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)
Takahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)
Takahiro Inoue
 

Recently uploaded (20)

IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 

MongoDB全機能解説2

  • 11. { "_id" : <unspecified>, //file ID "length" : data_number, // bytes "chunkSize" : data_number, // :256KB "uploadDate" : data_date, //file "md5" : data_string //"filemd5" }
  • 12. { "filename" : data_string, "contentType" : data_string, "aliases" : data_array of data_string, "metadata" : data_object, }
  • 13. { "_id" : <unspecified>, //chunk ID "files_id" : <unspecified>, //file _id "n" : chunk_number, //0 chunk 0,1,2... chunk "data" : data_binary, // BSON }
  • 14. > db.fs.chunks.ensureIndex( {files_id:1, n:1}, {unique: true}); > db.fs.chunks.findOne({files_id: myFileID, n: 0});
  • 15. ➜ ~ mongofiles --help usage: mongofiles [options] command [gridfs filename] command: one of (list|search|put|get) list - file search - file put - file get - file delete - file
  • 16. ➜ ~ mongofiles list connected to: 127.0.0.1 ➜ ~ mongofiles put ByeForNow.mp3 connected to: 127.0.0.1 added file: { _id: ObjectId('4df17f8d9d47ba5c0247e72e'), filename: "ByeForNow.mp3", chunkSize: 262144, uploadDate: new Date(1307672462538), md5: "9ee9472200a2e18bf376ce622c3b0055", length: 11183104 } done! ➜ ~ mongofiles list -v // -v Fri Jun 10 11:21:05 creating new connection to:127.0.0.1 Fri Jun 10 11:21:05 BackgroundJob starting: connected to: 127.0.0.1 ByeForNow.mp3 11183104
  • 17. ➜ ~ mongofiles put Maria.mp3 connected to: 127.0.0.1 added file: { _id: ObjectId('4df181fc5e354129e833193f'), filename: "Maria.mp3", chunkSize: 262144, uploadDate: new Date(1307673086293), md5: "9d4f424fa1843711e196e502d8a00183", length: 12225353 } done! ➜ ~ mongofiles list connected to: 127.0.0.1 ByeForNow.mp3 11183104 Maria.mp3 12225353 ➜ ~ mongofiles list M connected to: 127.0.0.1 Maria.mp3 12225353 ➜ ~ mongofiles search .mp3 connected to: 127.0.0.1 ByeForNow.mp3 11183104 Maria.mp3 12225353
  • 18. ~ mkdir tmp // get ➜ ~ cd tmp ➜ mongofiles get Maria.mp3 connected to: 127.0.0.1 done write to: Maria.mp3 ➜ ls Maria.mp3 ➜ mongofiles get Bye ERROR: file not found ➜ mongofiles get ByeForNow.mp3 done write to: ByeForNow.mp3 ➜ md5 Maria.mp3 MD5 (Maria.mp3) = 9d4f424fa1843711e196e502d8a00183 ➜ md5 ../Maria.mp3 MD5 (../Maria.mp3) = 9d4f424fa1843711e196e502d8a00183
  • 19. > db.fs.files.find().forEach(printjson) { "_id" : ObjectId("4df17f8d9d47ba5c0247e72e"), "filename" : "ByeForNow.mp3", "chunkSize" : 262144, "uploadDate" : ISODate("2011-06-10T02:21:02.538Z"), "md5" : "9ee9472200a2e18bf376ce622c3b0055", "length" : 11183104 } { "_id" : ObjectId("4df181fc5e354129e833193f"), "filename" : "Maria.mp3", "chunkSize" : 262144, "uploadDate" : ISODate("2011-06-10T02:31:26.293Z"), "md5" : "9d4f424fa1843711e196e502d8a00183", "length" : 12225353 }
  • 20. > db.fs.chunks.findOne( {n:0,files_id:ObjectId("4df181fc5e354129e833193f")}) { "_id" : ObjectId("4df181fcd40994ca1de28d09"), "files_id" : ObjectId("4df181fc5e354129e833193f"), "n" : 0, "data" : BinData(0,"SUQzAwAAAABQdlRSQ0sAAAACAAAAM1RJVDIA AAAHAAAAg32DioNBVUZJRAAAAGYAAGh0dHA6Ly93d3cuY2RkYi5jb20vaWQ zL3RhZ2luZm8xLmh0bWwAM0NEM00xMTBRMjA3NTYwOTc4VjY4MTBCQTlBNj UzN0JCQUQ1QTgyOUE4NTRCRkQ2QTdBRjNQOAAAAAAAAAAAAEdFT0IAACNgA AAAYXBwbGljYX...) }
  • 21. > db.fs.chunks.ensureIndex({files_id: 1}); > db.runCommand({ shardcollection : "test.fs.chunks", key : { files_id : 1 }}) { "collectionsharded" : "test.fs.chunks", "ok" : 1 }
  • 22. MongoDB GridFS
  • 23. Replace Amazon S3 with MongoDB GridFS and Grails
  • 26. { loc : [ 50 , 30 ] } { loc : { x : 50 , y : 30 } } { loc : { foo : 50 , y : 30 } } { loc : { long : 40.739037, lat: 73.992964 } }
  • 27. db.places.ensureIndex( { loc : "2d" } ) db.places.ensureIndex( { loc : "2d" } , { min : -500 , max : 500 } )
  • 28. db.places.find( { loc : [50,50] } ) db.places.find( { loc : { $near : [50,50] } } ) db.places.find( { loc : { $near : [50,50] } } ).limit(20) db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20)
  • 29. // > box = [[40.73083, -73.99756], [40.741404, -73.988135]] > db.places.find({"loc" : {"$within" : {"$box" : box}}}) // > center = [50, 50] > radius = 10 > db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}}) // v1.9 > polygonA = [ [ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ] ] > polygonB = { a : { x : 10, y : 20 }, b : { x : 15, y : 25 }, c : { x : 20, y : 20 } } > db.places.find({ "loc" : { "$within" : { "$polygon" : polygonA } } }) > db.places.find({ "loc" : { "$within" : { "$polygon" : polygonB } } })
  • 30. > db.runCommand( { geoNear : "places" , near : [ 50 , 50 ], num : 10, query : { type : "museum" } } ); { "ns" : "test.places", "near" : "1100110000001111110000001111110000001111110000001111", "results" : [ { "dis" : 69.29646421910687, "obj" : { "_id" : ObjectId("4b8bd6b93b83c574d8760280"), "y" : [ 1, 1 ], "category" : "Coffee" } }, { "dis" : 69.29646421910687, "obj" : { "_id" : ObjectId("4b8bd6b03b83c574d876027f"), 1 ...}
  • 33. > db.points.insert({ pos : { long : 30, lat : 30 } }) > db.points.insert({ pos : { long : -10, lat : -20 } }) > db.points.ensureIndex({ pos : "2d" }) > db.points.find({ pos: { $nearSphere: [0,0], $maxDistance : 0.4 } }) { "_id" : ObjectId("4df11e47b8e84370f84afdd3"), "pos" : { "long" : -10, "lat" : -20 } }
  • 34. > var earthRadius = 6378 // km > var range = 3000 // km > distances = db.runCommand({ geoNear : "points", near : [0, 0], spherical : true, maxDistance : range / earthRadius }).results [ { "dis" : 0.3886630122897946, // "obj" : { "_id" : ObjectId("4df11e47b8e84370f84afdd3"), "pos" : { "long" : -10, "lat" : -20 } } } ] > pointDistance = distances[0].dis * earthRadius 2478.89269238431 // km
  • 46. ~ mkdir -p shard/shard00 ~ mkdir -p shard/shard01 ~ mkdir -p shard/shard02 ~ mkdir -p shard/config ~ mongod --shardsvr --port 27017 --dbpath shard/shard00 ~ mongod --shardsvr --port 27018 --dbpath shard/shard01 ~ mongod --shardsvr --port 27019 --dbpath shard/shard02 ~ mongod --configsvr --port 27020 --dbpath shard/config ~ mongos --configdb localhost:27020 --port 27021
  • 47. ~ mongo localhost:27021 // mongos MongoDB shell version: 1.8.0 connecting to: localhost:27021/test > show dbs config 0.1875GB // sharding > db.adminCommand( { addshard: "localhost:27017", name: "shard00" } ) { "shardAdded" : "shard00", "ok" : 1 } > db.adminCommand( { addshard: "localhost:27018", name: "shard01" } ) { "shardAdded" : "shard01", "ok" : 1 } > db.adminCommand( { addshard: "localhost:27019", name: "shard02" } ) { "shardAdded" : "shard02", "ok" : 1 }
  • 48. // mongos > db.adminCommand( { enablesharding : "test" } ) { "ok" : 1 } > db.adminCommand( { moveprimary : "test", to : "shard02" } ); { "primary " : "shard02:localhost:27019", "ok" : 1 } > db.adminCommand( { shardcollection : "test.myshard", key : { n : 1 } } ) { "collectionsharded" : "test.myshard", "ok" : 1 }
  • 49. // mongos > db.adminCommand({split : "test.myshard", middle : { n: 0 } } ) { "ok" : 1 } > db.adminCommand({split : "test.myshard", middle : { n: 1 } } ) { "ok" : 1 } > db.adminCommand({split : "test.myshard", middle : { n: 2 } } ) { "ok" : 1 }
  • 50. > db.printShardingStatus() // --- Sharding Status --- sharding version: { "_id" : 1, "version" : 3 } shards: { "_id" : "shard00", "host" : "localhost:27017" } { "_id" : "shard01", "host" : "localhost:27018" } { "_id" : "shard02", "host" : "localhost:27019" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "test", "partitioned" : true, "primary" : "shard02" } test.myshard chunks: shard02 4 { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "t" : 1000, "i" : 1 } { "n" : 0 } -->> { "n" : 1 } on : shard02 { "t" : 1000, "i" : 3 } { "n" : 1 } -->> { "n" : 2 } on : shard02 { "t" : 1000, "i" : 5 } { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "t" : 1000, "i" : 6 }
  • 51. // mongos > db.adminCommand({moveChunk: "test.myshard", find: { n: 0 }, to: "shard00" }); { "millis" : 1051, "ok" : 1 } > db.adminCommand({moveChunk: "test.myshard", find: { n: 1 }, to: "shard01" }); { "millis" : 1046, "ok" : 1 } > db.adminCommand({moveChunk :"test.myshard", find: { n: 2 }, to: "shard02" }); { "ok" : 0, "errmsg" : "that chunk is already on that shard" }
  • 52. > db.printShardingStatus() --- Sharding Status --- sharding version: { "_id" : 1, "version" : 3 } shards: { "_id" : "shard00", "host" : "localhost:27017" } { "_id" : "shard01", "host" : "localhost:27018" } { "_id" : "shard02", "host" : "localhost:27019" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "test", "partitioned" : true, "primary" : "shard02" } test.myshard chunks: shard02 2 shard00 1 shard01 1 { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "t" : 3000, "i" : 1 } { "n" : 0 } -->> { "n" : 1 } on : shard00 { "t" : 2000, "i" : 0 } { "n" : 1 } -->> { "n" : 2 } on : shard01 { "t" : 3000, "i" : 0 } { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "t" : 1000, "i" : 6 }
  • 53. // mongos > for(var m=0; m<100; m++){ db.myshard.insert({n: m % 3}) } // n =0,1,2,0,1,... > printShardingSizes() // Shard ... test.myshard chunks: { "n" : { $minKey : 1 } } -->> { "n" : 0 } on : shard02 { "estimate" : false, "size" : 0, "numObjects" : 0 } { "n" : 0 } -->> { "n" : 1 } on : shard00 { "estimate" : false, "size" : 1224, "numObjects" : 34 } { "n" : 1 } -->> { "n" : 2 } on : shard01 { "estimate" : false, "size" : 1188, "numObjects" : 33 } { "n" : 2 } -->> { "n" : { $maxKey : 1 } } on : shard02 { "estimate" : false, "size" : 1188, "numObjects" : 33 }
  • 54. ~ mongo localhost:27017 > db.myshard.count() 34 > db.myshard.distinct("n") [ 0 ] ➜ ~ mongo localhost:27018 > db.myshard.count() 33 > db.myshard.distinct("n") [ 1 ] ➜ ~ mongo localhost:27019 > db.myshard.count() 33 > db.myshard.distinct("n") [ 2 ]
  • 57. > db.adminCommand( { addshard: "set00/delta1:27017,delta2:27017", name: "shard00" } ) { "shardAdded" : "shard00", "ok" : 1 } > db.adminCommand( { addshard: "set01/delta3:27018,delta4:27018", name: "shard01" } ) { "shardAdded" : "shard01", "ok" : 1 } > db.adminCommand( { addshard: "set02/delta5:27019,delta6:27019", name: "shard02" } ) { "shardAdded" : "shard02", "ok" : 1 }
  • 67. db.mycoll.mapReduce( map : <map >, reduce : <reduce > [, finalize : <finalize >] [, query : < >] [, sort : < reduce >] [, out : < >] [, scope : <object where fields go into javascript global scope >] );
  • 68. db.people.insert({userId:1, age:24, type:"A"}) db.people.insert({userId:2, age:47, type:"B"}) db.people.insert({userId:3, age:34, type:"C"}) db.people.insert({userId:4, age:4, type:"B"}) db.people.insert({userId:5, age:14, type:"A"}) db.people.insert({userId:6, age:29, type:"C"}) db.people.insert({userId:7, age:39, type:"C"}) db.people.insert({userId:8, age:42, type:"B"}) db.people.insert({userId:9, age:56, type:"A"}) db.people.insert({userId:10, age:12, type:"A"})
  • 69. m = function() { emit(this.type, { age: this.age, num: 1 } ); }
  • 70. r = function(key, values) { var result = { age: 0, num: 0 }; values.forEach( function(value){ result.age += value.age; // age result.num += value.num; // } ); return result; }
  • 71. r = function(key, values) { var num = 0; var sum = 0; values.forEach( function(value){ sum += value.age; // age num += value.num; // } ); return sum/num; }
  • 72. m = function() { emit(this.type, { age: this.age, num: 1 } ); } r = function(key, values) { var result = { age: 0, num: 0 }; values.forEach( function(value){ result.age += value.age; // age result.num += value.num; // } ); return result; }
  • 73. m = function() { emit(this.type, { age: this.age, num: 1 } ); } r = function(key, values) { var result = { age: 0, num: 0 }; values.forEach( function(value){ result.age += value.age; // result.num += value.num; // } ); return result; }
  • 74. f = function( key, result ){ result.avg = result.age / result.num; return result; }
  • 75. > res = db.people.mapReduce( m , r , { finalize : f , out : "mr_out", verbose: true }); { "result" : "mr_out", // "timeMillis" : 18, // "timing" : { "mapTime" : NumberLong(1), "emitLoop" : 12, "total" : 18 }, "counts" : { "input" : 10, // 10 "emit" : 10, // 10 emit "output" : 3 // 3 }, "ok" : 1, }
  • 76. > db.mr_out.find() { "_id" : "A", "value" : { "age" : 106, "num" : 4, "avg" : 26.5 } } { "_id" : "B", "value" : { "age" : 93, "num" : 3, "avg" : 31 } } { "_id" : "C", "value" : { "age" : 102, "num" : 3, "avg" : 34 } }
  • 77. > res = db.people.mapReduce( m , r , { finalize : f , out : "mr_out", query: { age: { $gte: 20 } } }); { "result" : "mr_out", "timeMillis" : 35, "counts" : { "input" : 7, // 3 "emit" : 7, "output" : 3 }, "ok" : 1, }
  • 78. > db.mr_out.find() // { "_id" : "A", "value" : { "age" : 80, "num" : 2, "avg" : 40 } } { "_id" : "B", "value" : { "age" : 89, "num" : 2, "avg" : 44.5 } } { "_id" : "C", "value" : { "age" : 102, "num" : 3, "avg" : 34 } }
  • 81. db.items.insert({ date: "2011-06-01", item: "apple", price: 100 }) db.items.insert({ date: "2011-06-01", item: "banana", price: 200 }) db.items.insert({ date: "2011-06-01", item: "apple" , price :100}) db.items.insert({ date: "2011-06-02", item: "orange", price: 50 }) db.items.insert({ date: "2011-06-02", item: "orange", price: 50 }) db.items.insert({ date: "2011-06-02", item: "apple", price: 100 })
  • 82. m = function() { emit(this.item, this.price); } r = function(key,values) { var result = 0; values.forEach( function(value){ result += value } ); return result; } > res = db.items.mapReduce( m, r, { query: {date: "2011-06-01"} , out: {replace: "mr_out2"}} ); { "result" : "mr_out2", "timeMillis" : 10, "counts" : { "input" : 3, "emit" : 3, "output" : 2 }, "ok" : 1, } >db.mr_out2.find() { "_id" : "apple", "value" : 200 } { "_id" : "banana", "value" : 200 }
  • 83. > res = db.items.mapReduce( m, r, { query: {date: "2011-06-02"} , out: {reduce: "mr_out2"}} ); { "result" : "mr_out2", "timeMillis" : 23, "counts" : { "input" : 3, "emit" : 3, "output" : 3 }, "ok" : 1, } > db.mr_out2.find() { "_id" : "apple", "value" : 300 } // { "_id" : "banana", "value" : 200 } // { "_id" : "orange", "value" : 100 } //