accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russ Weeks <rwe...@newbrightidea.com>
Subject Re: How to generate UUID in real time environment for Accumulo
Date Wed, 24 Jun 2015 19:48:07 GMT
Hi, Mohit,

I'm not sure what you mean when you say,

> which makes the UUID 32 bit long. I want UUID to be 16 digits long

Do you want the UUID to be 16 bytes long, giving you 128 bits to work with?
Do you care if the UUID is human-readable (ie. ascii text) or not?

If not, take a look at how Twitter's Snowflake[1] project generates IDs. It
follows a form very similar to Keith's suggestion but with a more compact,
binary encoding. It squeezes IDs into 64 bits, allocating (IIRC) 42 bits
for the timestamp, 10 bits for the client id and 12 bits for the client
counter. It uses a custom epoch to ensure that the timestamp won't overflow
for something like 65 years. If you're OK with 128 bit IDs, you don't need
to be too concerned about that.

I'm not saying, bring in this project just to generate your IDs. I'm just
saying that the code is small enough that you could port it pretty easily.

1: https://github.com/twitter/snowflake/tree/snowflake-2010/src

On Wed, Jun 24, 2015 at 11:33 AM Keith Turner <keith@deenlo.com> wrote:

> Could look into using Lexicoders.  The following program prints out 19.
> However this will vary depending on how many leading 0 bytes the longs
> have, because those are dropped.
>
>     long time = System.currentTimeMillis();
>
>     ListLexicoder<Long> ll =  new ListLexicoder<Long>(new
> ULongLexicoder());
>
>     List<Long> list = Arrays.asList(new Long[3]);
>     list.set(0, time);
>     list.set(1, 123456l);
>     list.set(2, 987654l);
>
>     byte[] b = ll.encode(list);
>
>     System.out.println(b.length);
>
> On Wed, Jun 24, 2015 at 2:32 AM, mohit.kaushik <mohit.kaushik@orkash.com>
> wrote:
>
>> On 06/23/2015 06:44 PM, Keith Turner wrote:
>>
>>> row=<time>_<client id>_<client counter>
>>>
>> this will definitely generate a UUID but if I use "14 digits for <time> +
>> 12 digits for <client_id> + say 6 digits for <client_counter>" which
makes
>> the UUID 32 bit long. I want UUID to be 16 digits long.
>>
>> Can you suggest some encoding technique which can encode it to 16 digits
>> and also maintains the time order?
>>
>> -Mohit kaushik
>>
>>
>

Mime
View raw message