How to algorithmically partion a keyspace?
- by pbhogan
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 );
// ...
}