Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-14206

MultiRowRangeFilter returns records whose rowKeys are out of allowed ranges

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.1.0
    • 1.2.0, 1.1.2, 1.3.0, 0.98.21, 2.0.0
    • Filters
    • linux, java7

    • Reviewed

    Description

      I haven't found a way to attach test program to JIRA issue, so put it below :

      public class MultiRowRangeFilterTest {
       
          byte[] key1Start = new byte[] {-3};
          byte[] key1End  = new byte[] {-2};
      
          byte[] key2Start = new byte[] {5};
          byte[] key2End  = new byte[] {6};
      
          byte[] badKey = new byte[] {-10};
      
          @Test
          public void testRanges() throws IOException {
              MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
                      new MultiRowRangeFilter.RowRange(key1Start, true, key1End, false),
                      new MultiRowRangeFilter.RowRange(key2Start, true, key2End, false)
              ));
              filter.filterRowKey(badKey, 0, 1);
              /*
              * FAILS -- includes BAD key!
              * Expected :SEEK_NEXT_USING_HINT
              * Actual   :INCLUDE
              * */
              assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null));
          }
      }
      

      It seems to happen on 2.0.0-SNAPSHOT too, but I wasn't able to link one with included class.

      I have played some time with algorithm, and found that quick fix may be applied to "getNextRangeIndex(byte[] rowKey)" method (hbase-client:1.1.0) :

      if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) {
              return ROW_BEFORE_FIRST_RANGE;
      }
      // FIX START
      if(!this.initialized) {
          this.initialized = true;
      }
      // FIX END
      return insertionPosition;
      

      Thanks, hope it will help.

      Attachments

        1. 14206-branch-1.txt
          2 kB
          Ted Yu
        2. 14206-test.patch
          1 kB
          Ted Yu
        3. 14206-v1.txt
          2 kB
          Ted Yu

        Activity

          People

            anton.nazaruk@gmail.com Anton Nazaruk
            anton.nazaruk@gmail.com Anton Nazaruk
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: