Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Timing test is done for mongod running on psanaphi105 and scripts on psanagpu106.

Initialization

Code Block
titleInitialization MongoDB and GridFS
collapsetrue
import gridfs
from pymongo import MongoClient
#client = MongoClient('localhost')
client = MongoClient('psanaphi105', 27017)
db = client['calib-cxi12345']
fs = gridfs.GridFS(db)
col = db['camera-0-cxids1-0']

...

Code Block
titlePreparation of document with metadata and insertationinsert
collapsetrue
doc = {
   "experiment": "cxi12345",
   "run": 126,
   "detector": col.name,
   "ctype": "pedestals",
   "data_size":  nda.size,
   "data_shape": nda.shape,
   "data_type":  str(nda.dtype),
   "data_id":    ida,
	...
}
doc_id = col.insert_one(doc).inserted_id

...

Insert metadata time 0.5-0.6ms.

Get

Code Block
titleFind and get document
collapsetrue
docs = col.find({"time_stamp" : "2018-01-25T09:33:10PST"})
doc = docs[0]

Metadata find and get time: 0.7ms

Code Block
titleGet data from fs
collapsetrue
s = fs.get(doc['data_id']).read()
nda = gu.np.fromstring(s)

...