From 7f13f8f2be60c43006efd384d6d94bdeeb792416 Mon Sep 17 00:00:00 2001 From: arnikola Date: Wed, 14 Nov 2018 15:32:40 -0500 Subject: [PATCH] [coordinator] Add tag search completion (#1103) * Initial commit with new protos and scaffolding * Proto update in response to PR * Refactor tag search endpoint to expose RawSearch method * Finish tag search grpc endpoint on server side * Add client code to decompress m3search rpc response, PR responses to WIP * Add decompressed tag search decoding * linter * Add CompleteTags request protos * Add autocomplete tags endpoint to proto, with client that is able to decode results * PR responses, changes to proto definition * PR response to change search response type protos * Rename sort functions * PR responses * PR response * PR response in client * Fixing merge issues * delete bad merge artifact --- src/query/errors/storage.go | 3 + src/query/generated/proto/rpcpb/query.pb.go | 4811 +++++++++++++---- src/query/generated/proto/rpcpb/query.proto | 75 +- src/query/models/matcher.go | 10 + src/query/pools/pool_wrapper.go | 33 + src/query/server/server_test.go | 24 +- src/query/storage/completed_tags.go | 141 + src/query/storage/completed_tags_test.go | 62 + src/query/storage/m3/multi_fetch_result.go | 14 +- .../storage/m3/multi_fetch_tags_result.go | 87 +- src/query/storage/m3/storage.go | 55 +- src/query/storage/m3/types.go | 50 +- src/query/storage/types.go | 44 +- src/query/tsdb/remote/client.go | 148 +- src/query/tsdb/remote/codecs.go | 23 +- src/query/tsdb/remote/codecs_complete_tags.go | 98 + src/query/tsdb/remote/codecs_search.go | 187 + src/query/tsdb/remote/codecs_test.go | 18 +- src/query/tsdb/remote/compressed_codecs.go | 22 +- .../tsdb/remote/compressed_codecs_test.go | 12 +- src/query/tsdb/remote/server.go | 96 +- 21 files changed, 4787 insertions(+), 1226 deletions(-) create mode 100644 src/query/storage/completed_tags.go create mode 100644 src/query/storage/completed_tags_test.go create mode 100644 src/query/tsdb/remote/codecs_complete_tags.go create mode 100644 src/query/tsdb/remote/codecs_search.go diff --git a/src/query/errors/storage.go b/src/query/errors/storage.go index d5589f8995..61aae7d033 100644 --- a/src/query/errors/storage.go +++ b/src/query/errors/storage.go @@ -66,4 +66,7 @@ var ( // ErrOnlyFixedResSupported is an error returned we try to get step size for variable resolution ErrOnlyFixedResSupported = errors.New("only fixed resolution supported") + + // ErrUnexpectedGRPCResponseType is an error returned when rpc response type is unhandled + ErrUnexpectedGRPCResponseType = errors.New("unexpected grpc response type") ) diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index 7dee48ad75..cfffca612a 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -41,6 +41,18 @@ M3CompressedValuesReplica M3Segments M3Segment + SearchRequest + M3TagProperty + M3TagProperties + TagProperty + TagProperties + SearchResponse + CompleteTagsRequestOptions + CompleteTagsRequest + TagNames + TagValue + TagValues + CompleteTagsResponse */ package rpcpb @@ -101,6 +113,29 @@ func (x MatcherType) String() string { } func (MatcherType) EnumDescriptor() ([]byte, []int) { return fileDescriptorQuery, []int{0} } +type CompleteTagsType int32 + +const ( + // Requests tag names and values + CompleteTagsType_DEFAULT CompleteTagsType = 0 + // Requests tag names only + CompleteTagsType_TAGNAME CompleteTagsType = 1 +) + +var CompleteTagsType_name = map[int32]string{ + 0: "DEFAULT", + 1: "TAGNAME", +} +var CompleteTagsType_value = map[string]int32{ + "DEFAULT": 0, + "TAGNAME": 1, +} + +func (x CompleteTagsType) String() string { + return proto.EnumName(CompleteTagsType_name, int32(x)) +} +func (CompleteTagsType) EnumDescriptor() ([]byte, []int) { return fileDescriptorQuery, []int{1} } + type FetchRequest struct { Start int64 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` End int64 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` @@ -612,853 +647,3314 @@ func (m *M3Segment) GetBlockSize() int64 { return 0 } -func init() { - proto.RegisterType((*FetchRequest)(nil), "rpc.FetchRequest") - proto.RegisterType((*TagMatchers)(nil), "rpc.TagMatchers") - proto.RegisterType((*TagMatcher)(nil), "rpc.TagMatcher") - proto.RegisterType((*FetchResponse)(nil), "rpc.FetchResponse") - proto.RegisterType((*Series)(nil), "rpc.Series") - proto.RegisterType((*SeriesMetadata)(nil), "rpc.SeriesMetadata") - proto.RegisterType((*DecompressedSeries)(nil), "rpc.DecompressedSeries") - proto.RegisterType((*Datapoint)(nil), "rpc.Datapoint") - proto.RegisterType((*Tag)(nil), "rpc.Tag") - proto.RegisterType((*M3CompressedSeries)(nil), "rpc.M3CompressedSeries") - proto.RegisterType((*M3CompressedValuesReplica)(nil), "rpc.M3CompressedValuesReplica") - proto.RegisterType((*M3Segments)(nil), "rpc.M3Segments") - proto.RegisterType((*M3Segment)(nil), "rpc.M3Segment") - proto.RegisterEnum("rpc.MatcherType", MatcherType_name, MatcherType_value) +type SearchRequest struct { + // Types that are valid to be assigned to Matchers: + // *SearchRequest_TagMatchers + Matchers isSearchRequest_Matchers `protobuf_oneof:"matchers"` } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +func (m *SearchRequest) Reset() { *m = SearchRequest{} } +func (m *SearchRequest) String() string { return proto.CompactTextString(m) } +func (*SearchRequest) ProtoMessage() {} +func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{13} } -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +type isSearchRequest_Matchers interface { + isSearchRequest_Matchers() + MarshalTo([]byte) (int, error) + Size() int +} -// Client API for Query service +type SearchRequest_TagMatchers struct { + TagMatchers *TagMatchers `protobuf:"bytes,1,opt,name=tagMatchers,oneof"` +} -type QueryClient interface { - Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (Query_FetchClient, error) +func (*SearchRequest_TagMatchers) isSearchRequest_Matchers() {} + +func (m *SearchRequest) GetMatchers() isSearchRequest_Matchers { + if m != nil { + return m.Matchers + } + return nil } -type queryClient struct { - cc *grpc.ClientConn +func (m *SearchRequest) GetTagMatchers() *TagMatchers { + if x, ok := m.GetMatchers().(*SearchRequest_TagMatchers); ok { + return x.TagMatchers + } + return nil } -func NewQueryClient(cc *grpc.ClientConn) QueryClient { - return &queryClient{cc} +// XXX_OneofFuncs is for the internal use of the proto package. +func (*SearchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _SearchRequest_OneofMarshaler, _SearchRequest_OneofUnmarshaler, _SearchRequest_OneofSizer, []interface{}{ + (*SearchRequest_TagMatchers)(nil), + } } -func (c *queryClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (Query_FetchClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Query_serviceDesc.Streams[0], c.cc, "/rpc.Query/Fetch", opts...) - if err != nil { - return nil, err +func _SearchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*SearchRequest) + // matchers + switch x := m.Matchers.(type) { + case *SearchRequest_TagMatchers: + _ = b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.TagMatchers); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("SearchRequest.Matchers has unexpected type %T", x) } - x := &queryFetchClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err + return nil +} + +func _SearchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*SearchRequest) + switch tag { + case 1: // matchers.tagMatchers + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(TagMatchers) + err := b.DecodeMessage(msg) + m.Matchers = &SearchRequest_TagMatchers{msg} + return true, err + default: + return false, nil } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err +} + +func _SearchRequest_OneofSizer(msg proto.Message) (n int) { + m := msg.(*SearchRequest) + // matchers + switch x := m.Matchers.(type) { + case *SearchRequest_TagMatchers: + s := proto.Size(x.TagMatchers) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } - return x, nil + return n } -type Query_FetchClient interface { - Recv() (*FetchResponse, error) - grpc.ClientStream +type M3TagProperty struct { + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + CompressedTags []byte `protobuf:"bytes,2,opt,name=compressedTags,proto3" json:"compressedTags,omitempty"` } -type queryFetchClient struct { - grpc.ClientStream +func (m *M3TagProperty) Reset() { *m = M3TagProperty{} } +func (m *M3TagProperty) String() string { return proto.CompactTextString(m) } +func (*M3TagProperty) ProtoMessage() {} +func (*M3TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{14} } + +func (m *M3TagProperty) GetId() []byte { + if m != nil { + return m.Id + } + return nil } -func (x *queryFetchClient) Recv() (*FetchResponse, error) { - m := new(FetchResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (m *M3TagProperty) GetCompressedTags() []byte { + if m != nil { + return m.CompressedTags } - return m, nil + return nil } -// Server API for Query service +type M3TagProperties struct { + Properties []*M3TagProperty `protobuf:"bytes,1,rep,name=properties" json:"properties,omitempty"` +} -type QueryServer interface { - Fetch(*FetchRequest, Query_FetchServer) error +func (m *M3TagProperties) Reset() { *m = M3TagProperties{} } +func (m *M3TagProperties) String() string { return proto.CompactTextString(m) } +func (*M3TagProperties) ProtoMessage() {} +func (*M3TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{15} } + +func (m *M3TagProperties) GetProperties() []*M3TagProperty { + if m != nil { + return m.Properties + } + return nil } -func RegisterQueryServer(s *grpc.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) +type TagProperty struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []byte `protobuf:"bytes,2,opt,name=values,proto3" json:"values,omitempty"` } -func _Query_Fetch_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(FetchRequest) - if err := stream.RecvMsg(m); err != nil { - return err +func (m *TagProperty) Reset() { *m = TagProperty{} } +func (m *TagProperty) String() string { return proto.CompactTextString(m) } +func (*TagProperty) ProtoMessage() {} +func (*TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{16} } + +func (m *TagProperty) GetKey() []byte { + if m != nil { + return m.Key } - return srv.(QueryServer).Fetch(m, &queryFetchServer{stream}) + return nil } -type Query_FetchServer interface { - Send(*FetchResponse) error - grpc.ServerStream +func (m *TagProperty) GetValues() []byte { + if m != nil { + return m.Values + } + return nil } -type queryFetchServer struct { - grpc.ServerStream +type TagProperties struct { + Properties []*TagProperty `protobuf:"bytes,1,rep,name=properties" json:"properties,omitempty"` } -func (x *queryFetchServer) Send(m *FetchResponse) error { - return x.ServerStream.SendMsg(m) +func (m *TagProperties) Reset() { *m = TagProperties{} } +func (m *TagProperties) String() string { return proto.CompactTextString(m) } +func (*TagProperties) ProtoMessage() {} +func (*TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{17} } + +func (m *TagProperties) GetProperties() []*TagProperty { + if m != nil { + return m.Properties + } + return nil } -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "rpc.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Fetch", - Handler: _Query_Fetch_Handler, - ServerStreams: true, - }, - }, - Metadata: "github.com/m3db/m3/src/query/generated/proto/rpcpb/query.proto", +type SearchResponse struct { + // Types that are valid to be assigned to Value: + // *SearchResponse_Decompressed + // *SearchResponse_Compressed + Value isSearchResponse_Value `protobuf_oneof:"value"` } -func (m *FetchRequest) 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 *SearchResponse) Reset() { *m = SearchResponse{} } +func (m *SearchResponse) String() string { return proto.CompactTextString(m) } +func (*SearchResponse) ProtoMessage() {} +func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{18} } + +type isSearchResponse_Value interface { + isSearchResponse_Value() + MarshalTo([]byte) (int, error) + Size() int } -func (m *FetchRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Start != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Start)) - } - if m.End != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.End)) - } - if m.Matchers != nil { - nn1, err := m.Matchers.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += nn1 +type SearchResponse_Decompressed struct { + Decompressed *TagProperties `protobuf:"bytes,1,opt,name=decompressed,oneof"` +} +type SearchResponse_Compressed struct { + Compressed *M3TagProperties `protobuf:"bytes,2,opt,name=compressed,oneof"` +} + +func (*SearchResponse_Decompressed) isSearchResponse_Value() {} +func (*SearchResponse_Compressed) isSearchResponse_Value() {} + +func (m *SearchResponse) GetValue() isSearchResponse_Value { + if m != nil { + return m.Value } - return i, nil + return nil } -func (m *FetchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { - i := 0 - if m.TagMatchers != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n2, err := m.TagMatchers.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n2 +func (m *SearchResponse) GetDecompressed() *TagProperties { + if x, ok := m.GetValue().(*SearchResponse_Decompressed); ok { + return x.Decompressed } - return i, nil + return nil } -func (m *TagMatchers) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err + +func (m *SearchResponse) GetCompressed() *M3TagProperties { + if x, ok := m.GetValue().(*SearchResponse_Compressed); ok { + return x.Compressed } - return dAtA[:n], nil + return nil } -func (m *TagMatchers) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.TagMatchers) > 0 { - for _, msg := range m.TagMatchers { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } +// XXX_OneofFuncs is for the internal use of the proto package. +func (*SearchResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _SearchResponse_OneofMarshaler, _SearchResponse_OneofUnmarshaler, _SearchResponse_OneofSizer, []interface{}{ + (*SearchResponse_Decompressed)(nil), + (*SearchResponse_Compressed)(nil), } - return i, nil } -func (m *TagMatcher) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func _SearchResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*SearchResponse) + // value + switch x := m.Value.(type) { + case *SearchResponse_Decompressed: + _ = b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Decompressed); err != nil { + return err + } + case *SearchResponse_Compressed: + _ = b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Compressed); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("SearchResponse.Value has unexpected type %T", x) } - return dAtA[:n], nil + return nil } -func (m *TagMatcher) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) +func _SearchResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*SearchResponse) + switch tag { + case 1: // value.decompressed + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(TagProperties) + err := b.DecodeMessage(msg) + m.Value = &SearchResponse_Decompressed{msg} + return true, err + case 2: // value.compressed + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(M3TagProperties) + err := b.DecodeMessage(msg) + m.Value = &SearchResponse_Compressed{msg} + return true, err + default: + return false, nil } - if len(m.Value) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) +} + +func _SearchResponse_OneofSizer(msg proto.Message) (n int) { + m := msg.(*SearchResponse) + // value + switch x := m.Value.(type) { + case *SearchResponse_Decompressed: + s := proto.Size(x.Decompressed) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case *SearchResponse_Compressed: + s := proto.Size(x.Compressed) + n += proto.SizeVarint(2<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } - if m.Type != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Type)) + return n +} + +type CompleteTagsRequestOptions struct { + Type CompleteTagsType `protobuf:"varint,1,opt,name=type,proto3,enum=rpc.CompleteTagsType" json:"type,omitempty"` + FilterNameTags [][]byte `protobuf:"bytes,2,rep,name=filterNameTags" json:"filterNameTags,omitempty"` +} + +func (m *CompleteTagsRequestOptions) Reset() { *m = CompleteTagsRequestOptions{} } +func (m *CompleteTagsRequestOptions) String() string { return proto.CompactTextString(m) } +func (*CompleteTagsRequestOptions) ProtoMessage() {} +func (*CompleteTagsRequestOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{19} } + +func (m *CompleteTagsRequestOptions) GetType() CompleteTagsType { + if m != nil { + return m.Type } - return i, nil + return CompleteTagsType_DEFAULT } -func (m *FetchResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func (m *CompleteTagsRequestOptions) GetFilterNameTags() [][]byte { + if m != nil { + return m.FilterNameTags } - return dAtA[:n], nil + return nil } -func (m *FetchResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Series) > 0 { - for _, msg := range m.Series { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } +type CompleteTagsRequest struct { + // Types that are valid to be assigned to Matchers: + // *CompleteTagsRequest_TagMatchers + Matchers isCompleteTagsRequest_Matchers `protobuf_oneof:"matchers"` + Options *CompleteTagsRequestOptions `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"` +} + +func (m *CompleteTagsRequest) Reset() { *m = CompleteTagsRequest{} } +func (m *CompleteTagsRequest) String() string { return proto.CompactTextString(m) } +func (*CompleteTagsRequest) ProtoMessage() {} +func (*CompleteTagsRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{20} } + +type isCompleteTagsRequest_Matchers interface { + isCompleteTagsRequest_Matchers() + MarshalTo([]byte) (int, error) + Size() int +} + +type CompleteTagsRequest_TagMatchers struct { + TagMatchers *TagMatchers `protobuf:"bytes,1,opt,name=tagMatchers,oneof"` +} + +func (*CompleteTagsRequest_TagMatchers) isCompleteTagsRequest_Matchers() {} + +func (m *CompleteTagsRequest) GetMatchers() isCompleteTagsRequest_Matchers { + if m != nil { + return m.Matchers } - return i, nil + return nil } -func (m *Series) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func (m *CompleteTagsRequest) GetTagMatchers() *TagMatchers { + if x, ok := m.GetMatchers().(*CompleteTagsRequest_TagMatchers); ok { + return x.TagMatchers } - return dAtA[:n], nil + return nil } -func (m *Series) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Meta != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n3, err := m.Meta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n3 +func (m *CompleteTagsRequest) GetOptions() *CompleteTagsRequestOptions { + if m != nil { + return m.Options } - if m.Value != nil { - nn4, err := m.Value.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += nn4 + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*CompleteTagsRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _CompleteTagsRequest_OneofMarshaler, _CompleteTagsRequest_OneofUnmarshaler, _CompleteTagsRequest_OneofSizer, []interface{}{ + (*CompleteTagsRequest_TagMatchers)(nil), } - return i, nil } -func (m *Series_Decompressed) MarshalTo(dAtA []byte) (int, error) { - i := 0 - if m.Decompressed != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n5, err := m.Decompressed.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err +func _CompleteTagsRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*CompleteTagsRequest) + // matchers + switch x := m.Matchers.(type) { + case *CompleteTagsRequest_TagMatchers: + _ = b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.TagMatchers); err != nil { + return err } - i += n5 + case nil: + default: + return fmt.Errorf("CompleteTagsRequest.Matchers has unexpected type %T", x) } - return i, nil + return nil } -func (m *Series_Compressed) MarshalTo(dAtA []byte) (int, error) { - i := 0 - if m.Compressed != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n6, err := m.Compressed.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + +func _CompleteTagsRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*CompleteTagsRequest) + switch tag { + case 1: // matchers.tagMatchers + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType } - i += n6 + msg := new(TagMatchers) + err := b.DecodeMessage(msg) + m.Matchers = &CompleteTagsRequest_TagMatchers{msg} + return true, err + default: + return false, nil } - return i, nil } -func (m *SeriesMetadata) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err + +func _CompleteTagsRequest_OneofSizer(msg proto.Message) (n int) { + m := msg.(*CompleteTagsRequest) + // matchers + switch x := m.Matchers.(type) { + case *CompleteTagsRequest_TagMatchers: + s := proto.Size(x.TagMatchers) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } - return dAtA[:n], nil + return n } -func (m *SeriesMetadata) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Id) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) - i += copy(dAtA[i:], m.Id) - } - if m.StartTime != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.StartTime)) - } - if m.EndTime != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.EndTime)) - } - return i, nil +type TagNames struct { + Names [][]byte `protobuf:"bytes,1,rep,name=names" json:"names,omitempty"` } -func (m *DecompressedSeries) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func (m *TagNames) Reset() { *m = TagNames{} } +func (m *TagNames) String() string { return proto.CompactTextString(m) } +func (*TagNames) ProtoMessage() {} +func (*TagNames) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{21} } + +func (m *TagNames) GetNames() [][]byte { + if m != nil { + return m.Names } - return dAtA[:n], nil + return nil } -func (m *DecompressedSeries) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Datapoints) > 0 { - for _, msg := range m.Datapoints { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } +type TagValue struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values [][]byte `protobuf:"bytes,2,rep,name=values" json:"values,omitempty"` +} + +func (m *TagValue) Reset() { *m = TagValue{} } +func (m *TagValue) String() string { return proto.CompactTextString(m) } +func (*TagValue) ProtoMessage() {} +func (*TagValue) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{22} } + +func (m *TagValue) GetKey() []byte { + if m != nil { + return m.Key } - if len(m.Tags) > 0 { - for _, msg := range m.Tags { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } + return nil +} + +func (m *TagValue) GetValues() [][]byte { + if m != nil { + return m.Values } - return i, nil + return nil } -func (m *Datapoint) 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 +type TagValues struct { + Values []*TagValue `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` } -func (m *Datapoint) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Timestamp != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Timestamp)) - } - if m.Value != 0 { - dAtA[i] = 0x11 - i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) - i += 8 +func (m *TagValues) Reset() { *m = TagValues{} } +func (m *TagValues) String() string { return proto.CompactTextString(m) } +func (*TagValues) ProtoMessage() {} +func (*TagValues) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{23} } + +func (m *TagValues) GetValues() []*TagValue { + if m != nil { + return m.Values } - return i, nil + return nil } -func (m *Tag) 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 +type CompleteTagsResponse struct { + // Types that are valid to be assigned to Value: + // *CompleteTagsResponse_Default + // *CompleteTagsResponse_NamesOnly + Value isCompleteTagsResponse_Value `protobuf_oneof:"value"` } -func (m *Tag) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - } - if len(m.Value) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) - } - return i, nil +func (m *CompleteTagsResponse) Reset() { *m = CompleteTagsResponse{} } +func (m *CompleteTagsResponse) String() string { return proto.CompactTextString(m) } +func (*CompleteTagsResponse) ProtoMessage() {} +func (*CompleteTagsResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{24} } + +type isCompleteTagsResponse_Value interface { + isCompleteTagsResponse_Value() + MarshalTo([]byte) (int, error) + Size() int } -func (m *M3CompressedSeries) 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 +type CompleteTagsResponse_Default struct { + Default *TagValues `protobuf:"bytes,1,opt,name=default,oneof"` +} +type CompleteTagsResponse_NamesOnly struct { + NamesOnly *TagNames `protobuf:"bytes,2,opt,name=namesOnly,oneof"` } -func (m *M3CompressedSeries) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.CompressedTags) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.CompressedTags))) - i += copy(dAtA[i:], m.CompressedTags) - } - if len(m.Replicas) > 0 { - for _, msg := range m.Replicas { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } +func (*CompleteTagsResponse_Default) isCompleteTagsResponse_Value() {} +func (*CompleteTagsResponse_NamesOnly) isCompleteTagsResponse_Value() {} + +func (m *CompleteTagsResponse) GetValue() isCompleteTagsResponse_Value { + if m != nil { + return m.Value } - return i, nil + return nil } -func (m *M3CompressedValuesReplica) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func (m *CompleteTagsResponse) GetDefault() *TagValues { + if x, ok := m.GetValue().(*CompleteTagsResponse_Default); ok { + return x.Default } - return dAtA[:n], nil + return nil } -func (m *M3CompressedValuesReplica) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Segments) > 0 { - for _, msg := range m.Segments { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } +func (m *CompleteTagsResponse) GetNamesOnly() *TagNames { + if x, ok := m.GetValue().(*CompleteTagsResponse_NamesOnly); ok { + return x.NamesOnly } - return i, nil + return nil } -func (m *M3Segments) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +// XXX_OneofFuncs is for the internal use of the proto package. +func (*CompleteTagsResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _CompleteTagsResponse_OneofMarshaler, _CompleteTagsResponse_OneofUnmarshaler, _CompleteTagsResponse_OneofSizer, []interface{}{ + (*CompleteTagsResponse_Default)(nil), + (*CompleteTagsResponse_NamesOnly)(nil), } - return dAtA[:n], nil } -func (m *M3Segments) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Merged != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.Merged.Size())) - n7, err := m.Merged.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err +func _CompleteTagsResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*CompleteTagsResponse) + // value + switch x := m.Value.(type) { + case *CompleteTagsResponse_Default: + _ = b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Default); err != nil { + return err } - i += n7 - } - if len(m.Unmerged) > 0 { - for _, msg := range m.Unmerged { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n + case *CompleteTagsResponse_NamesOnly: + _ = b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.NamesOnly); err != nil { + return err } + case nil: + default: + return fmt.Errorf("CompleteTagsResponse.Value has unexpected type %T", x) } - return i, nil + return nil } -func (m *M3Segment) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err +func _CompleteTagsResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*CompleteTagsResponse) + switch tag { + case 1: // value.default + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(TagValues) + err := b.DecodeMessage(msg) + m.Value = &CompleteTagsResponse_Default{msg} + return true, err + case 2: // value.namesOnly + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(TagNames) + err := b.DecodeMessage(msg) + m.Value = &CompleteTagsResponse_NamesOnly{msg} + return true, err + default: + return false, nil } - return dAtA[:n], nil } -func (m *M3Segment) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Head) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Head))) - i += copy(dAtA[i:], m.Head) - } - if len(m.Tail) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintQuery(dAtA, i, uint64(len(m.Tail))) - i += copy(dAtA[i:], m.Tail) - } - if m.StartTime != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.StartTime)) - } - if m.BlockSize != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintQuery(dAtA, i, uint64(m.BlockSize)) +func _CompleteTagsResponse_OneofSizer(msg proto.Message) (n int) { + m := msg.(*CompleteTagsResponse) + // value + switch x := m.Value.(type) { + case *CompleteTagsResponse_Default: + s := proto.Size(x.Default) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case *CompleteTagsResponse_NamesOnly: + s := proto.Size(x.NamesOnly) + n += proto.SizeVarint(2<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } - return i, nil + return n } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return offset + 1 -} -func (m *FetchRequest) Size() (n int) { - var l int - _ = l - if m.Start != 0 { - n += 1 + sovQuery(uint64(m.Start)) - } - if m.End != 0 { - n += 1 + sovQuery(uint64(m.End)) - } - if m.Matchers != nil { - n += m.Matchers.Size() - } - return n +func init() { + proto.RegisterType((*FetchRequest)(nil), "rpc.FetchRequest") + proto.RegisterType((*TagMatchers)(nil), "rpc.TagMatchers") + proto.RegisterType((*TagMatcher)(nil), "rpc.TagMatcher") + proto.RegisterType((*FetchResponse)(nil), "rpc.FetchResponse") + proto.RegisterType((*Series)(nil), "rpc.Series") + proto.RegisterType((*SeriesMetadata)(nil), "rpc.SeriesMetadata") + proto.RegisterType((*DecompressedSeries)(nil), "rpc.DecompressedSeries") + proto.RegisterType((*Datapoint)(nil), "rpc.Datapoint") + proto.RegisterType((*Tag)(nil), "rpc.Tag") + proto.RegisterType((*M3CompressedSeries)(nil), "rpc.M3CompressedSeries") + proto.RegisterType((*M3CompressedValuesReplica)(nil), "rpc.M3CompressedValuesReplica") + proto.RegisterType((*M3Segments)(nil), "rpc.M3Segments") + proto.RegisterType((*M3Segment)(nil), "rpc.M3Segment") + proto.RegisterType((*SearchRequest)(nil), "rpc.SearchRequest") + proto.RegisterType((*M3TagProperty)(nil), "rpc.M3TagProperty") + proto.RegisterType((*M3TagProperties)(nil), "rpc.M3TagProperties") + proto.RegisterType((*TagProperty)(nil), "rpc.TagProperty") + proto.RegisterType((*TagProperties)(nil), "rpc.TagProperties") + proto.RegisterType((*SearchResponse)(nil), "rpc.SearchResponse") + proto.RegisterType((*CompleteTagsRequestOptions)(nil), "rpc.CompleteTagsRequestOptions") + proto.RegisterType((*CompleteTagsRequest)(nil), "rpc.CompleteTagsRequest") + proto.RegisterType((*TagNames)(nil), "rpc.TagNames") + proto.RegisterType((*TagValue)(nil), "rpc.TagValue") + proto.RegisterType((*TagValues)(nil), "rpc.TagValues") + proto.RegisterType((*CompleteTagsResponse)(nil), "rpc.CompleteTagsResponse") + proto.RegisterEnum("rpc.MatcherType", MatcherType_name, MatcherType_value) + proto.RegisterEnum("rpc.CompleteTagsType", CompleteTagsType_name, CompleteTagsType_value) } -func (m *FetchRequest_TagMatchers) Size() (n int) { - var l int - _ = l - if m.TagMatchers != nil { - l = m.TagMatchers.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for Query service + +type QueryClient interface { + Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (Query_FetchClient, error) + Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (Query_SearchClient, error) + CompleteTags(ctx context.Context, in *CompleteTagsRequest, opts ...grpc.CallOption) (Query_CompleteTagsClient, error) } -func (m *TagMatchers) Size() (n int) { - var l int - _ = l - if len(m.TagMatchers) > 0 { - for _, e := range m.TagMatchers { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n + +type queryClient struct { + cc *grpc.ClientConn } -func (m *TagMatcher) Size() (n int) { - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func NewQueryClient(cc *grpc.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (Query_FetchClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Query_serviceDesc.Streams[0], c.cc, "/rpc.Query/Fetch", opts...) + if err != nil { + return nil, err } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + x := &queryFetchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err } - if m.Type != 0 { - n += 1 + sovQuery(uint64(m.Type)) + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err } - return n + return x, nil } -func (m *FetchResponse) Size() (n int) { - var l int - _ = l - if len(m.Series) > 0 { - for _, e := range m.Series { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } +type Query_FetchClient interface { + Recv() (*FetchResponse, error) + grpc.ClientStream +} + +type queryFetchClient struct { + grpc.ClientStream +} + +func (x *queryFetchClient) Recv() (*FetchResponse, error) { + m := new(FetchResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err } - return n + return m, nil } -func (m *Series) Size() (n int) { - var l int - _ = l - if m.Meta != nil { - l = m.Meta.Size() - n += 1 + l + sovQuery(uint64(l)) +func (c *queryClient) Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (Query_SearchClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Query_serviceDesc.Streams[1], c.cc, "/rpc.Query/Search", opts...) + if err != nil { + return nil, err } - if m.Value != nil { - n += m.Value.Size() + x := &querySearchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err } - return n + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil } -func (m *Series_Decompressed) Size() (n int) { - var l int - _ = l - if m.Decompressed != nil { - l = m.Decompressed.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +type Query_SearchClient interface { + Recv() (*SearchResponse, error) + grpc.ClientStream } -func (m *Series_Compressed) Size() (n int) { - var l int - _ = l - if m.Compressed != nil { - l = m.Compressed.Size() - n += 1 + l + sovQuery(uint64(l)) + +type querySearchClient struct { + grpc.ClientStream +} + +func (x *querySearchClient) Recv() (*SearchResponse, error) { + m := new(SearchResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err } - return n + return m, nil } -func (m *SeriesMetadata) Size() (n int) { - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + +func (c *queryClient) CompleteTags(ctx context.Context, in *CompleteTagsRequest, opts ...grpc.CallOption) (Query_CompleteTagsClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Query_serviceDesc.Streams[2], c.cc, "/rpc.Query/CompleteTags", opts...) + if err != nil { + return nil, err } - if m.StartTime != 0 { - n += 1 + sovQuery(uint64(m.StartTime)) + x := &queryCompleteTagsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err } - if m.EndTime != 0 { - n += 1 + sovQuery(uint64(m.EndTime)) + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err } - return n + return x, nil } -func (m *DecompressedSeries) Size() (n int) { - var l int - _ = l - if len(m.Datapoints) > 0 { - for _, e := range m.Datapoints { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if len(m.Tags) > 0 { - for _, e := range m.Tags { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n +type Query_CompleteTagsClient interface { + Recv() (*CompleteTagsResponse, error) + grpc.ClientStream } -func (m *Datapoint) Size() (n int) { - var l int - _ = l - if m.Timestamp != 0 { - n += 1 + sovQuery(uint64(m.Timestamp)) - } - if m.Value != 0 { - n += 9 - } - return n +type queryCompleteTagsClient struct { + grpc.ClientStream } -func (m *Tag) Size() (n int) { - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (x *queryCompleteTagsClient) Recv() (*CompleteTagsResponse, error) { + m := new(CompleteTagsResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err } - return n + return m, nil } -func (m *M3CompressedSeries) Size() (n int) { - var l int - _ = l - l = len(m.CompressedTags) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.Replicas) > 0 { - for _, e := range m.Replicas { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n +// Server API for Query service + +type QueryServer interface { + Fetch(*FetchRequest, Query_FetchServer) error + Search(*SearchRequest, Query_SearchServer) error + CompleteTags(*CompleteTagsRequest, Query_CompleteTagsServer) error } -func (m *M3CompressedValuesReplica) Size() (n int) { - var l int - _ = l - if len(m.Segments) > 0 { - for _, e := range m.Segments { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n +func RegisterQueryServer(s *grpc.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *M3Segments) Size() (n int) { - var l int - _ = l - if m.Merged != nil { - l = m.Merged.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.Unmerged) > 0 { - for _, e := range m.Unmerged { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } +func _Query_Fetch_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(FetchRequest) + if err := stream.RecvMsg(m); err != nil { + return err } - return n + return srv.(QueryServer).Fetch(m, &queryFetchServer{stream}) } -func (m *M3Segment) Size() (n int) { - var l int - _ = l - l = len(m.Head) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Tail) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.StartTime != 0 { - n += 1 + sovQuery(uint64(m.StartTime)) - } - if m.BlockSize != 0 { - n += 1 + sovQuery(uint64(m.BlockSize)) - } - return n +type Query_FetchServer interface { + Send(*FetchResponse) error + grpc.ServerStream } -func sovQuery(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } +type queryFetchServer struct { + grpc.ServerStream +} + +func (x *queryFetchServer) Send(m *FetchResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Query_Search_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(SearchRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(QueryServer).Search(m, &querySearchServer{stream}) +} + +type Query_SearchServer interface { + Send(*SearchResponse) error + grpc.ServerStream +} + +type querySearchServer struct { + grpc.ServerStream +} + +func (x *querySearchServer) Send(m *SearchResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Query_CompleteTags_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(CompleteTagsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(QueryServer).CompleteTags(m, &queryCompleteTagsServer{stream}) +} + +type Query_CompleteTagsServer interface { + Send(*CompleteTagsResponse) error + grpc.ServerStream +} + +type queryCompleteTagsServer struct { + grpc.ServerStream +} + +func (x *queryCompleteTagsServer) Send(m *CompleteTagsResponse) error { + return x.ServerStream.SendMsg(m) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rpc.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Fetch", + Handler: _Query_Fetch_Handler, + ServerStreams: true, + }, + { + StreamName: "Search", + Handler: _Query_Search_Handler, + ServerStreams: true, + }, + { + StreamName: "CompleteTags", + Handler: _Query_CompleteTags_Handler, + ServerStreams: true, + }, + }, + Metadata: "github.com/m3db/m3/src/query/generated/proto/rpcpb/query.proto", +} + +func (m *FetchRequest) 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 *FetchRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Start != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Start)) + } + if m.End != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.End)) + } + if m.Matchers != nil { + nn1, err := m.Matchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn1 + } + return i, nil +} + +func (m *FetchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.TagMatchers != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) + n2, err := m.TagMatchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } + return i, nil +} +func (m *TagMatchers) 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 *TagMatchers) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.TagMatchers) > 0 { + for _, msg := range m.TagMatchers { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *TagMatcher) 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 *TagMatcher) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Value) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + if m.Type != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Type)) + } + return i, nil +} + +func (m *FetchResponse) 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 *FetchResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Series) > 0 { + for _, msg := range m.Series { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *Series) 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 *Series) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Meta != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) + n3, err := m.Meta.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + } + if m.Value != nil { + nn4, err := m.Value.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn4 + } + return i, nil +} + +func (m *Series_Decompressed) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.Decompressed != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) + n5, err := m.Decompressed.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + return i, nil +} +func (m *Series_Compressed) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.Compressed != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) + n6, err := m.Compressed.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + } + return i, nil +} +func (m *SeriesMetadata) 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 *SeriesMetadata) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Id) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) + i += copy(dAtA[i:], m.Id) + } + if m.StartTime != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.StartTime)) + } + if m.EndTime != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.EndTime)) + } + return i, nil +} + +func (m *DecompressedSeries) 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 *DecompressedSeries) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Datapoints) > 0 { + for _, msg := range m.Datapoints { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Tags) > 0 { + for _, msg := range m.Tags { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *Datapoint) 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 *Datapoint) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Timestamp != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Timestamp)) + } + if m.Value != 0 { + dAtA[i] = 0x11 + i++ + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i += 8 + } + return i, nil +} + +func (m *Tag) 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 *Tag) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Value) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + return i, nil +} + +func (m *M3CompressedSeries) 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 *M3CompressedSeries) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.CompressedTags) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.CompressedTags))) + i += copy(dAtA[i:], m.CompressedTags) + } + if len(m.Replicas) > 0 { + for _, msg := range m.Replicas { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *M3CompressedValuesReplica) 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 *M3CompressedValuesReplica) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Segments) > 0 { + for _, msg := range m.Segments { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *M3Segments) 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 *M3Segments) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Merged != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Merged.Size())) + n7, err := m.Merged.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n7 + } + if len(m.Unmerged) > 0 { + for _, msg := range m.Unmerged { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *M3Segment) 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 *M3Segment) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Head) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Head))) + i += copy(dAtA[i:], m.Head) + } + if len(m.Tail) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Tail))) + i += copy(dAtA[i:], m.Tail) + } + if m.StartTime != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.StartTime)) + } + if m.BlockSize != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.BlockSize)) + } + return i, nil +} + +func (m *SearchRequest) 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 *SearchRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Matchers != nil { + nn8, err := m.Matchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn8 + } + return i, nil +} + +func (m *SearchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.TagMatchers != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) + n9, err := m.TagMatchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n9 + } + return i, nil +} +func (m *M3TagProperty) 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 *M3TagProperty) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Id) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) + i += copy(dAtA[i:], m.Id) + } + if len(m.CompressedTags) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.CompressedTags))) + i += copy(dAtA[i:], m.CompressedTags) + } + return i, nil +} + +func (m *M3TagProperties) 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 *M3TagProperties) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Properties) > 0 { + for _, msg := range m.Properties { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *TagProperty) 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 *TagProperty) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if len(m.Values) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Values))) + i += copy(dAtA[i:], m.Values) + } + return i, nil +} + +func (m *TagProperties) 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 *TagProperties) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Properties) > 0 { + for _, msg := range m.Properties { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *SearchResponse) 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 *SearchResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != nil { + nn10, err := m.Value.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn10 + } + return i, nil +} + +func (m *SearchResponse_Decompressed) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.Decompressed != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) + n11, err := m.Decompressed.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n11 + } + return i, nil +} +func (m *SearchResponse_Compressed) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.Compressed != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) + n12, err := m.Compressed.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n12 + } + return i, nil +} +func (m *CompleteTagsRequestOptions) 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 *CompleteTagsRequestOptions) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Type != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Type)) + } + if len(m.FilterNameTags) > 0 { + for _, b := range m.FilterNameTags { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } + } + return i, nil +} + +func (m *CompleteTagsRequest) 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 *CompleteTagsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Matchers != nil { + nn13, err := m.Matchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn13 + } + if m.Options != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) + n14, err := m.Options.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n14 + } + return i, nil +} + +func (m *CompleteTagsRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.TagMatchers != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) + n15, err := m.TagMatchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n15 + } + return i, nil +} +func (m *TagNames) 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 *TagNames) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Names) > 0 { + for _, b := range m.Names { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } + } + return i, nil +} + +func (m *TagValue) 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 *TagValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if len(m.Values) > 0 { + for _, b := range m.Values { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } + } + return i, nil +} + +func (m *TagValues) 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 *TagValues) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Values) > 0 { + for _, msg := range m.Values { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *CompleteTagsResponse) 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 *CompleteTagsResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != nil { + nn16, err := m.Value.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn16 + } + return i, nil +} + +func (m *CompleteTagsResponse_Default) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.Default != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.Default.Size())) + n17, err := m.Default.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n17 + } + return i, nil +} +func (m *CompleteTagsResponse_NamesOnly) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.NamesOnly != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.NamesOnly.Size())) + n18, err := m.NamesOnly.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n18 + } + return i, nil +} +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *FetchRequest) Size() (n int) { + var l int + _ = l + if m.Start != 0 { + n += 1 + sovQuery(uint64(m.Start)) + } + if m.End != 0 { + n += 1 + sovQuery(uint64(m.End)) + } + if m.Matchers != nil { + n += m.Matchers.Size() + } + return n +} + +func (m *FetchRequest_TagMatchers) Size() (n int) { + var l int + _ = l + if m.TagMatchers != nil { + l = m.TagMatchers.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *TagMatchers) Size() (n int) { + var l int + _ = l + if len(m.TagMatchers) > 0 { + for _, e := range m.TagMatchers { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *TagMatcher) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Type != 0 { + n += 1 + sovQuery(uint64(m.Type)) + } + return n +} + +func (m *FetchResponse) Size() (n int) { + var l int + _ = l + if len(m.Series) > 0 { + for _, e := range m.Series { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *Series) Size() (n int) { + var l int + _ = l + if m.Meta != nil { + l = m.Meta.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *Series_Decompressed) Size() (n int) { + var l int + _ = l + if m.Decompressed != nil { + l = m.Decompressed.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *Series_Compressed) Size() (n int) { + var l int + _ = l + if m.Compressed != nil { + l = m.Compressed.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *SeriesMetadata) Size() (n int) { + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.StartTime != 0 { + n += 1 + sovQuery(uint64(m.StartTime)) + } + if m.EndTime != 0 { + n += 1 + sovQuery(uint64(m.EndTime)) + } + return n +} + +func (m *DecompressedSeries) Size() (n int) { + var l int + _ = l + if len(m.Datapoints) > 0 { + for _, e := range m.Datapoints { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.Tags) > 0 { + for _, e := range m.Tags { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *Datapoint) Size() (n int) { + var l int + _ = l + if m.Timestamp != 0 { + n += 1 + sovQuery(uint64(m.Timestamp)) + } + if m.Value != 0 { + n += 9 + } + return n +} + +func (m *Tag) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *M3CompressedSeries) Size() (n int) { + var l int + _ = l + l = len(m.CompressedTags) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Replicas) > 0 { + for _, e := range m.Replicas { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *M3CompressedValuesReplica) Size() (n int) { + var l int + _ = l + if len(m.Segments) > 0 { + for _, e := range m.Segments { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *M3Segments) Size() (n int) { + var l int + _ = l + if m.Merged != nil { + l = m.Merged.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Unmerged) > 0 { + for _, e := range m.Unmerged { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *M3Segment) Size() (n int) { + var l int + _ = l + l = len(m.Head) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Tail) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.StartTime != 0 { + n += 1 + sovQuery(uint64(m.StartTime)) + } + if m.BlockSize != 0 { + n += 1 + sovQuery(uint64(m.BlockSize)) + } + return n +} + +func (m *SearchRequest) Size() (n int) { + var l int + _ = l + if m.Matchers != nil { + n += m.Matchers.Size() + } + return n +} + +func (m *SearchRequest_TagMatchers) Size() (n int) { + var l int + _ = l + if m.TagMatchers != nil { + l = m.TagMatchers.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *M3TagProperty) Size() (n int) { + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.CompressedTags) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *M3TagProperties) Size() (n int) { + var l int + _ = l + if len(m.Properties) > 0 { + for _, e := range m.Properties { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *TagProperty) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Values) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *TagProperties) Size() (n int) { + var l int + _ = l + if len(m.Properties) > 0 { + for _, e := range m.Properties { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *SearchResponse) Size() (n int) { + var l int + _ = l + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *SearchResponse_Decompressed) Size() (n int) { + var l int + _ = l + if m.Decompressed != nil { + l = m.Decompressed.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *SearchResponse_Compressed) Size() (n int) { + var l int + _ = l + if m.Compressed != nil { + l = m.Compressed.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *CompleteTagsRequestOptions) Size() (n int) { + var l int + _ = l + if m.Type != 0 { + n += 1 + sovQuery(uint64(m.Type)) + } + if len(m.FilterNameTags) > 0 { + for _, b := range m.FilterNameTags { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *CompleteTagsRequest) Size() (n int) { + var l int + _ = l + if m.Matchers != nil { + n += m.Matchers.Size() + } + if m.Options != nil { + l = m.Options.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *CompleteTagsRequest_TagMatchers) Size() (n int) { + var l int + _ = l + if m.TagMatchers != nil { + l = m.TagMatchers.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *TagNames) Size() (n int) { + var l int + _ = l + if len(m.Names) > 0 { + for _, b := range m.Names { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *TagValue) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Values) > 0 { + for _, b := range m.Values { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *TagValues) Size() (n int) { + var l int + _ = l + if len(m.Values) > 0 { + for _, e := range m.Values { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *CompleteTagsResponse) Size() (n int) { + var l int + _ = l + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *CompleteTagsResponse_Default) Size() (n int) { + var l int + _ = l + if m.Default != nil { + l = m.Default.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *CompleteTagsResponse_NamesOnly) Size() (n int) { + var l int + _ = l + if m.NamesOnly != nil { + l = m.NamesOnly.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FetchRequest) 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 ErrIntOverflowQuery + } + 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: FetchRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FetchRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + } + m.Start = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Start |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field End", wireType) + } + m.End = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.End |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TagMatchers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &TagMatchers{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Matchers = &FetchRequest_TagMatchers{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TagMatchers) 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 ErrIntOverflowQuery + } + 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: TagMatchers: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TagMatchers: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TagMatchers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TagMatchers = append(m.TagMatchers, &TagMatcher{}) + if err := m.TagMatchers[len(m.TagMatchers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TagMatcher) 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 ErrIntOverflowQuery + } + 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: TagMatcher: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TagMatcher: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...) + if m.Name == nil { + m.Name = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= (MatcherType(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FetchResponse) 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 ErrIntOverflowQuery + } + 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: FetchResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FetchResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Series", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Series = append(m.Series, &Series{}) + if err := m.Series[len(m.Series)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Series) 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 ErrIntOverflowQuery + } + 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: Series: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Series: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Meta == nil { + m.Meta = &SeriesMetadata{} + } + if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Decompressed", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &DecompressedSeries{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &Series_Decompressed{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Compressed", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &M3CompressedSeries{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &Series_Compressed{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SeriesMetadata) 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 ErrIntOverflowQuery + } + 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: SeriesMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SeriesMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) + if m.Id == nil { + m.Id = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + m.StartTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartTime |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + m.EndTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EndTime |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecompressedSeries) 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 ErrIntOverflowQuery + } + 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: DecompressedSeries: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecompressedSeries: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Datapoints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Datapoints = append(m.Datapoints, &Datapoint{}) + if err := m.Datapoints[len(m.Datapoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tags = append(m.Tags, &Tag{}) + if err := m.Tags[len(m.Tags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Datapoint) 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 ErrIntOverflowQuery + } + 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: Datapoint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Datapoint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Tag) 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 ErrIntOverflowQuery + } + 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: Tag: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Tag: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...) + if m.Name == nil { + m.Name = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *M3CompressedSeries) 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 ErrIntOverflowQuery + } + 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: M3CompressedSeries: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: M3CompressedSeries: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompressedTags", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CompressedTags = append(m.CompressedTags[:0], dAtA[iNdEx:postIndex]...) + if m.CompressedTags == nil { + m.CompressedTags = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Replicas", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Replicas = append(m.Replicas, &M3CompressedValuesReplica{}) + if err := m.Replicas[len(m.Replicas)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *FetchRequest) Unmarshal(dAtA []byte) error { +func (m *M3CompressedValuesReplica) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1481,17 +3977,17 @@ func (m *FetchRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: FetchRequest: wiretype end group for non-group") + return fmt.Errorf("proto: M3CompressedValuesReplica: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: FetchRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: M3CompressedValuesReplica: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Segments", wireType) } - m.Start = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1501,16 +3997,78 @@ func (m *FetchRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Start |= (int64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field End", wireType) + if msglen < 0 { + return ErrInvalidLengthQuery } - m.End = 0 + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Segments = append(m.Segments, &M3Segments{}) + if err := m.Segments[len(m.Segments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *M3Segments) 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 ErrIntOverflowQuery + } + 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: M3Segments: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: M3Segments: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Merged", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1520,14 +4078,28 @@ func (m *FetchRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.End |= (int64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - case 3: + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Merged == nil { + m.Merged = &M3Segment{} + } + if err := m.Merged.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TagMatchers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Unmerged", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1551,12 +4123,161 @@ func (m *FetchRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &TagMatchers{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Unmerged = append(m.Unmerged, &M3Segment{}) + if err := m.Unmerged[len(m.Unmerged)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { return err } - m.Matchers = &FetchRequest_TagMatchers{v} - iNdEx = postIndex + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *M3Segment) 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 ErrIntOverflowQuery + } + 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: M3Segment: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: M3Segment: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Head", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Head = append(m.Head[:0], dAtA[iNdEx:postIndex]...) + if m.Head == nil { + m.Head = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tail", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tail = append(m.Tail[:0], dAtA[iNdEx:postIndex]...) + if m.Tail == nil { + m.Tail = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + m.StartTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartTime |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockSize", wireType) + } + m.BlockSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockSize |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1578,7 +4299,7 @@ func (m *FetchRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *TagMatchers) Unmarshal(dAtA []byte) error { +func (m *SearchRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1601,10 +4322,10 @@ func (m *TagMatchers) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TagMatchers: wiretype end group for non-group") + return fmt.Errorf("proto: SearchRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TagMatchers: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SearchRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1633,10 +4354,11 @@ func (m *TagMatchers) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TagMatchers = append(m.TagMatchers, &TagMatcher{}) - if err := m.TagMatchers[len(m.TagMatchers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + v := &TagMatchers{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } + m.Matchers = &SearchRequest_TagMatchers{v} iNdEx = postIndex default: iNdEx = preIndex @@ -1659,7 +4381,7 @@ func (m *TagMatchers) Unmarshal(dAtA []byte) error { } return nil } -func (m *TagMatcher) Unmarshal(dAtA []byte) error { +func (m *M3TagProperty) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1682,15 +4404,15 @@ func (m *TagMatcher) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TagMatcher: wiretype end group for non-group") + return fmt.Errorf("proto: M3TagProperty: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TagMatcher: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: M3TagProperty: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1714,14 +4436,14 @@ func (m *TagMatcher) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...) - if m.Name == nil { - m.Name = []byte{} + m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) + if m.Id == nil { + m.Id = []byte{} } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CompressedTags", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1745,30 +4467,11 @@ func (m *TagMatcher) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} + m.CompressedTags = append(m.CompressedTags[:0], dAtA[iNdEx:postIndex]...) + if m.CompressedTags == nil { + m.CompressedTags = []byte{} } iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= (MatcherType(b) & 0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1790,7 +4493,7 @@ func (m *TagMatcher) Unmarshal(dAtA []byte) error { } return nil } -func (m *FetchResponse) Unmarshal(dAtA []byte) error { +func (m *M3TagProperties) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1813,15 +4516,15 @@ func (m *FetchResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: FetchResponse: wiretype end group for non-group") + return fmt.Errorf("proto: M3TagProperties: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: FetchResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: M3TagProperties: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Series", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Properties", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1845,8 +4548,8 @@ func (m *FetchResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Series = append(m.Series, &Series{}) - if err := m.Series[len(m.Series)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Properties = append(m.Properties, &M3TagProperty{}) + if err := m.Properties[len(m.Properties)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1871,7 +4574,7 @@ func (m *FetchResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *Series) Unmarshal(dAtA []byte) error { +func (m *TagProperty) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1894,17 +4597,17 @@ func (m *Series) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Series: wiretype end group for non-group") + return fmt.Errorf("proto: TagProperty: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Series: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TagProperty: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1914,62 +4617,28 @@ func (m *Series) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex > l { return io.ErrUnexpectedEOF } - if m.Meta == nil { - m.Meta = &SeriesMetadata{} - } - if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Decompressed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &DecompressedSeries{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Series_Decompressed{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Compressed", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1979,23 +4648,22 @@ func (m *Series) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex > l { return io.ErrUnexpectedEOF } - v := &M3CompressedSeries{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Values = append(m.Values[:0], dAtA[iNdEx:postIndex]...) + if m.Values == nil { + m.Values = []byte{} } - m.Value = &Series_Compressed{v} iNdEx = postIndex default: iNdEx = preIndex @@ -2018,7 +4686,7 @@ func (m *Series) Unmarshal(dAtA []byte) error { } return nil } -func (m *SeriesMetadata) Unmarshal(dAtA []byte) error { +func (m *TagProperties) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2041,17 +4709,17 @@ func (m *SeriesMetadata) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SeriesMetadata: wiretype end group for non-group") + return fmt.Errorf("proto: TagProperties: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SeriesMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TagProperties: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Properties", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2061,61 +4729,23 @@ func (m *SeriesMetadata) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) - if m.Id == nil { - m.Id = []byte{} + m.Properties = append(m.Properties, &TagProperty{}) + if err := m.Properties[len(m.Properties)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) - } - m.StartTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartTime |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) - } - m.EndTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EndTime |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2137,7 +4767,7 @@ func (m *SeriesMetadata) Unmarshal(dAtA []byte) error { } return nil } -func (m *DecompressedSeries) Unmarshal(dAtA []byte) error { +func (m *SearchResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2160,46 +4790,15 @@ func (m *DecompressedSeries) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DecompressedSeries: wiretype end group for non-group") + return fmt.Errorf("proto: SearchResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DecompressedSeries: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SearchResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Datapoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Datapoints = append(m.Datapoints, &Datapoint{}) - if err := m.Datapoints[len(m.Datapoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Decompressed", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2219,70 +4818,21 @@ func (m *DecompressedSeries) Unmarshal(dAtA []byte) error { if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Tags = append(m.Tags, &Tag{}) - if err := m.Tags[len(m.Tags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Datapoint) 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 ErrIntOverflowQuery - } - if iNdEx >= l { + postIndex := iNdEx + msglen + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break + v := &TagProperties{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Datapoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Datapoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + m.Value = &SearchResponse_Decompressed{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Compressed", wireType) } - m.Timestamp = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2292,22 +4842,24 @@ func (m *Datapoint) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Timestamp |= (int64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + if msglen < 0 { + return ErrInvalidLengthQuery } - var v uint64 - if (iNdEx + 8) > l { + postIndex := iNdEx + msglen + if postIndex > l { return io.ErrUnexpectedEOF } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = float64(math.Float64frombits(v)) + v := &M3TagProperties{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &SearchResponse_Compressed{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2329,7 +4881,7 @@ func (m *Datapoint) Unmarshal(dAtA []byte) error { } return nil } -func (m *Tag) Unmarshal(dAtA []byte) error { +func (m *CompleteTagsRequestOptions) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2352,17 +4904,17 @@ func (m *Tag) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Tag: wiretype end group for non-group") + return fmt.Errorf("proto: CompleteTagsRequestOptions: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Tag: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CompleteTagsRequestOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } - var byteLen int + m.Type = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2372,26 +4924,14 @@ func (m *Tag) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + m.Type |= (CompleteTagsType(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...) - if m.Name == nil { - m.Name = []byte{} - } - iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FilterNameTags", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2415,10 +4955,8 @@ func (m *Tag) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } + m.FilterNameTags = append(m.FilterNameTags, make([]byte, postIndex-iNdEx)) + copy(m.FilterNameTags[len(m.FilterNameTags)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2441,7 +4979,7 @@ func (m *Tag) Unmarshal(dAtA []byte) error { } return nil } -func (m *M3CompressedSeries) Unmarshal(dAtA []byte) error { +func (m *CompleteTagsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2464,17 +5002,17 @@ func (m *M3CompressedSeries) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: M3CompressedSeries: wiretype end group for non-group") + return fmt.Errorf("proto: CompleteTagsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: M3CompressedSeries: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CompleteTagsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CompressedTags", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TagMatchers", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2484,26 +5022,27 @@ func (m *M3CompressedSeries) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.CompressedTags = append(m.CompressedTags[:0], dAtA[iNdEx:postIndex]...) - if m.CompressedTags == nil { - m.CompressedTags = []byte{} + v := &TagMatchers{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } + m.Matchers = &CompleteTagsRequest_TagMatchers{v} iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Replicas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2527,8 +5066,10 @@ func (m *M3CompressedSeries) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Replicas = append(m.Replicas, &M3CompressedValuesReplica{}) - if err := m.Replicas[len(m.Replicas)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Options == nil { + m.Options = &CompleteTagsRequestOptions{} + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2553,7 +5094,7 @@ func (m *M3CompressedSeries) Unmarshal(dAtA []byte) error { } return nil } -func (m *M3CompressedValuesReplica) Unmarshal(dAtA []byte) error { +func (m *TagNames) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2576,17 +5117,17 @@ func (m *M3CompressedValuesReplica) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: M3CompressedValuesReplica: wiretype end group for non-group") + return fmt.Errorf("proto: TagNames: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: M3CompressedValuesReplica: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TagNames: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Segments", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Names", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2596,22 +5137,20 @@ func (m *M3CompressedValuesReplica) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex > l { return io.ErrUnexpectedEOF } - m.Segments = append(m.Segments, &M3Segments{}) - if err := m.Segments[len(m.Segments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Names = append(m.Names, make([]byte, postIndex-iNdEx)) + copy(m.Names[len(m.Names)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2634,7 +5173,7 @@ func (m *M3CompressedValuesReplica) Unmarshal(dAtA []byte) error { } return nil } -func (m *M3Segments) Unmarshal(dAtA []byte) error { +func (m *TagValue) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2657,17 +5196,17 @@ func (m *M3Segments) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: M3Segments: wiretype end group for non-group") + return fmt.Errorf("proto: TagValue: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: M3Segments: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TagValue: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Merged", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2677,30 +5216,28 @@ func (m *M3Segments) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex > l { return io.ErrUnexpectedEOF } - if m.Merged == nil { - m.Merged = &M3Segment{} - } - if err := m.Merged.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Unmerged", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2710,22 +5247,20 @@ func (m *M3Segments) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex > l { return io.ErrUnexpectedEOF } - m.Unmerged = append(m.Unmerged, &M3Segment{}) - if err := m.Unmerged[len(m.Unmerged)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Values = append(m.Values, make([]byte, postIndex-iNdEx)) + copy(m.Values[len(m.Values)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2748,7 +5283,7 @@ func (m *M3Segments) Unmarshal(dAtA []byte) error { } return nil } -func (m *M3Segment) Unmarshal(dAtA []byte) error { +func (m *TagValues) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2771,17 +5306,17 @@ func (m *M3Segment) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: M3Segment: wiretype end group for non-group") + return fmt.Errorf("proto: TagValues: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: M3Segment: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TagValues: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Head", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2791,28 +5326,78 @@ func (m *M3Segment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Head = append(m.Head[:0], dAtA[iNdEx:postIndex]...) - if m.Head == nil { - m.Head = []byte{} + m.Values = append(m.Values, &TagValue{}) + if err := m.Values[len(m.Values)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex - case 2: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompleteTagsResponse) 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 ErrIntOverflowQuery + } + 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: CompleteTagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompleteTagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tail", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Default", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2822,28 +5407,29 @@ func (m *M3Segment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Tail = append(m.Tail[:0], dAtA[iNdEx:postIndex]...) - if m.Tail == nil { - m.Tail = []byte{} + v := &TagValues{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } + m.Value = &CompleteTagsResponse_Default{v} iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NamesOnly", wireType) } - m.StartTime = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2853,30 +5439,24 @@ func (m *M3Segment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartTime |= (int64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockSize", wireType) + if msglen < 0 { + return ErrInvalidLengthQuery } - m.BlockSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockSize |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF } + v := &TagNames{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &CompleteTagsResponse_NamesOnly{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3008,50 +5588,73 @@ func init() { } var fileDescriptorQuery = []byte{ - // 712 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xdd, 0x6e, 0xda, 0x58, - 0x10, 0xc6, 0x18, 0x08, 0x8c, 0x09, 0x61, 0x67, 0x57, 0x0a, 0xbb, 0x8a, 0x50, 0xe4, 0x5d, 0x65, - 0xa3, 0xac, 0x84, 0xb3, 0x90, 0x9b, 0x54, 0xea, 0x5f, 0x5a, 0xda, 0x54, 0x6a, 0x92, 0xe6, 0xe0, - 0x56, 0x51, 0x95, 0x8b, 0x1e, 0xec, 0x11, 0x58, 0xc5, 0xd8, 0xb1, 0x0f, 0x55, 0xd2, 0xa7, 0xe8, - 0xc3, 0xf4, 0x21, 0x7a, 0xd9, 0x47, 0xa8, 0xd2, 0x17, 0xa9, 0x7c, 0x7c, 0xc0, 0x26, 0xa8, 0x52, - 0xef, 0xce, 0x7c, 0xdf, 0x37, 0xc3, 0xcc, 0xf8, 0x63, 0xe0, 0xc1, 0xc8, 0x13, 0xe3, 0xd9, 0xb0, - 0xe3, 0x04, 0xbe, 0xe5, 0xf7, 0xdc, 0xa1, 0xe5, 0xf7, 0xac, 0x38, 0x72, 0xac, 0xab, 0x19, 0x45, - 0x37, 0xd6, 0x88, 0xa6, 0x14, 0x71, 0x41, 0xae, 0x15, 0x46, 0x81, 0x08, 0xac, 0x28, 0x74, 0xc2, - 0x61, 0xca, 0x75, 0x24, 0x82, 0x7a, 0x14, 0x3a, 0xe6, 0x35, 0xd4, 0x9f, 0x91, 0x70, 0xc6, 0x8c, - 0xae, 0x66, 0x14, 0x0b, 0xfc, 0x03, 0xca, 0xb1, 0xe0, 0x91, 0x68, 0x69, 0xdb, 0xda, 0xae, 0xce, - 0xd2, 0x00, 0x9b, 0xa0, 0xd3, 0xd4, 0x6d, 0x15, 0x25, 0x96, 0x3c, 0xf1, 0x00, 0x0c, 0xc1, 0x47, - 0x27, 0x5c, 0x38, 0x63, 0x8a, 0xe2, 0x96, 0xbe, 0xad, 0xed, 0x1a, 0xdd, 0x66, 0x27, 0x0a, 0x9d, - 0x8e, 0x9d, 0xe1, 0xc7, 0x05, 0x96, 0x97, 0x1d, 0x01, 0x54, 0x7d, 0xf5, 0x36, 0x1f, 0x81, 0x91, - 0x53, 0xe2, 0xff, 0xcb, 0x05, 0xb5, 0x6d, 0x7d, 0xd7, 0xe8, 0x6e, 0xdc, 0x29, 0xb8, 0x54, 0xcd, - 0xbc, 0x04, 0xc8, 0x28, 0x44, 0x28, 0x4d, 0xb9, 0x4f, 0xb2, 0xf1, 0x3a, 0x93, 0xef, 0x64, 0x9a, - 0x0f, 0x7c, 0x32, 0x23, 0xd9, 0x79, 0x9d, 0xa5, 0x01, 0xfe, 0x03, 0x25, 0x71, 0x13, 0x92, 0x6c, - 0xba, 0xa1, 0x9a, 0x56, 0x55, 0xec, 0x9b, 0x90, 0x98, 0x64, 0xcd, 0x03, 0x58, 0x57, 0x9b, 0x89, - 0xc3, 0x60, 0x1a, 0x13, 0xfe, 0x0d, 0x95, 0x98, 0x22, 0x8f, 0xe6, 0xcd, 0x19, 0x32, 0x71, 0x20, - 0x21, 0xa6, 0x28, 0xf3, 0xb3, 0x06, 0x95, 0x14, 0xc2, 0x7f, 0xa1, 0xe4, 0x93, 0xe0, 0xb2, 0x21, - 0xa3, 0xfb, 0x7b, 0x4e, 0x7d, 0x42, 0x82, 0xbb, 0x5c, 0x70, 0x26, 0x05, 0x78, 0x1f, 0xea, 0x2e, - 0x39, 0x81, 0x1f, 0x46, 0x14, 0xc7, 0x94, 0xae, 0xd9, 0xe8, 0x6e, 0xca, 0x84, 0xa7, 0x39, 0x22, - 0x4d, 0x3e, 0x2e, 0xb0, 0x25, 0x39, 0x1e, 0x02, 0xe4, 0x92, 0xf5, 0x5c, 0xf2, 0x49, 0xef, 0xc9, - 0x6a, 0x72, 0x4e, 0x7c, 0xb4, 0xa6, 0xf6, 0x63, 0x5e, 0x40, 0x63, 0xb9, 0x35, 0x6c, 0x40, 0xd1, - 0x73, 0xd5, 0x32, 0x8b, 0x9e, 0x8b, 0x5b, 0x50, 0x93, 0x5e, 0xb0, 0x3d, 0x9f, 0x94, 0x11, 0x32, - 0x00, 0x5b, 0xb0, 0x46, 0x53, 0x57, 0x72, 0xba, 0xe4, 0xe6, 0xa1, 0x39, 0x04, 0x5c, 0x9d, 0x01, - 0x3b, 0x00, 0xc9, 0xaf, 0x84, 0x81, 0x37, 0x15, 0xf3, 0x7d, 0x36, 0xd2, 0x81, 0xe7, 0x30, 0xcb, - 0x29, 0x70, 0x0b, 0x4a, 0x82, 0x8f, 0xe2, 0x56, 0x51, 0x2a, 0xab, 0x73, 0x5b, 0x30, 0x89, 0x9a, - 0x0f, 0xa1, 0xb6, 0x48, 0x4b, 0x1a, 0x15, 0x9e, 0x4f, 0xb1, 0xe0, 0x7e, 0xa8, 0x5c, 0x9c, 0x01, - 0xcb, 0x8e, 0xd0, 0x94, 0x23, 0x4c, 0x0b, 0x74, 0x9b, 0x8f, 0x7e, 0xdd, 0x42, 0xe6, 0x35, 0xe0, - 0xea, 0x72, 0x71, 0x07, 0x1a, 0xd9, 0xa4, 0x76, 0xd2, 0x6f, 0x5a, 0xe9, 0x0e, 0x8a, 0xf7, 0xa0, - 0x1a, 0x51, 0x38, 0xf1, 0x1c, 0x3e, 0x9f, 0xa8, 0xbd, 0xf2, 0xbd, 0xde, 0x24, 0xbf, 0x13, 0xb3, - 0x54, 0xc6, 0x16, 0x7a, 0xf3, 0x18, 0xfe, 0xfc, 0xa9, 0x0c, 0xff, 0x83, 0x6a, 0x4c, 0x23, 0x9f, - 0xb2, 0xa5, 0x6e, 0xa8, 0xc2, 0x03, 0x05, 0xb3, 0x85, 0xc0, 0x7c, 0x07, 0x90, 0xe1, 0xb8, 0x03, - 0x15, 0x9f, 0xa2, 0x11, 0xb9, 0xca, 0xaf, 0x8d, 0xe5, 0x44, 0xa6, 0x58, 0xdc, 0x83, 0xea, 0x6c, - 0xaa, 0x94, 0xc5, 0xdc, 0x77, 0xcb, 0x94, 0x0b, 0xde, 0x0c, 0xa0, 0xb6, 0x80, 0x93, 0xe5, 0x8e, - 0x89, 0xcf, 0x2d, 0x25, 0xdf, 0x09, 0x26, 0xb8, 0x37, 0x51, 0xbb, 0x95, 0xef, 0x65, 0xa3, 0xe9, - 0x77, 0x8d, 0xb6, 0x05, 0xb5, 0xe1, 0x24, 0x70, 0xde, 0x0f, 0xbc, 0x8f, 0xd4, 0x2a, 0xa5, 0xec, - 0x02, 0xd8, 0xbb, 0x04, 0x23, 0xf7, 0x47, 0xc6, 0x1a, 0x94, 0xfb, 0xe7, 0xaf, 0x1f, 0xbf, 0x6c, - 0x16, 0xb0, 0x0e, 0xd5, 0xd3, 0x33, 0x3b, 0x8d, 0x34, 0x04, 0xa8, 0xb0, 0xfe, 0xf3, 0xfe, 0xc5, - 0xab, 0x66, 0x11, 0xd7, 0xa1, 0x76, 0x7a, 0x66, 0xab, 0x50, 0x4f, 0xa8, 0xfe, 0xc5, 0x8b, 0x81, - 0x3d, 0x68, 0x96, 0x14, 0xa5, 0xc2, 0x72, 0xf7, 0x10, 0xca, 0xe7, 0xc9, 0xfd, 0xc4, 0x7d, 0x28, - 0xcb, 0xd3, 0x80, 0xbf, 0xc9, 0xd1, 0xf3, 0x07, 0xf4, 0x2f, 0xcc, 0x43, 0xe9, 0xe5, 0xd8, 0xd7, - 0x8e, 0x36, 0xbf, 0xdc, 0xb6, 0xb5, 0xaf, 0xb7, 0x6d, 0xed, 0xdb, 0x6d, 0x5b, 0xfb, 0xf4, 0xbd, - 0x5d, 0x78, 0x5b, 0x96, 0x07, 0x79, 0x58, 0x91, 0xb7, 0xb8, 0xf7, 0x23, 0x00, 0x00, 0xff, 0xff, - 0x08, 0xc6, 0xe3, 0x21, 0xcd, 0x05, 0x00, 0x00, + // 1075 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x6d, 0x6f, 0x1b, 0x45, + 0x10, 0xf6, 0xf9, 0x6c, 0xc7, 0x1e, 0xbf, 0xd4, 0x4c, 0x02, 0x75, 0xa3, 0x28, 0x44, 0x07, 0x94, + 0x10, 0x20, 0x0e, 0x76, 0x04, 0x14, 0x89, 0x97, 0x84, 0xba, 0x09, 0x52, 0x93, 0x34, 0xeb, 0x2b, + 0x8a, 0x50, 0x3f, 0xb0, 0xbe, 0xdb, 0x3a, 0xa7, 0xfa, 0x7c, 0xd7, 0xbb, 0x35, 0xaa, 0xfb, 0x17, + 0xf8, 0x82, 0xf8, 0x2d, 0xf0, 0x1f, 0xf8, 0xc8, 0x4f, 0x40, 0xe1, 0x8f, 0xa0, 0xdd, 0xdb, 0x7b, + 0xb3, 0x5d, 0xde, 0xbe, 0xdd, 0xcc, 0x3c, 0x33, 0x3b, 0x33, 0xfb, 0xf8, 0xf1, 0xc2, 0x17, 0x63, + 0x87, 0x5f, 0xcf, 0x46, 0xfb, 0x96, 0xe7, 0x76, 0xdd, 0xbe, 0x3d, 0xea, 0xba, 0xfd, 0x6e, 0x18, + 0x58, 0xdd, 0xe7, 0x33, 0x16, 0xcc, 0xbb, 0x63, 0x36, 0x65, 0x01, 0xe5, 0xcc, 0xee, 0xfa, 0x81, + 0xc7, 0xbd, 0x6e, 0xe0, 0x5b, 0xfe, 0x28, 0x8a, 0xed, 0x4b, 0x0f, 0xea, 0x81, 0x6f, 0x19, 0x2f, + 0xa0, 0xf1, 0x80, 0x71, 0xeb, 0x9a, 0xb0, 0xe7, 0x33, 0x16, 0x72, 0xdc, 0x80, 0x72, 0xc8, 0x69, + 0xc0, 0x3b, 0xda, 0x8e, 0xb6, 0xab, 0x93, 0xc8, 0xc0, 0x36, 0xe8, 0x6c, 0x6a, 0x77, 0x8a, 0xd2, + 0x27, 0x3e, 0xf1, 0x10, 0xea, 0x9c, 0x8e, 0xcf, 0x28, 0xb7, 0xae, 0x59, 0x10, 0x76, 0xf4, 0x1d, + 0x6d, 0xb7, 0xde, 0x6b, 0xef, 0x07, 0xbe, 0xb5, 0x6f, 0xa6, 0xfe, 0xd3, 0x02, 0xc9, 0xc2, 0x8e, + 0x01, 0xaa, 0xae, 0xfa, 0x36, 0xbe, 0x82, 0x7a, 0x06, 0x89, 0x1f, 0xe5, 0x0b, 0x6a, 0x3b, 0xfa, + 0x6e, 0xbd, 0x77, 0x6b, 0xa1, 0x60, 0xae, 0x9a, 0xf1, 0x04, 0x20, 0x0d, 0x21, 0x42, 0x69, 0x4a, + 0x5d, 0x26, 0x1b, 0x6f, 0x10, 0xf9, 0x2d, 0xa6, 0xf9, 0x81, 0x4e, 0x66, 0x4c, 0x76, 0xde, 0x20, + 0x91, 0x81, 0x6f, 0x43, 0x89, 0xcf, 0x7d, 0x26, 0x9b, 0x6e, 0xa9, 0xa6, 0x55, 0x15, 0x73, 0xee, + 0x33, 0x22, 0xa3, 0xc6, 0x21, 0x34, 0xd5, 0x66, 0x42, 0xdf, 0x9b, 0x86, 0x0c, 0xdf, 0x82, 0x4a, + 0xc8, 0x02, 0x87, 0xc5, 0xcd, 0xd5, 0x65, 0xe2, 0x50, 0xba, 0x88, 0x0a, 0x19, 0xbf, 0x68, 0x50, + 0x89, 0x5c, 0xf8, 0x2e, 0x94, 0x5c, 0xc6, 0xa9, 0x6c, 0xa8, 0xde, 0x5b, 0xcf, 0xa0, 0xcf, 0x18, + 0xa7, 0x36, 0xe5, 0x94, 0x48, 0x00, 0x7e, 0x0e, 0x0d, 0x9b, 0x59, 0x9e, 0xeb, 0x07, 0x2c, 0x0c, + 0x59, 0xb4, 0xe6, 0x7a, 0xef, 0xb6, 0x4c, 0xb8, 0x9f, 0x09, 0x44, 0xc9, 0xa7, 0x05, 0x92, 0x83, + 0xe3, 0x3d, 0x80, 0x4c, 0xb2, 0x9e, 0x49, 0x3e, 0xeb, 0x7f, 0xbd, 0x9c, 0x9c, 0x01, 0x1f, 0xaf, + 0xa9, 0xfd, 0x18, 0x57, 0xd0, 0xca, 0xb7, 0x86, 0x2d, 0x28, 0x3a, 0xb6, 0x5a, 0x66, 0xd1, 0xb1, + 0x71, 0x0b, 0x6a, 0x92, 0x0b, 0xa6, 0xe3, 0x32, 0x45, 0x84, 0xd4, 0x81, 0x1d, 0x58, 0x63, 0x53, + 0x5b, 0xc6, 0x74, 0x19, 0x8b, 0x4d, 0x63, 0x04, 0xb8, 0x3c, 0x03, 0xee, 0x03, 0x88, 0x53, 0x7c, + 0xcf, 0x99, 0xf2, 0x78, 0x9f, 0xad, 0x68, 0xe0, 0xd8, 0x4d, 0x32, 0x08, 0xdc, 0x82, 0x12, 0xa7, + 0xe3, 0xb0, 0x53, 0x94, 0xc8, 0x6a, 0x4c, 0x0b, 0x22, 0xbd, 0xc6, 0x97, 0x50, 0x4b, 0xd2, 0x44, + 0xa3, 0xdc, 0x71, 0x59, 0xc8, 0xa9, 0xeb, 0x2b, 0x16, 0xa7, 0x8e, 0x3c, 0x23, 0x34, 0xc5, 0x08, + 0xa3, 0x0b, 0xba, 0x49, 0xc7, 0xff, 0x9e, 0x42, 0xc6, 0x0b, 0xc0, 0xe5, 0xe5, 0xe2, 0x5d, 0x68, + 0xa5, 0x93, 0x9a, 0xa2, 0xdf, 0xa8, 0xd2, 0x82, 0x17, 0x3f, 0x83, 0x6a, 0xc0, 0xfc, 0x89, 0x63, + 0xd1, 0x78, 0xa2, 0xed, 0xa5, 0xfb, 0xfa, 0x56, 0x9c, 0x13, 0x92, 0x08, 0x46, 0x12, 0xbc, 0x71, + 0x0a, 0x77, 0x5e, 0x09, 0xc3, 0xf7, 0xa1, 0x1a, 0xb2, 0xb1, 0xcb, 0xd2, 0xa5, 0xde, 0x52, 0x85, + 0x87, 0xca, 0x4d, 0x12, 0x80, 0xf1, 0x3d, 0x40, 0xea, 0xc7, 0xbb, 0x50, 0x71, 0x59, 0x30, 0x66, + 0xb6, 0xe2, 0x6b, 0x2b, 0x9f, 0x48, 0x54, 0x14, 0xf7, 0xa0, 0x3a, 0x9b, 0x2a, 0x64, 0x31, 0x73, + 0x6f, 0x29, 0x32, 0x89, 0x1b, 0x1e, 0xd4, 0x12, 0xb7, 0x58, 0xee, 0x35, 0xa3, 0x31, 0xa5, 0xe4, + 0xb7, 0xf0, 0x71, 0xea, 0x4c, 0xd4, 0x6e, 0xe5, 0x77, 0x9e, 0x68, 0xfa, 0x22, 0xd1, 0xb6, 0xa0, + 0x36, 0x9a, 0x78, 0xd6, 0xb3, 0xa1, 0xf3, 0x92, 0x75, 0x4a, 0x51, 0x34, 0x71, 0x18, 0x97, 0xd0, + 0x1c, 0x32, 0x1a, 0xa4, 0x72, 0x76, 0xb8, 0xa8, 0x2a, 0xff, 0x59, 0xa6, 0x4e, 0xa0, 0x79, 0xd6, + 0x37, 0xe9, 0xf8, 0x51, 0xe0, 0xf9, 0x2c, 0xe0, 0xf3, 0xa5, 0x1f, 0xc6, 0xf2, 0xa5, 0x17, 0x57, + 0x5d, 0xba, 0x31, 0x80, 0x5b, 0xd9, 0x42, 0x82, 0x2f, 0x3d, 0x00, 0x3f, 0xb1, 0xd4, 0x85, 0xa1, + 0xda, 0x66, 0xe6, 0x48, 0x92, 0x41, 0x19, 0x9f, 0x48, 0xd9, 0x4c, 0xba, 0x69, 0x83, 0xfe, 0x8c, + 0xcd, 0x55, 0x3b, 0xe2, 0x13, 0xdf, 0x80, 0x8a, 0xe4, 0x68, 0xdc, 0x87, 0xb2, 0x8c, 0x23, 0x68, + 0xe6, 0x4f, 0x3f, 0x58, 0x71, 0x7a, 0xb2, 0x9a, 0x95, 0x67, 0xff, 0xa8, 0x09, 0x99, 0x88, 0xf6, + 0xab, 0x44, 0xf1, 0xd3, 0x05, 0xed, 0x8a, 0x36, 0x8c, 0x0b, 0x65, 0x56, 0xc9, 0xd6, 0xc7, 0x39, + 0xd9, 0x8a, 0x34, 0x6f, 0x63, 0x69, 0xf8, 0xbf, 0xd1, 0x2c, 0x0f, 0x36, 0xc5, 0xef, 0x60, 0xc2, + 0x38, 0x13, 0x0b, 0x56, 0x57, 0x7e, 0xe1, 0x73, 0xc7, 0x9b, 0x86, 0xf8, 0x9e, 0x12, 0x79, 0x4d, + 0x8a, 0xfc, 0xeb, 0xb2, 0x70, 0x16, 0x9e, 0x2a, 0xbd, 0xb8, 0xc1, 0xa7, 0xce, 0x84, 0xb3, 0xe0, + 0x9c, 0xba, 0xcc, 0x8c, 0x65, 0xa6, 0x41, 0x16, 0xbc, 0xc6, 0xcf, 0x1a, 0xac, 0xaf, 0x38, 0xf1, + 0xff, 0x91, 0x0c, 0xef, 0xc1, 0x9a, 0x17, 0xf5, 0xaa, 0x86, 0x7f, 0x73, 0xa9, 0xc7, 0xfc, 0x48, + 0x24, 0xc6, 0xe7, 0xf8, 0xb9, 0x03, 0x55, 0x93, 0x8e, 0x45, 0x8f, 0xa1, 0xd0, 0x2a, 0xa1, 0x59, + 0xd1, 0x65, 0x36, 0x48, 0x64, 0x18, 0x87, 0x12, 0x21, 0x85, 0xe2, 0x1f, 0xe8, 0xa2, 0x67, 0xe8, + 0xd2, 0x83, 0x5a, 0x9c, 0x15, 0xe2, 0x3b, 0x09, 0x28, 0xa2, 0x49, 0x33, 0x1e, 0x4e, 0xc6, 0x93, + 0x9c, 0x97, 0xb0, 0x91, 0x6f, 0x5f, 0x91, 0x64, 0x0f, 0xd6, 0x6c, 0xf6, 0x94, 0xce, 0x26, 0x3c, + 0x27, 0x2e, 0x49, 0xfd, 0xd3, 0x02, 0x89, 0x01, 0xf8, 0x21, 0xd4, 0x64, 0xdb, 0x17, 0xd3, 0xc9, + 0x5c, 0x2d, 0x26, 0x39, 0x4d, 0x4e, 0x79, 0x5a, 0x20, 0x29, 0x22, 0x61, 0xc3, 0xde, 0x13, 0xa8, + 0x67, 0xfe, 0xc3, 0xb1, 0x06, 0xe5, 0xc1, 0xe5, 0xe3, 0xa3, 0x87, 0xed, 0x02, 0x36, 0xa0, 0x7a, + 0x7e, 0x61, 0x46, 0x96, 0x86, 0x00, 0x15, 0x32, 0x38, 0x19, 0x5c, 0x3d, 0x6a, 0x17, 0xb1, 0x09, + 0xb5, 0xf3, 0x0b, 0x53, 0x99, 0xba, 0x08, 0x0d, 0xae, 0xbe, 0x19, 0x9a, 0xc3, 0x76, 0x49, 0x85, + 0x94, 0x59, 0xde, 0xfb, 0x00, 0xda, 0x8b, 0xe4, 0xc1, 0x3a, 0xac, 0xdd, 0x1f, 0x3c, 0x38, 0x7a, + 0xfc, 0xd0, 0x6c, 0x17, 0x84, 0x61, 0x1e, 0x9d, 0x9c, 0x1f, 0x9d, 0x0d, 0xda, 0x5a, 0xef, 0x57, + 0x0d, 0xca, 0x97, 0xe2, 0xa5, 0x85, 0x07, 0x50, 0x96, 0x8f, 0x08, 0x7c, 0x4d, 0xce, 0x90, 0x7d, + 0x6a, 0x6d, 0x62, 0xd6, 0x15, 0x6d, 0xea, 0x40, 0xc3, 0xbe, 0x78, 0x3f, 0x88, 0x9f, 0x18, 0xa2, + 0x7a, 0x31, 0x64, 0xf4, 0x6c, 0x73, 0x3d, 0xe7, 0x4b, 0x92, 0x06, 0xd0, 0xc8, 0xb6, 0x87, 0x9d, + 0x57, 0x51, 0x69, 0xf3, 0xce, 0x8a, 0x48, 0x5c, 0xe6, 0xf8, 0xf6, 0x6f, 0x37, 0xdb, 0xda, 0xef, + 0x37, 0xdb, 0xda, 0x1f, 0x37, 0xdb, 0xda, 0x4f, 0x7f, 0x6e, 0x17, 0xbe, 0x2b, 0xcb, 0x67, 0xe3, + 0xa8, 0x22, 0x5f, 0x8c, 0xfd, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x41, 0x85, 0x94, 0x73, + 0x0a, 0x00, 0x00, } diff --git a/src/query/generated/proto/rpcpb/query.proto b/src/query/generated/proto/rpcpb/query.proto index aa8d967f3b..60b2514ffc 100644 --- a/src/query/generated/proto/rpcpb/query.proto +++ b/src/query/generated/proto/rpcpb/query.proto @@ -5,7 +5,10 @@ package rpc; option go_package = "rpcpb"; service Query { - rpc Fetch(FetchRequest) returns (stream FetchResponse); + rpc Fetch(FetchRequest) returns (stream FetchResponse); + + rpc Search(SearchRequest) returns (stream SearchResponse); + rpc CompleteTags(CompleteTagsRequest) returns (stream CompleteTagsResponse); } message FetchRequest { @@ -90,3 +93,73 @@ message M3Segment { int64 startTime = 3; int64 blockSize = 4; } + +message SearchRequest { + oneof matchers { + TagMatchers tagMatchers = 1; + } +} + +message M3TagProperty { + bytes id = 1; + bytes compressedTags = 2; +} + +message M3TagProperties { + repeated M3TagProperty properties = 1; +} + +message TagProperty { + bytes key = 1; + bytes values = 2; +} + +message TagProperties { + repeated TagProperty properties = 1; +} + +message SearchResponse { + oneof value { + TagProperties decompressed = 1; + M3TagProperties compressed = 2; + } +} + +enum CompleteTagsType { + // Requests tag names and values + DEFAULT = 0; + // Requests tag names only + TAGNAME = 1; +} + +message CompleteTagsRequestOptions { + CompleteTagsType type = 1; + repeated bytes filterNameTags = 2; +} + +message CompleteTagsRequest { + oneof matchers { + TagMatchers tagMatchers = 1; + } + CompleteTagsRequestOptions options = 2; +} + +message TagNames { + repeated bytes names = 1; +} + +message TagValue { + bytes key = 1; + repeated bytes values = 2; +} + +message TagValues { + repeated TagValue values = 1; +} + +message CompleteTagsResponse { + oneof value { + TagValues default = 1; + TagNames namesOnly = 2; + } +} diff --git a/src/query/models/matcher.go b/src/query/models/matcher.go index c576657d4b..58173f8a7d 100644 --- a/src/query/models/matcher.go +++ b/src/query/models/matcher.go @@ -98,3 +98,13 @@ func (m Matchers) ToTags( return tags, nil } + +func (m Matchers) String() string { + var buffer bytes.Buffer + for _, match := range m { + buffer.WriteString(match.String()) + buffer.WriteByte(sep) + } + + return buffer.String() +} diff --git a/src/query/pools/pool_wrapper.go b/src/query/pools/pool_wrapper.go index 0c74455fb8..1e2b97acc6 100644 --- a/src/query/pools/pool_wrapper.go +++ b/src/query/pools/pool_wrapper.go @@ -21,7 +21,9 @@ package pools import ( + "errors" "sync" + "time" "github.com/m3db/m3/src/dbnode/encoding" ) @@ -77,3 +79,34 @@ func (w *PoolWrapper) IteratorPools() ( w.watchersErr = append(w.watchersErr, watcherErr) return false, nil, nil, watcher, watcherErr } + +// WaitForIteratorPools will block until iterator pools are available. +// If given a timeout of 0, will block indefinitely +func (w *PoolWrapper) WaitForIteratorPools( + timeout time.Duration, +) (encoding.IteratorPools, error) { + available, pools, err, poolCh, errCh := w.IteratorPools() + if err != nil { + return nil, err + } + + if !available { + if timeout == 0 { + select { + case pools = <-poolCh: + case err = <-errCh: + return nil, err + } + } + + select { + case pools = <-poolCh: + case err = <-errCh: + return nil, err + case <-time.After(timeout): + return nil, errors.New("timeout waiting for iterator pools") + } + } + + return pools, err +} diff --git a/src/query/server/server_test.go b/src/query/server/server_test.go index 90aac42d47..aaf01dfe81 100644 --- a/src/query/server/server_test.go +++ b/src/query/server/server_test.go @@ -192,8 +192,8 @@ func waitForServerHealthy(t *testing.T, port int) { } type queryServer struct { - reads int - mu sync.Mutex + reads, searches, tagCompletes int + mu sync.Mutex } func (s *queryServer) Fetch( @@ -206,6 +206,26 @@ func (s *queryServer) Fetch( return nil } +func (s *queryServer) Search( + *rpc.SearchRequest, + rpc.Query_SearchServer, +) error { + s.mu.Lock() + defer s.mu.Unlock() + s.searches++ + return nil +} + +func (s *queryServer) CompleteTags( + *rpc.CompleteTagsRequest, + rpc.Query_CompleteTagsServer, +) error { + s.mu.Lock() + defer s.mu.Unlock() + s.tagCompletes++ + return nil +} + func TestGRPCBackend(t *testing.T) { var grpcConfigYAML = ` listenAddress: diff --git a/src/query/storage/completed_tags.go b/src/query/storage/completed_tags.go new file mode 100644 index 0000000000..fce9b93b77 --- /dev/null +++ b/src/query/storage/completed_tags.go @@ -0,0 +1,141 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "bytes" + "errors" + "sort" +) + +type completeTagsResultBuilder struct { + nameOnly bool + tagBuilders map[string]completedTagBuilder +} + +// NewCompleteTagsResultBuilder creates a new complete tags result builder. +func NewCompleteTagsResultBuilder( + nameOnly bool, +) CompleteTagsResultBuilder { + return &completeTagsResultBuilder{ + nameOnly: nameOnly, + } +} + +func (b *completeTagsResultBuilder) Add(tagResult *CompleteTagsResult) error { + nameOnly := b.nameOnly + if nameOnly != tagResult.CompleteNameOnly { + return errors.New("incoming tag result has mismatched type") + } + + completedTags := tagResult.CompletedTags + if b.tagBuilders == nil { + b.tagBuilders = make(map[string]completedTagBuilder, len(completedTags)) + } + + if nameOnly { + for _, tag := range completedTags { + b.tagBuilders[string(tag.Name)] = completedTagBuilder{} + } + + return nil + } + + for _, tag := range completedTags { + if builder, exists := b.tagBuilders[string(tag.Name)]; exists { + builder.add(tag.Values) + } else { + builder := completedTagBuilder{} + builder.add(tag.Values) + b.tagBuilders[string(tag.Name)] = builder + } + } + + return nil +} + +type completedTagsByName []CompletedTag + +func (s completedTagsByName) Len() int { return len(s) } +func (s completedTagsByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s completedTagsByName) Less(i, j int) bool { + return bytes.Compare(s[i].Name, s[j].Name) == -1 +} + +func (b *completeTagsResultBuilder) Build() CompleteTagsResult { + result := make([]CompletedTag, len(b.tagBuilders)) + if b.nameOnly { + for name := range b.tagBuilders { + result = append(result, CompletedTag{Name: []byte(name)}) + } + + sort.Sort(completedTagsByName(result)) + return CompleteTagsResult{ + CompleteNameOnly: true, + CompletedTags: result, + } + } + + for name, builder := range b.tagBuilders { + result = append(result, CompletedTag{ + Name: []byte(name), + Values: builder.build(), + }) + } + + sort.Sort(completedTagsByName(result)) + return CompleteTagsResult{ + CompleteNameOnly: false, + CompletedTags: result, + } +} + +type completedTagBuilder struct { + seenMap map[string]struct{} +} + +func (b *completedTagBuilder) add(values [][]byte) { + if b.seenMap == nil { + b.seenMap = make(map[string]struct{}, len(values)) + } + + for _, val := range values { + b.seenMap[string(val)] = struct{}{} + } +} + +type tagValuesByName [][]byte + +func (s tagValuesByName) Len() int { return len(s) } +func (s tagValuesByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s tagValuesByName) Less(i, j int) bool { + return bytes.Compare(s[i], s[j]) == -1 +} + +func (b *completedTagBuilder) build() [][]byte { + result := make([][]byte, 0, len(b.seenMap)) + for v := range b.seenMap { + result = append(result, []byte(v)) + } + + sort.Sort(tagValuesByName(result)) + return result +} diff --git a/src/query/storage/completed_tags_test.go b/src/query/storage/completed_tags_test.go new file mode 100644 index 0000000000..4eb4acf924 --- /dev/null +++ b/src/query/storage/completed_tags_test.go @@ -0,0 +1,62 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func strsToBytes(str []string) [][]byte { + b := make([][]byte, len(str)) + for i, s := range str { + b[i] = []byte(s) + } + + return b +} + +func TestFinalizeCompletedTag(t *testing.T) { + initialVals := []string{"a", "z", "b", "z"} + expected := []string{"a", "b", "z"} + + builder := completedTagBuilder{} + builder.add(strsToBytes(initialVals)) + actual := builder.build() + + assert.Equal(t, strsToBytes(expected), actual) +} + +func TestMergeCompletedTag(t *testing.T) { + initialVals := []string{"a", "z", "b"} + secondVals := []string{"a", "ab"} + thirdVals := []string{"ab", "c", "d"} + expected := []string{"a", "ab", "b", "c", "d", "z"} + + builder := completedTagBuilder{} + builder.add(strsToBytes(initialVals)) + builder.add(strsToBytes(secondVals)) + builder.add(strsToBytes(thirdVals)) + actual := builder.build() + + assert.Equal(t, strsToBytes(expected), actual) +} diff --git a/src/query/storage/m3/multi_fetch_result.go b/src/query/storage/m3/multi_fetch_result.go index 814c2c766c..74d14ffb15 100644 --- a/src/query/storage/m3/multi_fetch_result.go +++ b/src/query/storage/m3/multi_fetch_result.go @@ -29,18 +29,6 @@ import ( xerrors "github.com/m3db/m3x/errors" ) -type multiFetchResult interface { - Add( - attrs storage.Attributes, - iterators encoding.SeriesIterators, - err error, - ) - - FinalResult() (encoding.SeriesIterators, error) - - Close() error -} - // TODO: use a better seriesIterators merge here type multiResult struct { sync.Mutex @@ -57,7 +45,7 @@ type multiResult struct { func newMultiFetchResult( fanout queryFanoutType, pools encoding.IteratorPools, -) multiFetchResult { +) MultiFetchResult { return &multiResult{ fanout: fanout, pools: pools, diff --git a/src/query/storage/m3/multi_fetch_tags_result.go b/src/query/storage/m3/multi_fetch_tags_result.go index ffc1b6fafa..06c296baa2 100644 --- a/src/query/storage/m3/multi_fetch_tags_result.go +++ b/src/query/storage/m3/multi_fetch_tags_result.go @@ -23,19 +23,60 @@ package m3 import ( "sync" - "github.com/m3db/m3/src/query/storage" + "github.com/m3db/m3/src/dbnode/client" xerrors "github.com/m3db/m3x/errors" ) -type multiFetchTagsResult struct { +const initSize = 10 + +type multiSearchResult struct { sync.Mutex - result *storage.SearchResults + seenIters []client.TaggedIDsIterator // track known iterators to avoid leaking + dedupeMap map[string]MultiTagResult err xerrors.MultiError - dedupeMap map[string]struct{} } -func (r *multiFetchTagsResult) add( - result *storage.SearchResults, +// NewMultiFetchTagsResult builds a new multi fetch tags result +func NewMultiFetchTagsResult() MultiFetchTagsResult { + return &multiSearchResult{ + dedupeMap: make(map[string]MultiTagResult, initSize), + seenIters: make([]client.TaggedIDsIterator, 0, initSize), + } +} + +func (r *multiSearchResult) Close() error { + r.Lock() + defer r.Unlock() + for _, iters := range r.seenIters { + iters.Finalize() + } + + r.seenIters = nil + r.dedupeMap = nil + r.err = xerrors.NewMultiError() + + return nil +} + +func (r *multiSearchResult) FinalResult() ([]MultiTagResult, error) { + r.Lock() + defer r.Unlock() + + err := r.err.FinalError() + if err != nil { + return nil, err + } + + result := make([]MultiTagResult, 0, len(r.dedupeMap)) + for _, it := range r.dedupeMap { + result = append(result, it) + } + + return result, nil +} + +func (r *multiSearchResult) Add( + newIterator client.TaggedIDsIterator, err error, ) { r.Lock() @@ -46,29 +87,27 @@ func (r *multiFetchTagsResult) add( return } - if r.result == nil { - r.result = result + r.seenIters = append(r.seenIters, newIterator) + // Need to check the error to bail early after accumulating the iterators + // otherwise when we close the the multi fetch result + if !r.err.Empty() { + // don't need to do anything if the final result is going to be an error return } - // Need to dedupe - if r.dedupeMap == nil { - r.dedupeMap = make(map[string]struct{}, len(r.result.Metrics)) - for _, s := range r.result.Metrics { - r.dedupeMap[s.ID] = struct{}{} - } - } - - for _, s := range result.Metrics { - id := s.ID + for newIterator.Next() { + _, ident, tagIter := newIterator.Current() + id := ident.String() _, exists := r.dedupeMap[id] - if exists { - // Already exists - continue + if !exists { + r.dedupeMap[id] = MultiTagResult{ + ID: ident, + Iter: tagIter, + } } + } - // Does not exist already, add result - r.result.Metrics = append(r.result.Metrics, s) - r.dedupeMap[id] = struct{}{} + if err := newIterator.Err(); err != nil { + r.err = r.err.Add(err) } } diff --git a/src/query/storage/m3/storage.go b/src/query/storage/m3/storage.go index 07979e9002..aa2068b582 100644 --- a/src/query/storage/m3/storage.go +++ b/src/query/storage/m3/storage.go @@ -79,7 +79,7 @@ func (s *m3storage) Fetch( query *storage.FetchQuery, options *storage.FetchOptions, ) (*storage.FetchResult, error) { - raw, cleanup, err := s.FetchRaw(ctx, query, options) + raw, cleanup, err := s.FetchCompressed(ctx, query, options) defer cleanup() if err != nil { return nil, err @@ -101,7 +101,7 @@ func (s *m3storage) FetchBlocks( return storage.FetchResultToBlockResult(fetchResult, query) } -func (s *m3storage) FetchRaw( +func (s *m3storage) FetchCompressed( ctx context.Context, query *storage.FetchQuery, options *storage.FetchOptions, @@ -179,43 +179,72 @@ func (s *m3storage) FetchTags( query *storage.FetchQuery, options *storage.FetchOptions, ) (*storage.SearchResults, error) { + tagResult, cleanup, err := s.SearchCompressed(ctx, query, options) + defer cleanup() + if err != nil { + return nil, err + } + + metrics := make(models.Metrics, len(tagResult)) + for i, result := range tagResult { + m, err := storage.FromM3IdentToMetric(result.ID, result.Iter, s.tagOptions) + if err != nil { + return nil, err + } + + metrics[i] = m + } + + return &storage.SearchResults{ + Metrics: metrics, + }, nil +} + +func (s *m3storage) SearchCompressed( + ctx context.Context, + query *storage.FetchQuery, + options *storage.FetchOptions, +) ([]MultiTagResult, Cleanup, error) { // Check if the query was interrupted. select { case <-ctx.Done(): - return nil, ctx.Err() + return nil, nil, ctx.Err() default: } m3query, err := storage.FetchQueryToM3Query(query) if err != nil { - return nil, err + return nil, noop, err } var ( - opts = storage.FetchOptionsToM3Options(options, query) + m3opts = storage.FetchOptionsToM3Options(options, query) namespaces = s.clusters.ClusterNamespaces() - result multiFetchTagsResult + result = NewMultiFetchTagsResult() wg sync.WaitGroup ) + if len(namespaces) == 0 { - return nil, errNoNamespacesConfigured + return nil, noop, errNoNamespacesConfigured } + wg.Add(len(namespaces)) for _, namespace := range namespaces { namespace := namespace // Capture var - wg.Add(1) go func() { - result.add(s.fetchTags(namespace, m3query, opts)) + session := namespace.Session() + namespaceID := namespace.NamespaceID() + iter, _, err := session.FetchTaggedIDs(namespaceID, m3query, m3opts) + result.Add(iter, err) wg.Done() }() } wg.Wait() - if err := result.err.LastError(); err != nil { - return nil, err - } - return result.result, nil + + tagResult, err := result.FinalResult() + return tagResult, result.Close, err } func (s *m3storage) fetchTags( diff --git a/src/query/storage/m3/types.go b/src/query/storage/m3/types.go index 0d0c5653fa..d89eef9052 100644 --- a/src/query/storage/m3/types.go +++ b/src/query/storage/m3/types.go @@ -23,8 +23,10 @@ package m3 import ( "context" + "github.com/m3db/m3/src/dbnode/client" "github.com/m3db/m3/src/dbnode/encoding" genericstorage "github.com/m3db/m3/src/query/storage" + "github.com/m3db/m3x/ident" ) // Cleanup is a cleanup function to be called after resources are freed @@ -42,10 +44,54 @@ type Storage interface { // Querier handles queries against an M3 instance. type Querier interface { - // FetchRaw fetches timeseries data based on a query - FetchRaw( + // FetchCompressed fetches timeseries data based on a query + FetchCompressed( ctx context.Context, query *genericstorage.FetchQuery, options *genericstorage.FetchOptions, ) (encoding.SeriesIterators, Cleanup, error) + // SearchCompressed fetches matching tags based on a query + SearchCompressed( + ctx context.Context, + query *genericstorage.FetchQuery, + options *genericstorage.FetchOptions, + ) ([]MultiTagResult, Cleanup, error) +} + +// MultiFetchResult is a deduping accumalator for series iterators +// that allows merging using a given strategy +type MultiFetchResult interface { + // Add adds series iterators with corresponding attributes to the accumulator + Add( + attrs genericstorage.Attributes, + iterators encoding.SeriesIterators, + err error, + ) + // FinalResult returns a series iterators object containing + // deduplciated series values + FinalResult() (encoding.SeriesIterators, error) + // Close releases all resources held by this accumulator + Close() error +} + +// MultiFetchTagsResult is a deduping accumalator for tag iterators +type MultiFetchTagsResult interface { + // Add adds tagged ID iterators to the accumulator + Add( + newIterator client.TaggedIDsIterator, + err error, + ) + // FinalResult returns a deduped list of tag iterators with + // corresponding series ids + FinalResult() ([]MultiTagResult, error) + // Close releases all resources held by this accumulator + Close() error +} + +// MultiTagResult represents a tag iterator with its string ID +type MultiTagResult struct { + // ID is the series ID + ID ident.ID + // Iter is the tag iterator for the series + Iter ident.TagIterator } diff --git a/src/query/storage/types.go b/src/query/storage/types.go index 3c74acb10b..d9f0b8aebb 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -81,6 +81,13 @@ type FetchOptions struct { Limit int } +// NewFetchOptions creates a new fetch options. +func NewFetchOptions() *FetchOptions { + return &FetchOptions{ + Limit: 0, + } +} + // Querier handles queries against a storage. type Querier interface { // Fetch fetches timeseries data based on a query @@ -105,7 +112,7 @@ type Querier interface { ) (*SearchResults, error) } -// WriteQuery represents the input timeseries that is written to M3DB +// WriteQuery represents the input timeseries that is written to the db type WriteQuery struct { Tags models.Tags Datapoints ts.Datapoints @@ -118,6 +125,41 @@ func (q *WriteQuery) String() string { return q.Tags.ID() } +// CompleteTagsQuery represents a query that returns an autocompleted +// set of tags that exist in the db +type CompleteTagsQuery struct { + TagMatchers models.Matchers + FilterNameTags [][]byte + CompleteNameOnly bool +} + +func (q *CompleteTagsQuery) String() string { + if q.CompleteNameOnly { + return fmt.Sprintf("completing tag name for query %s", q.TagMatchers) + } + + return fmt.Sprintf("completing tag values for query %s", q.TagMatchers) +} + +// CompletedTag is an autocompleted tag with a name and a list of possible values +type CompletedTag struct { + Name []byte + Values [][]byte +} + +// CompleteTagsResult represents a set of autocompleted tag names and values +type CompleteTagsResult struct { + CompleteNameOnly bool + CompletedTags []CompletedTag +} + +// CompleteTagsResultBuilder is a builder that accumulates and deduplicates +// incoming CompleteTagsResult values +type CompleteTagsResultBuilder interface { + Add(*CompleteTagsResult) error + Build() CompleteTagsResult +} + // Appender provides batched appends against a storage. type Appender interface { // Write value to the database for an ID diff --git a/src/query/tsdb/remote/client.go b/src/query/tsdb/remote/client.go index edf99353cd..6a09ae9d3b 100644 --- a/src/query/tsdb/remote/client.go +++ b/src/query/tsdb/remote/client.go @@ -22,8 +22,8 @@ package remote import ( "context" - "fmt" "io" + "sync" "github.com/m3db/m3/src/dbnode/encoding" "github.com/m3db/m3/src/query/block" @@ -50,6 +50,9 @@ type grpcClient struct { connection *grpc.ClientConn poolWrapper *pools.PoolWrapper readWorkerPool xsync.PooledWorkerPool + once sync.Once + pools encoding.IteratorPools + poolErr error } const initResultSize = 10 @@ -99,19 +102,33 @@ func (c *grpcClient) Fetch( return storage.SeriesIteratorsToFetchResult(iters, c.readWorkerPool, true, c.tagOptions) } +func (c *grpcClient) waitForPools() (encoding.IteratorPools, error) { + c.once.Do(func() { + c.pools, c.poolErr = c.poolWrapper.WaitForIteratorPools(poolTimeout) + }) + + return c.pools, c.poolErr +} + func (c *grpcClient) fetchRaw( ctx context.Context, query *storage.FetchQuery, options *storage.FetchOptions, ) (encoding.SeriesIterators, error) { - request, err := EncodeFetchRequest(query) + pools, err := c.waitForPools() + if err != nil { + return nil, err + } + + request, err := encodeFetchRequest(query) if err != nil { return nil, err } // Send the id from the client to the remote server so that provides logging + // TODO: replace id propagation with opentracing id := logging.ReadContextID(ctx) - mdCtx := EncodeMetadata(ctx, id) + mdCtx := encodeMetadata(ctx, id) fetchClient, err := c.client.Fetch(mdCtx, request) if err != nil { return nil, err @@ -136,20 +153,7 @@ func (c *grpcClient) fetchRaw( return nil, err } - available, pools, err, poolCh, errCh := c.poolWrapper.IteratorPools() - if err != nil { - return nil, err - } - - if !available { - select { - case pools = <-poolCh: - case err = <-errCh: - return nil, err - } - } - - iters, err := DecodeCompressedFetchResponse(result, pools) + iters, err := decodeCompressedFetchResponse(result, pools) if err != nil { return nil, err } @@ -197,7 +201,115 @@ func (c *grpcClient) FetchTags( query *storage.FetchQuery, options *storage.FetchOptions, ) (*storage.SearchResults, error) { - return nil, fmt.Errorf("remote fetch tags endpoint not supported") + pools, err := c.waitForPools() + if err != nil { + return nil, err + } + + request, err := encodeSearchRequest(query) + if err != nil { + return nil, err + } + + // Send the id from the client to the remote server so that provides logging + // TODO: replace id propagation with opentracing + id := logging.ReadContextID(ctx) + // TODO: add relevant fields to the metadata + mdCtx := encodeMetadata(ctx, id) + searchClient, err := c.client.Search(mdCtx, request) + if err != nil { + return nil, err + } + + defer searchClient.CloseSend() + metrics := make(models.Metrics, 0, initResultSize) + for { + select { + // If query is killed during gRPC streaming, close the channel + case <-ctx.Done(): + return nil, ctx.Err() + default: + } + + received, err := searchClient.Recv() + if err == io.EOF { + break + } + + if err != nil { + return nil, err + } + + m, err := decodeSearchResponse(received, pools, c.tagOptions) + if err != nil { + return nil, err + } + + metrics = append(metrics, m...) + } + + return &storage.SearchResults{ + Metrics: metrics, + }, nil +} + +// CompleteTags returns autocompleted tags +func (c *grpcClient) CompleteTags( + ctx context.Context, + query *storage.CompleteTagsQuery, + options *storage.FetchOptions, +) (storage.CompleteTagsResult, error) { + request, err := encodeCompleteTagsRequest(query) + if err != nil { + return storage.CompleteTagsResult{}, err + } + + // Send the id from the client to the remote server so that provides logging + // TODO: replace id propagation with opentracing + id := logging.ReadContextID(ctx) + // TODO: add relevant fields to the metadata + mdCtx := encodeMetadata(ctx, id) + completeTagsClient, err := c.client.CompleteTags(mdCtx, request) + if err != nil { + return storage.CompleteTagsResult{}, err + } + + defer completeTagsClient.CloseSend() + var accumulatedTags storage.CompleteTagsResultBuilder + for { + select { + // If query is killed during gRPC streaming, close the channel + case <-ctx.Done(): + return storage.CompleteTagsResult{}, ctx.Err() + default: + } + + received, err := completeTagsClient.Recv() + if err == io.EOF { + break + } + + if err != nil { + return storage.CompleteTagsResult{}, err + } + + result, err := decodeCompleteTagsResponse(received) + if err != nil { + return storage.CompleteTagsResult{}, err + } + + if accumulatedTags == nil { + accumulatedTags = storage.NewCompleteTagsResultBuilder(result.CompleteNameOnly) + } + + err = accumulatedTags.Add(result) + if err != nil { + return storage.CompleteTagsResult{}, err + } + } + + // Sort tags in the result post-merge. + return accumulatedTags.Build(), nil } // Close closes the underlying connection diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index bb3c96e05b..6bdc1783a5 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -59,8 +59,8 @@ func encodeTags(tags models.Tags) []*rpc.Tag { return encodedTags } -// EncodeFetchResult encodes fetch result to rpc response -func EncodeFetchResult(results *storage.FetchResult) *rpc.FetchResponse { +// encodeFetchResult encodes fetch result to rpc response +func encodeFetchResult(results *storage.FetchResult) *rpc.FetchResponse { series := make([]*rpc.Series, len(results.SeriesList)) for i, result := range results.SeriesList { vLen := result.Len() @@ -91,8 +91,8 @@ func EncodeFetchResult(results *storage.FetchResult) *rpc.FetchResponse { } } -// DecodeDecompressedFetchResult decodes fetch results from a GRPC-compatible type. -func DecodeDecompressedFetchResult( +// decodeDecompressedFetchResult decodes fetch results from a GRPC-compatible type. +func decodeDecompressedFetchResult( name string, tagOptions models.TagOptions, rpcSeries []*rpc.DecompressedSeries, @@ -144,8 +144,8 @@ func decodeRawTs(r *rpc.DecompressedSeries) ts.Datapoints { return datapoints } -// EncodeFetchRequest encodes fetch request into rpc FetchRequest -func EncodeFetchRequest( +// encodeFetchRequest encodes fetch request into rpc FetchRequest +func encodeFetchRequest( query *storage.FetchQuery, ) (*rpc.FetchRequest, error) { matchers, err := encodeTagMatchers(query.TagMatchers) @@ -197,8 +197,8 @@ func encodeMatcherTypeToProto(t models.MatchType) (rpc.MatcherType, error) { } } -// EncodeMetadata creates a context that propagates request metadata as well as requestID -func EncodeMetadata(ctx context.Context, requestID string) context.Context { +// encodeMetadata creates a context that propagates request metadata as well as requestID +func encodeMetadata(ctx context.Context, requestID string) context.Context { if ctx == nil { return ctx } @@ -224,8 +224,8 @@ func convertHeaderToMetaWithID(headers http.Header, requestID string) metadata.M return meta } -// RetrieveMetadata creates a context with propagated request metadata as well as requestID -func RetrieveMetadata(streamCtx context.Context) context.Context { +// creates a context with propagated request metadata as well as requestID +func retrieveMetadata(streamCtx context.Context) context.Context { md, ok := metadata.FromIncomingContext(streamCtx) id := "unknown" if ok { @@ -238,8 +238,7 @@ func RetrieveMetadata(streamCtx context.Context) context.Context { return logging.NewContextWithID(streamCtx, id) } -// DecodeFetchRequest decodes rpc fetch request to read query and read options -func DecodeFetchRequest( +func decodeFetchRequest( req *rpc.FetchRequest, ) (*storage.FetchQuery, error) { tags, err := decodeTagMatchers(req.GetTagMatchers()) diff --git a/src/query/tsdb/remote/codecs_complete_tags.go b/src/query/tsdb/remote/codecs_complete_tags.go new file mode 100644 index 0000000000..872e520002 --- /dev/null +++ b/src/query/tsdb/remote/codecs_complete_tags.go @@ -0,0 +1,98 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package remote + +import ( + "github.com/m3db/m3/src/query/errors" + rpc "github.com/m3db/m3/src/query/generated/proto/rpcpb" + "github.com/m3db/m3/src/query/storage" +) + +func decodeTagNamesOnly( + response *rpc.TagNames, +) *storage.CompleteTagsResult { + names := response.GetNames() + tags := make([]storage.CompletedTag, len(names)) + for i, name := range names { + tags[i] = storage.CompletedTag{Name: name} + } + + return &storage.CompleteTagsResult{ + CompleteNameOnly: true, + CompletedTags: tags, + } +} + +func decodeTagProperties( + response *rpc.TagValues, +) *storage.CompleteTagsResult { + values := response.GetValues() + tags := make([]storage.CompletedTag, len(values)) + for i, value := range values { + tags[i] = storage.CompletedTag{ + Name: value.GetKey(), + Values: value.GetValues(), + } + } + + return &storage.CompleteTagsResult{ + CompleteNameOnly: false, + CompletedTags: tags, + } +} + +func decodeCompleteTagsResponse( + response *rpc.CompleteTagsResponse, +) (*storage.CompleteTagsResult, error) { + if names := response.GetNamesOnly(); names != nil { + return decodeTagNamesOnly(names), nil + } + + if props := response.GetDefault(); props != nil { + return decodeTagProperties(props), nil + } + + return nil, errors.ErrUnexpectedGRPCResponseType +} + +func encodeCompleteTagsRequest( + query *storage.CompleteTagsQuery, +) (*rpc.CompleteTagsRequest, error) { + completionType := rpc.CompleteTagsType_DEFAULT + if query.CompleteNameOnly { + completionType = rpc.CompleteTagsType_TAGNAME + } + + matchers, err := encodeTagMatchers(query.TagMatchers) + if err != nil { + return nil, err + } + + return &rpc.CompleteTagsRequest{ + Matchers: &rpc.CompleteTagsRequest_TagMatchers{ + TagMatchers: matchers, + }, + Options: &rpc.CompleteTagsRequestOptions{ + Type: completionType, + FilterNameTags: query.FilterNameTags, + }, + }, nil +} diff --git a/src/query/tsdb/remote/codecs_search.go b/src/query/tsdb/remote/codecs_search.go new file mode 100644 index 0000000000..c1fd57a414 --- /dev/null +++ b/src/query/tsdb/remote/codecs_search.go @@ -0,0 +1,187 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package remote + +import ( + "github.com/m3db/m3/src/dbnode/encoding" + "github.com/m3db/m3/src/query/errors" + rpc "github.com/m3db/m3/src/query/generated/proto/rpcpb" + "github.com/m3db/m3/src/query/models" + "github.com/m3db/m3/src/query/storage" + "github.com/m3db/m3/src/query/storage/m3" + "github.com/m3db/m3/src/x/serialize" +) + +func multiTagResultsToM3TagProperties( + results []m3.MultiTagResult, + encoderPool serialize.TagEncoderPool, +) (*rpc.M3TagProperties, error) { + props := make([]rpc.M3TagProperty, len(results)) + for i, result := range results { + tags, err := compressedTagsFromTagIterator(result.Iter, encoderPool) + if err != nil { + return nil, err + } + + props[i] = rpc.M3TagProperty{ + Id: result.ID.Bytes(), + CompressedTags: tags, + } + } + + pprops := make([]*rpc.M3TagProperty, len(props)) + for i, prop := range props { + pprops[i] = &prop + } + + return &rpc.M3TagProperties{ + Properties: pprops, + }, nil +} + +// encodeToCompressedSearchResult encodes SearchResults to a compressed search result +func encodeToCompressedSearchResult( + results []m3.MultiTagResult, + pools encoding.IteratorPools, +) (*rpc.SearchResponse, error) { + if pools == nil { + return nil, errors.ErrCannotEncodeCompressedTags + } + + encoderPool := pools.TagEncoder() + if encoderPool == nil { + return nil, errors.ErrCannotEncodeCompressedTags + } + + compressedTags, err := multiTagResultsToM3TagProperties(results, encoderPool) + if err != nil { + return nil, err + } + + return &rpc.SearchResponse{ + Value: &rpc.SearchResponse_Compressed{ + Compressed: compressedTags, + }, + }, nil +} + +func decodeDecompressedSearchResponse( + response *rpc.TagProperties, + pools encoding.IteratorPools, +) (models.Metrics, error) { + return nil, errors.ErrNotImplemented +} + +func decodeCompressedSearchResponse( + response *rpc.M3TagProperties, + pools encoding.IteratorPools, +) ([]m3.MultiTagResult, error) { + if pools == nil || pools.CheckedBytesWrapper() == nil || pools.TagDecoder() == nil { + return nil, errors.ErrCannotDecodeCompressedTags + } + + cbwPool := pools.CheckedBytesWrapper() + decoderPool := pools.TagDecoder() + idPool := pools.ID() + + props := response.GetProperties() + decoded := make([]m3.MultiTagResult, len(props)) + for i, prop := range props { + checkedBytes := cbwPool.Get(prop.GetCompressedTags()) + decoder := decoderPool.Get() + decoder.Reset(checkedBytes) + if err := decoder.Err(); err != nil { + return nil, err + } + + id := idPool.BinaryID(cbwPool.Get(prop.GetId())) + decoded[i] = m3.MultiTagResult{ + ID: id, + // Copy underlying TagIterator bytes before closing the decoder and returning it to the pool + Iter: decoder.Duplicate(), + } + + decoder.Close() + } + + return decoded, nil +} + +func decodeSearchResponse( + response *rpc.SearchResponse, + pools encoding.IteratorPools, + tagOptions models.TagOptions, +) (models.Metrics, error) { + if compressed := response.GetCompressed(); compressed != nil { + results, err := decodeCompressedSearchResponse(compressed, pools) + if err != nil { + return nil, err + } + + metrics := make(models.Metrics, len(results)) + for i, r := range results { + m, err := storage.FromM3IdentToMetric(r.ID, r.Iter, tagOptions) + if err != nil { + return nil, err + } + + metrics[i] = m + } + + return metrics, nil + } + + if decompressed := response.GetDecompressed(); decompressed != nil { + return decodeDecompressedSearchResponse(decompressed, pools) + } + + return nil, errors.ErrUnexpectedGRPCResponseType +} + +// encodeSearchRequest encodes search request into rpc SearchRequest +func encodeSearchRequest( + query *storage.FetchQuery, +) (*rpc.SearchRequest, error) { + matchers, err := encodeTagMatchers(query.TagMatchers) + if err != nil { + return nil, err + } + + return &rpc.SearchRequest{ + Matchers: &rpc.SearchRequest_TagMatchers{ + TagMatchers: matchers, + }, + }, nil +} + +// decodeSearchRequest decodes rpc search request to read query and read options +func decodeSearchRequest( + req *rpc.SearchRequest, +) (*storage.FetchQuery, error) { + matchers, err := decodeTagMatchers(req.GetTagMatchers()) + if err != nil { + return nil, err + } + + return &storage.FetchQuery{ + TagMatchers: matchers, + }, nil +} diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index 0ae3a1dcd5..01fbd3e15d 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -98,7 +98,7 @@ func TestDecodeFetchResult(t *testing.T) { name := "name" metricName := []byte("!") - tsSeries, err := DecodeDecompressedFetchResult(name, models.NewTagOptions().SetMetricName(metricName), rpcSeries) + tsSeries, err := decodeDecompressedFetchResult(name, models.NewTagOptions().SetMetricName(metricName), rpcSeries) assert.NoError(t, err) assert.Len(t, tsSeries, 3) assert.Equal(t, name, tsSeries[0].Name()) @@ -127,7 +127,7 @@ func TestDecodeFetchResult(t *testing.T) { // Encode again fetchResult := &storage.FetchResult{SeriesList: tsSeries} - revert := EncodeFetchResult(fetchResult) + revert := encodeFetchResult(fetchResult) require.Len(t, revert.GetSeries(), len(rpcSeries)) for i, expected := range rpcSeries { assert.Equal(t, expected.GetDatapoints(), revert.GetSeries()[i].GetDecompressed().GetDatapoints()) @@ -167,7 +167,7 @@ func createStorageFetchQuery(t *testing.T) (*storage.FetchQuery, time.Time, time func TestEncodeFetchMessage(t *testing.T) { rQ, start, end := createStorageFetchQuery(t) - grpcQ, err := EncodeFetchRequest(rQ) + grpcQ, err := encodeFetchRequest(rQ) require.NotNil(t, grpcQ) require.NoError(t, err) assert.Equal(t, fromTime(start), grpcQ.GetStart()) @@ -184,19 +184,19 @@ func TestEncodeFetchMessage(t *testing.T) { func TestEncodeDecodeFetchQuery(t *testing.T) { rQ, _, _ := createStorageFetchQuery(t) - gq, err := EncodeFetchRequest(rQ) + gq, err := encodeFetchRequest(rQ) require.NoError(t, err) - reverted, err := DecodeFetchRequest(gq) + reverted, err := decodeFetchRequest(gq) require.NoError(t, err) readQueriesAreEqual(t, rQ, reverted) // Encode again - gqr, err := EncodeFetchRequest(reverted) + gqr, err := encodeFetchRequest(reverted) require.NoError(t, err) assert.Equal(t, gq, gqr) } -func TestEncodeMetadata(t *testing.T) { +func TestencodeMetadata(t *testing.T) { headers := make(http.Header) headers.Add("Foo", "bar") headers.Add("Foo", "baz") @@ -205,7 +205,7 @@ func TestEncodeMetadata(t *testing.T) { ctx := context.WithValue(context.TODO(), handler.HeaderKey, headers) requestID := "requestID" - encodedCtx := EncodeMetadata(ctx, requestID) + encodedCtx := encodeMetadata(ctx, requestID) md, ok := metadata.FromOutgoingContext(encodedCtx) require.True(t, ok) assert.Equal(t, []string{"bar", "baz", "abc"}, md["foo"], "metadat keys must be lower case") @@ -224,7 +224,7 @@ func TestRetrieveMetadata(t *testing.T) { requestID := "requestID" headers[reqIDKey] = []string{requestID} ctx := metadata.NewIncomingContext(context.TODO(), metadata.MD(headers)) - encodedCtx := RetrieveMetadata(ctx) + encodedCtx := retrieveMetadata(ctx) require.Equal(t, requestID, logging.ReadContextID(encodedCtx)) } diff --git a/src/query/tsdb/remote/compressed_codecs.go b/src/query/tsdb/remote/compressed_codecs.go index 03a753744f..307a000b41 100644 --- a/src/query/tsdb/remote/compressed_codecs.go +++ b/src/query/tsdb/remote/compressed_codecs.go @@ -70,7 +70,9 @@ func compressedSegmentFromBlockReader(br xio.BlockReader) (*rpc.M3Segment, error }, nil } -func compressedSegmentsFromReaders(readers xio.ReaderSliceOfSlicesIterator) (*rpc.M3Segments, error) { +func compressedSegmentsFromReaders( + readers xio.ReaderSliceOfSlicesIterator, +) (*rpc.M3Segments, error) { segments := &rpc.M3Segments{} l, _, _ := readers.CurrentReaders() // NB(arnikola) If there's only a single reader, the segment has been merged @@ -100,7 +102,10 @@ func compressedSegmentsFromReaders(readers xio.ReaderSliceOfSlicesIterator) (*rp return segments, nil } -func compressedTagsFromTagIterator(tagIter ident.TagIterator, encoderPool serialize.TagEncoderPool) ([]byte, error) { +func compressedTagsFromTagIterator( + tagIter ident.TagIterator, + encoderPool serialize.TagEncoderPool, +) ([]byte, error) { encoder := encoderPool.Get() err := encoder.Encode(tagIter) if err != nil { @@ -143,7 +148,10 @@ SeriesIterator also has a TagIterator representing the tags associated with it This function transforms a SeriesIterator into a protobuf representation to be able to send it across the wire without needing to expand the series */ -func compressedSeriesFromSeriesIterator(it encoding.SeriesIterator, iterPools encoding.IteratorPools) (*rpc.Series, error) { +func compressedSeriesFromSeriesIterator( + it encoding.SeriesIterator, + iterPools encoding.IteratorPools, +) (*rpc.Series, error) { replicas := it.Replicas() compressedReplicas := make([]*rpc.M3CompressedValuesReplica, 0, len(replicas)) for _, replica := range replicas { @@ -186,8 +194,8 @@ func compressedSeriesFromSeriesIterator(it encoding.SeriesIterator, iterPools en }, nil } -// EncodeToCompressedFetchResult encodes SeriesIterators to compressed fetch response -func EncodeToCompressedFetchResult( +// encodeToCompressedFetchResult encodes SeriesIterators to compressed fetch response +func encodeToCompressedFetchResult( iterators encoding.SeriesIterators, iterPools encoding.IteratorPools, ) (*rpc.FetchResponse, error) { @@ -383,8 +391,8 @@ func seriesIteratorFromCompressedSeries( return seriesIter, nil } -// DecodeCompressedFetchResponse decodes compressed fetch response to seriesIterators -func DecodeCompressedFetchResponse( +// decodeCompressedFetchResponse decodes compressed fetch response to seriesIterators +func decodeCompressedFetchResponse( fetchResult *rpc.FetchResponse, iteratorPools encoding.IteratorPools, ) (encoding.SeriesIterators, error) { diff --git a/src/query/tsdb/remote/compressed_codecs_test.go b/src/query/tsdb/remote/compressed_codecs_test.go index 207f958462..186832b47b 100644 --- a/src/query/tsdb/remote/compressed_codecs_test.go +++ b/src/query/tsdb/remote/compressed_codecs_test.go @@ -223,10 +223,10 @@ func TestSeriesConversionFromCompressedDataWithIteratorPool(t *testing.T) { assert.False(t, ip.msiPoolUsed) } -func TestEncodeToCompressedFetchResult(t *testing.T) { +func TestencodeToCompressedFetchResult(t *testing.T) { iters := encoding.NewSeriesIterators([]encoding.SeriesIterator{buildTestSeriesIterator(t), buildTestSeriesIterator(t)}, nil) ip := &mockIteratorPool{} - fetchResult, err := EncodeToCompressedFetchResult(iters, ip) + fetchResult, err := encodeToCompressedFetchResult(iters, ip) require.NoError(t, err) require.Len(t, fetchResult.Series, 2) @@ -246,7 +246,7 @@ func TestEncodeToCompressedFetchResult(t *testing.T) { func TestDecodeCompressedFetchResult(t *testing.T) { iters := encoding.NewSeriesIterators([]encoding.SeriesIterator{buildTestSeriesIterator(t), buildTestSeriesIterator(t)}, nil) - fetchResult, err := EncodeToCompressedFetchResult(iters, nil) + fetchResult, err := encodeToCompressedFetchResult(iters, nil) require.Error(t, err) require.Nil(t, fetchResult) } @@ -254,14 +254,14 @@ func TestDecodeCompressedFetchResult(t *testing.T) { func TestDecodeCompressedFetchResultWithIteratorPool(t *testing.T) { ip := &mockIteratorPool{} iters := encoding.NewSeriesIterators([]encoding.SeriesIterator{buildTestSeriesIterator(t), buildTestSeriesIterator(t)}, nil) - fetchResult, err := EncodeToCompressedFetchResult(iters, ip) + fetchResult, err := encodeToCompressedFetchResult(iters, ip) require.NoError(t, err) require.Len(t, fetchResult.Series, 2) for _, series := range fetchResult.Series { verifyCompressedSeries(t, series) } - revertedIters, err := DecodeCompressedFetchResponse(fetchResult, ip) + revertedIters, err := decodeCompressedFetchResponse(fetchResult, ip) require.NoError(t, err) revertedIterList := revertedIters.Iters() require.Len(t, revertedIterList, 2) @@ -269,7 +269,7 @@ func TestDecodeCompressedFetchResultWithIteratorPool(t *testing.T) { validateSeries(t, seriesIterator) } - revertedIters, err = DecodeCompressedFetchResponse(fetchResult, ip) + revertedIters, err = decodeCompressedFetchResponse(fetchResult, ip) require.NoError(t, err) revertedIterList = revertedIters.Iters() require.Len(t, revertedIterList, 2) diff --git a/src/query/tsdb/remote/server.go b/src/query/tsdb/remote/server.go index 3d49824557..9167d5e0f3 100644 --- a/src/query/tsdb/remote/server.go +++ b/src/query/tsdb/remote/server.go @@ -22,9 +22,14 @@ package remote import ( "net" + "sync" + "time" + "github.com/m3db/m3/src/dbnode/encoding" + "github.com/m3db/m3/src/query/errors" rpc "github.com/m3db/m3/src/query/generated/proto/rpcpb" "github.com/m3db/m3/src/query/pools" + "github.com/m3db/m3/src/query/storage" "github.com/m3db/m3/src/query/storage/m3" "github.com/m3db/m3/src/query/util/logging" @@ -32,10 +37,15 @@ import ( "google.golang.org/grpc" ) +const poolTimeout = time.Second * 10 + // TODO: add metrics type grpcServer struct { storage m3.Storage poolWrapper *pools.PoolWrapper + once sync.Once + pools encoding.IteratorPools + poolErr error } // CreateNewGrpcServer builds a grpc server which must be started later @@ -63,44 +73,50 @@ func StartNewGrpcServer( if err != nil { return err } + waitForStart <- struct{}{} return server.Serve(lis) } +func (s *grpcServer) waitForPools() (encoding.IteratorPools, error) { + s.once.Do(func() { + s.pools, s.poolErr = s.poolWrapper.WaitForIteratorPools(poolTimeout) + }) + + return s.pools, s.poolErr +} + // Fetch reads decompressed series from m3 storage func (s *grpcServer) Fetch( message *rpc.FetchRequest, stream rpc.Query_FetchServer, ) error { - ctx := RetrieveMetadata(stream.Context()) + ctx := retrieveMetadata(stream.Context()) logger := logging.WithContext(ctx) - storeQuery, err := DecodeFetchRequest(message) + storeQuery, err := decodeFetchRequest(message) if err != nil { - logger.Error("unable to decode fetch query", zap.Any("error", err)) + logger.Error("unable to decode fetch query", zap.Error(err)) return err } - result, cleanup, err := s.storage.FetchRaw(ctx, storeQuery, nil) + result, cleanup, err := s.storage.FetchCompressed( + ctx, + storeQuery, + storage.NewFetchOptions(), + ) defer cleanup() if err != nil { logger.Error("unable to fetch local query", zap.Error(err)) return err } - available, pools, err, poolCh, errCh := s.poolWrapper.IteratorPools() + pools, err := s.waitForPools() if err != nil { + logger.Error("unable to get pools", zap.Error(err)) return err } - if !available { - select { - case pools = <-poolCh: - case err = <-errCh: - return err - } - } - - response, err := EncodeToCompressedFetchResult(result, pools) + response, err := encodeToCompressedFetchResult(result, pools) if err != nil { logger.Error("unable to compress query", zap.Error(err)) return err @@ -113,3 +129,55 @@ func (s *grpcServer) Fetch( return err } + +func (s *grpcServer) Search( + message *rpc.SearchRequest, + stream rpc.Query_SearchServer, +) error { + var err error + + ctx := retrieveMetadata(stream.Context()) + logger := logging.WithContext(ctx) + searchQuery, err := decodeSearchRequest(message) + if err != nil { + logger.Error("unable to decode search query", zap.Error(err)) + return err + } + + results, cleanup, err := s.storage.SearchCompressed( + ctx, + searchQuery, + storage.NewFetchOptions(), + ) + defer cleanup() + if err != nil { + logger.Error("unable to search tags", zap.Error(err)) + return err + } + + pools, err := s.waitForPools() + if err != nil { + logger.Error("unable to get pools", zap.Error(err)) + return err + } + + response, err := encodeToCompressedSearchResult(results, pools) + if err != nil { + logger.Error("unable to encode search result", zap.Error(err)) + return err + } + + err = stream.SendMsg(response) + if err != nil { + logger.Error("unable to send search result", zap.Error(err)) + } + + return err +} + +func (s *grpcServer) CompleteTags( + message *rpc.CompleteTagsRequest, + stream rpc.Query_CompleteTagsServer, +) error { + return errors.ErrNotImplemented +}