FlyDB icon indicating copy to clipboard operation
FlyDB copied to clipboard

New data structure —— Hash

Open qishenonly opened this issue 2 years ago • 5 comments

We need a new data structure, Hash, to extend the database's key-value storage structure. We need to build some instructions into Hash to make it more complete. If you are interested in extending the Hashdata structure, you can comment below on the issue id you would like to try and we will assign it to you.

id issue method describtion people process
1 Hash method HSet HSet key field value Sets the value of the specified field in the specified hash key to the specified value. @qishenonly  finished
2 Hash method HGet HGet key field Gets the value of the specified field in the specified hash key. @qishenonly   finished
3 Hash method HMSet HMSet key field1 value1 [field2 value2 ...] Sets values for multiple fields in the specified hash key at the same time.    
4 Hash method HMGet HMGet key field1 [field2 ...] Gets the values of multiple fields in the specified hash key at the same time. @saeid-a   finished
5 Hash method HDel HDel key field1 [field2 ...] Removes one or more fields from the specified hash key. @qishenonly   finished
6 Hash method HExists HExists key field Checks whether the specified field exists in the specified hash key. @qishenonly  finished 
7 Hash method HKeys HKeys key Gets all field names in the specified hash key.    
8 Hash method HVals HVals key Gets all field values in the specified hash key.    
9 Hash method HLen HLen key Gets the number of fields in the specified hash key @qishenonly   finished
10 Hash method HGetAll HGetAll key Gets all fields and their values in the specified hash key.    

qishenonly avatar Jul 03 '23 06:07 qishenonly

#184

saeid-a avatar Jul 09 '23 13:07 saeid-a

I've noticed the function decodeHashField in hash.go does not work; I mean, the way function encodeHashField encodes the HashField structure is impossible to decode since there are no delimiters; as a result, implementing the functions HKeys and HVals become very hard if not impossible. We can, however, rewrite the decode/encode functions using Golang's gob. Let me know what you think.

saeid-a avatar Jul 09 '23 13:07 saeid-a

Unfortunately, due to my personal development habits, I usually write the corresponding decodeHashField method after writing the encodeHashField method. However, when I wrote various methods of hash, I actually did not use the decoding method, which may have some problems.

For your consideration, perhaps you can try to use gob to rewrite the codec function part, it may not affect the functional implementation of other functions, but still have to actually run the test.

Thank you very much for your valuable comments.

qishenonly avatar Jul 09 '23 15:07 qishenonly

#184

saeid-a avatar Jul 10 '23 14:07 saeid-a

#184

thanks

qishenonly avatar Jul 10 '23 14:07 qishenonly