// Range returns the ids corresponding to the given range of values func (idx *UniqueIndex) Range(min []byte, max []byte, opts *Options) ([][]byte, error) { var list [][]byte c := internal.RangeCursor{ C: idx.IndexBucket.Cursor(), Reverse: opts != nil && opts.Reverse, Min: min, Max: max, CompareFn: func(val, limit []byte) int { return bytes.Compare(val, limit) }, } for val, ident := c.First(); val != nil && c.Continue(val); val, ident = c.Next() { if opts != nil && opts.Skip > 0 { opts.Skip-- continue } if opts != nil && opts.Limit == 0 { break } if opts != nil && opts.Limit > 0 { opts.Limit-- } list = append(list, ident) } return list, nil }
// Range returns the ids corresponding to the given range of values func (idx *ListIndex) Range(min []byte, max []byte, opts *Options) ([][]byte, error) { var list [][]byte c := internal.RangeCursor{ C: idx.IndexBucket.Cursor(), Reverse: opts != nil && opts.Reverse, Min: min, Max: max, CompareFn: func(val, limit []byte) int { pos := bytes.LastIndex(val, []byte("__")) return bytes.Compare(val[:pos], limit) }, } for k, id := c.First(); c.Continue(k); k, id = c.Next() { if id == nil || bytes.Equal(k, []byte("storm__ids")) { continue } if opts != nil && opts.Skip > 0 { opts.Skip-- continue } if opts != nil && opts.Limit == 0 { break } if opts != nil && opts.Limit > 0 { opts.Limit-- } list = append(list, id) } return list, nil }