[
https://issues.apache.org/jira/browse/HBASE-1347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Evgeny Ryabitskiy updated HBASE-1347:
-------------------------------------
Attachment: HBASE-1347.patch
* Added support for negative amount and negative value to incrementBytes... so
now you can use any value and amount :)
* Increment method moved to Bytes utility and changed to static
{code}
public class Bytes {
//.......... some methods
/**
* Bytewise binary increment/deincrement of long contained in byte array
* on given amount.
*
* @param value - array of bytes containing long (length <= SIZEOF_LONG)
* @param amount value will be incremented on (deincremented if negative)
* @return array of bytes containing incremented long (length == SIZEOF_LONG)
* @throws IOException - if value.length > SIZEOF_LONG
*/
public static byte [] incrementBytes(byte[] value, long amount)
throws IOException {
//..........
{code}
* JUnits: Added asserts for TestAtomicIncrement and added test for increment
to TestBytes
* One not solved problem in exception, think there should be another exception
for this case:
{code}
// @throws IOException - if value.length > SIZEOF_LONG
{code}
> HTable.incrementColumnValue does not take negative 'amount'
> -----------------------------------------------------------
>
> Key: HBASE-1347
> URL: https://issues.apache.org/jira/browse/HBASE-1347
> Project: Hadoop HBase
> Issue Type: Improvement
> Components: client
> Affects Versions: 0.19.1
> Environment: Ubuntu 8.10
> Reporter: atppp
> Assignee: Evgeny Ryabitskiy
> Priority: Minor
> Fix For: 0.19.2
>
> Attachments: HBASE-1347-quick-fix.patch, HBASE-1347.patch
>
>
> Apparently HRegion.binaryIncrement() assumes argument 'amount' is always
> positive. It would be nice to support decrement operation. In my application,
> a counter can go both up and down.
> Quick fix is
> public byte [] binaryIncrement(byte [] value, long amount) {
> return Bytes.toBytes(Bytes.toLong(value) + amount);
> }
> but it is 2x~3x slower than current implementation for small positive
> 'amount' value. I have not yet found a good implementation to support
> negative 'amount' argument, AND match the speed of current implementation.
> Anyway, I just want to throw this out there and see if anybody is interested
> in negative 'amount' support.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.