diff --git a/Makefile b/Makefile index 1697e4d..41b24de 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ cover: go test -cover -tags=integration generate: - protoc --go_out=. internal/public.proto + protoc --go_out=. gopilosa_pbuf/public.proto test: go test diff --git a/client.go b/client.go index 810e45f..8b4cdcf 100644 --- a/client.go +++ b/client.go @@ -44,7 +44,7 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/pilosa/go-pilosa/internal" + pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf" "github.com/pkg/errors" ) @@ -120,7 +120,7 @@ func (c *Client) Query(query PQLQuery, options *QueryOptions) (*QueryResponse, e if err != nil { return nil, err } - iqr := &internal.QueryResponse{} + iqr := &pbuf.QueryResponse{} err = proto.Unmarshal(buf, iqr) if err != nil { return nil, err @@ -439,7 +439,7 @@ func (c *Client) fetchFragmentNodes(indexName string, slice uint64) ([]fragmentN return fragmentNodes, nil } -func (c *Client) importNode(uri *URI, request *internal.ImportRequest) error { +func (c *Client) importNode(uri *URI, request *pbuf.ImportRequest) error { data, err := proto.Marshal(request) if err != nil { return errors.Wrap(err, "marshaling to protobuf") @@ -451,7 +451,7 @@ func (c *Client) importNode(uri *URI, request *internal.ImportRequest) error { return errors.Wrap(resp.Body.Close(), "closing import response body") } -func (c *Client) importValueNode(uri *URI, request *internal.ImportValueRequest) error { +func (c *Client) importValueNode(uri *URI, request *pbuf.ImportValueRequest) error { data, _ := proto.Marshal(request) // request.Marshal never returns an error _, err := c.doRequest(uri, "POST", "/import-value", protobufHeaders, bytes.NewReader(data)) @@ -626,7 +626,7 @@ func newHTTPClient(options *ClientOptions) *http.Client { } func makeRequestData(query string, options *QueryOptions) ([]byte, error) { - request := &internal.QueryRequest{ + request := &pbuf.QueryRequest{ Query: query, ColumnAttrs: options.Columns, ExcludeAttrs: options.ExcludeAttrs, @@ -649,7 +649,7 @@ func matchError(msg string) error { return nil } -func bitsToImportRequest(indexName string, frameName string, slice uint64, bits []Bit) *internal.ImportRequest { +func bitsToImportRequest(indexName string, frameName string, slice uint64, bits []Bit) *pbuf.ImportRequest { rowIDs := make([]uint64, 0, len(bits)) columnIDs := make([]uint64, 0, len(bits)) timestamps := make([]int64, 0, len(bits)) @@ -658,7 +658,7 @@ func bitsToImportRequest(indexName string, frameName string, slice uint64, bits columnIDs = append(columnIDs, bit.ColumnID) timestamps = append(timestamps, bit.Timestamp) } - return &internal.ImportRequest{ + return &pbuf.ImportRequest{ Index: indexName, Frame: frameName, Slice: slice, @@ -668,14 +668,14 @@ func bitsToImportRequest(indexName string, frameName string, slice uint64, bits } } -func valsToImportRequest(indexName string, frameName string, slice uint64, fieldName string, vals []FieldValue) *internal.ImportValueRequest { +func valsToImportRequest(indexName string, frameName string, slice uint64, fieldName string, vals []FieldValue) *pbuf.ImportValueRequest { columnIDs := make([]uint64, 0, len(vals)) values := make([]uint64, 0, len(vals)) for _, val := range vals { columnIDs = append(columnIDs, val.ColumnID) values = append(values, val.Value) } - return &internal.ImportValueRequest{ + return &pbuf.ImportValueRequest{ Index: indexName, Frame: frameName, Slice: slice, diff --git a/client_it_test.go b/client_it_test.go index 5873d7a..381dfe1 100644 --- a/client_it_test.go +++ b/client_it_test.go @@ -48,7 +48,7 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/pilosa/go-pilosa/internal" + pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf" ) var index *Index @@ -1177,7 +1177,7 @@ func TestImportNodeFails(t *testing.T) { t.Fatal(err) } client := NewClientWithURI(uri) - importRequest := &internal.ImportRequest{ + importRequest := &pbuf.ImportRequest{ ColumnIDs: []uint64{}, RowIDs: []uint64{}, Timestamps: []int64{}, @@ -1207,12 +1207,12 @@ func TestImportNodeProtobufMarshalFails(t *testing.T) { } func TestResponseWithInvalidType(t *testing.T) { - qr := &internal.QueryResponse{ + qr := &pbuf.QueryResponse{ Err: "", - ColumnAttrSets: []*internal.ColumnAttrSet{ + ColumnAttrSets: []*pbuf.ColumnAttrSet{ { ID: 0, - Attrs: []*internal.Attr{ + Attrs: []*pbuf.Attr{ { Type: 9999, StringValue: "NOVAL", @@ -1220,7 +1220,7 @@ func TestResponseWithInvalidType(t *testing.T) { }, }, }, - Results: []*internal.QueryResult{}, + Results: []*pbuf.QueryResult{}, } data, err := proto.Marshal(qr) if err != nil { diff --git a/client_test.go b/client_test.go index 975376b..01b06f0 100644 --- a/client_test.go +++ b/client_test.go @@ -35,7 +35,7 @@ package pilosa_test import ( "testing" - pilosa "github.com/pilosa/go-pilosa" + "github.com/pilosa/go-pilosa" ) func TestQueryWithError(t *testing.T) { diff --git a/internal/public.pb.go b/gopilosa_pbuf/public.pb.go similarity index 52% rename from internal/public.pb.go rename to gopilosa_pbuf/public.pb.go index 7daba87..7f949fb 100644 --- a/internal/public.pb.go +++ b/gopilosa_pbuf/public.pb.go @@ -1,12 +1,11 @@ -// Code generated by protoc-gen-go. -// source: internal/public.proto -// DO NOT EDIT! +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: gopilosa_pbuf/public.proto /* -Package internal is a generated protocol buffer package. +Package gopilosa_pbuf is a generated protocol buffer package. It is generated from these files: - internal/public.proto + gopilosa_pbuf/public.proto It has these top-level messages: Bitmap @@ -22,7 +21,7 @@ It has these top-level messages: ImportRequest ImportValueRequest */ -package internal +package gopilosa_pbuf import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -49,6 +48,13 @@ func (m *Bitmap) String() string { return proto.CompactTextString(m) func (*Bitmap) ProtoMessage() {} func (*Bitmap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *Bitmap) GetBits() []uint64 { + if m != nil { + return m.Bits + } + return nil +} + func (m *Bitmap) GetAttrs() []*Attr { if m != nil { return m.Attrs @@ -66,6 +72,20 @@ func (m *Pair) String() string { return proto.CompactTextString(m) } func (*Pair) ProtoMessage() {} func (*Pair) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +func (m *Pair) GetKey() uint64 { + if m != nil { + return m.Key + } + return 0 +} + +func (m *Pair) GetCount() uint64 { + if m != nil { + return m.Count + } + return 0 +} + type SumCount struct { Sum int64 `protobuf:"varint,1,opt,name=Sum" json:"Sum,omitempty"` Count int64 `protobuf:"varint,2,opt,name=Count" json:"Count,omitempty"` @@ -76,6 +96,20 @@ func (m *SumCount) String() string { return proto.CompactTextString(m func (*SumCount) ProtoMessage() {} func (*SumCount) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (m *SumCount) GetSum() int64 { + if m != nil { + return m.Sum + } + return 0 +} + +func (m *SumCount) GetCount() int64 { + if m != nil { + return m.Count + } + return 0 +} + type Bit struct { RowID uint64 `protobuf:"varint,1,opt,name=RowID" json:"RowID,omitempty"` ColumnID uint64 `protobuf:"varint,2,opt,name=ColumnID" json:"ColumnID,omitempty"` @@ -87,6 +121,27 @@ func (m *Bit) String() string { return proto.CompactTextString(m) } func (*Bit) ProtoMessage() {} func (*Bit) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (m *Bit) GetRowID() uint64 { + if m != nil { + return m.RowID + } + return 0 +} + +func (m *Bit) GetColumnID() uint64 { + if m != nil { + return m.ColumnID + } + return 0 +} + +func (m *Bit) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + type ColumnAttrSet struct { ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` Attrs []*Attr `protobuf:"bytes,2,rep,name=Attrs" json:"Attrs,omitempty"` @@ -97,6 +152,13 @@ func (m *ColumnAttrSet) String() string { return proto.CompactTextStr func (*ColumnAttrSet) ProtoMessage() {} func (*ColumnAttrSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (m *ColumnAttrSet) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + func (m *ColumnAttrSet) GetAttrs() []*Attr { if m != nil { return m.Attrs @@ -118,6 +180,48 @@ func (m *Attr) String() string { return proto.CompactTextString(m) } func (*Attr) ProtoMessage() {} func (*Attr) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (m *Attr) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Attr) GetType() uint64 { + if m != nil { + return m.Type + } + return 0 +} + +func (m *Attr) GetStringValue() string { + if m != nil { + return m.StringValue + } + return "" +} + +func (m *Attr) GetIntValue() int64 { + if m != nil { + return m.IntValue + } + return 0 +} + +func (m *Attr) GetBoolValue() bool { + if m != nil { + return m.BoolValue + } + return false +} + +func (m *Attr) GetFloatValue() float64 { + if m != nil { + return m.FloatValue + } + return 0 +} + type AttrMap struct { Attrs []*Attr `protobuf:"bytes,1,rep,name=Attrs" json:"Attrs,omitempty"` } @@ -148,6 +252,48 @@ func (m *QueryRequest) String() string { return proto.CompactTextStri func (*QueryRequest) ProtoMessage() {} func (*QueryRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +func (m *QueryRequest) GetQuery() string { + if m != nil { + return m.Query + } + return "" +} + +func (m *QueryRequest) GetSlices() []uint64 { + if m != nil { + return m.Slices + } + return nil +} + +func (m *QueryRequest) GetColumnAttrs() bool { + if m != nil { + return m.ColumnAttrs + } + return false +} + +func (m *QueryRequest) GetRemote() bool { + if m != nil { + return m.Remote + } + return false +} + +func (m *QueryRequest) GetExcludeAttrs() bool { + if m != nil { + return m.ExcludeAttrs + } + return false +} + +func (m *QueryRequest) GetExcludeBits() bool { + if m != nil { + return m.ExcludeBits + } + return false +} + type QueryResponse struct { Err string `protobuf:"bytes,1,opt,name=Err" json:"Err,omitempty"` Results []*QueryResult `protobuf:"bytes,2,rep,name=Results" json:"Results,omitempty"` @@ -159,6 +305,13 @@ func (m *QueryResponse) String() string { return proto.CompactTextStr func (*QueryResponse) ProtoMessage() {} func (*QueryResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } +func (m *QueryResponse) GetErr() string { + if m != nil { + return m.Err + } + return "" +} + func (m *QueryResponse) GetResults() []*QueryResult { if m != nil { return m.Results @@ -193,6 +346,13 @@ func (m *QueryResult) GetBitmap() *Bitmap { return nil } +func (m *QueryResult) GetN() uint64 { + if m != nil { + return m.N + } + return 0 +} + func (m *QueryResult) GetPairs() []*Pair { if m != nil { return m.Pairs @@ -207,6 +367,13 @@ func (m *QueryResult) GetSumCount() *SumCount { return nil } +func (m *QueryResult) GetChanged() bool { + if m != nil { + return m.Changed + } + return false +} + type ImportRequest struct { Index string `protobuf:"bytes,1,opt,name=Index" json:"Index,omitempty"` Frame string `protobuf:"bytes,2,opt,name=Frame" json:"Frame,omitempty"` @@ -221,6 +388,48 @@ func (m *ImportRequest) String() string { return proto.CompactTextStr func (*ImportRequest) ProtoMessage() {} func (*ImportRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } +func (m *ImportRequest) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *ImportRequest) GetFrame() string { + if m != nil { + return m.Frame + } + return "" +} + +func (m *ImportRequest) GetSlice() uint64 { + if m != nil { + return m.Slice + } + return 0 +} + +func (m *ImportRequest) GetRowIDs() []uint64 { + if m != nil { + return m.RowIDs + } + return nil +} + +func (m *ImportRequest) GetColumnIDs() []uint64 { + if m != nil { + return m.ColumnIDs + } + return nil +} + +func (m *ImportRequest) GetTimestamps() []int64 { + if m != nil { + return m.Timestamps + } + return nil +} + type ImportValueRequest struct { Index string `protobuf:"bytes,1,opt,name=Index" json:"Index,omitempty"` Frame string `protobuf:"bytes,2,opt,name=Frame" json:"Frame,omitempty"` @@ -235,63 +444,105 @@ func (m *ImportValueRequest) String() string { return proto.CompactTe func (*ImportValueRequest) ProtoMessage() {} func (*ImportValueRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (m *ImportValueRequest) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *ImportValueRequest) GetFrame() string { + if m != nil { + return m.Frame + } + return "" +} + +func (m *ImportValueRequest) GetSlice() uint64 { + if m != nil { + return m.Slice + } + return 0 +} + +func (m *ImportValueRequest) GetField() string { + if m != nil { + return m.Field + } + return "" +} + +func (m *ImportValueRequest) GetColumnIDs() []uint64 { + if m != nil { + return m.ColumnIDs + } + return nil +} + +func (m *ImportValueRequest) GetValues() []uint64 { + if m != nil { + return m.Values + } + return nil +} + func init() { - proto.RegisterType((*Bitmap)(nil), "internal.Bitmap") - proto.RegisterType((*Pair)(nil), "internal.Pair") - proto.RegisterType((*SumCount)(nil), "internal.SumCount") - proto.RegisterType((*Bit)(nil), "internal.Bit") - proto.RegisterType((*ColumnAttrSet)(nil), "internal.ColumnAttrSet") - proto.RegisterType((*Attr)(nil), "internal.Attr") - proto.RegisterType((*AttrMap)(nil), "internal.AttrMap") - proto.RegisterType((*QueryRequest)(nil), "internal.QueryRequest") - proto.RegisterType((*QueryResponse)(nil), "internal.QueryResponse") - proto.RegisterType((*QueryResult)(nil), "internal.QueryResult") - proto.RegisterType((*ImportRequest)(nil), "internal.ImportRequest") - proto.RegisterType((*ImportValueRequest)(nil), "internal.ImportValueRequest") -} - -func init() { proto.RegisterFile("internal/public.proto", fileDescriptor0) } + proto.RegisterType((*Bitmap)(nil), "gopilosa_pbuf.Bitmap") + proto.RegisterType((*Pair)(nil), "gopilosa_pbuf.Pair") + proto.RegisterType((*SumCount)(nil), "gopilosa_pbuf.SumCount") + proto.RegisterType((*Bit)(nil), "gopilosa_pbuf.Bit") + proto.RegisterType((*ColumnAttrSet)(nil), "gopilosa_pbuf.ColumnAttrSet") + proto.RegisterType((*Attr)(nil), "gopilosa_pbuf.Attr") + proto.RegisterType((*AttrMap)(nil), "gopilosa_pbuf.AttrMap") + proto.RegisterType((*QueryRequest)(nil), "gopilosa_pbuf.QueryRequest") + proto.RegisterType((*QueryResponse)(nil), "gopilosa_pbuf.QueryResponse") + proto.RegisterType((*QueryResult)(nil), "gopilosa_pbuf.QueryResult") + proto.RegisterType((*ImportRequest)(nil), "gopilosa_pbuf.ImportRequest") + proto.RegisterType((*ImportValueRequest)(nil), "gopilosa_pbuf.ImportValueRequest") +} + +func init() { proto.RegisterFile("gopilosa_pbuf/public.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 631 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xd6, 0xc6, 0x8e, 0xe3, 0x4c, 0xda, 0xaa, 0x5a, 0xd1, 0x62, 0x21, 0x84, 0x2c, 0x8b, 0x83, - 0x4f, 0xa9, 0x14, 0x1e, 0x00, 0x91, 0x36, 0x95, 0x2c, 0x44, 0x05, 0x9b, 0xc2, 0xdd, 0x4d, 0x56, - 0xc5, 0x92, 0xff, 0x58, 0xaf, 0x45, 0xf3, 0x1c, 0xbc, 0x01, 0x17, 0x78, 0x01, 0x6e, 0x3c, 0x1c, - 0x9a, 0x59, 0x6f, 0xec, 0x70, 0x00, 0x0e, 0xdc, 0xf6, 0xfb, 0xe6, 0xc7, 0xf3, 0xf3, 0x8d, 0xe1, - 0x2c, 0x2b, 0xb5, 0x54, 0x65, 0x9a, 0x5f, 0xd4, 0xed, 0x5d, 0x9e, 0x6d, 0xe6, 0xb5, 0xaa, 0x74, - 0xc5, 0x7d, 0x4b, 0x47, 0x4b, 0xf0, 0x96, 0x99, 0x2e, 0xd2, 0x9a, 0x73, 0x70, 0x97, 0x99, 0x6e, - 0x02, 0x16, 0x3a, 0xb1, 0x2b, 0xe8, 0xcd, 0x9f, 0xc3, 0xf8, 0x95, 0xd6, 0xaa, 0x09, 0x46, 0xa1, - 0x13, 0xcf, 0x16, 0x27, 0x73, 0x1b, 0x37, 0x47, 0x5a, 0x18, 0x63, 0x34, 0x07, 0xf7, 0x6d, 0x9a, - 0x29, 0x7e, 0x0a, 0xce, 0x6b, 0xb9, 0x0b, 0x58, 0xc8, 0x62, 0x57, 0xe0, 0x93, 0x3f, 0x82, 0xf1, - 0x65, 0xd5, 0x96, 0x3a, 0x18, 0x11, 0x67, 0x40, 0xb4, 0x00, 0x7f, 0xdd, 0x16, 0xf4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 0x16, 0x46, 0xf6, 0x53, 0x61, - 0x00, 0xb2, 0xa4, 0x0a, 0x52, 0x81, 0x2b, 0x0c, 0xa0, 0xfd, 0xe3, 0x19, 0x37, 0x81, 0x6b, 0x94, - 0x63, 0x10, 0xea, 0xdc, 0x5e, 0x71, 0x13, 0x8c, 0xc9, 0xd4, 0x13, 0xa8, 0xf3, 0xfd, 0x19, 0xa3, - 0x36, 0x9c, 0xd8, 0x11, 0x03, 0x26, 0xfa, 0xca, 0x80, 0x9b, 0x4a, 0x49, 0xf7, 0xff, 0xaf, 0x5c, - 0xf4, 0xcd, 0x64, 0x6e, 0x46, 0x83, 0xbe, 0x08, 0xfe, 0x52, 0xec, 0x39, 0x78, 0x54, 0x85, 0x29, - 0xd4, 0x15, 0x1d, 0xba, 0xf3, 0xe8, 0x77, 0xfc, 0xe2, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb6, - 0xf6, 0x9b, 0xb5, 0xa7, 0x05, 0x00, 0x00, + // 640 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0xd5, 0xc4, 0xce, 0xeb, 0xa6, 0xa9, 0xd0, 0x00, 0xc5, 0xaa, 0x2a, 0x14, 0x79, 0x15, 0x16, + 0x04, 0x29, 0xed, 0x0f, 0x90, 0xa6, 0x45, 0x01, 0x51, 0xc1, 0xa4, 0xb0, 0x45, 0x6e, 0x3b, 0x14, + 0x4b, 0xb6, 0xc7, 0xd8, 0x33, 0xa2, 0xf9, 0x18, 0x36, 0x6c, 0xe0, 0x23, 0x58, 0xf2, 0x61, 0xe8, + 0xde, 0xf1, 0xc4, 0x8e, 0x37, 0x15, 0x12, 0xbb, 0x39, 0xf7, 0xe5, 0x73, 0x1f, 0xc7, 0x70, 0x78, + 0xab, 0xf2, 0x38, 0x51, 0x65, 0xf4, 0x29, 0xbf, 0x32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0x7f, 0x47, 0xd9, 0x05, 0x00, 0x00, } diff --git a/internal/public.proto b/gopilosa_pbuf/public.proto similarity index 98% rename from internal/public.proto rename to gopilosa_pbuf/public.proto index 5a5df76..67b0d82 100644 --- a/internal/public.proto +++ b/gopilosa_pbuf/public.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package internal; +package gopilosa_pbuf; message Bitmap { repeated uint64 Bits = 1; diff --git a/response.go b/response.go index 005366a..cd3e4fe 100644 --- a/response.go +++ b/response.go @@ -35,7 +35,7 @@ package pilosa import ( "errors" - "github.com/pilosa/go-pilosa/internal" + pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf" ) // QueryResponse represents the response from a Pilosa query. @@ -46,7 +46,7 @@ type QueryResponse struct { Success bool `json:"success,omitempty"` } -func newQueryResponseFromInternal(response *internal.QueryResponse) (*QueryResponse, error) { +func newQueryResponseFromInternal(response *pbuf.QueryResponse) (*QueryResponse, error) { if response.Err != "" { return &QueryResponse{ ErrorMessage: response.Err, @@ -111,7 +111,7 @@ type QueryResult struct { Sum int64 `json:"sum,omitempty"` } -func newQueryResultFromInternal(result *internal.QueryResult) (*QueryResult, error) { +func newQueryResultFromInternal(result *pbuf.QueryResult) (*QueryResult, error) { var bitmapResult *BitmapResult var err error var sum int64 @@ -145,7 +145,7 @@ type CountResultItem struct { Count uint64 } -func countItemsFromInternal(items []*internal.Pair) []*CountResultItem { +func countItemsFromInternal(items []*pbuf.Pair) []*CountResultItem { result := make([]*CountResultItem, 0, len(items)) for _, v := range items { result = append(result, &CountResultItem{ID: v.Key, Count: v.Count}) @@ -159,7 +159,7 @@ type BitmapResult struct { Bits []uint64 } -func newBitmapResultFromInternal(bitmap *internal.Bitmap) (*BitmapResult, error) { +func newBitmapResultFromInternal(bitmap *pbuf.Bitmap) (*BitmapResult, error) { attrs, err := convertInternalAttrsToMap(bitmap.Attrs) if err != nil { return nil, err @@ -178,7 +178,7 @@ const ( floatType = 4 ) -func convertInternalAttrsToMap(attrs []*internal.Attr) (attrsMap map[string]interface{}, err error) { +func convertInternalAttrsToMap(attrs []*pbuf.Attr) (attrsMap map[string]interface{}, err error) { attrsMap = make(map[string]interface{}, len(attrs)) for _, attr := range attrs { switch attr.Type { @@ -205,7 +205,7 @@ type ColumnItem struct { Attributes map[string]interface{} `json:"attributes,omitempty"` } -func newColumnItemFromInternal(column *internal.ColumnAttrSet) (*ColumnItem, error) { +func newColumnItemFromInternal(column *pbuf.ColumnAttrSet) (*ColumnItem, error) { attrs, err := convertInternalAttrsToMap(column.Attrs) if err != nil { return nil, err diff --git a/response_test.go b/response_test.go index acb3159..2af65eb 100644 --- a/response_test.go +++ b/response_test.go @@ -36,7 +36,7 @@ import ( "reflect" "testing" - "github.com/pilosa/go-pilosa/internal" + pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf" ) func TestNewBitmapResultFromInternal(t *testing.T) { @@ -47,13 +47,13 @@ func TestNewBitmapResultFromInternal(t *testing.T) { "height": 1.83, } targetBits := []uint64{5, 10} - attrs := []*internal.Attr{ + attrs := []*pbuf.Attr{ {Key: "name", StringValue: "some string", Type: 1}, {Key: "age", IntValue: 95, Type: 2}, {Key: "registered", BoolValue: true, Type: 3}, {Key: "height", FloatValue: 1.83, Type: 4}, } - bitmap := &internal.Bitmap{ + bitmap := &pbuf.Bitmap{ Attrs: attrs, Bits: []uint64{5, 10}, } @@ -81,21 +81,21 @@ func TestNewQueryResponseFromInternal(t *testing.T) { targetCountItems := []*CountResultItem{ {ID: 10, Count: 100}, } - attrs := []*internal.Attr{ + attrs := []*pbuf.Attr{ {Key: "name", StringValue: "some string", Type: 1}, {Key: "age", IntValue: 95, Type: 2}, {Key: "registered", BoolValue: true, Type: 3}, {Key: "height", FloatValue: 1.83, Type: 4}, } - bitmap := &internal.Bitmap{ + bitmap := &pbuf.Bitmap{ Attrs: attrs, Bits: []uint64{5, 10}, } - pairs := []*internal.Pair{ + pairs := []*pbuf.Pair{ {Key: 10, Count: 100}, } - response := &internal.QueryResponse{ - Results: []*internal.QueryResult{ + response := &pbuf.QueryResponse{ + Results: []*pbuf.QueryResult{ {Bitmap: bitmap}, {Pairs: pairs}, }, @@ -131,7 +131,7 @@ func TestNewQueryResponseFromInternal(t *testing.T) { } func TestNewQueryResponseWithErrorFromInternal(t *testing.T) { - response := &internal.QueryResponse{ + response := &pbuf.QueryResponse{ Err: "some error", } qr, err := newQueryResponseFromInternal(response) @@ -150,21 +150,21 @@ func TestNewQueryResponseWithErrorFromInternal(t *testing.T) { } func TestNewQueryResponseFromInternalFailure(t *testing.T) { - attrs := []*internal.Attr{ + attrs := []*pbuf.Attr{ {Key: "name", StringValue: "some string", Type: 99}, } - bitmap := &internal.Bitmap{ + bitmap := &pbuf.Bitmap{ Attrs: attrs, } - response := &internal.QueryResponse{ - Results: []*internal.QueryResult{{Bitmap: bitmap}}, + response := &pbuf.QueryResponse{ + Results: []*pbuf.QueryResult{{Bitmap: bitmap}}, } qr, err := newQueryResponseFromInternal(response) if qr != nil && err == nil { t.Fatalf("Should have failed") } - response = &internal.QueryResponse{ - ColumnAttrSets: []*internal.ColumnAttrSet{{ID: 1, Attrs: attrs}}, + response = &pbuf.QueryResponse{ + ColumnAttrSets: []*pbuf.ColumnAttrSet{{ID: 1, Attrs: attrs}}, } qr, err = newQueryResponseFromInternal(response) if qr != nil && err == nil {