Skip to content

feat: add optimization for finding the best CURIE #82

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

michaeladler
Copy link
Contributor

Summary

This is a port of a performance optimization for framing objects, originally implemented in jsonld.js.

  • Build a map for searching for a matching IRI when computing the inverse context. Each letter of an IRI can be used to key into the map to find the best set of partial matches (which can be used to create CURIEs).
  • This approach is a faster alternative to trying each possible term in the active context as a possible CURIE, linearly, one at a time.

Motivation

This optimization significantly improves performance when framing a large number of objects. For example, when framing ~ 10,000 objects, it's almost twice as fast.

Checks

  • Passes make test

@kazarena
Copy link
Member

@michaeladler, thank you, will review asap.

@kazarena
Copy link
Member

@michaeladler, thanks again for submitting the pull request. It's a useful feature. I would appreciate if you fix 3 linter errors in the new code. I'll be happy to approve after that.

- Build a map for searching for a matching IRI when
  computing the inverse context. Each letter of an
  IRI can be used to key into the map to find the
  best set of partial matches (which can be used
  to create CURIEs).
- This approach is a faster alternative to trying each
  possible term in the active context as a possible
  CURIE, linearly, one at a time.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
@michaeladler michaeladler force-pushed the feat/fast-curie-map branch from 0750860 to 0c3dbf0 Compare May 28, 2025 07:25
@michaeladler
Copy link
Contributor Author

Yes of course, sorry I forgot to run the linter. It's fixed now.

@kazarena kazarena merged commit 49748f1 into piprate:master May 28, 2025
2 of 3 checks passed
@kazarena
Copy link
Member

Thank you. PR merged. I've also published a new release (v0.6.0) that contains your feature.

@michaeladler michaeladler deleted the feat/fast-curie-map branch May 29, 2025 07:21
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

Successfully merging this pull request may close these issues.

2 participants