msg("<b>could not get the to-database.");
return;
}
// Prepare
final Driver fromDriver = fromDb.getDriver();
final Driver toDriver = toDb.getDriver();
Set<String> collnames = fromDb.getCollnames();
// Statistics
int countCollCurrent = 0;
int countCollTotal = collnames.size();
// Do it!
long before = System.currentTimeMillis();
msg("<i>Now copying database with <h>%d <i>collections.", countCollTotal);
for (String collname : fromDb.getCollnames())
{
countCollCurrent++;
final Coll<?> fromColl = new Coll<Object>(collname, Object.class, fromDb, MCore.get());
final Coll<?> toColl = new Coll<Object>(collname, Object.class, toDb, MCore.get());
Collection<String> ids = fromDriver.getIds(fromColl);
msg("<i>Now copying collection <h>%d/%d %s <i>with <h>%d <i>documents.", countCollCurrent, countCollTotal, collname, ids.size());
for (String id : ids)
{
Entry<JsonElement, Long> data = fromDriver.load(fromColl, id);
toDriver.save(toColl, id, data.getKey());
}
}
long after = System.currentTimeMillis();
long duration = after - before;
msg("<g>The copy is now complete. <i>It took <h>%dms<i>.", duration);