Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Optimize storage with aliases #54

Closed
sidvishnoi opened this issue Oct 15, 2019 · 2 comments
Closed

Optimize storage with aliases #54

sidvishnoi opened this issue Oct 15, 2019 · 2 comments

Comments

@sidvishnoi
Copy link
Owner

sidvishnoi commented Oct 15, 2019

Presently, we alias methods with arguments to argument-less versions - as they're easier to link in documents. This leads to data duplication (wasted memory):
image

Also, the data is duplicated (not unique) with alias based search:

GET https://respec.org/xref/?term=add()&cite=indexeddb

image

Proposal:

type Term = string;
interface DataByTerm {
   $$aliases: Record<Term, Term[]>;
   $$data: Record<Term, DataEntry[]>;
}

Present:

{
  "add()": [
    {
      "type": "method",
      "spec": "indexeddb-2",
      "shortname": "indexeddb",
      "status": "current",
      "uri": "#dom-idbobjectstore-add",
      "for": ["IDBObjectStore"]
    },
    {
      "type": "method",
      "spec": "indexeddb-2",
      "shortname": "indexeddb",
      "status": "current",
      "uri": "#dom-idbobjectstore-add",
      "for": ["IDBObjectStore"]
    },
    {
      "type": "method",
      "spec": "css-font-loading-3",
      "shortname": "css-font-loading",
      "status": "current",
      "uri": "#dom-fontfaceset-add",
      "for": ["FontFaceSet"]
    }
  ],
  "add(value)": [
    {
      "type": "method",
      "spec": "indexeddb-2",
      "shortname": "indexeddb",
      "status": "current",
      "uri": "#dom-idbobjectstore-add",
      "for": ["IDBObjectStore"]
    }
  ],
  "add(value, key)": [
    {
      "type": "method",
      "spec": "indexeddb-2",
      "shortname": "indexeddb",
      "status": "current",
      "uri": "#dom-idbobjectstore-add",
      "for": ["IDBObjectStore"]
    }
  ],
  "add(font)": [
    {
      "type": "method",
      "spec": "css-font-loading-3",
      "shortname": "css-font-loading",
      "status": "current",
      "uri": "#dom-fontfaceset-add",
      "for": ["FontFaceSet"]
    }
  ]
}

Proposed:

{
  "$$data": {
    "add(value, key)": [
      {
        "type": "method",
        "spec": "indexeddb-2",
        "shortname": "indexeddb",
        "status": "current",
        "uri": "#dom-idbobjectstore-add",
        "for": ["IDBObjectStore"]
      }
    ],
    "add(font)": [
      {
        "type": "method",
        "spec": "css-font-loading-3",
        "shortname": "css-font-loading",
        "status": "current",
        "uri": "#dom-fontfaceset-add",
        "for": ["FontFaceSet"]
      }
    ]
  },
  "$$aliases": {
    "add()": ["add(font)", "add(value, key)"],
    "add(value)": ["add(value, key)"]
  }
}

Impact:

  • improved storage
  • better search results (no duplicates)
  • data will need to be re-parsed
  • search logic will have additional indirection
  • list of terms at /xref/meta/terms would require a little change (Object.keys($$data) + Object.keys($$aliases)
  • API will not be affected.
@marcoscaceres
Copy link
Collaborator

I've no objections to this. Seems like a good change.

@sidvishnoi
Copy link
Owner Author

Moved to speced/respec-web-services#152

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

No branches or pull requests

2 participants