mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 00:25:55 +00:00
new range command
This commit is contained in:
parent
4190b720dc
commit
ee260ba693
2 changed files with 38 additions and 0 deletions
|
|
@ -259,3 +259,18 @@ func (self *CmdLoadRequest) Execute(f *Fragment) Calculation {
|
|||
f.impl.Get(self.bitmap_id)
|
||||
return 0
|
||||
}
|
||||
|
||||
type CmdRange struct {
|
||||
*Responder
|
||||
bitmap_id uint64
|
||||
start_time time.Time
|
||||
end_time time.Time
|
||||
}
|
||||
|
||||
func NewRange(bitmap_id uint64, start, end time.Time) *CmdRange {
|
||||
return &CmdRange{NewResponder("Range"), bitmap_id, start, end}
|
||||
}
|
||||
|
||||
func (self *CmdRange) Execute(f *Fragment) Calculation {
|
||||
return f.build_time_range_bitmap(self.bitmap_id, self.start_time, self.end_time)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,17 @@ func (self *FragmentContainer) Get(frag_id util.SUUID, bitmap_id uint64) (Bitmap
|
|||
return 0, errors.New("Invalid Bitmap Handle")
|
||||
}
|
||||
|
||||
func (self *FragmentContainer) Range(frag_id util.SUUID, bitmap_id uint64, start, end time.Time) (BitmapHandle, error) {
|
||||
if fragment, found := self.GetFragment(frag_id); found {
|
||||
request := NewRange(bitmap_id, start, end)
|
||||
fragment.requestChan <- request
|
||||
result := request.Response()
|
||||
util.SendTimer("fragmant_container_Range", result.exec_time.Nanoseconds())
|
||||
return result.answer.(BitmapHandle), nil
|
||||
}
|
||||
return 0, errors.New("Invalid Bitmap Handle")
|
||||
}
|
||||
|
||||
func (self *FragmentContainer) TopN(frag_id util.SUUID, bh BitmapHandle, n int, categories []uint64) ([]Pair, error) {
|
||||
if fragment, found := self.GetFragment(frag_id); found {
|
||||
request := NewTopN(bh, n, categories)
|
||||
|
|
@ -327,6 +338,18 @@ func (self *Fragment) union(bitmaps []BitmapHandle) BitmapHandle {
|
|||
}
|
||||
return self.AllocHandle(result)
|
||||
}
|
||||
func (self *Fragment) build_time_range_bitmap(bitmap_id uint64, start, end time.Time) BitmapHandle {
|
||||
result := NewBitmap()
|
||||
for i, bid := range GetRange(start, end, bitmap_id) {
|
||||
bm := self.impl.Get(bid)
|
||||
if i == 0 {
|
||||
result = bm
|
||||
} else {
|
||||
result = Union(result, bm)
|
||||
}
|
||||
}
|
||||
return self.AllocHandle(result)
|
||||
}
|
||||
|
||||
func (self *Fragment) intersect(bitmaps []BitmapHandle) BitmapHandle {
|
||||
var result IBitmap
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue