63
possibilityisworkable,itmakesthedefinitionofthebasicdatastructuremuchmore
complicated,andpresentsadifficultuser-interfaceproblem.Howshouldaprogramindi-
catethatsomenumberofsequentialitems(substringsinatext,forinstance)areinfact
unorderedwithrespecttoeachother?Thisoptionrespectsexactlytheinformation
available,butcomplicatestheapplicationdatamodelseverely,byallowingsequences
thatarenon-sequential,atleastinpart.
Usesomearbitraryorderingtoresolvetheconflict.Thisoptioncanbeimplementedas
longassometotalorderrelationbetweenchangescanbefound.Thiscouldbebasedon
timestamps,inareal-timecollaborationsituation,possiblysupplementedbyoneofthe
manyheuristicsforchoosinguniqueIds.Forinstance,theycouldbelexicographically
orderedaccordingtoawell-definedbinaryrepresentation.Becausesucharepresentation
islikelytobeverylong,acryptographichashofitwouldserveaswell.Whileahashal-
gorithmlikeMD5(Rivest1992)canprovideonlyaprobabilisticguaranteeofuniqueness,
inpracticetheprobabilityoffailureisvanishinglysmall.
Thisisnottheonlytimewewillusesomerelativelyarbitraryorderingtoresolveacon-
flict.Wheneverthishappensthereisonlyonestrongrequirement.Theorderingchosenmust
becalculablebyaprogramgivennootherinformationthanthetwochangesinconflict.In
thecaseofconflictinginsertionpoints,thestrategyofusinguniqueIdsmeetsthisrequire-
ment,butdoesimposeanadditionalrequirementonanyimplementation:thatastrategybe
chosenandimplementedtoreliablydeterminesuchIdsatnon-communicatingsites.
3.3.2 Point/rangeconflicts(foralloperations)
Sincepointoperationsalwaysinsertdataatthepoint,therearetwobasiccasestocon-
sider,dependingonwhetherthecontentsoftherangearetobedeleted(asbymoveand
delete),orduplicatedelsewhere(asbycopyandmove).Inthecaseofarangethatisbeing
deleted,thereisonlyonegoodchoice,outoftwopossibilities:thedatainsertedatthe
pointshouldbeignored,sincethedeletionhasremovedthecontextaroundthepoint.Al-
64
ternatively,thedatacouldbeallowedtoremaininplace,eventhoughitscontextisdeleted.
Thisseemssuperficiallyattractiveinthecaseofasinglemergeoperation,sinceitdoesnot
allowtheinserteddatatosilentlyvanish,butitisabadideainanoperationallycomplete
system.Ifthissemanticswereadopted,anapplicationtryingtodeletearangecontaining
datafromseveralinsertionpointswouldhavetospecifyeachportionofthedesiredrange
thatintersectedwithanyoftheinsertionchangesinitsdesiredrange.
Inthecaseofarangewhosedataisbeingreplicatedelsewhere,therearealsotwo
choices:Eithertheinsertionshouldbevisibleinthecopiedsubsequenceatitsdestination,
oritshouldnot.Exactlythesameproblemthatwehavejustseenoccursindifferentformif
theinsertionisnotvisibleatthedestination.Anapplicationdesiringtospecifyanentire
subsequencewouldberequiredtodetermine,andexplicitlyinclude,everyinsertionpointin
theaffectedrange.Thisalsoreducestheflexibilityofamergeoperation,sinceeditsmadeto
asourcerangewouldfailtopropagateiftheywerenotexplicitlymentionedinthatrange.
Thesetwocaseshighlightageneralprincipleinconflictresolution.Oneofthegreatad-
vantagesofthesequencestructureisthatoperationsthatareappliedtorangesshould,in
generalapplytoeverythingwithinthatrange.Thepoweroftherangeconceptisessentially
thatitallowstheuseoftwoorderedpointstorefertoalargenumberofelements(thesub-
sequence),anditsindividualhistoryasexpressedbytheoperationsthatcreateit.Becausethe
systemischange-complete,theoperationsinthathistorymaybedifferentindifferent
statesofthesequence(dependingonwhatchangesarecurrentlyactive),andoperations
shouldhavethemaximumeffectpossiblewithoutcompromisingtheabilitytouserangesas
awaytospecifyextentsofeffect.
Inthecaseofdelete,themostflexibleoption(andtheonlyonethatpreservesthebasic
conceptoftherange)istohavedeletiontakepriorityoveranyoperationthataddsdatain
themiddleofthedeletedrange,whileinthecaseofthecopyingofdata,thegreatestflexi-
Previous Page Next Page