0% found this document useful (0 votes)
24 views

Distributed Key-Value Store

The document describes requirements for a distributed key-value store including storing and fetching values by key, deleting keys, and performing secondary index scans to fetch keys by attribute value. Keys can have multiple attributes of different types, and the type is set when first inserted and cannot change. The requirements are explained with examples.

Uploaded by

kenji.wiguna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Distributed Key-Value Store

The document describes requirements for a distributed key-value store including storing and fetching values by key, deleting keys, and performing secondary index scans to fetch keys by attribute value. Keys can have multiple attributes of different types, and the type is set when first inserted and cannot change. The requirements are explained with examples.

Uploaded by

kenji.wiguna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Design a distributed key-value store that can perform the following

Functional requirements

● Store a set of attributes (value) against a particular key (k)


● Fetch the value stored against a particular key (k)
● Delete a key (k)
● ​Stretch​ ​- Perform a secondary index scan to fetch all key along with their
attributes where one of the attribute values is v.

Example:

Key can have a value consisting of multiple attributes.

Each attribute will have name, type associated (primitive types - boolean, double, integer, string)
& type has to be identified at run time.

1) Key = delhi has 2 attributes only ( pollution_level & population)

2) Key = jakarta has 3 attributes (latitude, longitude, pollution_level)

3) Key = bangalore has 4 attributes (extra - free_food)

4) Key = india has 2 attributes (capital & population)

5) Key = crocin has 2 attributes (category & manufacturer)

Example of Secondary index:

● Get all keys (cities) where pollution_level is high, it will return delhi , jakarta
● Get all medicines by manufacturer (GSK) , it will return Crocin

So, in a nutshell, value must be strongly typed when defined.

Attribute

1. Attribute is uniquely identified by its name (latitude, longitude etc.


2. Data type of the attribute is defined at the first insert. (i.e. data type of pollution_level is
set when key = delhi is inserted)
3. Once data type is associated with a particular attribute, it cannot be changed.
(i.e. free_food when defined takes type = boolean, hence, any key when using the
attribute - free_food must allow only boolean values on subsequent inserts/updates)

Notes

● Preferable Language - Java

● Follow standard OOPs concept and best practices in the industry

● Make sure code is thread safe.

● Make use of generics .

● Stub the methods for complex logic with comments supporting your

assumptions.

● Write at least 1 test case for each functionality.

Case-1
Key:[ BBSR : {{ “temperature”:20.0} ,{ “latitude”:”20.5”} }] allowed
Key:[ bangalore : { “temperature”:true}] - not allowed should throws exception
Key:[ Chennai : {{ “temperature”:20.0} ,{ “latitude”:”30.5”} ,{“population”:1000000 } }] allowed
Key:[ Mombay : {{ “temperature”:20.0} ,{ “latitude”:”30.5”} ,{“population”:”1 million” } }] not
allowed

String Key , List

Case -2
Sec index- population
Make sec index as population_level

Query

population_level-> High - {‘delhi’,’jakarta’}

Population -> 1 million -{ India }


Sec index population_level
population_level-> High - {‘delhi’,’jakarta’}

You might also like