[
https://issues.apache.org/jira/browse/HBASE-16645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15513079#comment-15513079
]
Anastasia Braginsky commented on HBASE-16645:
---------------------------------------------
Hi [~chia7712],
It is a genius idea to use Karnaugh Map for code generation. :)
I didn't mean to take over this jira, but if you need a help I can do this.
I left some easy to apply comments in Review Board, did you see them?
The hardest part was probably to generate the comments to the K-map generated
code.
Hereby, please find my best effort for the comments for intuition...
What do you say?
{\code}
/* Get the index of the given anchor key for creating subsequent set.
** It doesn't matter whether the given key exists in the set or not.
**
** taking into consideration whether
** the key should be inclusive or exclusive */
private int getValidIndex(Cell key, boolean inclusive, boolean tail) {
final int index = find(key);
// get the valid (positive) insertion point from the output of the find()
method
int insertionPoint = index < 0 ? ~index : index;
// correct the insertion point in case the given anchor key DOES EXIST in
the set
if (index >= 0) {
if ( descending && !(tail ^ inclusive)) {
// for the descending case
// if anchor for head set (tail=false) AND anchor is not inclusive ->
move the insertion pt
// if anchor for tail set (tail=true) AND the keys is inclusive -> move
the insertion point
// because the end index of a set is the index of the cell
after the maximal cell
insertionPoint += 1;
} else if ( !descending && (tail ^ inclusive)) {
// for the ascending case
// if anchor for head set (tail=false) AND anchor is inclusive -> move
the insertion point
// because the end index of a set is the index of the cell
after the maximal cell
// if anchor for tail set (tail=true) AND the keys is not inclusive ->
move the insertion pt
insertionPoint += 1;
}
}
// insert the insertion point into the valid range,
// as we may enlarge it too much in the above correction
return Math.min(Math.max(insertionPoint, minCellIdx), maxCellIdx);
}
{\code}
Thanks,
Anastasia
> Wrong range of Cells is caused by CellFlatMap#tailMap, headMap, and SubMap
> --------------------------------------------------------------------------
>
> Key: HBASE-16645
> URL: https://issues.apache.org/jira/browse/HBASE-16645
> Project: HBase
> Issue Type: Bug
> Affects Versions: 2.0.0
> Reporter: ChiaPing Tsai
> Fix For: 2.0.0
>
> Attachments: HBASE-16645.v0.patch, HBASE-16645.v1.patch
>
>
> Two reasons are shown below:
> 1) CellFlatMap#find doesn’t consider desc order array
> 2) CellFlatMap#getValidIndex return the wrong upper bound
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)