You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Ted Yu <yu...@gmail.com> on 2017/09/06 13:56:03 UTC

trying to put empty string

How did you specify the empty string ("") ?

bq. can add any binary data as value casting it to char?

Not as char but as const std::string&

On Tue, Sep 5, 2017 at 4:17 AM, Andrzej <bo...@wp.pl> wrote:

> W dniu 26.08.2017 o 16:02, Ted Yu pisze:
>
>>      auto int_val = hbase::BytesUtil::ToInt64(*(result->Value(family, >
>> incrPrefix + col)));
>>
>
> There is in load-client.cc
>
> In method BytesUtil::ToInt64 is:
>
> int64_t BytesUtil::ToInt64(std::string str) {
>   if (str.length() < 8) {
>     throw std::runtime_error("There are not enough bytes. Expected: 8,
> actual: " + str.length());
>   }
>   const unsigned char *bytes = reinterpret_cast<unsigned char
> *>(const_cast<char *>(str.c_str()));
>   int64_t l = 0;
>   for (int i = 0; i < 8; i++) {
>     l <<= 8;
>     l ^= bytes[i];
>   }
>   return l;
> }
>
> This means that is possible retrieve any binary data from string,
> including not utf-8 chars and \0 char ?
>
> Similar, put->AddColumn(family, qualifier, value) can add any binary data
> as value casting it to char?
>
> In example simple-test.cc was error when trying put empty string.
>