How to algorithmically partion a keyspace?

Posted by pbhogan on Stack Overflow See other posts from Stack Overflow or by pbhogan
Published on 2010-05-28T20:19:15Z Indexed on 2010/05/28 20:22 UTC
Read the original article Hit count: 125

Filed under:
|
|
|

This is related to consistent hashing and while I conceptually understand what I need to do, I'm having a hard time translating this into code.

I'm trying to divide a given keyspace (say, 128 bits) into equal sized partitions. I want the upper bound (highest key) of each partition.

Basically, how would I complete this?

#define KEYSPACE_BYTE_SIZE  16
#define KEYSPACE_BIT_SIZE   (KEYSPACE_BYTE_SIZE * 8)

typedef struct _key
{ 
    char byte[KEYSPACE_BYTE_SIZE];
} key;

key * partition_keyspace( int num_partitions )
{
    key * partitions = malloc( sizeof(key) * num_partitions );

    // ...

}

© Stack Overflow or respective owner

Related posts about hash

Related posts about partition