guluo2016 commented on code in PR #7473:
URL: https://github.com/apache/hbase/pull/7473#discussion_r2549885143


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java:
##########
@@ -1118,31 +1114,30 @@ private static void addRows(int count, final MemStore 
mem) {
     }
   }
 
-  static void doScan(MemStore ms, int iteration) throws IOException {
+  private static int doScan(MemStore ms, int iteration) throws IOException {
     long nanos = System.nanoTime();
     KeyValueScanner s = ms.getScanners(0).get(0);
     s.seek(KeyValueUtil.createFirstOnRow(new byte[] {}));
 
-    System.out.println(iteration + " create/seek took: " + (System.nanoTime() 
- nanos) / 1000);
+    LOG.info("Iteration {} create/seek took: {}", iteration, 
(System.nanoTime() - nanos) / 1000);
     int cnt = 0;
-    while (s.next() != null)
+    while (s.next() != null) {
       ++cnt;
-
-    System.out
-      .println(iteration + " took usec: " + (System.nanoTime() - nanos) / 1000 
+ " for: " + cnt);
-
+    }
+    LOG.info("Iteration {} took usec: {} for: {}", iteration, 
(System.nanoTime() - nanos) / 1000,
+      cnt);
+    return cnt;
   }
 
-  public static void main(String[] args) throws IOException {
-    MemStore ms = new DefaultMemStore();
-
+  @Test
+  public void testScan() throws IOException {
     long n1 = System.nanoTime();
-    addRows(25000, ms);
-    System.out.println("Took for insert: " + (System.nanoTime() - n1) / 1000);
+    addRows(25000, memstore);
+    LOG.info("Took for insert: {}", (System.nanoTime() - n1) / 1000);
 
-    System.out.println("foo");
-
-    for (int i = 0; i < 50; i++)
-      doScan(ms, i);
+    for (int i = 0; i < 50; i++) {
+      int cnt = doScan(memstore, i);
+      assertEquals(memstore.getActive().getCellsCount(), cnt);

Review Comment:
   In this test case,  the cell count after executing `doRow(25000, memstore)` 
is `25000 * QUALIFIER_COUNT = 250000`, which is a fixed value.
   
   I mean using a fixed expected value  in this assertion instead of 
`memstore.getActive().getCellsCount()` to ensure proper test verification. 
@liuxiaocs7 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to