mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 03:17:50 +00:00
added mask function for testing
This commit is contained in:
parent
ee260ba693
commit
216e7695a7
2 changed files with 28 additions and 0 deletions
|
|
@ -274,3 +274,20 @@ func NewRange(bitmap_id uint64, start, end time.Time) *CmdRange {
|
|||
func (self *CmdRange) Execute(f *Fragment) Calculation {
|
||||
return f.build_time_range_bitmap(self.bitmap_id, self.start_time, self.end_time)
|
||||
}
|
||||
|
||||
type CmdMask struct {
|
||||
*Responder
|
||||
start, end uint64
|
||||
}
|
||||
|
||||
func NewMask(start, end uint64) *CmdMask {
|
||||
return &CmdMask{NewResponder("Mask"), start, end}
|
||||
}
|
||||
|
||||
func (self *CmdMask) Execute(f *Fragment) Calculation {
|
||||
result := NewBitmap()
|
||||
for i := self.start; i < self.end; i++ {
|
||||
SetBit(result, i)
|
||||
}
|
||||
return f.AllocHandle(result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) Mask(frag_id util.SUUID, start, end uint64) (BitmapHandle, error) {
|
||||
if fragment, found := self.GetFragment(frag_id); found {
|
||||
request := NewMask(start, end)
|
||||
fragment.requestChan <- request
|
||||
result := request.Response()
|
||||
util.SendTimer("fragmant_container_Mask", result.exec_time.Nanoseconds())
|
||||
return result.answer.(BitmapHandle), nil
|
||||
}
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue