简体   繁体   English

为什么Google Docs的操作转换在删除方面有误?

[英]Why does Google Docs operational transformation err on the side of deletion?

Tried out this experiment today: opened two offline editors for a Google document. 今天尝试了这个实验:为Google文档打开了两个离线编辑器。 In one, I bolded the first word. 在其中一个,我加粗了第一个字。 In the second, I deleted it. 在第二个,我删除了它。 Regardless of which client I turn on first, the word always ends up deleted. 无论我先打开哪个客户端,该字总是会被删除。

First off, why is this the case - my understanding of operational transformation is that ordering matters? 首先,为什么会这样 - 我对运营转型的理解是订购问题? In the simple example of two people typing "a" and "b" respectively, if the server receives "a" first, it will enforce the output of "ab" by transforming the second person's "b" event into a "pass one space, then add b" event, and vice versa. 在两个人分别输入“a”和“b”的简单例子中,如果服务器首先接收“a”,它将通过将第二个人的“b”事件转换为“通过一个空格”来强制执行“ab”的输出。 ,然后添加b“事件,反之亦然。

Secondly, if ordering doesn't matter, are there technical reasons as to why Google Docs has chosen to err on the side of deletion? 其次,如果排序无关紧要,是否存在技术原因导致Google Docs选择在删除方面犯错? Or are the reasons largely simplicity for users? 或者用户的原因很简单?

OT does not try to discern intent, it applies transformations in an order which produces a consistent result. OT不会尝试辨别意图,它会按照产生一致结果的顺序应用转换。 When you apply both of those changes to a document, it does not matter which order you apply them in. 将这两个更改应用于文档时,将它们应用于哪个顺序无关紧要。

"first second" -> "first second " -> "first" “第一秒” - >“第一 ” - >“第一”

"first second" -> "first" -> "first" “第一秒” - >“第一” - >“第一”

In the second stream, the bold operation is performed on a zero-length string. 在第二个流中,对零长度字符串执行粗体操作。

This is the exact same result you would get if in one of those documents you had italicized the second word: the end result would be "first second " regardless of transformation order. 如果在其中一个文档中您使用斜体字表示第二个单词,则会得到完全相同的结果:无论转换顺序如何,最终结果都是“第一 ”。 Delete transformation is no different. 删除转换也不例外。

Here is (5 years later I know) a graphical explanation of whats going on (which is in fact what @osma describes but graphically explained): 这是(5年后我知道)对正在发生的事情的图解说明(实际上是@osma所描述的,但是以图形方式解释):

When you bold a string in GDocs you are actually wrapping the string into a container, presumably <strong></strong> but they may use any other syntax. 当您在GDocs中加粗字符串时,实际上是将字符串包装到容器中,可能是<strong></strong>但它们可能使用任何其他语法。 For simplicity lets just say that bold'ing a string just requires a "+" at the beginning of the word. 为简单起见,我们只想说一个字符串的粗体只需要在单词的开头加一个“+”。 So that the text "lorem ipsum" would become lorem +ipsum and not lorem <something>ipsum<something> 所以文本“lorem ipsum”将成为lorem +ipsum而不是lorem <something>ipsum<something>

1 1

Both Alice and Bob have the starting text "Lorem ipsum" 爱丽丝和鲍勃都有起始文本“Lorem ipsum” 在此输入图像描述

2 2

Then bob deletes "ipsum". 然后鲍勃删除“ipsum”。 Notice that what he sends to the server is the changeset retain(6), delete(5) . 请注意,他发送给服务器的是changeset retain(6), delete(5) A changeset is essentially a patch, and its structure is very likely based on this library . 变更集本质上是一个补丁,其结构很可能基于此库 在此输入图像描述

3 3

And Alice bolds "ipsum" (adding "+"). 爱丽丝大胆地说“ipsum”(加上“+”)。 Notice that what she sends is the changeset retain(6), insert(+), retain(5) 请注意,她发送的是变更集retain(6), insert(+), retain(5) 在此输入图像描述

4 4

Both changeset are traveling now to the server who knows nothing about these changesets yet. 这两个变更集现在都在前往服务器,而服务器对这些变更集一无所知。 在此输入图像描述

5

Assuming the worst scenario: Bob's package arrives first and then the word will be deleted. 假设最糟糕的情况:Bob的包首先到达,然后该单词将被删除。 (The other scenario is obvious). (另一种情况很明显)。 在此输入图像描述

6 6

When Alice's package arrives, it will only add a "+" to the text because what she sent is only a changeset . 当Alice的包裹到达时,它只会在文本中添加“+”,因为她发送的内容只是一个变更集 在此输入图像描述

7 7

Both texts are changesets are broadcasted to the clients. 两个文本都是变更集,广播给客户。 This is the first one. 这是第一个。 在此输入图像描述

8 8

And this is the second one. 这是第二个。 在此输入图像描述

9 9

After patching these changesets into the original text you end up with "Lorem +". 将这些变更集修补到原始文本后,最终会出现“Lorem +”。 This symbol is later erased by an common HTML clean process which eliminate any tag with the format <tag></tag> , 此符号后来被一个常见的HTML清理过程删除,该过程消除了格式为<tag></tag>任何标记,

在此输入图像描述

To test this demo go to: http://operational-transformation.github.io/visualization.html . 要测试此演示,请访问: http//operational-transformation.github.io/visualization.html There you can play with the texts and packages as they are sent/received. 在那里,您可以在发送/接收时播放文本和包。

It's not a question of erring on the side of deletion. 这不是在删除方面犯错的问题。

In cases where both clients have equality valid but differing versions of truth, Google Docs must elect to uphold one version, or else force users to resolve conflicts, something that is inherently complicated and hard to explain. 如果两个客户都有平等有效但不同的真实版本,Google Docs必须选择维护一个版本,否则强迫用户解决冲突,这本身就很复杂,难以解释。

Thus, "truth" for Google Docs is consistency of the document, not discernment of intent. 因此,Google Docs的“真相”是文档的一致性,而不是意图的辨别力。 And consistency is best more easily achieved through destruction of information - a sort of tendency to entropy. 通过破坏信息最好更容易实现一致性 - 这是一种熵的倾向。

All this is basically my semi-philosophical BS though... 所有这些基本上都是我的半哲学学士学位......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果简单地将操作转换视为纯文本,那么操作转换是否适用于HTML等结构化文档 - Does operational transformation work on structured documents such as HTML if simply treated as plain text? Google文档共享如何工作? - How does google docs sharing work? 您如何编写基于网络的实时协作工具,例如 google docs? - How do you write a real-time webbased collaboration tool such as google docs? 什么样的服务器进行操作转换操作? - What kind of server for operational transform operations? 谷歌如何收集推文? - How does google collect tweets? MATLAB中的实时语音转换 - Real time speech transformation in MATLAB 为什么 cmsis 要求最大优先级为 64 - why does cmsis oblige a max of priorities of 64 Google Analytics(分析)不实时显示“事件价值”吗? - Google analytics does not show Event Value in real-time? Google App Engine为从Java应用程序到客户端的实时数据传输提供了什么? - What does Google App Engine provide for realtime data transfer from java app to your client? RTCweb服务器端实现 - RTCweb server side implementation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM