Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out empty register in NodeToJson converter #15

Open
TanUkkii007 opened this issue Jan 14, 2017 · 0 comments
Open

Filter out empty register in NodeToJson converter #15

TanUkkii007 opened this issue Jan 14, 2017 · 0 comments

Comments

@TanUkkii007
Copy link
Contributor

Overriding causally dependent primitive value with empty list or map creates an empty register in document state.

val p0 = Replica
    .empty("p")
    .applyCmd(doc.downField("key") := "A")
    .applyCmd(doc.downField("key") := `[]`)
    .applyCmd(doc.downField("key").iter.insert("A"))
MapNode(
  Map(
    MapT(DocK) -> MapNode(
      Map(
        RegT(StrK(key)) -> RegNode(Map()),
        ListT(StrK(key)) -> ListNode(
          Map(
            RegT(IdK(Id(3,p))) -> RegNode(Map(Id(3,p) -> Str(A)))
          ),
          Map(IdK(Id(3,p)) -> Set(Id(3,p))),
          Map(HeadR -> IdR(Id(3,p)), IdR(Id(3,p)) -> TailR)
        )
      ),
      Map(StrK(key) -> Set(Id(2,p), Id(3,p)))
    )
  ),
  Map(DocK -> Set(Id(1,p), Id(2,p), Id(3,p)))
)

Converting documents that contain empty resister with last-writer-wins conflict resolver causes Exception: java.lang.UnsupportedOperationException: empty.max

This is because the empty register is viewed present as presSets has key "key" so JSON converter tries to convert the empty register to JSON value, which is impossible.

By the way Node#values query works correctly against empty register because it returns register's values that is empty. An implementation depends on Node states and does not use its query interface may hit this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant