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

Do not compact @graph arrays with one element to just the element #202

Closed
lanthaler opened this issue Dec 8, 2012 · 5 comments

Comments

@lanthaler
Copy link
Member

@lanthaler lanthaler commented Dec 8, 2012

In trying to simplify the compaction algorithms I realized that we probably shouldn't compact @graph arrays with just one element to the element. The reasoning behind it is that it is quite confusing when the value is a single IRI (yes, it's a free-floating node that should be avoided):

{
  "@context": {
    "foaf": "http://xmlns.com/foaf/0.1/",
    "ex": "http://property.com/"
  },
  "@id": "http://example.com/named/",
  "http://example.com/label": "Named graph",
  "@graph": "http://example.com/named/nodeInNamedGraph"
}

This suggests that the node http://example.com/named/ is in the named graph http://example.com/named/nodeInNamedGraph while it's actually the other way round.

The other advantage is that compacted documents become more deterministic as the value of @graph would always be an array:

{
   "@context": {
      "foaf": "http://xmlns.com/foaf/0.1/",
      "ex": "http://property.com/"
   },
   "@id": "http://example.com/named/",
   "http://example.com/label": "Named graph",
   "@graph": [
      {
         "@id": "http://example.com/named/nodeInNamedGraph",
         "http://example.com/label": "Node in a named graph"
      }
   ]
}

Please note, this doesn't affect the fact that the default graph's @graph is optimized away.

lanthaler added a commit that referenced this issue Dec 8, 2012
lanthaler added a commit that referenced this issue Dec 8, 2012
@lanthaler

This comment has been minimized.

Copy link
Member Author

@lanthaler lanthaler commented Dec 8, 2012

PROPOSAL 1: Keep values of @graph that are arrays consisting of just one element as arrays.

PROPOSAL 2: Do not compact "node references" that are values of @graph to strings.

The second proposal means that the first example above would compact to

{
  "@context": {
    "foaf": "http://xmlns.com/foaf/0.1/",
    "ex": "http://property.com/"
  },
  "@id": "http://example.com/named/",
  "http://example.com/label": "Named graph",
  "@graph": [
    { "@id": "http://example.com/named/nodeInNamedGraph" }
  ]
}
@gkellogg

This comment has been minimized.

Copy link
Member

@gkellogg gkellogg commented Dec 8, 2012

Does PROPOSAL 1 require adding steps to the compaction algorithm for @graph; right now, my version doesn't have any special treatment for @graph, and I don't see it in the current algorithm either. However, I think it's probably a good idea to do this in any case, as it makes it easier to deal with the results. So, I'm +1

PROPOSAL 2: +1

@lanthaler

This comment has been minimized.

Copy link
Member Author

@lanthaler lanthaler commented Dec 9, 2012

That depends on how you implemented it.. You could internally assign a @set-container to @graph

@lanthaler

This comment has been minimized.

Copy link
Member Author

@lanthaler lanthaler commented Dec 11, 2012

RESOLVED: Keep values of @graph that are arrays consisting of just one element as arrays.

RESOLVED: Do not compact "node references" that are values of @graph to strings.

lanthaler added a commit that referenced this issue Dec 20, 2012
@lanthaler

This comment has been minimized.

Copy link
Member Author

@lanthaler lanthaler commented Dec 20, 2012

I've updated all algorithms, unless I hear objections I will close this issue in 24 hours.

@lanthaler lanthaler closed this Dec 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.