SDiffByOneBucket returns the members of the set resulting from the difference between the first set and all the successive sets in one bucket.
(bucket string, key1, key2 []byte)
| 251 | // SDiffByOneBucket returns the members of the set resulting from the difference |
| 252 | // between the first set and all the successive sets in one bucket. |
| 253 | func (tx *Tx) SDiffByOneBucket(bucket string, key1, key2 []byte) ([][]byte, error) { |
| 254 | if err := tx.checkTxIsClosed(); err != nil { |
| 255 | return nil, err |
| 256 | } |
| 257 | b, err := tx.db.bucketMgr.GetBucket(DataStructureSet, bucket) |
| 258 | if err != nil { |
| 259 | return nil, err |
| 260 | } |
| 261 | bucketId := b.Id |
| 262 | if set, ok := tx.db.Index.Set.exist(bucketId); ok { |
| 263 | items, err := set.SDiff(string(key1), string(key2)) |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | values := make([][]byte, len(items)) |
| 268 | for i, item := range items { |
| 269 | value, err := tx.db.getValueByRecord(item) |
| 270 | if err != nil { |
| 271 | return nil, err |
| 272 | } |
| 273 | values[i] = value |
| 274 | } |
| 275 | return values, nil |
| 276 | } |
| 277 | |
| 278 | return nil, ErrBucketNotFound |
| 279 | } |
| 280 | |
| 281 | // SDiffByTwoBuckets returns the members of the set resulting from the difference |
| 282 | // between the first set and all the successive sets in two buckets. |