Class TestFuzzyRowFilterWoUnsafe

java.lang.Object
org.apache.hadoop.hbase.filter.TestFuzzyRowFilterWoUnsafe

@Tag("org.apache.hadoop.hbase.testclassification.FilterTests") @Tag("org.apache.hadoop.hbase.testclassification.SmallTests") public class TestFuzzyRowFilterWoUnsafe extends Object
Exercises FuzzyRowFilter on the "no-unsafe" code path (HBasePlatformDependent.unaligned() == false) end-to-end, i.e. through the constructor, FuzzyRowFilter.filterCell(org.apache.hadoop.hbase.Cell) and FuzzyRowFilter.getNextCellHint(org.apache.hadoop.hbase.Cell). On this path the mask uses the {0 (fixed), 1 (non-fixed)} encoding, which differs from the unsafe {-1, 2} encoding that the rest of the scan machinery assumes.
  • Constructor Details

  • Method Details

    • disableUnsafe

      @BeforeAll public static void disableUnsafe() throws Exception
      Throws:
      Exception
    • testForwardMatchesWildcardRow

      @Test public void testForwardMatchesWildcardRow()
      A row that matches the fuzzy rule only thanks to a wildcard position must be INCLUDEd. On the broken no-unsafe path the mask was shifted to all-zeroes (all positions treated as fixed), so the wildcard row was wrongly rejected.
    • testForwardHintSkipsToSmallestMatchingRow

      For a non-matching row the next-cell hint must be the smallest row that can satisfy the rule. With fixed positions 5 and 5 and a wildcard in the middle, the smallest row at or after {3,0,0} is {5,0,5}. On the broken no-unsafe path the wildcard key byte was never cleared and the mask was corrupted, producing a wrong hint.
    • testReverseHintSkipsSameRow

      @Test public void testReverseHintSkipsSameRow()
      No-unsafe analogue of TestFuzzyRowFilter#testReverseFilterCellSkipsSameRowHint. This is the most subtle composition point this change touches: the reverse next-cell hint is computed from the no-unsafe mask (updateWith -> preprocessMaskForHinting({0,1}->{-1,0}) -> getNextForFuzzyRule(reverse)) and must still play with the HBASE-30226 same-row short-circuit. A non-matching row seeks back to "abb"; revisiting "abb" must be skipped with NEXT_ROW instead of recreating the same hint.
    • testForwardHintWithMultipleKeysReturnsSmallest

      With multiple fuzzy keys the RowTracker priority queue holds one (separately converted) hint mask per key and must return the smallest matching row across all of them. Here key1 {5,*,5} hints {5,0,5} and key2 {4,9,9} hints {4,9,9}; the smaller {4,9,9} must win.
    • testUnsafeEncodedMaskFromPeerEnforcesFixedPositions

      A FuzzyRowFilter serialized by an unsafe peer puts the mask on the wire in its preprocessed {-1 (fixed), 2 (non-fixed)} form. A no-unsafe server must still interpret it correctly: this is exactly the {key, mask} pair FuzzyRowFilter.parseFrom(byte[]) hands to the constructor for such a filter. Before the fix the no-unsafe constructor left {-1, 2} untouched, so FuzzyRowFilter.satisfiesNoUnsafe(boolean, byte[], int, int, byte[], byte[]) (which keys off {0, 1}) treated every position as a wildcard and stopped enforcing the fixed bytes, wrongly INCLUDEing non-matching rows.
    • testParseFromUnsafeEncodedFilterEnforcesFixedPositions

      Faithful wire-level companion to testUnsafeEncodedMaskFromPeerEnforcesFixedPositions(): build the exact protobuf bytes an unsafe peer emits (mask in the preprocessed {-1, 2} form) and run them through FuzzyRowFilter.parseFrom(byte[]). A no-unsafe server must normalize the mask back to {0, 1} on deserialization and still enforce the fixed positions.
      Throws:
      Exception
    • testSerializationRoundTripPreservesFilter

      A filter built on a no-unsafe server must survive its own FuzzyRowFilter.toByteArray() / FuzzyRowFilter.parseFrom(byte[]) round-trip with identical behavior and identical equals/hashCode (the wire form is the canonical {0, 1}).
      Throws:
      Exception
    • assertRow

      private static void assertRow(byte[] expected, org.apache.hadoop.hbase.Cell cell)
    • testPreprocessMaskForSatisfiesNoUnsafeKeepsMaskSemantics

    • testPreprocessMaskForHintingNoUnsafeConvertsToGetNextSemantics

    • testNoUnsafePreprocessSearchKeyClearsWildcardBytes