mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
added list gethandle operation
This commit is contained in:
parent
3e72e36ec5
commit
f741623420
3 changed files with 35 additions and 0 deletions
|
|
@ -170,3 +170,21 @@ func (self *CmdEmpty) Execute(f *Fragment) Calculation {
|
|||
result := NewBitmap()
|
||||
return f.AllocHandle(result)
|
||||
}
|
||||
|
||||
type CmdGetList struct {
|
||||
*Responder
|
||||
bitmap_ids []uint64
|
||||
}
|
||||
|
||||
func NewGetList(bitmap_ids []uint64) *CmdGetList {
|
||||
return &CmdGetList{NewResponder("GetList"), bitmap_ids}
|
||||
}
|
||||
|
||||
func (self *CmdGetList) Execute(f *Fragment) Calculation {
|
||||
ret := make([]BitmapHandle, len(self.bitmap_ids))
|
||||
for i, v := range self.bitmap_ids {
|
||||
ret[i] = f.NewHandle(v)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,16 @@ func (self *FragmentContainer) Get(frag_id SUUID, bitmap_id uint64) (BitmapHandl
|
|||
}
|
||||
return 0, errors.New("Invalid Bitmap Handle")
|
||||
}
|
||||
|
||||
func (self *FragmentContainer) GetList(frag_id SUUID, bitmap_id []uint64) ([]BitmapHandle, error) {
|
||||
if fragment, found := self.GetFragment(frag_id); found {
|
||||
request := NewGetList(bitmap_id)
|
||||
fragment.requestChan <- request
|
||||
return request.Response().answer.([]BitmapHandle), nil
|
||||
}
|
||||
return nil, errors.New("Invalid Bitmap Handle")
|
||||
}
|
||||
|
||||
func (self *FragmentContainer) Count(frag_id SUUID, bitmap BitmapHandle) (uint64, error) {
|
||||
if fragment, found := self.GetFragment(frag_id); found {
|
||||
request := NewCount(bitmap)
|
||||
|
|
|
|||
|
|
@ -68,4 +68,11 @@ func TestServer(t *testing.T) {
|
|||
before, _ := dummy.Count(id, bh)
|
||||
So(before, ShouldEqual, 0)
|
||||
})
|
||||
|
||||
Convey("GetList ", t, func() {
|
||||
bhs, _ := dummy.GetList(id, []uint64{1234, 4321, 789})
|
||||
result, _ := dummy.Union(id, bhs)
|
||||
num, _ := dummy.Count(id, result)
|
||||
So(num, ShouldNotEqual, 2)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue