HBase
  1. HBase
  2. HBASE-1301

HTable.getRow() returns null if the row does no exist

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.19.0, 0.19.1
    • Fix Version/s: 0.19.2, 0.20.0
    • Component/s: Client, documentation
    • Labels:
      None
    • Release Note:
      Fix API doc of HTable.getRow (non-existent row key returns null instead of empty RowResult)

      Description

      The HBase API docs says when the row does not exist, getRow() returns

      RowResult is empty if row does not exist.

      However, in regionserver/HRegionServer.java's getRow():

      if (result == null || result.isEmpty())
      return null;
      return new RowResult(row, result);

      It actually returns null. Either fix the code or the document.

      1. 1301.patch
        5 kB
        Rong-En Fan

        Issue Links

          Activity

          Hide
          Rong-En Fan added a comment -

          From the doc, I would expect we got a valid RowResult with RowResult.isEmpty() is true for non-existent row.

          Show
          Rong-En Fan added a comment - From the doc, I would expect we got a valid RowResult with RowResult.isEmpty() is true for non-existent row.
          Hide
          Andrew Purtell added a comment -

          I remember we accepted a patch that changed getRow to return a null if no row exists, so the documentation is what is in error in my opinion.

          Show
          Andrew Purtell added a comment - I remember we accepted a patch that changed getRow to return a null if no row exists, so the documentation is what is in error in my opinion.
          Hide
          stack added a comment -

          Thanks Andrew for the kick. Looking at code, I see this change that went in:

          $ svn diff -r722690:722707 src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java 
          Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
          ===================================================================
          --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java    (revision 722690)
          +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java    (revision 722707)
          @@ -1287,7 +1287,8 @@
             }
           
             public RowResult getRow(final byte [] regionName, final byte [] row, 
          -    final byte [][] columns, final long ts, final long lockId)
          +    final byte [][] columns, final long ts,
          +    final int numVersions, final long lockId)
             throws IOException {
               checkOpen();
               requestCount.incrementAndGet();
          @@ -1300,13 +1301,11 @@
                 }
                 
                 HRegion region = getRegion(regionName);
          -      Map<byte [], Cell> map = region.getFull(row, columnSet, ts,
          -          getLockFromId(lockId));
          -      if (map == null || map.isEmpty())
          -        return null;
                 HbaseMapWritable<byte [], Cell> result =
          -        new HbaseMapWritable<byte [], Cell>();
          -      result.putAll(map);
          +        region.getFull(row, columnSet, 
          +          ts, numVersions, getLockFromId(lockId));
          +      if (result == null || result.isEmpty())
          +        return null;
                 return new RowResult(row, result);
               } catch (IOException e) {
                 checkOOME(e);
          

          The commit mentions "HBASE-847 new API: HTable.getRow with numVersion specified" but that doesn't seem to be the right issue. This seems to be it HBASE-1028.

          So, yeah, seems like its the doc thats wrong.

          Show
          stack added a comment - Thanks Andrew for the kick. Looking at code, I see this change that went in: $ svn diff -r722690:722707 src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 722690) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 722707) @@ -1287,7 +1287,8 @@ } public RowResult getRow( final byte [] regionName, final byte [] row, - final byte [][] columns, final long ts, final long lockId) + final byte [][] columns, final long ts, + final int numVersions, final long lockId) throws IOException { checkOpen(); requestCount.incrementAndGet(); @@ -1300,13 +1301,11 @@ } HRegion region = getRegion(regionName); - Map< byte [], Cell> map = region.getFull(row, columnSet, ts, - getLockFromId(lockId)); - if (map == null || map.isEmpty()) - return null ; HbaseMapWritable< byte [], Cell> result = - new HbaseMapWritable< byte [], Cell>(); - result.putAll(map); + region.getFull(row, columnSet, + ts, numVersions, getLockFromId(lockId)); + if (result == null || result.isEmpty()) + return null ; return new RowResult(row, result); } catch (IOException e) { checkOOME(e); The commit mentions " HBASE-847 new API: HTable.getRow with numVersion specified" but that doesn't seem to be the right issue. This seems to be it HBASE-1028 . So, yeah, seems like its the doc thats wrong.
          Hide
          Rong-En Fan added a comment -

          Fix javadoc

          Show
          Rong-En Fan added a comment - Fix javadoc
          Hide
          stack added a comment -

          Committed branch and trunk.

          Thanks for the patch Rong-en.

          Show
          stack added a comment - Committed branch and trunk. Thanks for the patch Rong-en.

            People

            • Assignee:
              Rong-En Fan
              Reporter:
              Rong-En Fan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development