You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by ch huang <ju...@gmail.com> on 2014/05/22 03:57:03 UTC
how to calculate key length in hbase?
hi,maillist:
i observe command " hbase hfile -m -f
/hbase/pipe_url/da8687017e0d5ef0a274153426127ef3/info/9efda5a9f07e47248af4e998b42afafd"
output ,and i do not know how to calculate the key length,
it's say
firstKey=2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put
and
avgKeyLen=53
but
# echo 2-F9150DB8A200991BCCA59B5D4E554181|wc -c
35
# echo 2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put|wc -c
62
none match the number 53,why?
Re: how to calculate key length in hbase?
Posted by Ted Yu <yu...@gmail.com>.
See the following in AbstractHFileWriter:
int avgKeyLen =
entryCount == 0 ? 0 : (int) (totalKeyLength / entryCount);
fileInfo.append(FileInfo.AVG_KEY_LEN, Bytes.toBytes(avgKeyLen), false);
On Thu, May 22, 2014 at 5:43 PM, ch huang <ju...@gmail.com> wrote:
> it just say the value is get from FileInfo struct ,i do not see any
> algorithm of caculate AVG_KEY_LEN.
>
> On Thu, May 22, 2014 at 10:08 AM, Ted Yu <yu...@gmail.com> wrote:
>
> > Please take a look at HFileReaderV2 ctor (line 159 in trunk):
> >
> > avgKeyLen = Bytes.toInt(fileInfo.get(FileInfo.AVG_KEY_LEN));
> >
> > Cheers
> >
> >
> > On Wed, May 21, 2014 at 6:57 PM, ch huang <ju...@gmail.com> wrote:
> >
> > > hi,maillist:
> > > i observe command " hbase hfile -m -f
> > >
> > >
> >
> /hbase/pipe_url/da8687017e0d5ef0a274153426127ef3/info/9efda5a9f07e47248af4e998b42afafd"
> > > output ,and i do not know how to calculate the key length,
> > >
> > > it's say
> > > firstKey=2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put
> > >
> > > and
> > > avgKeyLen=53
> > >
> > > but
> > > # echo 2-F9150DB8A200991BCCA59B5D4E554181|wc -c
> > > 35
> > > # echo 2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put|wc
> > -c
> > > 62
> > > none match the number 53,why?
> > >
> >
>
Re: how to calculate key length in hbase?
Posted by ch huang <ju...@gmail.com>.
it just say the value is get from FileInfo struct ,i do not see any
algorithm of caculate AVG_KEY_LEN.
On Thu, May 22, 2014 at 10:08 AM, Ted Yu <yu...@gmail.com> wrote:
> Please take a look at HFileReaderV2 ctor (line 159 in trunk):
>
> avgKeyLen = Bytes.toInt(fileInfo.get(FileInfo.AVG_KEY_LEN));
>
> Cheers
>
>
> On Wed, May 21, 2014 at 6:57 PM, ch huang <ju...@gmail.com> wrote:
>
> > hi,maillist:
> > i observe command " hbase hfile -m -f
> >
> >
> /hbase/pipe_url/da8687017e0d5ef0a274153426127ef3/info/9efda5a9f07e47248af4e998b42afafd"
> > output ,and i do not know how to calculate the key length,
> >
> > it's say
> > firstKey=2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put
> >
> > and
> > avgKeyLen=53
> >
> > but
> > # echo 2-F9150DB8A200991BCCA59B5D4E554181|wc -c
> > 35
> > # echo 2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put|wc
> -c
> > 62
> > none match the number 53,why?
> >
>
Re: how to calculate key length in hbase?
Posted by Ted Yu <yu...@gmail.com>.
Please take a look at HFileReaderV2 ctor (line 159 in trunk):
avgKeyLen = Bytes.toInt(fileInfo.get(FileInfo.AVG_KEY_LEN));
Cheers
On Wed, May 21, 2014 at 6:57 PM, ch huang <ju...@gmail.com> wrote:
> hi,maillist:
> i observe command " hbase hfile -m -f
>
> /hbase/pipe_url/da8687017e0d5ef0a274153426127ef3/info/9efda5a9f07e47248af4e998b42afafd"
> output ,and i do not know how to calculate the key length,
>
> it's say
> firstKey=2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put
>
> and
> avgKeyLen=53
>
> but
> # echo 2-F9150DB8A200991BCCA59B5D4E554181|wc -c
> 35
> # echo 2-F9150DB8A200991BCCA59B5D4E554181/info:url/1400052220386/Put|wc -c
> 62
> none match the number 53,why?
>