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

HiveError('Not all bytes have been used.') in Hive.init() #24

Closed
escamoteur opened this issue Aug 23, 2019 · 6 comments
Closed

HiveError('Not all bytes have been used.') in Hive.init() #24

escamoteur opened this issue Aug 23, 2019 · 6 comments

Comments

@escamoteur
Copy link

Hi,

I thought I give hive a try. It worked well when I only stored one short string; But after storing a longer JSON String I get this exeption in line 144 of your frame.dart.

The string in questions is 1665544 characters long.

Btw: I tried first to store the map without converting to json, but when readin back I only got one long string.

I hope you can fix this.

Cheers
Thomas

@simc
Copy link
Member

simc commented Aug 23, 2019

Hi,

Thanks for using Hive.

Wow you are trying to store a massive String 😆

Currently Hive only supports Strings with a max length of 2^16-1 bytes. (see Limitations)

The reason why I limited the max String length is that most of the Strings will be much shorter than the limit. This way the length can be stored in two bytes which saves disk space and improves performance.

I'll try to think of a way support storing longer Strings while still maintaining the benefits for smaller strings.

What kind of map did you try to store?

@escamoteur
Copy link
Author

But binary do you store with more bytes right?

Honestly forget to save 2 bytes per String, it doesn't make sense compared to other data on an SD card.

I tries to store the map that I get back from jaguar_serializer, but its a nested map if I think about it don't know if Hive can deal with that.

Cheers
Thomas

@simc
Copy link
Member

simc commented Aug 23, 2019

But binary do you store with more bytes right?

Currently not but I plan to change that. I need to run a few benchmarks before tho.

Honestly forget to save 2 bytes per String, it doesn't make sense compared to other data on an SD card.

Sorry I don't quite understand. Could you please rephrase that?

I tries to store the map that I get back from jaguar_serializer, but its a nested map if I think about it don't know if Hive can deal with that.

Nested maps should be no problem. But they have to be below 2^16-1 bytes.

@escamoteur
Copy link
Author

Ah I guess that was the problem

I meant just use 4 bytes per entry. It really doesn't matter on todays phones

@simc
Copy link
Member

simc commented Aug 23, 2019

Yeah you are probably right. I'll change that with the next update. This means another breaking change of the binary format.
But I think nobody uses Hive in production yet...

@simc
Copy link
Member

simc commented Aug 31, 2019

The limitations have been removed with version 0.5.0.

But it seems like lazy boxes have a problem with very long lists. I'm working on a fix.

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

No branches or pull requests

2 participants