objectbox / objectbox/objectbox-dart

Lazy loading wrapper

Open
#200 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs more interest
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

We could provide a Lazy<T> wrapper to improve loading large data. It could work similarly to ToOne relation wrapper, with value getter loading the content on-demand.

@Entity
TestEntity {
  int id;

  // current, non-lazy property
  String largeString;

  // suggested, lazy-loading wrapper
  Lazy<String> lazilyLoadedLargeString;
}

Not sure about storage though... With the current native API, we can't serialize partial object data (when .value wasn't set if the object is put()). The workaround would be to read the whole object before putting copy the binary data of the existing value without converting from & back to flatbuffers.

On the other hand, a similar thing can be achieved with ToOne already, it just means you have to an additional entity. However, that could actually also be the solution, with Lazy<> defining a non-accessible 1-to-1 relation ... there are many options and this isn't a priority at the moment (unless there's strong demand)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing ToOne relation wrapper and the native API's put() serialization path; the issue names no files or tests. Compare partial-object handling and flatbuffer copying before choosing whether Lazy<T> should be a wrapper or a hidden 1-to-1 relation. Done requires an agreed design and storage behavior, plus tests for loading and putting values.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.