Type | Command | Syntax | Description | Version change |
Write operation | TR.SETBIT | TR.SETBIT key offset value
| Sets the specified bit in a TairRoaring key to a value of 1 or 0 and returns the original bit value. The offset starts from 0. | - (N/A) |
TR.SETBITS | TR.SETBITS key offset [offset1 offset2 ... offsetN]
| Sets the value of the specified bit in a TairRoaring key to 1. You can set multiple bits to a value of 1. | Added in V2. |
TR.CLEARBITS | TR.CLEARBITS key offset [offset1 offset2 ... offsetN]
| Sets the value of the specified bit in a TairRoaring key to 0. If the specified bit already has a value of 0, the operation is not performed. You can set multiple bits to a value of 0. | Added in V2. |
TR.SETRANGE | TR.SETRANGE key start end
| Sets the bits within the specified range in a TairRoaring key to a value of 1. The range is a closed interval. | Updated in V2. After the command update in V2, the command output is changed to the number of bits that have been set to 1. |
TR.APPENDBITARRAY | TR.APPENDBITARRAY key offset bitarray
| Inserts a bit array into a position after the specified bit in a TairRoaring key and overwrites the original data. The bit array consists of 0 and 1. | Added in V2. |
TR.FLIPRANGE | TR.FLIPRANGE key start end
| Changes the values for bits within the specified range in a TairRoaring key from 0 to 1 or from 1 to 0. The range is a closed interval. If the key does not exist, the key is created as an empty dataset and the operation is performed on the key. | Added in V2. |
TR.APPENDINTARRAY | TR.APPENDINTARRAY key value [value1 value2 ... valueN]
| Sets the value of the specified bit in a TairRoaring key to 1. You can set multiple bits to a value of 1. Note In TairRoaring V2, we recommend that you use TR.SETBITS instead of this command. | - |
TR.SETINTARRAY | TR.SETINTARRAY key value [value1 value2 ... valueN]
| Creates a TairRoaring key based on the specified integer array. If the key already exists, this command overwrites the data in the key. Note In TairRoaring V2, we recommend that you use TR.SETBITS instead of this command. | - |
TR.SETBITARRAY | TR.SETBITARRAY key value
| Creates a TairRoaring key based on the specified bit array string. The bit array string consists of 0 and 1. If the key already exists, this command overwrites the data in the key. Note In TairRoaring V2, we recommend that you use TR.APPENDBITARRAY instead of this command. | - |
TR.BITOP | TR.BITOP destkey operation key [key1 key2 ... keyN]
| Performs a bitwise operation on multiple TairRoaring keys and stores the result in the destination key. The AND, OR, XOR, NOT, and DIFF bitwise operations are supported. Note This command is unavailable for keys that reside across slots in cluster instances. | - |
TR.BITOPCARD | TR.BITOPCARD operation key [key1 key2 ... keyN]
| Performs a bitwise operation on multiple TairRoaring keys. The AND, OR, XOR, NOT, and DIFF bitwise operations are supported. Note This command is unavailable for keys that reside across slots in cluster instances. | Added in V2. |
TR.OPTIMIZE | TR.OPTIMIZE key
| Optimizes the storage of a TairRoaring key. If the key stores a large number of elements and is used mainly for read operations after the key is created, you can run this command. | - |
Read operation | TR.GETBIT | TR.GETBIT key offset
| Retrieves the value of the specified bit from a TairRoaring key. | - |
TR.GETBITS | TR.GETBITS key offset [offset1 offset2 ... offsetN]
| Retrieves the value of the specified bit from a TairRoaring key. You can specify multiple bits for value retrieval. | Added in V2. |
TR.BITCOUNT | TR.BITCOUNT key [start end]
| Counts the number of bits that have a value of 1 within the specified range in a TairRoaring key. The range is a closed interval. | Updated in V2 and compatible with V1. |
TR.BITPOS | TR.BITPOS <key> <value> [count]
| Retrieves the offset of the bit that has an ordinal number of count. A bit can have a value of 1 or 0. The count parameter is optional and has a default value of 1. A value of 1 indicates the first bit retrieved by using the left-right counting approach. | Updated in V2 and compatible with V1. |
TR.SCAN | TR.SCAN key start_offset [COUNT count]
| Scans all bits located after a specified bit in a TairRoaring key and returns the offsets corresponding to a count of the scanned bits that have a value of 1. The returned cursor is the offset corresponding to the key. Note This command may or may not scan and return added or removed elements. | Added in V2. |
TR.RANGE | TR.RANGE key start end
| Retrieves the offsets of the bits that have a value of 1 within the specified range in a TairRoaring key. The range is a closed interval. | Renamed as TR.RANGE in V2 from TR.RANGEINTARRAY in V1. |
TR.RANGEBITARRAY | TR.RANGEBITARRAY key start end
| Retrieves a string that consists of bit values of 0 and 1 within the specified range in a TairRoaring key. The range is a closed interval. | Added in V2. |
TR.MIN | TR.MIN key
| Retrieves the offset of the first bit that has a value of 1 in a TairRoaring key. If no bits have a value of 1, a value of -1 is returned. | - |
TR.MAX | TR.MAX key
| Retrieves the offset of the last bit that has a value of 1 in a TairRoaring key. If no bits have a value of 1, -1 is returned. | - |
TR.STAT | TR.STAT key [JSON]
| Returns the statistical information of the specified TairRoaring key. The information includes the number of containers and the memory usage. | Added in V2. |
TR.JACCARD | TR.JACCARD key1 key2
| Retrieves the Jaccard similarity coefficient of two TairRoaring keys. The higher the coefficient, the higher the similarity. Note This command is unavailable for keys that reside across slots in cluster instances. | Added in V2.2. |
TR.CONTAINS | TR.CONTAINS key1 key2
| Checks whether key2 contains key1. If yes, key1 is a subset of key2 and a value of 1 is returned. Otherwise, key1 is not a subset of key2 and a value of 0 is returned. Note This command is unavailable for keys that reside across slots in cluster instances. | Added in V2.2. |
TR.RANK | TR.RANK key offset
| Retrieves the number of bits that have a value of 1 within the range from the first bit to the specified bit. The range is a closed interval. | Added in V2.2. |
General-purpose operation | DEL | DEL key [key ...]
| Deletes one or more TairRoaring keys. | - |