From 1bc0a2a0a37e689685d1c69a29c24999890deaa0 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 13 Jun 2008 19:53:23 +0000 Subject: [PATCH] HBASE-682 unnecessary iteration in HMemcache.internalGet? got much better reading performance after break it. git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@667631 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 5 ++++- .../apache/hadoop/hbase/regionserver/Memcache.java | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 633402b12fd..eb5d996e5ec 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -47,8 +47,11 @@ Hbase Change Log HBASE-662 UI in table.jsp gives META locations, not the table's regions location (Jean-Daniel Cryans via Stack) HBASE-676 Bytes.getInt returns a long (Clint Morgan via Stack) - HBASE-680 config parameter hbase.io.index.interval should be + HBASE-680 Config parameter hbase.io.index.interval should be hbase.index.interval, according to HBaseMapFile.HbaseWriter + (LN via Stack) + HBASE-682 Unnecessary iteration in HMemcache.internalGet? got much better + reading performance after break it (LN via Stack) IMPROVEMENTS HBASE-559 MR example job to count table rows diff --git a/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java b/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java index 368117fe6e8..457f849c754 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java @@ -514,6 +514,9 @@ class Memcache { if (ttl == HConstants.FOREVER || now < itKey.getTimestamp() + ttl) { result.add(new Cell(tailMap.get(itKey), itKey.getTimestamp())); + if (numVersions > 0 && result.size() >= numVersions) { + break; + } } else { victims.add(itKey); if (LOG.isDebugEnabled()) { @@ -521,15 +524,15 @@ class Memcache { } } } - } - if (numVersions > 0 && result.size() >= numVersions) { + } else { + // By L.N. HBASE-684, map is sorted, so we can't find match any more. break; } } // Remove expired victims from the map. - for (HStoreKey v: victims) + for (HStoreKey v: victims) { map.remove(v); - + } return result; } @@ -735,4 +738,4 @@ class Memcache { } } } -} \ No newline at end of file +}