mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Unexport RowSegment
This commit is contained in:
parent
259f5ac3b9
commit
45f3439a7f
3 changed files with 34 additions and 34 deletions
|
|
@ -375,7 +375,7 @@ func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
}
|
||||
|
||||
if opt.ExcludeColumns {
|
||||
row.segments = []RowSegment{}
|
||||
row.segments = []rowSegment{}
|
||||
}
|
||||
|
||||
return row, nil
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ func (f *fragment) unprotectedRow(rowID uint64, checkRowCache bool, updateRowCac
|
|||
// We Clone() data because otherwise row will contains pointers to containers in storage.
|
||||
// This causes unexpected results when we cache the row and try to use it later.
|
||||
row := &Row{
|
||||
segments: []RowSegment{{
|
||||
segments: []rowSegment{{
|
||||
data: *data.Clone(),
|
||||
shard: f.shard,
|
||||
writable: false,
|
||||
|
|
|
|||
64
row.go
64
row.go
|
|
@ -24,7 +24,7 @@ import (
|
|||
// Row is a set of integers (the associated columns), and attributes which are
|
||||
// arbitrary key/value pairs storing metadata about what the row represents.
|
||||
type Row struct {
|
||||
segments []RowSegment
|
||||
segments []rowSegment
|
||||
|
||||
// String keys translated to/from segment columns.
|
||||
Keys []string
|
||||
|
|
@ -44,7 +44,7 @@ func NewRow(columns ...uint64) *Row {
|
|||
|
||||
// Merge merges data from other into r.
|
||||
func (r *Row) Merge(other *Row) {
|
||||
var segments []RowSegment
|
||||
var segments []rowSegment
|
||||
|
||||
itr := newMergeSegmentIterator(r.segments, other.segments)
|
||||
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
|
||||
|
|
@ -84,7 +84,7 @@ func (r *Row) intersectionCount(other *Row) uint64 {
|
|||
|
||||
// intersect returns the itersection of r and other.
|
||||
func (r *Row) intersect(other *Row) *Row {
|
||||
var segments []RowSegment
|
||||
var segments []rowSegment
|
||||
|
||||
itr := newMergeSegmentIterator(r.segments, other.segments)
|
||||
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
|
||||
|
|
@ -100,7 +100,7 @@ func (r *Row) intersect(other *Row) *Row {
|
|||
|
||||
// Xor returns the xor of r and other.
|
||||
func (r *Row) Xor(other *Row) *Row {
|
||||
var segments []RowSegment
|
||||
var segments []rowSegment
|
||||
|
||||
itr := newMergeSegmentIterator(r.segments, other.segments)
|
||||
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
|
||||
|
|
@ -120,7 +120,7 @@ func (r *Row) Xor(other *Row) *Row {
|
|||
|
||||
// Union returns the bitwise union of r and other.
|
||||
func (r *Row) Union(other *Row) *Row {
|
||||
var segments []RowSegment
|
||||
var segments []rowSegment
|
||||
itr := newMergeSegmentIterator(r.segments, other.segments)
|
||||
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
|
||||
if s1 == nil {
|
||||
|
|
@ -138,7 +138,7 @@ func (r *Row) Union(other *Row) *Row {
|
|||
|
||||
// Difference returns the diff of r and other.
|
||||
func (r *Row) Difference(other *Row) *Row {
|
||||
var segments []RowSegment
|
||||
var segments []rowSegment
|
||||
|
||||
itr := newMergeSegmentIterator(r.segments, other.segments)
|
||||
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
|
||||
|
|
@ -169,13 +169,13 @@ func (r *Row) clearBit(i uint64) (changed bool) {
|
|||
}
|
||||
|
||||
// Segments returns a list of all segments in the row.
|
||||
func (r *Row) Segments() []RowSegment {
|
||||
func (r *Row) Segments() []rowSegment {
|
||||
return r.segments
|
||||
}
|
||||
|
||||
// segment returns a segment for a given shard.
|
||||
// Returns nil if segment does not exist.
|
||||
func (r *Row) segment(shard uint64) *RowSegment {
|
||||
func (r *Row) segment(shard uint64) *rowSegment {
|
||||
if i := sort.Search(len(r.segments), func(i int) bool {
|
||||
return r.segments[i].shard >= shard
|
||||
}); i < len(r.segments) && r.segments[i].shard == shard {
|
||||
|
|
@ -184,7 +184,7 @@ func (r *Row) segment(shard uint64) *RowSegment {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Row) createSegmentIfNotExists(shard uint64) *RowSegment {
|
||||
func (r *Row) createSegmentIfNotExists(shard uint64) *rowSegment {
|
||||
i := sort.Search(len(r.segments), func(i int) bool {
|
||||
return r.segments[i].shard >= shard
|
||||
})
|
||||
|
|
@ -195,11 +195,11 @@ func (r *Row) createSegmentIfNotExists(shard uint64) *RowSegment {
|
|||
}
|
||||
|
||||
// Insert new segment.
|
||||
r.segments = append(r.segments, RowSegment{data: *roaring.NewBitmap()})
|
||||
r.segments = append(r.segments, rowSegment{data: *roaring.NewBitmap()})
|
||||
if i < len(r.segments) {
|
||||
copy(r.segments[i+1:], r.segments[i:])
|
||||
}
|
||||
r.segments[i] = RowSegment{
|
||||
r.segments[i] = rowSegment{
|
||||
data: *roaring.NewBitmap(),
|
||||
shard: shard,
|
||||
writable: true,
|
||||
|
|
@ -251,10 +251,10 @@ func (r *Row) Columns() []uint64 {
|
|||
return a
|
||||
}
|
||||
|
||||
// RowSegment holds a subset of a row.
|
||||
// rowSegment holds a subset of a row.
|
||||
// This could point to a mmapped roaring bitmap or an in-memory bitmap. The
|
||||
// width of the segment will always match the shard width.
|
||||
type RowSegment struct {
|
||||
type rowSegment struct {
|
||||
// Shard this segment belongs to
|
||||
shard uint64
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ type RowSegment struct {
|
|||
|
||||
// Merge adds chunks from other to s.
|
||||
// Chunks in s are overwritten if they exist in other.
|
||||
func (s *RowSegment) Merge(other *RowSegment) {
|
||||
func (s *rowSegment) Merge(other *rowSegment) {
|
||||
s.ensureWritable()
|
||||
|
||||
itr := other.data.Iterator()
|
||||
|
|
@ -280,15 +280,15 @@ func (s *RowSegment) Merge(other *RowSegment) {
|
|||
}
|
||||
|
||||
// IntersectionCount returns the number of intersections between s and other.
|
||||
func (s *RowSegment) IntersectionCount(other *RowSegment) uint64 {
|
||||
func (s *rowSegment) IntersectionCount(other *rowSegment) uint64 {
|
||||
return s.data.IntersectionCount(&other.data)
|
||||
}
|
||||
|
||||
// Intersect returns the itersection of s and other.
|
||||
func (s *RowSegment) Intersect(other *RowSegment) *RowSegment {
|
||||
func (s *rowSegment) Intersect(other *rowSegment) *rowSegment {
|
||||
data := s.data.Intersect(&other.data)
|
||||
|
||||
return &RowSegment{
|
||||
return &rowSegment{
|
||||
data: *data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
|
|
@ -296,10 +296,10 @@ func (s *RowSegment) Intersect(other *RowSegment) *RowSegment {
|
|||
}
|
||||
|
||||
// Union returns the bitwise union of s and other.
|
||||
func (s *RowSegment) Union(other *RowSegment) *RowSegment {
|
||||
func (s *rowSegment) Union(other *rowSegment) *rowSegment {
|
||||
data := s.data.Union(&other.data)
|
||||
|
||||
return &RowSegment{
|
||||
return &rowSegment{
|
||||
data: *data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
|
|
@ -307,10 +307,10 @@ func (s *RowSegment) Union(other *RowSegment) *RowSegment {
|
|||
}
|
||||
|
||||
// Difference returns the diff of s and other.
|
||||
func (s *RowSegment) Difference(other *RowSegment) *RowSegment {
|
||||
func (s *rowSegment) Difference(other *rowSegment) *rowSegment {
|
||||
data := s.data.Difference(&other.data)
|
||||
|
||||
return &RowSegment{
|
||||
return &rowSegment{
|
||||
data: *data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
|
|
@ -318,10 +318,10 @@ func (s *RowSegment) Difference(other *RowSegment) *RowSegment {
|
|||
}
|
||||
|
||||
// Xor returns the xor of s and other.
|
||||
func (s *RowSegment) Xor(other *RowSegment) *RowSegment {
|
||||
func (s *rowSegment) Xor(other *rowSegment) *rowSegment {
|
||||
data := s.data.Xor(&other.data)
|
||||
|
||||
return &RowSegment{
|
||||
return &rowSegment{
|
||||
data: *data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
|
|
@ -329,7 +329,7 @@ func (s *RowSegment) Xor(other *RowSegment) *RowSegment {
|
|||
}
|
||||
|
||||
// SetBit sets the i-th column of the row.
|
||||
func (s *RowSegment) SetBit(i uint64) (changed bool) {
|
||||
func (s *rowSegment) SetBit(i uint64) (changed bool) {
|
||||
s.ensureWritable()
|
||||
changed, _ = s.data.Add(i)
|
||||
if changed {
|
||||
|
|
@ -339,7 +339,7 @@ func (s *RowSegment) SetBit(i uint64) (changed bool) {
|
|||
}
|
||||
|
||||
// ClearBit clears the i-th column of the row.
|
||||
func (s *RowSegment) ClearBit(i uint64) (changed bool) {
|
||||
func (s *rowSegment) ClearBit(i uint64) (changed bool) {
|
||||
s.ensureWritable()
|
||||
|
||||
changed, _ = s.data.Remove(i)
|
||||
|
|
@ -350,12 +350,12 @@ func (s *RowSegment) ClearBit(i uint64) (changed bool) {
|
|||
}
|
||||
|
||||
// InvalidateCount updates the cached count in the row.
|
||||
func (s *RowSegment) InvalidateCount() {
|
||||
func (s *rowSegment) InvalidateCount() {
|
||||
s.n = s.data.Count()
|
||||
}
|
||||
|
||||
// Columns returns a list of all columns set in the segment.
|
||||
func (s *RowSegment) Columns() []uint64 {
|
||||
func (s *rowSegment) Columns() []uint64 {
|
||||
a := make([]uint64, 0, s.Count())
|
||||
itr := s.data.Iterator()
|
||||
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
|
||||
|
|
@ -365,10 +365,10 @@ func (s *RowSegment) Columns() []uint64 {
|
|||
}
|
||||
|
||||
// Count returns the number of set columns in the row.
|
||||
func (s *RowSegment) Count() uint64 { return s.n }
|
||||
func (s *rowSegment) Count() uint64 { return s.n }
|
||||
|
||||
// ensureWritable clones the segment if it is pointing to non-writable data.
|
||||
func (s *RowSegment) ensureWritable() {
|
||||
func (s *rowSegment) ensureWritable() {
|
||||
if s.writable {
|
||||
return
|
||||
}
|
||||
|
|
@ -379,16 +379,16 @@ func (s *RowSegment) ensureWritable() {
|
|||
|
||||
// mergeSegmentIterator produces an iterator that loops through two sets of segments.
|
||||
type mergeSegmentIterator struct {
|
||||
a0, a1 []RowSegment
|
||||
a0, a1 []rowSegment
|
||||
}
|
||||
|
||||
// newMergeSegmentIterator returns a new instance of mergeSegmentIterator.
|
||||
func newMergeSegmentIterator(a0, a1 []RowSegment) mergeSegmentIterator {
|
||||
func newMergeSegmentIterator(a0, a1 []rowSegment) mergeSegmentIterator {
|
||||
return mergeSegmentIterator{a0: a0, a1: a1}
|
||||
}
|
||||
|
||||
// next returns the next set of segments.
|
||||
func (itr *mergeSegmentIterator) next() (s0, s1 *RowSegment) {
|
||||
func (itr *mergeSegmentIterator) next() (s0, s1 *rowSegment) {
|
||||
// Find current segments.
|
||||
if len(itr.a0) > 0 {
|
||||
s0 = &itr.a0[0]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue