void MergeDispatcher::start_play( SeekRange const & range, response_t const & seek_resp) { LOG_DEBUG("[start_play]"); dispatch_io_svc().post(MergeTask(task_info(), sink_group(), range, seek_resp, boost::bind(&MergeDispatcher::handle_play, this, _1), merger_)); }
MergeResult ThreeWayMerge::mergeKeySet (const KeySet & base, const KeySet & ours, const KeySet & theirs, const Key & mergeRoot) { Key ourkey = ours.head ().dup (); Key theirkey = theirs.head ().dup (); Key basekey = base.head ().dup (); MergeResult merged = mergeKeySet ( MergeTask (BaseMergeKeys (base, basekey), OurMergeKeys (ours, ourkey), TheirMergeKeys (theirs, theirkey), mergeRoot)); return merged; }
int MergingKDB::synchronize (KeySet & returned, Key & parentKey, ThreeWayMerge & merger) { try { // write our config int ret = KDB::set (returned, parentKey); // update our config (if no conflict) KDB::get (returned, parentKey); return ret; } catch (KDBException const &) { // a conflict occurred, see if we can solve it with the merger // refresh the key database KeySet theirs = returned.dup (); KDB::get (theirs, parentKey); // try to merge MergeResult result = merger.mergeKeySet (MergeTask (BaseMergeKeys (base, parentKey), OurMergeKeys (returned, parentKey), TheirMergeKeys (theirs, parentKey), parentKey)); if (!result.hasConflicts ()) { // hurray, we solved the issue KeySet resultKeys = result.getMergedKeys (); int ret = KDB::set (resultKeys, parentKey); base = resultKeys; return ret; } else { // nothing we can do anymore KeySet conflictSet = result.getConflictSet (); throw MergingKDBException (parentKey, conflictSet); } } }
MergeTask reverse () const { return MergeTask (BaseMergeKeys (base, baseParent), OurMergeKeys (theirs, theirParent), TheirMergeKeys (ours, ourParent), mergeRoot); }
void MergeDispatcher::start_buffer() { LOG_DEBUG("[start_buffer]"); dispatch_io_svc().post(MergeTask(task_info(), boost::bind(&MergeDispatcher::handle_buffer, this, _1), merger_)); }
void schedule_merge (Ob dep) { schedule(MergeTask(dep)); }