From 216e7695a70c21335498106a86348ba523fa74e9 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Tue, 29 Jul 2014 17:54:05 +0000 Subject: [PATCH] added mask function for testing --- index/commands.go | 17 +++++++++++++++++ index/fragment_container.go | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/index/commands.go b/index/commands.go index cfc2be479..71f6a1ede 100644 --- a/index/commands.go +++ b/index/commands.go @@ -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) +} diff --git a/index/fragment_container.go b/index/fragment_container.go index ef1a98022..a61f1a549 100644 --- a/index/fragment_container.go +++ b/index/fragment_container.go @@ -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)