VCNC / haeinsa

Haeinsa is linearly scalable multi-row, multi-table transaction library for HBase
Apache License 2.0
158 stars 42 forks source link

Merge mutations during apply mutations step if possible #6

Closed eincs closed 8 years ago

eincs commented 10 years ago

Haeinsa applies mutations of transaction to rows on commit phase. If transaction contains several mutations for certain row, Haeinsa applies mutations step by step with checkAndPut and checkAndDelete operation. We can optimize this step.

Let's assume that certain transaction should applies following mutations to certain row:

Here is comparison of how Haeinsa works on current version and optimized version:

AS-IS Haeinsa TO-BE Haeinsa
checkAndPut(row, [{col1, value1}, {col2, value2}, {lock, newLock})
checkAndDelete(row, [col1])
checkAndPut(row, [{col3, value3}, {col4, value4}])
checkAndDelete(row, [col3])
checkAndPut(row, [{col5, value5}], {lock, newLock})
checkAndPut(row, [{col2, value2}, {lock, newLock}])
checkAndDelete(row, [col1, col3])
checkAndPut(row, [{col1, value4}, {col2, value5}, {lock, newLock}])

Series of operations above have the same result but TO-BE has small number of operations which means faster. I didn't mention deleteFamily operation on the example, but this should be consider too.

Note that this optimization is effective on complicate transaction. With this merging mutation algorithm, we can achieve faster execution of complicate transaction.

ewmkkpe commented 10 years ago

Good idea!

eincs commented 8 years ago

I close this issue since #49 merged.