HBase
  1. HBase
  2. HBASE-5856

byte <-> String is not consistent between HBaseAdmin and HRegionInfo

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 0.92.1
    • Fix Version/s: None
    • Component/s: Client
    • Labels:
      None

      Description

      In HBaseAdmin
      public void split(final String tableNameOrRegionName)
      throws IOException, InterruptedException

      { split(Bytes.toBytes(tableNameOrRegionName)); // string -> byte }

      In HRegionInfo
      this.regionNameStr = Bytes.toStringBinary(this.regionName); // byte -> string
      Should we use Bytes.toBytesBinary in HBaseAdmin ?

        Activity

        Hide
        binlijin added a comment -

        for example, one region's information HRegionInfo is :
        regionNameStr: testsplit,\x00\x00\x00\x00\x00\x00\x00\x00,1335169851181.79d80fbc6c4f6cfc2cdca8a5310b7223.
        regionName :
        [116, 101, 115, 116, 115, 112, 108, 105, 116, 44, 0, 0, 0, 0, 0, 0, 0, 0, 44, 49, 51, 51, 53, 49, 54, 57, 56, 53, 49, 49, 56, 49, 46, 55, 57, 100, 56, 48, 102, 98, 99, 54, 99, 52, 102, 54, 99, 102, 99, 50, 99, 100, 99, 97, 56, 97, 53, 51, 49, 48, 98, 55, 50, 50, 51, 46]

        if we use HBaseAdmin.split(regionName), this is correct, but if we use HBaseAdmin.split(regionNameStr); this is wrong.
        Because Bytes.toBytes(regionNameStr) will get byte : [116, 101, 115, 116, 115, 112, 108, 105, 116, 44, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 44, 49, 51, 51, 53, 49, 54, 57, 56, 53, 49, 49, 56, 49, 46, 55, 57, 100, 56, 48, 102, 98, 99, 54, 99, 52, 102, 54, 99, 102, 99, 50, 99, 100, 99, 97, 56, 97, 53, 51, 49, 48, 98, 55, 50, 50, 51, 46], this will get a TableNotFoundException in 0.92

        Show
        binlijin added a comment - for example, one region's information HRegionInfo is : regionNameStr: testsplit,\x00\x00\x00\x00\x00\x00\x00\x00,1335169851181.79d80fbc6c4f6cfc2cdca8a5310b7223. regionName : [116, 101, 115, 116, 115, 112, 108, 105, 116, 44, 0, 0, 0, 0, 0, 0, 0, 0, 44, 49, 51, 51, 53, 49, 54, 57, 56, 53, 49, 49, 56, 49, 46, 55, 57, 100, 56, 48, 102, 98, 99, 54, 99, 52, 102, 54, 99, 102, 99, 50, 99, 100, 99, 97, 56, 97, 53, 51, 49, 48, 98, 55, 50, 50, 51, 46] if we use HBaseAdmin.split(regionName), this is correct, but if we use HBaseAdmin.split(regionNameStr); this is wrong. Because Bytes.toBytes(regionNameStr) will get byte : [116, 101, 115, 116, 115, 112, 108, 105, 116, 44, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 92, 120, 48, 48, 44, 49, 51, 51, 53, 49, 54, 57, 56, 53, 49, 49, 56, 49, 46, 55, 57, 100, 56, 48, 102, 98, 99, 54, 99, 52, 102, 54, 99, 102, 99, 50, 99, 100, 99, 97, 56, 97, 53, 51, 49, 48, 98, 55, 50, 50, 51, 46] , this will get a TableNotFoundException in 0.92
        Hide
        stack added a comment -

        I think regionNameStr in HRI is wrong. We should only do toBytesBinary for the cases where we are outputting in shell or in ui; toBytesBinary is for human consumption. HBase should be about undoctored bytes.

        Show
        stack added a comment - I think regionNameStr in HRI is wrong. We should only do toBytesBinary for the cases where we are outputting in shell or in ui; toBytesBinary is for human consumption. HBase should be about undoctored bytes.
        Hide
        stack added a comment -

        Help me understand Binlijin. This does not seem right to me but you are obviously on to something. The String that is being passed in here is coming from the shell? Is jruby shell doing the escaping before it passes the String to HBaseAdmin? Thanks.

        Show
        stack added a comment - Help me understand Binlijin. This does not seem right to me but you are obviously on to something. The String that is being passed in here is coming from the shell? Is jruby shell doing the escaping before it passes the String to HBaseAdmin? Thanks.
        Hide
        binlijin added a comment -

        @stack
        We can get the string(testsplit,\x00\x00\x00\x00\x00\x00\x00\x00,1335169851181.79d80fbc6c4f6cfc2cdca8a5310b7223. ) from the web (/table.jsp) or HRegionInfo.getRegionNameAsString(), if we pass the string to web or jruby shell or HBaseAdmin.split(String) will get TableNotFoundException.

        Show
        binlijin added a comment - @stack We can get the string(testsplit,\x00\x00\x00\x00\x00\x00\x00\x00,1335169851181.79d80fbc6c4f6cfc2cdca8a5310b7223. ) from the web (/table.jsp) or HRegionInfo.getRegionNameAsString(), if we pass the string to web or jruby shell or HBaseAdmin.split(String) will get TableNotFoundException.
        Hide
        stack added a comment -

        Are you passing the name copied from the UI using double quotes or single quotes? The shell acts differently if double quotes. If double quotes it will pass to hbase unescaped region name. At least, it used to do this. Thanks Binlijin.

        Show
        stack added a comment - Are you passing the name copied from the UI using double quotes or single quotes? The shell acts differently if double quotes. If double quotes it will pass to hbase unescaped region name. At least, it used to do this. Thanks Binlijin.
        Hide
        binlijin added a comment -

        @stack
        Yes, I find the single quotes will fail and double quotes success. Thanks stack.

        Show
        binlijin added a comment - @stack Yes, I find the single quotes will fail and double quotes success. Thanks stack.
        Hide
        stack added a comment -

        So, can we close out this issue binlijin ?

        Show
        stack added a comment - So, can we close out this issue binlijin ?
        Hide
        binlijin added a comment -

        @stack
        Yes, we should close this issue.

        Show
        binlijin added a comment - @stack Yes, we should close this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            binlijin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development