@@ -751,6 +751,65 @@ public void testFilter() throws Exception {
751
751
}
752
752
Assert .assertEquals (res_count , 1 );
753
753
scanner .close ();
754
+
755
+ Put putKey3Column3Value1 = new Put (toBytes ("getKey3" ));
756
+ putKey3Column3Value1 .add (toBytes (family ), toBytes (column1 ), toBytes (value1 ));
757
+ tryPut (hTable , putKey3Column3Value1 );
758
+ Put putKey4Column3Value1 = new Put (toBytes ("getKey4" ));
759
+ putKey4Column3Value1 .add (toBytes (family ), toBytes (column1 ), toBytes (value1 ));
760
+ tryPut (hTable , putKey4Column3Value1 );
761
+
762
+ scan = new Scan ();
763
+ scan .addFamily (family .getBytes ());
764
+ scan .setStartRow ("getKey1" .getBytes ());
765
+ scan .setStopRow ("getKey5" .getBytes ());
766
+ scan .setMaxVersions (10 );
767
+ scanner = hTable .getScanner (scan );
768
+
769
+ res_count = 0 ;
770
+ for (Result result : scanner ) {
771
+ for (KeyValue keyValue : result .raw ()) {
772
+ res_count += 1 ;
773
+ }
774
+ }
775
+ Assert .assertEquals (res_count , 30 );
776
+ scanner .close ();
777
+
778
+ scan = new Scan ();
779
+ scan .addFamily (family .getBytes ());
780
+ scan .setStartRow ("getKey1" .getBytes ());
781
+ scan .setStopRow ("getKey5" .getBytes ());
782
+ scan .setMaxVersions (10 );
783
+ RandomRowFilter rf = new RandomRowFilter (-1 );
784
+ scan .setFilter (rf );
785
+ scanner = hTable .getScanner (scan );
786
+
787
+ res_count = 0 ;
788
+ for (Result result : scanner ) {
789
+ for (KeyValue keyValue : result .raw ()) {
790
+ res_count += 1 ;
791
+ }
792
+ }
793
+ Assert .assertEquals (res_count , 0 );
794
+ scanner .close ();
795
+
796
+ scan = new Scan ();
797
+ scan .addFamily (family .getBytes ());
798
+ scan .setStartRow ("getKey1" .getBytes ());
799
+ scan .setStopRow ("getKey5" .getBytes ());
800
+ scan .setMaxVersions (10 );
801
+ rf = new RandomRowFilter (2 );
802
+ scan .setFilter (rf );
803
+ scanner = hTable .getScanner (scan );
804
+
805
+ res_count = 0 ;
806
+ for (Result result : scanner ) {
807
+ for (KeyValue keyValue : result .raw ()) {
808
+ res_count += 1 ;
809
+ }
810
+ }
811
+ Assert .assertEquals (res_count , 30 );
812
+ scanner .close ();
754
813
}
755
814
756
815
@ Test
0 commit comments