mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Merge pull request #195 from travisturner/sync-mutex-bool
support mutex/bool fields in anti-entropy
This commit is contained in:
commit
532f746f25
3 changed files with 27 additions and 15 deletions
6
api.go
6
api.go
|
|
@ -415,12 +415,6 @@ func (api *API) ImportRoaring(ctx context.Context, indexName, fieldName string,
|
|||
return newNotFoundError(ErrFieldNotFound)
|
||||
}
|
||||
|
||||
// only set and time fields are supported
|
||||
// TODO: get rid of this (need to confirm other field types)
|
||||
if field.Type() != FieldTypeSet && field.Type() != FieldTypeTime && field.Type() != FieldTypeInt && field.Type() != FieldTypeDecimal {
|
||||
return NewBadRequestError(errors.Errorf("roaring import is only supported for set, time, int, and decimal fields, not '%s' fields.", field.Type()))
|
||||
}
|
||||
|
||||
errCh := make(chan error, len(nodes))
|
||||
|
||||
for _, node := range nodes {
|
||||
|
|
|
|||
18
field.go
18
field.go
|
|
@ -1084,17 +1084,19 @@ func (f *Field) deleteView(name string) error {
|
|||
// Row returns a row of the standard view.
|
||||
// It seems this method is only being used by the test
|
||||
// package, and the fact that it's only allowed on
|
||||
// `set` fields is odd. This may be considered for
|
||||
// deprecation in a future version.
|
||||
// `set`,`mutex`, and `bool` fields is odd. This may
|
||||
// be considered for deprecation in a future version.
|
||||
func (f *Field) Row(rowID uint64) (*Row, error) {
|
||||
if f.Type() != FieldTypeSet {
|
||||
switch f.Type() {
|
||||
case FieldTypeSet, FieldTypeMutex, FieldTypeBool:
|
||||
view := f.view(viewStandard)
|
||||
if view == nil {
|
||||
return nil, ErrInvalidView
|
||||
}
|
||||
return view.row(rowID), nil
|
||||
default:
|
||||
return nil, errors.Errorf("row method unsupported for field type: %s", f.Type())
|
||||
}
|
||||
view := f.view(viewStandard)
|
||||
if view == nil {
|
||||
return nil, ErrInvalidView
|
||||
}
|
||||
return view.row(rowID), nil
|
||||
}
|
||||
|
||||
// SetBit sets a bit on a view within the field.
|
||||
|
|
|
|||
|
|
@ -409,10 +409,14 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("creating field f0: %v", err)
|
||||
}
|
||||
_, err = c[0].API.CreateField(context.Background(), "y", "z", pilosa.OptFieldTypeSet(pilosa.DefaultCacheType, pilosa.DefaultCacheSize))
|
||||
_, err = c[0].API.CreateField(context.Background(), "y", "z", pilosa.OptFieldTypeMutex(pilosa.DefaultCacheType, pilosa.DefaultCacheSize))
|
||||
if err != nil {
|
||||
t.Fatalf("creating field z in y: %v", err)
|
||||
}
|
||||
_, err = c[0].API.CreateField(context.Background(), "y", "b", pilosa.OptFieldTypeBool())
|
||||
if err != nil {
|
||||
t.Fatalf("creating field b in y: %v", err)
|
||||
}
|
||||
|
||||
hldr0 := &test.Holder{Holder: c[0].Server.Holder()}
|
||||
hldr1 := &test.Holder{Holder: c[1].Server.Holder()}
|
||||
|
|
@ -427,6 +431,7 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
|
||||
// Set a bit to create the fragment.
|
||||
hldr0.SetBit("y", "z", 0, 0)
|
||||
hldr0.SetBit("y", "b", 0, 0) // rowID = 0 means false
|
||||
|
||||
// Set data on the remote holder.
|
||||
hldr1.SetBit("i", "f", 0, 4000)
|
||||
|
|
@ -437,6 +442,10 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
hldr1.SetBit("y", "z", 10, (3*ShardWidth)+5)
|
||||
hldr1.SetBit("y", "z", 10, (3*ShardWidth)+7)
|
||||
|
||||
hldr1.SetBit("y", "b", 1, (3*ShardWidth)+4) // true
|
||||
hldr1.SetBit("y", "b", 0, (3*ShardWidth)+5) // false
|
||||
hldr1.SetBit("y", "b", 1, (3*ShardWidth)+7) // true
|
||||
|
||||
err = c[0].Server.SyncData()
|
||||
if err != nil {
|
||||
t.Fatalf("syncing node 0: %v", err)
|
||||
|
|
@ -471,6 +480,13 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
if a := hldr.Row("y", "z", 10).Columns(); !reflect.DeepEqual(a, []uint64{(3 * ShardWidth) + 4, (3 * ShardWidth) + 5, (3 * ShardWidth) + 7}) {
|
||||
t.Errorf("unexpected columns(%d/y/z): %+v", i, a)
|
||||
}
|
||||
|
||||
if a := hldr.Row("y", "b", 0).Columns(); !reflect.DeepEqual(a, []uint64{0, (3 * ShardWidth) + 5}) {
|
||||
t.Errorf("unexpected false columns(%d/y/b): %+v", i, a)
|
||||
}
|
||||
if a := hldr.Row("y", "b", 1).Columns(); !reflect.DeepEqual(a, []uint64{(3 * ShardWidth) + 4, (3 * ShardWidth) + 7}) {
|
||||
t.Errorf("unexpected true columns(%d/y/b): %+v", i, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue