This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hadoop jar mongo-hadoop-streaming-assembly*.jar -mapper mapper.rb -reducer reducer.rb -inputURI mongodb://127.0.0.1/twitter.in -outputURI mongodb://127.0.0.1/twitter.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* sample aggregate command queries */ | |
// make sure we're using the right db; this is the same as "use mydb;" in shell | |
db = db.getSisterDB("aggdb"); | |
// just passing through fields | |
var p1 = db.runCommand( | |
{ aggregate : "article", pipeline : [ | |
{ $project : { | |
tags : 1, | |
pageViews : 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make sure we're using the right db; this is the same as "use aggdb;" in shell | |
db = db.getSiblingDB("aggdb"); | |
// simple projection | |
var p1 = db.runCommand( | |
{ aggregate : "article", pipeline : [ | |
{ $project : { | |
tags : 1, | |
pageViews : 1 | |
}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getSiblingDB("admin"); | |
var databases = null; | |
databases = db.runCommand("listDatabases"); | |
if(databases){ | |
for(var i=0;i<databases.databases.length;i++){ | |
//TODO skip if it's the admin database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getSiblingDB("admin"); | |
var databases = null; | |
databases = db.runCommand("listDatabases"); | |
if(databases){ | |
for(var i=0;i<databases.databases.length;i++){ | |
//TODO skip if it's the admin database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env mongo --quiet | |
var m = new Mongo(); | |
var db = m.getDB('test'); | |
var t = db.getCollection('whatever'); | |
t.find( { group:3, 'x.a':1 }, { 'x.$':0 } ); | |
printjson(db.getLastErrorCmd()); | |
assert.eq( 16345, db.getLastErrorCmd().code, "exclusion of positional operator" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wed Jul 4 13:23:37 [conn1587] end connection 127.0.0.1:50894 (5 connections now open) | |
Wed Jul 4 13:23:37 [conn1581] end connection 127.0.0.1:50888 (4 connections now open) | |
Wed Jul 4 13:23:37 [conn1589] end connection 127.0.0.1:50896 (3 connections now open) | |
Wed Jul 4 13:23:37 [conn1591] end connection 127.0.0.1:50898 (2 connections now open) | |
Wed Jul 4 13:23:42 [conn59] CMD fsync: sync:1 lock:1 | |
Wed Jul 4 13:23:43 [fsyncLockWorker] removeJournalFiles | |
Wed Jul 4 13:23:43 [conn59] db is now locked for snapshotting, no writes allowed. db.fsyncUnlock() to unlock | |
Wed Jul 4 13:23:43 [conn59] For more info see http://www.mongodb.org/display/DOCS/fsync+Command | |
Wed Jul 4 13:23:43 [conn59] command admin.$cmd command: { fsync: 1.0, lock: true } ntoreturn:1 keyUpdates:0 locks(micros) W:10958 r:1268 reslen:168 699ms | |
Wed Jul 4 13:23:44 [conn59] CMD fsync: sync:1 lock:1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongo' | |
require './model/mongoModule' | |
require './model/user' | |
if ENV['RACK_ENV'] == 'production' | |
CONNECTION = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']) | |
else | |
CONNECTION = Mongo::Connection.new("localhost", 27017) | |
end | |
DB = CONNECTION.db('milieu') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Monitor | |
def initalize | |
puts "whatup" | |
@thread = Thread.new { | |
loop do | |
puts "ReplSetMonitor refreshing!" | |
sleep(1) | |
end | |
} | |
end |