Details
-
Bug
-
Resolution: Unresolved
-
Major
-
Cheshire-Cat
-
Untriaged
-
No
Description
processUpsert, processDelete and processUpsertDelete find the slice to do the operation on by running GetSliceByIndexKey method which runs a hash function on the mutation key. This is done to figure out which SliceId the mutation belongs to. In our current design, we only have one slice per partition. Hence, running of hash function is unnecessary when numSlices = 1.
GetSliceIdByIndexKey can be optimized to skip running the hash function, along the lines of:
func (sc *HashedSliceContainer) GetSliceIdByIndexKey(key common.IndexKey) SliceId {
if sc.NumSlices == 1 {
return SliceId(0)
}
//run hash function on index key and return slice id
hash := crc32.ChecksumIEEE([]byte(key))
sliceId := int(hash) % sc.NumSlices
return SliceId(sliceId)
}