liuxiaocs7 commented on code in PR #7473:
URL: https://github.com/apache/hbase/pull/7473#discussion_r2548565348
##########
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:
Hi, @guluo2016, thank you for your comments.
1. `TestDefaultMemStore` is inherited by `TestCompactingMemStore` and
`TestCompactingTocellFlatMapMemStore`, and the comparison in the subclasses
does not match
2. add a `tearDown` method to close memstore
Please help review this PR again when you are free, thanks!
--
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]