mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
drop unused helper functions
I have no idea what these functions were for, but we aren't using them so let's not have them.
This commit is contained in:
parent
39903bc17e
commit
5901bcd5d6
1 changed files with 0 additions and 73 deletions
|
|
@ -164,79 +164,6 @@ func GenerateValues(rand *rand.Rand, n int) []uint64 {
|
|||
return a
|
||||
}
|
||||
|
||||
var _ = ToRows
|
||||
|
||||
// ToRows returns a sorted list of rows from a set of values.
|
||||
func ToRows(values []uint64) []*Row {
|
||||
m := make(map[uint64][]uint64)
|
||||
for _, v := range values {
|
||||
id := v / rbf.ShardWidth
|
||||
m[id] = append(m[id], v&rbf.RowValueMask)
|
||||
}
|
||||
|
||||
a := make([]*Row, 0, len(m))
|
||||
for id, values := range m {
|
||||
a = append(a, &Row{ID: id, Values: values})
|
||||
}
|
||||
sort.Slice(a, func(i, j int) bool { return a[i].ID < a[j].ID })
|
||||
return a
|
||||
}
|
||||
|
||||
var _ = Row{}
|
||||
|
||||
type Row struct {
|
||||
ID uint64
|
||||
Values []uint64
|
||||
}
|
||||
|
||||
func (r *Row) Bitmap() []uint64 {
|
||||
a := make([]uint64, rbf.ShardWidth/64)
|
||||
for _, v := range r.Values {
|
||||
a[v/64] |= 1 << (v % 64)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// Union returns the union of r and other's values.
|
||||
func (r *Row) Union(other *Row) []uint64 {
|
||||
m := make(map[uint64]struct{})
|
||||
for _, v := range r.Values {
|
||||
m[v] = struct{}{}
|
||||
}
|
||||
for _, v := range other.Values {
|
||||
m[v] = struct{}{}
|
||||
}
|
||||
|
||||
a := make([]uint64, 0, len(m))
|
||||
for v := range m {
|
||||
a = append(a, v)
|
||||
}
|
||||
sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
|
||||
return a
|
||||
}
|
||||
|
||||
// Intersect returns the intersection of r & other's values.
|
||||
func (r *Row) Intersect(other *Row) []uint64 {
|
||||
m := make(map[uint64]struct{})
|
||||
for _, v := range r.Values {
|
||||
m[v] = struct{}{}
|
||||
}
|
||||
|
||||
a := make([]uint64, 0)
|
||||
used := make(map[uint64]struct{})
|
||||
for _, v := range other.Values {
|
||||
if _, ok := used[v]; ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := m[v]; ok {
|
||||
used[v] = struct{}{}
|
||||
a = append(a, v)
|
||||
}
|
||||
}
|
||||
sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
|
||||
return a
|
||||
}
|
||||
|
||||
// QuickCheck executes fn multiple times with a different PRNG.
|
||||
func QuickCheck(t *testing.T, fn func(t *testing.T, rand *rand.Rand)) {
|
||||
for i := 0; i < *quickCheckN; i++ {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue