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

Is Hive surpport transaction? #66

Closed
leedstyh opened this issue Oct 2, 2019 · 10 comments
Closed

Is Hive surpport transaction? #66

leedstyh opened this issue Oct 2, 2019 · 10 comments
Labels
question Further information is requested

Comments

@leedstyh
Copy link

leedstyh commented Oct 2, 2019

No description provided.

@leedstyh leedstyh added the question Further information is requested label Oct 2, 2019
@simc
Copy link
Member

simc commented Oct 2, 2019

Not currently. What would you need transactions for?

If you want to write multiple entries with a single disk access, you can use putAll().

@leedstyh
Copy link
Author

leedstyh commented Oct 3, 2019

If putAll() fails, are all the kv pairs not written?

@simc
Copy link
Member

simc commented Oct 3, 2019

Yes exactly

@leedstyh
Copy link
Author

leedstyh commented Oct 3, 2019

Thanks @leisim

@leedstyh leedstyh closed this as completed Oct 3, 2019
@benoitverstraete
Copy link

Hi @leisim ,

Do you plan to implement a "transaction" on multiples boxes ? I would like to save a complete set of data, or nothing.

Here is an example for an invoice and its lines/products :

Hive.transaction((transaction) {
   transaction.add(Hive.box('invoices').add(invoiceId, invoice));
   transaction.add(Hive.box('lines').add(lineId, line));

   // commit
   // rollback in case of error
});

@simc
Copy link
Member

simc commented Oct 10, 2019

@benoitverstraete

I do but it is not high on the priority list. The next update will improve performance and introduce HiveObjects, ListView and MapView. The update after that will contain queries. Then I plan to look at transactions...

@kaboc
Copy link

kaboc commented Jan 30, 2020

What if you need to do both put() and delete() in a single transaction?

e.g. ToDo app

  • categoryA
    • task1
    • task2
  • categoryB
    • task3

If you want to delete categoryB at the same time as task3 is moved to categoryA which makes categoryB empty, a series of update and removal operations is probably necessary. The feature of transaction seems useful in such a case.

@simc
Copy link
Member

simc commented Jan 31, 2020

The feature of transaction seems useful in such a case.

I agree. It's still on my radar...

@ShangyanLi
Copy link

An additional use case example would be a conditional write (reading value A and only writing value B if A satisfies a certain condition).

@simc
Copy link
Member

simc commented Aug 21, 2020

@ShangyanLi Why are transactions needed for such an operation? Wouldn't it be possible to implement this with the operations currently available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants