Partitionable is the interface which should be implemented by key type. It is to define how to partition the entries.
| 15 | // Partitionable is the interface which should be implemented by key type. |
| 16 | // It is to define how to partition the entries. |
| 17 | type Partitionable interface { |
| 18 | // Value is raw value of the key |
| 19 | Value() interface{} |
| 20 | |
| 21 | // PartitionKey is used for getting the partition to store the entry with the key. |
| 22 | // E.g. the key's hash could be used as its PartitionKey |
| 23 | // The partition for the key is partitions[(PartitionKey % m.numOfBlockets)] |
| 24 | // |
| 25 | // 1 Why not provide the default hash function for partition? |
| 26 | // Ans: As you known, the partition solution would impact the performance significantly. |
| 27 | // The proper partition solution balances the access to the different partitions and |
| 28 | // avoid of the hot partition. The access mode highly relates to your business. |
| 29 | // So, the better partition solution would just be designed according to your business. |
| 30 | PartitionKey() int64 |
| 31 | } |
| 32 | |
| 33 | type innerMap struct { |
| 34 | m map[interface{}]interface{} |