From 306cc0b64e3d6d7de076f53afc247605f7c96d90 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 12 Apr 2017 08:34:31 -0600 Subject: [PATCH] Opt-in to inverse storage. --- db.go | 6 +- executor.go | 22 ++++--- frame.go | 36 ++++++++--- handler_test.go | 6 +- internal/internal.pb.go | 135 +++++++++++++++++++++++++--------------- internal/internal.proto | 1 + pilosa.go | 9 +-- view.go | 4 +- 8 files changed, 142 insertions(+), 77 deletions(-) diff --git a/db.go b/db.go index 04a8c1328..ac13a9119 100644 --- a/db.go +++ b/db.go @@ -375,7 +375,11 @@ func (db *DB) createFrame(name string, opt FrameOptions) (*Frame, error) { } // Set options. - if err := f.SetRowLabel(opt.RowLabel); err != nil { + if opt.RowLabel != "" { + f.rowLabel = opt.RowLabel + } + f.inverseEnabled = opt.InverseEnabled + if err := f.saveMeta(); err != nil { f.Close() return nil, err } diff --git a/executor.go b/executor.go index efb9e8199..56cdcb44e 100644 --- a/executor.go +++ b/executor.go @@ -534,10 +534,13 @@ func (e *Executor) executeClearBit(ctx context.Context, db string, c *pql.Call, } else if changed { ret = true } - if changed, err := e.executeClearBitView(ctx, db, c, f, ViewInverse, rowID, colID, opt); err != nil { - return ret, err - } else if changed { - ret = true + + if f.InverseEnabled() { + if changed, err := e.executeClearBitView(ctx, db, c, f, ViewInverse, rowID, colID, opt); err != nil { + return ret, err + } else if changed { + ret = true + } } return ret, nil default: @@ -631,10 +634,13 @@ func (e *Executor) executeSetBit(ctx context.Context, db string, c *pql.Call, op } else if changed { ret = true } - if changed, err := e.executeSetBitView(ctx, db, c, f, ViewInverse, rowID, colID, timestamp, opt); err != nil { - return ret, err - } else if changed { - ret = true + + if f.InverseEnabled() { + if changed, err := e.executeSetBitView(ctx, db, c, f, ViewInverse, rowID, colID, timestamp, opt); err != nil { + return ret, err + } else if changed { + ret = true + } } return ret, nil default: diff --git a/frame.go b/frame.go index 06e5b0527..9069df26b 100644 --- a/frame.go +++ b/frame.go @@ -22,7 +22,8 @@ const ( // Default frame settings. const ( - DefaultRowLabel = "id" + DefaultRowLabel = "id" + DefaultInverseEnabled = false ) // Frame represents a container for views. @@ -40,8 +41,9 @@ type Frame struct { stats StatsClient - // Label used for referring to a row. - rowLabel string + // Frame settings. + inverseEnabled bool + rowLabel string LogOutput io.Writer } @@ -63,7 +65,8 @@ func NewFrame(path, db, name string) (*Frame, error) { stats: NopStatsClient, - rowLabel: DefaultRowLabel, + inverseEnabled: DefaultInverseEnabled, + rowLabel: DefaultRowLabel, LogOutput: ioutil.Discard, }, nil @@ -132,11 +135,17 @@ func (f *Frame) RowLabel() string { return v } +// InverseEnabled returns true if an inverse view is available. +func (f *Frame) InverseEnabled() bool { + return f.inverseEnabled +} + // Options returns all options for this frame. func (f *Frame) Options() FrameOptions { f.mu.Lock() opt := FrameOptions{ - RowLabel: f.rowLabel, + InverseEnabled: f.inverseEnabled, + RowLabel: f.rowLabel, } f.mu.Unlock() return opt @@ -214,6 +223,7 @@ func (f *Frame) loadMeta() error { if os.IsNotExist(err) { f.timeQuantum = "" f.rowLabel = DefaultRowLabel + f.inverseEnabled = DefaultInverseEnabled return nil } else if err != nil { return err @@ -226,6 +236,7 @@ func (f *Frame) loadMeta() error { // Copy metadata fields. f.timeQuantum = TimeQuantum(pb.TimeQuantum) f.rowLabel = pb.RowLabel + f.inverseEnabled = pb.InverseEnabled return nil } @@ -234,8 +245,9 @@ func (f *Frame) loadMeta() error { func (f *Frame) saveMeta() error { // Marshal metadata. buf, err := proto.Marshal(&internal.Frame{ - TimeQuantum: string(f.timeQuantum), - RowLabel: f.rowLabel, + TimeQuantum: string(f.timeQuantum), + RowLabel: f.rowLabel, + InverseEnabled: f.inverseEnabled, }) if err != nil { return err @@ -323,6 +335,11 @@ func (f *Frame) Views() []*View { } func (f *Frame) CreateViewIfNotExists(name string) (*View, error) { + // Don't create inverse views if they are not enabled. + if !f.InverseEnabled() && IsInverseView(name) { + return nil, ErrFrameInverseDisabled + } + f.mu.Lock() defer f.mu.Unlock() @@ -476,7 +493,7 @@ func (f *Frame) Import(bitmapIDs, profileIDs []uint64, timestamps []*time.Time) // Import into each fragment. for key, data := range dataByFragment { // Re-sort data for inverse views. - if IsViewInverted(key.View) { + if IsInverseView(key.View) { sort.Sort(importBitSet{ bitmapIDs: data.BitmapIDs, profileIDs: data.ProfileIDs, @@ -521,7 +538,8 @@ func (p frameInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } // FrameOptions represents options to set when initializing a frame. type FrameOptions struct { - RowLabel string `json:"rowLabel,omitempty"` + RowLabel string `json:"rowLabel,omitempty"` + InverseEnabled bool `json:"inverseEnabled,omitempty"` } // importBitSet represents slices of row and column ids. diff --git a/handler_test.go b/handler_test.go index 257e59713..95c77211a 100644 --- a/handler_test.go +++ b/handler_test.go @@ -37,7 +37,7 @@ func TestHandler_Schema(t *testing.T) { d0 := idx.MustCreateDBIfNotExists("d0", pilosa.DBOptions{}) d1 := idx.MustCreateDBIfNotExists("d1", pilosa.DBOptions{}) - if f, err := d0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if f, err := d0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{InverseEnabled: true}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) @@ -93,7 +93,7 @@ func TestHandler_MaxSlices_Inverse(t *testing.T) { idx := MustOpenIndex() defer idx.Close() - f0, err := idx.MustCreateDBIfNotExists("d0", pilosa.DBOptions{}).CreateFrame("f0", pilosa.FrameOptions{}) + f0, err := idx.MustCreateDBIfNotExists("d0", pilosa.DBOptions{}).CreateFrame("f0", pilosa.FrameOptions{InverseEnabled: true}) if err != nil { t.Fatal(err) } @@ -105,7 +105,7 @@ func TestHandler_MaxSlices_Inverse(t *testing.T) { t.Fatal(err) } - f1, err := idx.MustCreateDBIfNotExists("d1", pilosa.DBOptions{}).CreateFrame("f1", pilosa.FrameOptions{}) + f1, err := idx.MustCreateDBIfNotExists("d1", pilosa.DBOptions{}).CreateFrame("f1", pilosa.FrameOptions{InverseEnabled: true}) if err != nil { t.Fatal(err) } diff --git a/internal/internal.pb.go b/internal/internal.pb.go index 2314036cd..2b49c65dd 100644 --- a/internal/internal.pb.go +++ b/internal/internal.pb.go @@ -57,8 +57,9 @@ func (*DB) ProtoMessage() {} func (*DB) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{0} } type Frame struct { - TimeQuantum string `protobuf:"bytes,1,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` - RowLabel string `protobuf:"bytes,2,opt,name=RowLabel,proto3" json:"RowLabel,omitempty"` + TimeQuantum string `protobuf:"bytes,1,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` + RowLabel string `protobuf:"bytes,2,opt,name=RowLabel,proto3" json:"RowLabel,omitempty"` + InverseEnabled bool `protobuf:"varint,3,opt,name=InverseEnabled,proto3" json:"InverseEnabled,omitempty"` } func (m *Frame) Reset() { *m = Frame{} } @@ -363,6 +364,16 @@ func (m *Frame) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintInternal(dAtA, i, uint64(len(m.RowLabel))) i += copy(dAtA[i:], m.RowLabel) } + if m.InverseEnabled { + dAtA[i] = 0x18 + i++ + if m.InverseEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } return i, nil } @@ -1100,6 +1111,9 @@ func (m *Frame) Size() (n int) { if l > 0 { n += 1 + l + sovInternal(uint64(l)) } + if m.InverseEnabled { + n += 2 + } return n } @@ -1604,6 +1618,26 @@ func (m *Frame) Unmarshal(dAtA []byte) error { } m.RowLabel = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InverseEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInternal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.InverseEnabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipInternal(dAtA[iNdEx:]) @@ -3978,52 +4012,53 @@ var ( func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } var fileDescriptorInternal = []byte{ - // 746 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xdd, 0x6a, 0x14, 0x4b, - 0x10, 0x3e, 0xbd, 0x33, 0xb3, 0x3f, 0xb5, 0xc9, 0xb2, 0x69, 0x72, 0x0e, 0x43, 0x38, 0x2c, 0x43, - 0x73, 0x0e, 0x0c, 0x82, 0x09, 0xc4, 0x1b, 0x11, 0x41, 0x9c, 0xdd, 0x0d, 0x59, 0x34, 0x21, 0xe9, - 0xc4, 0xdc, 0x79, 0xd1, 0x89, 0x6d, 0x32, 0x64, 0x7e, 0xd6, 0x99, 0x1e, 0x93, 0xbd, 0xf4, 0xc2, - 0x77, 0x10, 0x7d, 0x02, 0x7d, 0x12, 0x2f, 0x7d, 0x04, 0x89, 0x2f, 0x22, 0xfd, 0x33, 0x3f, 0x51, - 0x8c, 0xf1, 0x6e, 0xea, 0xab, 0xae, 0xea, 0xfa, 0xea, 0xab, 0xea, 0x81, 0x41, 0x98, 0x08, 0x9e, - 0x25, 0x2c, 0x5a, 0x9f, 0x67, 0xa9, 0x48, 0x71, 0xb7, 0xb4, 0xc9, 0x36, 0xb4, 0x26, 0x01, 0xf6, - 0xa0, 0x7f, 0x18, 0xc6, 0x7c, 0xbf, 0x60, 0x89, 0x28, 0x62, 0x17, 0x79, 0xc8, 0xef, 0xd1, 0x26, - 0x24, 0x4f, 0x8c, 0xd3, 0xa8, 0x88, 0x93, 0xa7, 0xec, 0x98, 0x47, 0x6e, 0x4b, 0x9f, 0x68, 0x40, - 0x64, 0x0a, 0xce, 0x56, 0xc6, 0x62, 0x7e, 0x8b, 0x64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c3, 0x3c, - 0xc2, 0xca, 0x78, 0xd0, 0xba, 0x8f, 0x82, 0xe1, 0xe7, 0xab, 0x11, 0xfa, 0x72, 0x35, 0x42, 0x5f, - 0xaf, 0x46, 0xe8, 0xdd, 0xb7, 0xd1, 0x5f, 0xc7, 0x6d, 0xf5, 0xc3, 0xba, 0xf7, 0x3d, 0x00, 0x00, - 0xff, 0xff, 0x1c, 0xb1, 0xe1, 0x29, 0xc2, 0x06, 0x00, 0x00, + // 766 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x4e, 0x1c, 0x47, + 0x10, 0x4e, 0xef, 0xcc, 0xec, 0x4f, 0x2d, 0xac, 0x96, 0x16, 0x89, 0x46, 0x28, 0x5a, 0xad, 0x5a, + 0x49, 0xb4, 0x8a, 0x14, 0x90, 0xc8, 0x25, 0x8a, 0x22, 0x45, 0x9e, 0xdd, 0x45, 0xac, 0x6c, 0x10, + 0x34, 0x98, 0x9b, 0x0f, 0x0d, 0xb4, 0x61, 0xc4, 0xfc, 0xac, 0x7b, 0x7a, 0x80, 0x3d, 0xfa, 0xe0, + 0x77, 0xb0, 0xec, 0x27, 0xb0, 0x9f, 0xc4, 0x47, 0x3f, 0x82, 0x85, 0x5f, 0xc4, 0xea, 0x9f, 0xf9, + 0x01, 0xcb, 0x18, 0xdf, 0xba, 0xbe, 0xea, 0xaa, 0xa9, 0xaf, 0xbe, 0xaa, 0x1e, 0xe8, 0x85, 0x89, + 0xe4, 0x22, 0x61, 0xd1, 0xfa, 0x5c, 0xa4, 0x32, 0xc5, 0xed, 0xc2, 0x26, 0xdb, 0xd0, 0x98, 0x04, + 0x78, 0x08, 0xdd, 0xc3, 0x30, 0xe6, 0xfb, 0x39, 0x4b, 0x64, 0x1e, 0xfb, 0x68, 0x88, 0x46, 0x1d, + 0x5a, 0x87, 0xd4, 0x8d, 0x71, 0x1a, 0xe5, 0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bb, 0x52, 0x7e, 0x7a, 0x1b, 0x3a, 0x25, + 0x68, 0x97, 0xf5, 0xcf, 0x6a, 0x3a, 0xbe, 0xba, 0x5f, 0x21, 0xd3, 0x44, 0x8a, 0x05, 0xad, 0x82, + 0xd7, 0xfe, 0x83, 0xde, 0x6d, 0xa7, 0xea, 0xfb, 0x45, 0xf5, 0x66, 0x5d, 0x98, 0x47, 0xf8, 0x52, + 0x3f, 0x1e, 0xf6, 0x11, 0xd6, 0xc6, 0xbf, 0x8d, 0x7f, 0x50, 0xd0, 0xff, 0x70, 0x33, 0x40, 0x1f, + 0x6f, 0x06, 0xe8, 0xd3, 0xcd, 0x00, 0xbd, 0xfe, 0x3c, 0xf8, 0xe9, 0xb8, 0xa9, 0x7f, 0x6c, 0x7f, + 0x7f, 0x09, 0x00, 0x00, 0xff, 0xff, 0xba, 0xb0, 0xaa, 0x97, 0xea, 0x06, 0x00, 0x00, } diff --git a/internal/internal.proto b/internal/internal.proto index e256b35b5..5ab689f88 100644 --- a/internal/internal.proto +++ b/internal/internal.proto @@ -10,6 +10,7 @@ message DB { message Frame { string TimeQuantum = 1; string RowLabel = 2; + bool InverseEnabled = 3; } message Bitmap { diff --git a/pilosa.go b/pilosa.go index 93dd9fef3..814c69753 100644 --- a/pilosa.go +++ b/pilosa.go @@ -16,11 +16,12 @@ var ( ErrDatabaseNotFound = errors.New("database not found") // ErrFrameRequired is returned when no frame is specified. - ErrFrameRequired = errors.New("frame required") - ErrFrameExists = errors.New("frame already exists") - ErrFrameNotFound = errors.New("frame not found") + ErrFrameRequired = errors.New("frame required") + ErrFrameExists = errors.New("frame already exists") + ErrFrameNotFound = errors.New("frame not found") + ErrFrameInverseDisabled = errors.New("frame inverse disabled") - ErrInvalidView = errors.New("invalid veiw") + ErrInvalidView = errors.New("invalid view") ErrName = errors.New("invalid database or frame's name, must match [a-z0-9_-]") diff --git a/view.go b/view.go index a04764aa8..f113f22ca 100644 --- a/view.go +++ b/view.go @@ -237,8 +237,8 @@ func (v *View) ClearBit(bitmapID, profileID uint64) (changed bool, err error) { return frag.ClearBit(bitmapID, profileID) } -// IsViewInverted returns true if the view is used for storing an inverted representation. -func IsViewInverted(name string) bool { +// IsInverseView returns true if the view is used for storing an inverted representation. +func IsInverseView(name string) bool { return strings.HasPrefix(name, ViewInverse) }