linxGnu / grocksdb

RocksDB wrapper for Go. Support 9.x, 8.x, 7.x, 6.x, etc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

curious question, mind enlightening regarding batching?

hiqsociety opened this issue · comments

for batching writes (PUT), do I put the PutCF before the mutex lock? (faster) or after the mutex lock? can i do it before the mutex lock? the second version. is it ok?

first version

                b0 := grocksdb.NewWriteBatch()

                mutexCfhTK[((*i.(*[][]uint8))[2][0])+(((*i.(*[][]uint8))[4][0])%3)].Lock()
                mutexCfhTK[((*i.(*[][]uint8))[3][0])+(((*i.(*[][]uint8))[4][0])%3)].Lock()
                b0.PutCF(cfhTK[((*i.(*[][]uint8))[2][0])+((((*i.(*[][]uint8))[4][0]))%3)], (*i.(*[][]uint8))[5], (*i.(*[][]uint8))[6])
                b0.PutCF(cfhTK[((*i.(*[][]uint8))[3][0])+((((*i.(*[][]uint8))[4][0]))%3)], (*i.(*[][]uint8))[6][5:], (*i.(*[][]uint8))[7])
                dbr[((*i.(*[][]uint8))[1][0])].Write(wodb[((*i.(*[][]uint8))[1][0])], b0)
                mutexCfhTK[((*i.(*[][]uint8))[3][0])+(((*i.(*[][]uint8))[4][0])%3)].Unlock()
                mutexCfhTK[((*i.(*[][]uint8))[2][0])+(((*i.(*[][]uint8))[4][0])%3)].Unlock()

                b0.Destroy()

second version

                b0 := grocksdb.NewWriteBatch()
                b0.PutCF(cfhTK[((*i.(*[][]uint8))[2][0])+((((*i.(*[][]uint8))[4][0]))%3)], (*i.(*[][]uint8))[5], (*i.(*[][]uint8))[6])
                b0.PutCF(cfhTK[((*i.(*[][]uint8))[3][0])+((((*i.(*[][]uint8))[4][0]))%3)], (*i.(*[][]uint8))[6][5:], (*i.(*[][]uint8))[7])

                mutexCfhTK[((*i.(*[][]uint8))[2][0])+(((*i.(*[][]uint8))[4][0])%3)].Lock()
                mutexCfhTK[((*i.(*[][]uint8))[3][0])+(((*i.(*[][]uint8))[4][0])%3)].Lock()
                dbr[((*i.(*[][]uint8))[1][0])].Write(wodb[((*i.(*[][]uint8))[1][0])], b0)
                mutexCfhTK[((*i.(*[][]uint8))[3][0])+(((*i.(*[][]uint8))[4][0])%3)].Unlock()
                mutexCfhTK[((*i.(*[][]uint8))[2][0])+(((*i.(*[][]uint8))[4][0])%3)].Unlock()

                b0.Destroy()