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

checkAndPut feature request #66

Open
wkv opened this issue May 13, 2014 · 9 comments
Open

checkAndPut feature request #66

wkv opened this issue May 13, 2014 · 9 comments

Comments

@wkv
Copy link

wkv commented May 13, 2014

It doesn't appear to be in the thift interface however there is a checkAndPut function which is useful for those "atomic" operations. I haven't delved to deep, do you think it would possible to implement?

@wbolster
Copy link
Member

Happybase is limited to what the Thrift API exposes (it just wraps it in a clean and flexible way), so if the functionality you're looking for is not in the Thrift API (look at the upstream .thrift file to be sure) then Happybase is out of luck…

@wkv
Copy link
Author

wkv commented May 13, 2014

It is in the thrift interface, perhaps the one included in Happybase is older?

/**
 * Atomically checks if a row/family/qualifier value matches the expected
 * value. If it does, it adds the corresponding mutation operation for put.
 *
 * @return true if the new put was executed, false otherwise
 */
bool checkAndPut(
  /** name of table */
  1:Text tableName,

  /** row key */
  2:Text row,

  /** column name */
  3:Text column,

  /** the expected value for the column parameter, if not
      provided the check is for the non-existence of the
      column in question */
  5:Text value

  /** mutation for the put */
  6:Mutation mput,

  /** Mutation attributes */
  7:map<Text, Text> attributes
) throws (1:IOError io, 2:IllegalArgument ia)

@wbolster
Copy link
Member

Ah, your first comment mentioned:

(…) It doesn't appear to be in the thift interface (…)

Yes, upstream may have a newer version. To get this into Happybase, the following needs to be done:

  • design a proper API for this (maybe table.put() can have a check=...?)
  • figure out the HBase version when this was introduced in the Thrift server (for the compat=... stuff)

@wbolster
Copy link
Member

FYI, I'd be willing to add this to HappyBase, but without further discussion and cooperation it's not going to happen...

@wkv
Copy link
Author

wkv commented Jun 20, 2014

I started digging in the code myself however had a lot of work come up. The checkAndPut interface is useful for a type of optimistic locking. Using atomic counters can simulate this so I have an interim (less efficient) solution. With your comment about not working with hbase now I didn't think you would be interested.

@wbolster
Copy link
Member

The function is in the Thrift interface, so it is easy for me to add once the API at the Python side is settled. What are your thoughts about a clean API for this?

@dahlgrent
Copy link

I have a use case where I only want to put a cell value if it differs from the current value. It would be ideal to use the Thrift checkAndPut to push the compare operation to the server instead of doing a get for each row. Your suggestion to add check=... to table.put() could be check=True. This would be a simple way to implement this.

@wbolster
Copy link
Member

wbolster commented Apr 3, 2017

no. if there were you would've been able to see it here.

i am not actively working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@wbolster @wkv @dahlgrent and others