MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / preload_database

Function preload_database

test/correctness/preload_database.py:192–226  ·  view source on GitHub ↗
(ns)

Source from the content-addressed store, hash-verified

190
191
192def preload_database(ns):
193 gen.generator_options.numeric_fieldnames = ns['no_numeric_fieldnames']
194 gen.generator_options.test_nulls = ns['no_nulls']
195
196 instance = random.random()
197
198 client = pymongo.MongoClient(ns['host'], ns['port'])
199 if (ns['collection'] == ''):
200 collection = client['test']['performance' + str(instance)[2:]]
201 else:
202 collection = client['test'][ns['collection']]
203
204 collection.remove()
205
206 i = 0
207 while i < ns['number']:
208 docs = []
209 for j in range(0, min(100, ns['number'] - i)):
210 i += 1
211 if ns['big_documents']:
212 doc = d.copy()
213 else:
214 doc = gen.random_document(False)
215 doc["boo"] = i
216 doc["_id"] = str(i)
217 docs.append(doc)
218 collection.insert(docs, safe=False)
219 print "Inserted " + str(i)
220
221 # collection.insert(docs)
222
223 # print [i for i in collection.find()]
224 print "Inserted " + str(ns['number']) + " documents"
225 print "Database: test"
226 print "Collection: " + ('performance' + str(instance)[2:] if ns['collection'] == '' else ns['collection'])
227
228
229if __name__ == "__main__":

Callers 1

Calls 3

removeMethod · 0.80
appendMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected