You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Ruby Stevenson <ru...@gmail.com> on 2011/09/29 17:57:47 UTC

row key for string

hi all

I am reading some code related to encoding a string representing the
file path into a row key, it essentially went through a series of
transformation like this:

        String filepath = "/x/y/z";
        ByteBuffer bb = ByteBufferUtil.bytes(filepath);
        String s = FBUtilities.hashToBigInteger(bb).toString(16);
        return ByteBufferUtil.bytes(s);

why hashToBigInteger and then hex string? is this a convention/idiom
of generating row key this way?

thanks

Ruby

Re: row key for string

Posted by Ruby Stevenson <ru...@gmail.com>.
I see. Though I don't know enough about these util method to
appreciate it, yet,  but thank very much for the clarification.

Ruby

On Thu, Sep 29, 2011 at 12:22 PM, Jake Luciani <ja...@gmail.com> wrote:
> You need that to work with the OPP since it checks that the string is UTF-8
> Valid.
>
> If you are using RP or BOP no need.
>
> On Thu, Sep 29, 2011 at 12:14 PM, Ruby Stevenson <ru...@gmail.com> wrote:
>
>> btw - the original code is in brisk repo:
>>
>>
>> https://github.com/riptano/brisk/blob/master/src/java/src/org/apache/cassandra/hadoop/fs/CassandraFileSystemThriftStore.java#L657
>>
>>
>>
>> On Thu, Sep 29, 2011 at 12:07 PM, Jonathan Ellis <jb...@gmail.com>
>> wrote:
>> > Nope. That strikes me as odd, too.
>> > On Sep 29, 2011 10:58 AM, "Ruby Stevenson" <ru...@gmail.com> wrote:
>> >> hi all
>> >>
>> >> I am reading some code related to encoding a string representing the
>> >> file path into a row key, it essentially went through a series of
>> >> transformation like this:
>> >>
>> >> String filepath = "/x/y/z";
>> >> ByteBuffer bb = ByteBufferUtil.bytes(filepath);
>> >> String s = FBUtilities.hashToBigInteger(bb).toString(16);
>> >> return ByteBufferUtil.bytes(s);
>> >>
>> >> why hashToBigInteger and then hex string? is this a convention/idiom
>> >> of generating row key this way?
>> >>
>> >> thanks
>> >>
>> >> Ruby
>> >
>>
>
>
>
> --
> http://twitter.com/tjake
>

Re: row key for string

Posted by Jonathan Ellis <jb...@gmail.com>.
Why not just take the md5 [as byte[], not bigint] and send it through
bytesToHex then?

On Thu, Sep 29, 2011 at 11:22 AM, Jake Luciani <ja...@gmail.com> wrote:
> You need that to work with the OPP since it checks that the string is UTF-8
> Valid.
>
> If you are using RP or BOP no need.
>
> On Thu, Sep 29, 2011 at 12:14 PM, Ruby Stevenson <ru...@gmail.com> wrote:
>
>> btw - the original code is in brisk repo:
>>
>>
>> https://github.com/riptano/brisk/blob/master/src/java/src/org/apache/cassandra/hadoop/fs/CassandraFileSystemThriftStore.java#L657
>>
>>
>>
>> On Thu, Sep 29, 2011 at 12:07 PM, Jonathan Ellis <jb...@gmail.com>
>> wrote:
>> > Nope. That strikes me as odd, too.
>> > On Sep 29, 2011 10:58 AM, "Ruby Stevenson" <ru...@gmail.com> wrote:
>> >> hi all
>> >>
>> >> I am reading some code related to encoding a string representing the
>> >> file path into a row key, it essentially went through a series of
>> >> transformation like this:
>> >>
>> >> String filepath = "/x/y/z";
>> >> ByteBuffer bb = ByteBufferUtil.bytes(filepath);
>> >> String s = FBUtilities.hashToBigInteger(bb).toString(16);
>> >> return ByteBufferUtil.bytes(s);
>> >>
>> >> why hashToBigInteger and then hex string? is this a convention/idiom
>> >> of generating row key this way?
>> >>
>> >> thanks
>> >>
>> >> Ruby
>> >
>>
>
>
>
> --
> http://twitter.com/tjake
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of DataStax, the source for professional Cassandra support
http://www.datastax.com

Re: row key for string

Posted by Jake Luciani <ja...@gmail.com>.
You need that to work with the OPP since it checks that the string is UTF-8
Valid.

If you are using RP or BOP no need.

On Thu, Sep 29, 2011 at 12:14 PM, Ruby Stevenson <ru...@gmail.com> wrote:

> btw - the original code is in brisk repo:
>
>
> https://github.com/riptano/brisk/blob/master/src/java/src/org/apache/cassandra/hadoop/fs/CassandraFileSystemThriftStore.java#L657
>
>
>
> On Thu, Sep 29, 2011 at 12:07 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> > Nope. That strikes me as odd, too.
> > On Sep 29, 2011 10:58 AM, "Ruby Stevenson" <ru...@gmail.com> wrote:
> >> hi all
> >>
> >> I am reading some code related to encoding a string representing the
> >> file path into a row key, it essentially went through a series of
> >> transformation like this:
> >>
> >> String filepath = "/x/y/z";
> >> ByteBuffer bb = ByteBufferUtil.bytes(filepath);
> >> String s = FBUtilities.hashToBigInteger(bb).toString(16);
> >> return ByteBufferUtil.bytes(s);
> >>
> >> why hashToBigInteger and then hex string? is this a convention/idiom
> >> of generating row key this way?
> >>
> >> thanks
> >>
> >> Ruby
> >
>



-- 
http://twitter.com/tjake

Re: row key for string

Posted by Ruby Stevenson <ru...@gmail.com>.
btw - the original code is in brisk repo:

https://github.com/riptano/brisk/blob/master/src/java/src/org/apache/cassandra/hadoop/fs/CassandraFileSystemThriftStore.java#L657



On Thu, Sep 29, 2011 at 12:07 PM, Jonathan Ellis <jb...@gmail.com> wrote:
> Nope. That strikes me as odd, too.
> On Sep 29, 2011 10:58 AM, "Ruby Stevenson" <ru...@gmail.com> wrote:
>> hi all
>>
>> I am reading some code related to encoding a string representing the
>> file path into a row key, it essentially went through a series of
>> transformation like this:
>>
>> String filepath = "/x/y/z";
>> ByteBuffer bb = ByteBufferUtil.bytes(filepath);
>> String s = FBUtilities.hashToBigInteger(bb).toString(16);
>> return ByteBufferUtil.bytes(s);
>>
>> why hashToBigInteger and then hex string? is this a convention/idiom
>> of generating row key this way?
>>
>> thanks
>>
>> Ruby
>

Re: row key for string

Posted by Jonathan Ellis <jb...@gmail.com>.
Nope. That strikes me as odd, too.
On Sep 29, 2011 10:58 AM, "Ruby Stevenson" <ru...@gmail.com> wrote:
> hi all
>
> I am reading some code related to encoding a string representing the
> file path into a row key, it essentially went through a series of
> transformation like this:
>
> String filepath = "/x/y/z";
> ByteBuffer bb = ByteBufferUtil.bytes(filepath);
> String s = FBUtilities.hashToBigInteger(bb).toString(16);
> return ByteBufferUtil.bytes(s);
>
> why hashToBigInteger and then hex string? is this a convention/idiom
> of generating row key this way?
>
> thanks
>
> Ruby