diff --git a/broadcast.go b/broadcast.go index 866b03d02..0785a21cc 100644 --- a/broadcast.go +++ b/broadcast.go @@ -115,6 +115,7 @@ const ( MessageTypeDeleteFrame = 5 MessageTypeCreateInputDefinition = 6 MessageTypeDeleteInputDefinition = 7 + MessageTypeDeleteView = 8 ) // MarshalMessage encodes the protobuf message into a byte slice. @@ -135,6 +136,8 @@ func MarshalMessage(m proto.Message) ([]byte, error) { typ = MessageTypeCreateInputDefinition case *internal.DeleteInputDefinitionMessage: typ = MessageTypeDeleteInputDefinition + case *internal.DeleteViewMessage: + typ = MessageTypeDeleteView default: return nil, fmt.Errorf("message type not implemented for marshalling: %s", reflect.TypeOf(obj)) } @@ -165,6 +168,8 @@ func UnmarshalMessage(buf []byte) (proto.Message, error) { m = &internal.CreateInputDefinitionMessage{} case MessageTypeDeleteInputDefinition: m = &internal.DeleteInputDefinitionMessage{} + case MessageTypeDeleteView: + m = &internal.DeleteViewMessage{} default: return nil, fmt.Errorf("invalid message type: %d", typ) } diff --git a/fragment.go b/fragment.go index 06f451250..7e56c5597 100644 --- a/fragment.go +++ b/fragment.go @@ -294,11 +294,13 @@ func (f *Fragment) close() error { // Flush cache if closing gracefully. if err := f.flushCache(); err != nil { f.logger().Printf("fragment: error flushing cache on close: err=%s, path=%s", err, f.path) + return err } // Close underlying storage. if err := f.closeStorage(); err != nil { f.logger().Printf("fragment: error closing storage: err=%s, path=%s", err, f.path) + return err } // Remove checksums. diff --git a/frame.go b/frame.go index 9ca2d6109..73412a1d3 100644 --- a/frame.go +++ b/frame.go @@ -393,7 +393,9 @@ func (f *Frame) Close() error { // Close all views. for _, view := range f.views { - _ = view.Close() + if err := view.Close(); err != nil { + return err + } } f.views = make(map[string]*View) @@ -505,6 +507,28 @@ func (f *Frame) newView(path, name string) *View { return view } +// DeleteView removes the view from the frame. +func (f *Frame) DeleteView(name string) error { + view := f.views[name] + if view == nil { + return ErrInvalidView + } + + // Close data files before deletion. + if err := view.Close(); err != nil { + return err + } + + // Delete view directory. + if err := os.RemoveAll(view.Path()); err != nil { + return err + } + + delete(f.views, name) + + return nil +} + // SetBit sets a bit on a view within the frame. func (f *Frame) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. diff --git a/frame_test.go b/frame_test.go index 8cb48cca8..50f5fdef5 100644 --- a/frame_test.go +++ b/frame_test.go @@ -307,3 +307,36 @@ func TestFrame_RowLabelValidation(t *testing.T) { } } + +// Ensure frame can open and retrieve a view. +func TestFrame_DeleteView(t *testing.T) { + f := test.MustOpenFrame() + defer f.Close() + + viewName := pilosa.ViewStandard + "_v" + + // Create view. + view, err := f.CreateViewIfNotExists(viewName) + if err != nil { + t.Fatal(err) + } else if view == nil { + t.Fatal("expected view") + } + + err = f.DeleteView(viewName) + if err != nil { + t.Fatal(err) + } + + if f.View(viewName) != nil { + t.Fatal("view still exists in frame") + } + + // Recreate view with same name, verify that the old view was not reused. + view2, err := f.CreateViewIfNotExists(viewName) + if err != nil { + t.Fatal(err) + } else if view == view2 { + t.Fatal("failed to create new view") + } +} diff --git a/handler.go b/handler.go index 953aeb477..0aae927e0 100644 --- a/handler.go +++ b/handler.go @@ -27,6 +27,7 @@ import ( "io/ioutil" "log" "net/http" + // Imported for its side-effect of registering pprof endpoints with the server. _ "net/http/pprof" "os" "runtime/debug" @@ -43,6 +44,7 @@ import ( "unicode" + // Allow building Pilosa without the web UI. _ "github.com/pilosa/pilosa/statik" "github.com/rakyll/statik/fs" ) @@ -116,6 +118,7 @@ func NewRouter(handler *Handler) *mux.Router { router.HandleFunc("/index/{index}/frame/{frame}/restore", handler.handlePostFrameRestore).Methods("POST") router.HandleFunc("/index/{index}/frame/{frame}/time-quantum", handler.handlePatchFrameTimeQuantum).Methods("PATCH") router.HandleFunc("/index/{index}/frame/{frame}/views", handler.handleGetFrameViews).Methods("GET") + router.HandleFunc("/index/{index}/frame/{frame}/view/{view}", handler.handleDeleteView).Methods("DELETE") router.HandleFunc("/index/{index}/input/{input-definition}", handler.handlePostInput).Methods("POST") router.HandleFunc("/index/{index}/input-definition/{input-definition}", handler.handleGetInputDefinition).Methods("GET") router.HandleFunc("/index/{index}/input-definition/{input-definition}", handler.handlePostInputDefinition).Methods("POST") @@ -791,6 +794,47 @@ func (h *Handler) handleGetFrameViews(w http.ResponseWriter, r *http.Request) { } } +// handleDeleteView handles Delete /frame/view request. +func (h *Handler) handleDeleteView(w http.ResponseWriter, r *http.Request) { + indexName := mux.Vars(r)["index"] + frameName := mux.Vars(r)["frame"] + viewName := mux.Vars(r)["view"] + + // Retrieve frame. + f := h.Holder.Frame(indexName, frameName) + if f == nil { + http.Error(w, ErrFrameNotFound.Error(), http.StatusNotFound) + return + } + + // Delete the view. + if err := f.DeleteView(viewName); err != nil { + // Ingore this error becuase views do not exist on all nodes due to slice distribution. + if err != ErrInvalidView { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + } + + // Send the delete view message to all nodes. + err := h.Broadcaster.SendSync( + &internal.DeleteViewMessage{ + Index: indexName, + Frame: frameName, + View: viewName, + }) + if err != nil { + h.logger().Printf("problem sending DeleteView message: %s", err) + } + + // Encode response. + if err := json.NewEncoder(w).Encode(deleteViewResponse{}); err != nil { + h.logger().Printf("response encoding error: %s", err) + } +} + +type deleteViewResponse struct{} + type getFrameViewsResponse struct { Views []string `json:"views,omitempty"` } diff --git a/handler_test.go b/handler_test.go index 22a1fd4f3..dacb04b38 100644 --- a/handler_test.go +++ b/handler_test.go @@ -1511,3 +1511,25 @@ func TestHandler_GetTimeStamp(t *testing.T) { t.Fatalf("Expected Ignore nonexistent fields") } } + +// Ensure handler can delete a view. +func TestHandler_DeleteView(t *testing.T) { + hldr := test.MustOpenHolder() + defer hldr.Close() + viewName := pilosa.ViewStandard + "_2017" + hldr.MustCreateFragmentIfNotExists("i0", "f0", viewName, 1).MustSetBits(30, (1*SliceWidth)+1) + hldr.Index("i0").Frame("f0").SetTimeQuantum("YMD") + + h := test.NewHandler() + h.Holder = hldr.Holder + h.Cluster = test.NewCluster(1) + w := httptest.NewRecorder() + h.ServeHTTP(w, test.MustNewHTTPRequest("DELETE", "/index/i0/frame/f0/view/standard_2017", strings.NewReader(""))) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{}`+"\n" { + t.Fatalf("unexpected body: %s", body) + } else if f := hldr.Index("i0").Frame("f0").View(viewName); f != nil { + t.Fatal("expected nil view") + } +} diff --git a/holder.go b/holder.go index f7c363524..4270c2594 100644 --- a/holder.go +++ b/holder.go @@ -133,7 +133,9 @@ func (h *Holder) Close() error { h.wg.Wait() for _, index := range h.indexes { - index.Close() + if err := index.Close(); err != nil { + return err + } } return nil } diff --git a/holder_test.go b/holder_test.go index 108349bb2..b3947abb8 100644 --- a/holder_test.go +++ b/holder_test.go @@ -34,8 +34,9 @@ func TestHolder_Open(t *testing.T) { if err := os.Mkdir(h.IndexPath("!"), 0777); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } - if err := h.Reopen(); err != nil { t.Fatal(err) } else if logOutput := h.LogOutput.String(); !strings.Contains(logOutput, `ERROR opening index: !`) { @@ -49,6 +50,8 @@ func TestHolder_Open(t *testing.T) { if _, err := h.CreateIndex("test", pilosa.IndexOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(h.IndexPath("test"), 0000); err != nil { t.Fatal(err) } @@ -64,6 +67,8 @@ func TestHolder_Open(t *testing.T) { if _, err := h.CreateIndex("test", pilosa.IndexOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Truncate(filepath.Join(h.IndexPath("test"), ".meta"), 2); err != nil { t.Fatal(err) } @@ -78,6 +83,8 @@ func TestHolder_Open(t *testing.T) { if _, err := h.CreateIndex("test", pilosa.IndexOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Truncate(filepath.Join(h.IndexPath("test"), ".data"), 2); err != nil { t.Fatal(err) } @@ -95,6 +102,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(filepath.Join(h.Path, "foo", "bar"), 0000); err != nil { t.Fatal(err) } @@ -112,6 +121,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Truncate(filepath.Join(h.Path, "foo", "bar", ".meta"), 2); err != nil { t.Fatal(err) } @@ -128,6 +139,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Truncate(filepath.Join(h.Path, "foo", "bar", ".data"), 2); err != nil { t.Fatal(err) } @@ -147,6 +160,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(filepath.Join(h.Path, "foo", "bar", "views", "standard"), 0000); err != nil { t.Fatal(err) } @@ -166,6 +181,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(filepath.Join(h.Path, "foo", "bar", "views", "standard", "fragments"), 0000); err != nil { t.Fatal(err) } @@ -188,6 +205,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := view.SetBit(0, 0); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(filepath.Join(h.Path, "foo", "bar", "views", "standard", "fragments", "0"), 0000); err != nil { t.Fatal(err) } @@ -209,6 +228,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if _, err := view.SetBit(0, 0); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Truncate(filepath.Join(h.Path, "foo", "bar", "views", "standard", "fragments", "0"), 2); err != nil { t.Fatal(err) } @@ -232,6 +253,8 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } else if err := view.Fragment(0).FlushCache(); err != nil { t.Fatal(err) + } else if err := h.Holder.Close(); err != nil { + t.Fatal(err) } else if err := os.Chmod(filepath.Join(h.Path, "foo", "bar", "views", "standard", "fragments", "0.cache"), 0000); err != nil { t.Fatal(err) } diff --git a/index.go b/index.go index 8f1846c5f..345215690 100644 --- a/index.go +++ b/index.go @@ -248,7 +248,9 @@ func (i *Index) Close() error { // Close all frames. for _, f := range i.frames { - f.Close() + if err := f.Close(); err != nil { + return err + } } i.frames = make(map[string]*Frame) diff --git a/internal/private.pb.go b/internal/private.pb.go index abde718e9..0a9956279 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -32,6 +32,7 @@ ClusterStatus FrameSchema Field + DeleteViewMessage */ package internal @@ -405,6 +406,17 @@ func (m *Field) String() string { return proto.CompactTextString(m) } func (*Field) ProtoMessage() {} func (*Field) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{22} } +type DeleteViewMessage struct { + Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` + Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` + View string `protobuf:"bytes,3,opt,name=View,proto3" json:"View,omitempty"` +} + +func (m *DeleteViewMessage) Reset() { *m = DeleteViewMessage{} } +func (m *DeleteViewMessage) String() string { return proto.CompactTextString(m) } +func (*DeleteViewMessage) ProtoMessage() {} +func (*DeleteViewMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{23} } + func init() { proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta") proto.RegisterType((*FrameMeta)(nil), "internal.FrameMeta") @@ -429,6 +441,7 @@ func init() { proto.RegisterType((*ClusterStatus)(nil), "internal.ClusterStatus") proto.RegisterType((*FrameSchema)(nil), "internal.FrameSchema") proto.RegisterType((*Field)(nil), "internal.Field") + proto.RegisterType((*DeleteViewMessage)(nil), "internal.DeleteViewMessage") } func (m *IndexMeta) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -1344,6 +1357,42 @@ func (m *Field) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *DeleteViewMessage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteViewMessage) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Index) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) + i += copy(dAtA[i:], m.Index) + } + if len(m.Frame) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) + i += copy(dAtA[i:], m.Frame) + } + if len(m.View) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintPrivate(dAtA, i, uint64(len(m.View))) + i += copy(dAtA[i:], m.View) + } + return i, nil +} + func encodeFixed64Private(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) dAtA[offset+1] = uint8(v >> 8) @@ -1773,6 +1822,24 @@ func (m *Field) Size() (n int) { return n } +func (m *DeleteViewMessage) Size() (n int) { + var l int + _ = l + l = len(m.Index) + if l > 0 { + n += 1 + l + sovPrivate(uint64(l)) + } + l = len(m.Frame) + if l > 0 { + n += 1 + l + sovPrivate(uint64(l)) + } + l = len(m.View) + if l > 0 { + n += 1 + l + sovPrivate(uint64(l)) + } + return n +} + func sovPrivate(x uint64) (n int) { for { n++ @@ -4882,6 +4949,143 @@ func (m *Field) Unmarshal(dAtA []byte) error { } return nil } +func (m *DeleteViewMessage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteViewMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteViewMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrivate + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrivate + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Frame = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field View", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrivate + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.View = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPrivate(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPrivate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipPrivate(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -4990,62 +5194,64 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 912 bytes of a gzipped FileDescriptorProto + // 929 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xc1, 0x6e, 0x23, 0x45, - 0x10, 0x65, 0xec, 0xb1, 0xb1, 0x2b, 0x24, 0xf1, 0x36, 0x61, 0xe5, 0x8d, 0x22, 0x13, 0xf5, 0x81, - 0x0d, 0x91, 0xc8, 0x61, 0x91, 0x56, 0xc0, 0x72, 0x80, 0x8d, 0xb3, 0x8a, 0x05, 0x5e, 0xa0, 0xbd, - 0x5a, 0x6e, 0x48, 0x1d, 0xa7, 0xd8, 0x1d, 0x65, 0x3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ff, 0x0e, 0xd8, 0x61, 0x86, 0x52, 0x23, 0x39, 0x18, 0xa2, 0x52, - 0xf2, 0x15, 0xae, 0xfe, 0x0a, 0xb6, 0xb2, 0xb5, 0x72, 0x65, 0x77, 0xa0, 0x3d, 0x50, 0xae, 0xff, - 0xe8, 0x4b, 0xb4, 0x44, 0x01, 0xf0, 0x7d, 0x60, 0x7d, 0x8c, 0x51, 0xa3, 0x1b, 0x99, 0x1b, 0xfc, - 0xf3, 0x91, 0xd7, 0x72, 0x3b, 0x97, 0x3d, 0x84, 0xd0, 0x4c, 0x0b, 0x49, 0x59, 0x7b, 0xf4, 0x76, - 0x51, 0xba, 0x7c, 0x34, 0x05, 0x11, 0x78, 0xe4, 0x9d, 0xba, 0x09, 0xbb, 0x25, 0xc1, 0x6b, 0xda, - 0xcc, 0x87, 0xaa, 0x57, 0x43, 0xe5, 0x33, 0xeb, 0x42, 0x7d, 0xe6, 0x73, 0xfd, 0xbf, 0xa1, 0x78, - 0xdf, 0xa1, 0xa6, 0x5d, 0x9f, 0x9b, 0x5b, 0xfb, 0x86, 0xce, 0xab, 0x53, 0xae, 0xea, 0xf8, 0x27, - 0x70, 0x21, 0xef, 0xe6, 0xa6, 0x52, 0x39, 0xb3, 0x88, 0x7c, 0x63, 0xb9, 0x09, 0xcb, 0x6d, 0xf6, - 0x10, 0x9a, 0x14, 0x55, 0x75, 0x43, 0xea, 0xdd, 0xcd, 0x8a, 0x1a, 0xe1, 0xae, 0xcd, 0x38, 0xb9, - 0x26, 0x6f, 0xd8, 0x71, 0xb2, 0x16, 0x3b, 0x82, 0xce, 0x20, 0x99, 0xce, 0x74, 0x1f, 0xbf, 0x8f, - 0x92, 0x48, 0x47, 0x69, 0xa2, 0xba, 0x4d, 0x72, 0xf5, 0xa0, 0xac, 0x68, 0x81, 0x21, 0x96, 0x9e, - 0xf0, 0x9f, 0x03, 0xd8, 0xac, 0x80, 0x2b, 0x92, 0xf6, 0x7a, 0x6b, 0x37, 0xeb, 0x7d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0xde, 0x24, 0xa7, 0xe8, 0xdb, 0x66, 0xb3, 0x32, 0xeb, 0xc2, 0xdf, 0xf3, - 0x27, 0xb0, 0x7e, 0x18, 0xcf, 0x94, 0xc6, 0xcc, 0x45, 0xd9, 0x87, 0x86, 0x89, 0xe9, 0x7f, 0x9a, - 0xb6, 0x8a, 0x97, 0x85, 0x14, 0x61, 0x29, 0xfc, 0x31, 0xac, 0x51, 0xb7, 0x8c, 0xc6, 0xaf, 0x71, - 0x22, 0x69, 0xd4, 0xec, 0x04, 0x05, 0x4b, 0xa3, 0xb6, 0x30, 0x32, 0x23, 0x68, 0xac, 0x1e, 0x11, - 0x06, 0x21, 0xfd, 0x79, 0x71, 0x85, 0xa0, 0xff, 0x2d, 0x1d, 0xa8, 0x0f, 0x23, 0xfb, 0x19, 0xea, - 0xc2, 0x1c, 0x09, 0x91, 0x97, 0xd4, 0x26, 0x06, 0x91, 0x97, 0x4f, 0x3b, 0xbf, 0x5f, 0xf5, 0x82, - 0x3f, 0xae, 0x7a, 0xc1, 0x5f, 0x57, 0xbd, 0xe0, 0x97, 0xbf, 0x7b, 0x6f, 0x9c, 0x34, 0xe9, 0xff, - 0xdb, 0x87, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x29, 0x07, 0x36, 0x04, 0xd0, 0x09, 0x00, 0x00, + 0x10, 0x65, 0xec, 0xb1, 0xb1, 0x2b, 0x24, 0x71, 0x9a, 0xb0, 0xf2, 0x46, 0x91, 0x89, 0xfa, 0xc0, + 0x86, 0x48, 0xe4, 0xb0, 0x48, 0x2b, 0x60, 0x39, 0xc0, 0xc6, 0x59, 0xc5, 0x02, 0x2f, 0xd0, 0x5e, + 0x2d, 0x37, 0xa4, 0x8e, 0x53, 0xec, 0x8e, 0x32, 0x9e, 0x31, 0x33, 0x3d, 0x49, 0xcc, 0x81, 0x23, + 0xdf, 0x80, 0xc4, 0x91, 0x9f, 0xe1, 0x08, 0x7f, 0x80, 0xc2, 0x85, 0x3f, 0xe0,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 0x66, 0xa9, 0xc2, 0xc4, 0x46, 0x39, 0x80, 0x86, 0x8e, 0xe9, + 0x7e, 0x4d, 0xdb, 0xc5, 0xc9, 0x42, 0x8a, 0x30, 0x14, 0xfe, 0x08, 0xd6, 0xa8, 0x5a, 0x46, 0xe3, + 0x57, 0x38, 0x91, 0xd4, 0x6a, 0xa6, 0x83, 0xbc, 0x85, 0x56, 0x9b, 0x6b, 0x99, 0x11, 0x34, 0x96, + 0xb7, 0x08, 0x03, 0x9f, 0x1e, 0x2f, 0x36, 0x11, 0xf4, 0x6e, 0xe9, 0x40, 0x7d, 0x18, 0x98, 0xcf, + 0x50, 0x17, 0x7a, 0x49, 0x88, 0xbc, 0xa2, 0x32, 0xd1, 0x88, 0xd4, 0xff, 0x90, 0x2d, 0x93, 0x76, + 0xfd, 0x87, 0x7f, 0x93, 0x69, 0xef, 0x1e, 0x0a, 0xf5, 0xe2, 0xa1, 0xf0, 0xa4, 0xf3, 0xe7, 0x75, + 0xcf, 0xfb, 0xeb, 0xba, 0xe7, 0xfd, 0x73, 0xdd, 0xf3, 0x7e, 0xfb, 0xb7, 0xf7, 0xd6, 0x69, 0x93, + 0x1e, 0x85, 0x1f, 0xbf, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xcc, 0xe2, 0x4c, 0x25, 0x0a, 0x00, + 0x00, } diff --git a/internal/private.proto b/internal/private.proto index 3173b12a2..68e9a5e5f 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -131,3 +131,9 @@ message Field { int64 Min = 3; int64 Max = 4; } + +message DeleteViewMessage { + string Index = 1; + string Frame = 2; + string View = 3; +} \ No newline at end of file diff --git a/server.go b/server.go index 97883fae4..8194278ba 100644 --- a/server.go +++ b/server.go @@ -339,6 +339,15 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if err != nil { return err } + case *internal.DeleteViewMessage: + f := s.Holder.Frame(obj.Index, obj.Frame) + if f == nil { + return fmt.Errorf("Local Frame not found: %s", obj.Frame) + } + err := f.DeleteView(obj.View) + if err != nil { + return err + } } return nil } diff --git a/test/holder.go b/test/holder.go index 6bb346ec1..4cd0642e4 100644 --- a/test/holder.go +++ b/test/holder.go @@ -43,12 +43,9 @@ func (h *Holder) Close() error { return h.Holder.Close() } -// Reopen closes the holder and instantiates and opens a new holder. +// Reopen instantiates and opens a new holder. +// Note that the holder must be Closed first. func (h *Holder) Reopen() error { - if err := h.Holder.Close(); err != nil { - return err - } - path, logOutput := h.Path, h.Holder.LogOutput h.Holder = pilosa.NewHolder() h.Holder.Path = path diff --git a/view.go b/view.go index 99ce3f7f9..2d5b7d776 100644 --- a/view.go +++ b/view.go @@ -163,7 +163,9 @@ func (v *View) Close() error { // Close all fragments. for _, frag := range v.fragments { - _ = frag.Close() + if err := frag.Close(); err != nil { + return err + } } v.fragments = make(map[uint64]*Fragment)