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

A new chapter: Hive v4 #1225

Open
simc opened this issue Aug 1, 2023 · 49 comments
Open

A new chapter: Hive v4 #1225

simc opened this issue Aug 1, 2023 · 49 comments
Labels
enhancement New feature or request

Comments

@simc
Copy link
Member

simc commented Aug 1, 2023

Dear Hive Community,

I'd like to apologize for my lack of support and updates for Hive over the past year. Despite this, your commitment to the community has ensured that the package is still in a remarkably good state, and for that, I'm incredibly grateful.

As many of you know, I have spent a lot of time optimizing Isar to be as fast, reliable, and fun to use as possible. However, I recognize that a lot of you truly appreciate the simplicity of Hive. The thought of discontinuing Hive did cross my mind, but I now see a much more constructive way forward:

Over the next several weeks and months, I plan to invest my energy into the development of Hive v4. The primary focus will be to maintain the user-friendly interface and feature set that you've come to love. However, instead of continuing with the custom storage engine that has been causing several issues, we will transition Hive's data storage to Isar.

This significant change comes with several exciting advantages, including support for multiple isolates, significantly improving resource efficiency and reducing startup time, among others. Moreover, this will simplify the maintenance of Hive, ensuring its longevity through sustained support.

I cannot thank you enough for your continued support and use of Hive. Together, let's continue to make it a tool we all love and rely on. 💜

Simon

@simc simc added problem An unconfirmed bug. enhancement New feature or request and removed problem An unconfirmed bug. labels Aug 1, 2023
@simc simc pinned this issue Aug 1, 2023
@Zchandev
Copy link

Zchandev commented Aug 4, 2023

Great news!

I love Isar, but I also still use Hive in the same project, because it's just a simple key-value storage.

I use it to store cache, counters, json responses, lists and maps. I don't need complex stuff like indexes and queries, because I already have that data in isar.

@themisir
Copy link
Contributor

themisir commented Aug 7, 2023

Hey Simon, thanks for an update! I am wondering what's your plans regarding storage migration. How do you think to handle the transition to make sure existing applications won't lose any data.

Also considering both hive and isar has (or had) their own way of encoding data types, not sure about isar, but hive also have support for writing custom encoders/serializers. What's the plan for migrating them?

@simc
Copy link
Member Author

simc commented Aug 9, 2023

I am wondering what's your plans regarding storage migration.

That's indeed the biggest problem to solve. I think the best approach for now is to let the hive generator generate migration code.

For custom encoders & decoders I didn't find a solution yet. Maybe we can just deprecate them and ask users who rely on them to stay on Hive v2

@themisir
Copy link
Contributor

themisir commented Aug 9, 2023

Are you planning to support database queries like Isar does? If so, then it's tough, I don't have an idea to create smooth migration plan.

If not (only key to value lookups), maybe we can continue using the existing hive generated (and custom) encoders to encode structs into byte stream and store it within isar with its respective key.

@jamesdixon
Copy link

This is really exciting news!

Are you planning to support database queries like Isar does? If so, then it's tough, I don't have an idea to create smooth migration plan.

In my opinion, a migration to Isar as the data store should focus solely on that and leave out advanced functionality that Isar could provide. That simplifies the migration and maintains the simplicity of Hive. If you need more advanced functionality, using Isar directly is likely a better fit.

@simc
Copy link
Member Author

simc commented Aug 14, 2023

Are you planning to support database queries

In my opinion, a migration to Isar as the data store should focus solely on that

Yeah agreed! I think Hive has a good feature set and if someone is looking for queries, Isar should be used directly. The only feature I think would be valuable for Hive is (optional) atomic transactions.

@simc
Copy link
Member Author

simc commented Aug 21, 2023

I merged my work in the main branch. Check it out and provide feedback please 💜

@t-kozak
Copy link

t-kozak commented Aug 21, 2023

Hey @simc , that plan sounds great!

I wanted to use Isar but decided to stick with Hive, as Hive supports Flutter on the web. With the migration to Isar as the engine for Hive, will it still work over IndexedDB?

@holocronweaver
Copy link

holocronweaver commented Aug 22, 2023

This is promising, but I have a few questions.

Is there a list of things that Hive v4 will lack vs. v2?

Will there be a v2 support branch if v4 will not have feature parity?

Also what of Hive v3, is it being abandoned?

BTW, thanks for all this work! Glad to hear Hive will live on in one form or another.

@simc
Copy link
Member Author

simc commented Aug 22, 2023

With the migration to Isar as the engine for Hive, will it still work over IndexedDB?

No. Isar web uses SQLite compiled to WASM and so will Hive.

Is there a list of things that Hive v4 will lack

I don't think there is anything Hive v4 will lack. The API is almost identical with a few minor differences.

Edit: HiveObject and HiveList will be removed.

Also what of Hive v3, is it being abandoned?

To my knowledge Hive v3 was never released as a stable version and I don't have time to maintain it unfortunately.

@simc
Copy link
Member Author

simc commented Aug 22, 2023

I published the first version of Hive v4 and I'd love to hear your feedback

@978bobs
Copy link

978bobs commented Aug 23, 2023

Does "No more code generation" mean that we don't need to reference a generated file like part 'main.g.dart';?

If so sounds pretty good. As a follow-on, does this also hold for Isar 4.0?

@t-kozak
Copy link

t-kozak commented Aug 24, 2023

@simc, thanks for reply. Can you confirm that given this issue: isar/isar#1362 (Isar on the web supports only in-memory sqlite), in practice, Hive v4 cannot be used as a persistency service on the web?

@simc
Copy link
Member Author

simc commented Aug 24, 2023

Not right now that's correct @t-kozak. I hope to implement that before a stable release

@pishguy
Copy link

pishguy commented Sep 1, 2023

Because MY_APP depends on hive ^4.0.0 which doesn't match any versions, version solving failed.

You can try the following suggestion to make the pubspec resolve:

  • Consider downgrading your constraint on hive: flutter pub add hive:^2.2.3

@sprimm98
Copy link

sprimm98 commented Sep 2, 2023

@pishguy You can use hive: ^4.0.0-dev.2 to get access to the pre-release :)

@jamesdixon
Copy link

@simc we're working on testing this and noticed that it's leveraging Isar 4 Alpha. Any timeline on Isar 4 getting to stable? Also, any chance that Hive 4 could leverage Isar 3?

@Yetispapa
Copy link

Hi @simc,

First of all, I want to express my sincere appreciation for all your hard work on Hive and the dedication you've shown to the community. Hive has been an invaluable tool for me, and I'm excited to see its future unfold with Hive v4.

I'm sure many of us are eager to get our hands on the new Hive v4. Do you have a rough estimate of when we can expect a release candidate or a beta version?

Lastly, cheers from Munich! 🍻

Looking forward to Hive's continued evolution and success.

@rivella50
Copy link

@simc Do you have any rough time schedule when a stable release for Hive v4 will be available?

@sonysm
Copy link

sonysm commented Feb 6, 2024

Please make it happen i can't wait to see Hive V4.0.0 official release

@Macacoazul01
Copy link

@simc Do you have any rough time schedule when a stable release for Hive v4 will be available?

At the same week US starts using metric system 👀.

@giridat
Copy link

giridat commented Feb 28, 2024

LGTM!

@stavgafny
Copy link

Hi @simc,
I tried the v4 pre release version(^4.0.0-dev.2) and its absolutely awesome, registering the type with its .fromJson method is such an elegant way.
I really want to use it on my app and just wondering when will there be stable release.
If its still got time can you maybe specify how unstable it is? I would love to switch to that for an Android app I'm working on.

Anyway thanks for making this amazing package.

@Rexios80
Copy link

I have a PR built on Hive v2 that supports Flutter web WASM if anyone wants to try it: #1291

I know it's not really relevant to this discussion, but I figured people with notifications turned on for this issue might be interested.

@xxxIxxxx
Copy link

flutter: 3.19.6
hive: ^4.0.0-dev.2
isar_flutter_libs: ^4.0.0-dev.14
path_provider: ^2.1.0

static Box  settingBox = Hive.box(name: "setting", maxSizeMiB: 128);

When I call settingBox.clear();, the data is indeed cleared, and after restarting the app, there is no data. However, in the sandbox, the .isar size is 20MB, and I noticed that almost all .isar files are 20MB in size, but I'm sure the data they store is less than 1MB. Why is this happening?

some error

"DbError (12): Cannot allocate memory"

I am sure that the phone has enough RAM and enough disk storage space.

carsh in:

case ERROR_DB_FULL:
       throw DatabaseFullError();
     default:
       final length = IsarCore.b.isar_get_error(IsarCore.stringPtrPtr);
       final ptr = IsarCore.stringPtr;
       if (length != 0 && !ptr.isNull) {
         final error = utf8.decode(ptr.asU8List(length));
         throw DatabaseError(error);

@Fethi-Hamdani
Copy link

Any updates V4 stable release?

@Rexios80
Copy link

For anyone still on v2, I released hive_ce that supports WASM compilation and Sets. Also the hive_ce_generator generates a HiveRegistrar extension so you can register all your adapters in one call (and not forget to register new ones like I used to every single time):

import 'package:your_package/hive_registrar.g.dart';

void main() {
  final path = Directory.current.path;
  Hive
    ..init(path)
    ..registerAdapters();
}

@mrasityilmaz

This comment was marked as resolved.

@azmasamy
Copy link

azmasamy commented Aug 8, 2024

hive_flutter: ^1.1.0 hive: ^2.2.3

Hive is not persisting data after flutter mobile app gets terminated.. Is there any solution for this ?? @simc

Flutter secured storage

@rivella50
Copy link

I switched to objectbox recently.

@Rexios80
Copy link

Rexios80 commented Aug 8, 2024

I just use hive_ce since that was easier than migrating to an entirely different storage solution

@mrasityilmaz
Copy link

mrasityilmaz commented Aug 8, 2024

I just use hive_ce since that was easier than migrating to an entirely different storage solution

Actually, it's not different, it's just a package with a different name that contains traces of each version of Hive.
I recommend the Hive 4.x.x and my Hive extension https://pub.dev/packages/bee_hive

Also Hive 4.x.x doesn't need any generator.

@Rexios80
Copy link

Rexios80 commented Aug 8, 2024

I'm the maintainer of hive_ce so I know what it is. I have many apps that are using Hive v2 in production, and I see no easy way to migrate to v4. Even if there was a way to migrate from v2 to v4, I have little to no faith in the future support of Hive. Please do not recommend using Hive v4 in production applications. I wouldn't even recommend using hive_ce for new projects unless you intend to contribute.

I am aware of Hive v4 not requiring code generation, but you lose the efficient binary storage of Hive v2 which was like... the entire point of choosing Hive over other options...

@mrasityilmaz
Copy link

I'm the maintainer of hive_ce so I know what it is. I have many apps that are using Hive v2 in production, and I see no easy way to migrate to v4. Even if there was a way to migrate from v2 to v4, I have little to no faith in the future support of Hive. Please do not recommend using Hive v4 in production applications. I wouldn't even recommend using hive_ce for new projects unless you intend to contribute.

I am aware of Hive v4 not requiring code generation, but you lose the efficient binary storage of Hive v2 which was like... the entire point of choosing Hive over other options...

Actually, I'm not fully aware of the advantages of binary storage. But based on my research, I believe the new Hive may be faster than the old one.

@Rexios80
Copy link

Rexios80 commented Aug 8, 2024

Actually, I'm not fully aware of the advantages of binary storage. But based on my research, I believe the new Hive may be faster than the old one.

Well it doesn't really matter if it's a dead package

@mrasityilmaz
Copy link

Actually, I'm not fully aware of the advantages of binary storage. But based on my research, I believe the new Hive may be faster than the old one.

Well it doesn't really matter if it's a dead package

Okay, I respect your decisions.
Good luck

@rivella50
Copy link

do you face any issue while application move to terminate state?? on restart does it restore previous save data ??

@appconsultio Sure it does, and tbh i would be suprised if hive wouldn't do that too. Are you sure you're doing everything correctly on app startup?

@oscarshaitan
Copy link

I'm still using Hive and is working fine after phone restart or crash, the only place I have issues is on web.
@Rexios80 at this point I'm considering moving away from hive. do hive_ce has any improvement for web? I love the binary storage, but if the phone is a budget phone and you have stored a massive Box the app could suffer opening if you open that box in launch.

@Rexios80
Copy link

Rexios80 commented Aug 9, 2024

@oscarshaitan
hive_ce supports Flutter web WASM compilation which drastically improves performance.

If you're having issues opening boxes on startup, does making them lazy help?

@oscarshaitan
Copy link

@oscarshaitan hive_ce supports Flutter web WASM compilation which drastically improves performance.

If you're having issues opening boxes on startup, does making them lazy help?

Yes Im thinking on moving some to lazy.

I'm going to join to your discord so I can make more questions there

@tomvanoost
Copy link

@simc Thank you for all the great work. Any idea when we can expect a release version of Hive v4 based on Isar?
Would it be possible to execute queries on a Hive box using Isar?

@vishnuagbly
Copy link

I believe @simc has stopped supporting this package. The sad truth of the Open-Source Community is that we do not get paid, and hence the wobbly support for packages.

@nhCoder
Copy link

nhCoder commented Oct 1, 2024

RIP peace dear Bees

@chunghei0116
Copy link

Can someone suggest alternative since the V4 is dead now.

@vizakenjack
Copy link

Can someone suggest alternative since the V4 is dead now.

I use Hive Community Edition:
https://pub.dev/packages/hive_ce

@chunghei0116
Copy link

Can someone suggest alternative since the V4 is dead now.

I use Hive Community Edition: https://pub.dev/packages/hive_ce

I love the way Hive V4 does, code-gen make the folder a bit messy tbh

@Rexios80
Copy link

@chunghei0116
I'm the maintainer of hive_ce

Doesn't Hive v4 still need code-gen from json_serializable to work?

Also I'm making code-gen much better in this PR. With that change, you only need one generated adapters file per project. You can see how it works in the updated README. I'm waiting on feedback from users to release the feature. If you could try it out and put any feedback in a comment on that PR that would be very helpful!

@chunghei0116
Copy link

@Rexios80

Thank you for your contribution! I’ll definitely give it a try in my new project. Since I’m currently working on an enterprise project, I need a stable and well-maintained package. Cheers!

@Rexios80
Copy link

Rexios80 commented Nov 1, 2024

@chunghei0116

I just benchmarked Hive v2 vs v4 and the results are... not looking good...

Here's the PR for the benchmark if you want to check it out: IO-Design-Team/hive_ce#43

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

No branches or pull requests