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

Discuss the JSON schema #278

Open
kltm opened this issue Oct 6, 2022 · 4 comments
Open

Discuss the JSON schema #278

kltm opened this issue Oct 6, 2022 · 4 comments
Assignees

Comments

@kltm
Copy link
Member

kltm commented Oct 6, 2022

Once we have a draft schema in place from #277, we need to hammer out the "final" schema that we'll be using for the ShEx transformation into useful products for applications.

@tmushayahama tmushayahama added question Further information is requested and removed question Further information is requested labels Oct 28, 2022
@tmushayahama
Copy link

just a quick thought @sierra-moxon @cmungall after yesterday's discussion about the schema, I realized the array/list might have minor performance issues because it is no longer a dict lookup and the consumer needs to do a search/find algorithms. an example below. However, if it is not a quick change schema, no worries,

1) The lookup type id always a key

This one getting a specific relation is a simple lookup O(1)

 "relationships": {
    "rel1": {
      "medatada": ...,
    },
    "rel2": {
      "metadata": ...,
   }
}

getRelationship(rel) {
    return relationships[rel]
}

**2) List needs searching the whole list O(n) to find and prune to duplicate ids **

 "relationships": [
    {
      "id": "rel1",
     "medatada": ...,
    },   {
     "id": "rel2",
     "medatada": ...,
    },
]

getRelationship(rel) {
   for (let i = 0; i < relationships.length; i++) {
      if (rel === relationshps[i].id) {
          return relationships[i];
       }
    }
}

It might be a tiny loop, but the 2 way binding of client its been called multiple times

@kltm
Copy link
Member Author

kltm commented Oct 28, 2022

For "1" and "2", I would expect that the UI logic could unwind any data structure to a constant time lookup on load. I don't think the list is that long in the first place; I would be surprised if there was a lag there that a user would notice either way. Is this something you've noticed?

@tmushayahama
Copy link

@kltm it hits hard. Unfortunately, it is not onLoad, but per binding lifecycle and since it is a form, it cycles a lot (textChange, blur, focus etc) . Preferably binding to constant lookup is desirable if possible than binding to function
So everytime we want to display 'part_of' metadata we just get the value straight up

<p>{{MFnode.relationships['part_of'].metadata}}</>

Than do a loop
<p>{{getRelationships(MFNode, 'part_of').metadata}}</>

Then now it's for every relation and it refreshes per lifecycle detect changes.

@kltm
Copy link
Member Author

kltm commented Oct 28, 2022

Ah, that's interesting, and a bit nasty--too bad. Can you make global data structures in this case to take care of this overhead as the JSON should be invariant?

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

No branches or pull requests

4 participants