From be2442836700f0e958c749b29988fec75c4eb93b Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Wed, 17 Jan 2018 14:43:58 +0300 Subject: [PATCH 1/5] Uses NewServerCluster method in tests --- server/server_test.go | 104 +++++++++++------------------------------- test/pilosa.go | 1 + 2 files changed, 28 insertions(+), 77 deletions(-) diff --git a/server/server_test.go b/server/server_test.go index 70c415ba4..874783f8b 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -34,7 +34,6 @@ import ( "github.com/BurntSushi/toml" "github.com/pilosa/pilosa" - "github.com/pilosa/pilosa/gossip" "github.com/pilosa/pilosa/server" "github.com/pilosa/pilosa/test" ) @@ -277,17 +276,15 @@ func TestMain_SetColumnAttrsWithColumnOption(t *testing.T) { // Ensure program can set bits on one cluster and then restore to a second cluster. func TestMain_FrameRestore(t *testing.T) { - m0 := MustRunMain() - // TODO: this test used to start a two node cluster, but there was a race - // condition with anti-entropy. We need some general code for starting up - // arbitrarily sized Pilosa clusters for testing, and then we should - // re-instate the multi-node nature of this test. + mains1 := NewMainArrayWithCluster(2) + m0 := mains1[0] // Create frames. client := m0.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal("create index:", err) - } else if err := client.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } + if err := client.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { t.Fatal("create frame:", err) } @@ -312,18 +309,22 @@ func TestMain_FrameRestore(t *testing.T) { } // Start second cluster. - m2 := MustRunMain() + mains2 := NewMainArrayWithCluster(2) + m2 := mains2[0] defer m2.Close() // Import from first cluster. client, err := pilosa.NewInternalHTTPClient(m2.Server.URI.HostPort(), pilosa.GetHTTPClient(nil)) if err != nil { t.Fatal("new client:", err) - } else if err := m2.Client().CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { + } + if err := m2.Client().CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal("create new index:", err) - } else if err := m2.Client().CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } + if err := m2.Client().CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { t.Fatal("create new frame:", err) - } else if err := client.RestoreFrame(context.Background(), m0.Server.URI.HostPort(), "i", "f"); err != nil { + } + if err := client.RestoreFrame(context.Background(), m0.Server.URI.HostPort(), "i", "f"); err != nil { t.Fatal("restore frame:", err) } @@ -379,76 +380,13 @@ func TestCountOpenFiles(t *testing.T) { // Ensure program can send/receive broadcast messages. func TestMain_SendReceiveMessage(t *testing.T) { - t.SkipNow() - // TODO re-enable this test when we have a better way of - // creating a multi-node cluster that doesn't have data races. - m0 := MustRunMain() + mains := NewMainArrayWithCluster(2) + m0 := mains[0] defer m0.Close() - m1 := MustRunMain() + m1 := mains[1] defer m1.Close() - // Update cluster config - m0.Server.Cluster.Nodes = []*pilosa.Node{ - {Host: m0.Server.URI.HostPort()}, - {Host: m1.Server.URI.HostPort()}, - } - m1.Server.Cluster.Nodes = m0.Server.Cluster.Nodes - - // Configure node0 - - // get the host portion of addr to use for binding - gossipHost := m0.Server.URI.Host() - gossipPort := 0 - gossipSeed := "" - - gossipNodeSet0, err := gossip.NewGossipNodeSet(m0.Server.URI.HostPort(), gossipHost, gossipPort, gossipSeed, m0.Server, nil) - if err != nil { - t.Fatal(err) - } - m0.Server.Cluster.NodeSet = gossipNodeSet0 - m0.Server.Broadcaster = m0.Server - m0.Server.Gossiper = gossipNodeSet0 - m0.Server.Handler.Broadcaster = m0.Server.Broadcaster - m0.Server.Holder.Broadcaster = m0.Server.Broadcaster - m0.Server.BroadcastReceiver = gossipNodeSet0 - - if err := m0.Server.BroadcastReceiver.Start(m0.Server); err != nil { - t.Fatal(err) - } - // Open NodeSet communication - if err := m0.Server.Cluster.NodeSet.Open(); err != nil { - t.Fatal(err) - } - - // Configure node1 - - // get the host portion of addr to use for binding - gossipHost = m1.Server.URI.Host() - gossipPort = 0 - gossipSeed = gossipNodeSet0.Seed() - - gossipNodeSet1, err := gossip.NewGossipNodeSet(m1.Server.URI.HostPort(), gossipHost, gossipPort, gossipSeed, m1.Server, nil) - if err != nil { - t.Fatal(err) - } - m1.Server.Cluster.NodeSet = gossipNodeSet1 - m1.Server.Broadcaster = m1.Server - m1.Server.Gossiper = gossipNodeSet1 - m1.Server.Handler.Broadcaster = m1.Server.Broadcaster - m1.Server.Holder.Broadcaster = m1.Server.Broadcaster - m1.Server.BroadcastReceiver = gossipNodeSet1 - - if err := m1.Server.BroadcastReceiver.Start(m1.Server); err != nil { - t.Fatal(err) - } - // Open NodeSet communication - if err := m1.Server.Cluster.NodeSet.Open(); err != nil { - t.Fatal(err) - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Expected indexes and Frames expected := map[string][]string{ "i": []string{"f"}, @@ -586,6 +524,18 @@ func NewMain() *Main { return m } +func NewMainArrayWithCluster(size int) []*Main { + cluster, err := test.NewServerCluster(size) + if err != nil { + panic(err) + } + mainArray := make([]*Main, size) + for i := 0; i < size; i++ { + mainArray[i] = &Main{Command: cluster.Servers[i]} + } + return mainArray +} + // MustRunMain returns a new, running Main. Panic on error. func MustRunMain() *Main { m := NewMain() diff --git a/test/pilosa.go b/test/pilosa.go index d1bd45342..2af248098 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -101,6 +101,7 @@ func NewServerCluster(size int) (cluster *Cluster, err error) { cluster.Servers[i] = s hosts[i] = s.Config.Bind s.Config.GossipSeed = cluster.Servers[0].Config.GossipSeed + s.Config.Metric.Diagnostics = false // Disable diagnostics. } From 56ad70e1494c842e04d157a237a49ca3bed3a64a Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 22 Jan 2018 14:07:12 -0600 Subject: [PATCH 2/5] Add QueryResult.Type to protobuf message to distiguish results at the client --- handler.go | 14 +++ handler_test.go | 8 ++ internal/private.pb.go | 251 ++++++++++++++++++++++------------------- internal/public.pb.go | 157 ++++++++++++++++++-------- internal/public.proto | 1 + 5 files changed, 265 insertions(+), 166 deletions(-) diff --git a/handler.go b/handler.go index eb2621557..b81b8e124 100644 --- a/handler.go +++ b/handler.go @@ -1625,6 +1625,15 @@ func (h *Handler) logger() *log.Logger { return log.New(h.LogOutput, "", log.LstdFlags) } +// QueryResult types. +const ( + QueryResultTypeBitmap uint32 = iota + QueryResultTypePairs + QueryResultTypeSumCount + QueryResultTypeUint64 + QueryResultTypeBool +) + // QueryRequest represent a request to process a query. type QueryRequest struct { // Index to execute query against. @@ -1704,14 +1713,19 @@ func encodeQueryResponse(resp *QueryResponse) *internal.QueryResponse { switch result := resp.Results[i].(type) { case *Bitmap: + pb.Results[i].Type = QueryResultTypeBitmap pb.Results[i].Bitmap = encodeBitmap(result) case []Pair: + pb.Results[i].Type = QueryResultTypePairs pb.Results[i].Pairs = encodePairs(result) case SumCount: + pb.Results[i].Type = QueryResultTypeSumCount pb.Results[i].SumCount = encodeSumCount(result) case uint64: + pb.Results[i].Type = QueryResultTypeUint64 pb.Results[i].N = result case bool: + pb.Results[i].Type = QueryResultTypeBool pb.Results[i].Changed = result } } diff --git a/handler_test.go b/handler_test.go index f865d1510..04903c979 100644 --- a/handler_test.go +++ b/handler_test.go @@ -356,6 +356,8 @@ func TestHandler_Query_Uint64_Protobuf(t *testing.T) { var resp internal.QueryResponse if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { t.Fatal(err) + } else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypeUint64 { + t.Fatalf("unexpected response type: %s", resp.Results[0].Type) } else if n := resp.Results[0].N; n != 100 { t.Fatalf("unexpected n: %d", n) } @@ -442,6 +444,8 @@ func TestHandler_Query_Bitmap_Protobuf(t *testing.T) { var resp internal.QueryResponse if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { t.Fatal(err) + } else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypeBitmap { + t.Fatalf("unexpected response type: %s", resp.Results[0].Type) } else if bits := resp.Results[0].Bitmap.Bits; !reflect.DeepEqual(bits, []uint64{1, SliceWidth + 1}) { t.Fatalf("unexpected bits: %+v", bits) } else if attrs := resp.Results[0].Bitmap.Attrs; len(attrs) != 3 { @@ -501,6 +505,8 @@ func TestHandler_Query_Bitmap_ColumnAttrs_Protobuf(t *testing.T) { } if bits := resp.Results[0].Bitmap.Bits; !reflect.DeepEqual(bits, []uint64{1, SliceWidth + 1}) { t.Fatalf("unexpected bits: %+v", bits) + } else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypeBitmap { + t.Fatalf("unexpected response type: %s", resp.Results[0].Type) } else if attrs := resp.Results[0].Bitmap.Attrs; len(attrs) != 3 { t.Fatalf("unexpected attr length: %d", len(attrs)) } else if k, v := attrs[0].Key, attrs[0].StringValue; k != "a" || v != "b" { @@ -572,6 +578,8 @@ func TestHandler_Query_Pairs_Protobuf(t *testing.T) { var resp internal.QueryResponse if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { t.Fatal(err) + } else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypePairs { + t.Fatalf("unexpected response type: %s", resp.Results[0].Type) } else if a := resp.Results[0].GetPairs(); len(a) != 2 { t.Fatalf("unexpected pair length: %d", len(a)) } diff --git a/internal/private.pb.go b/internal/private.pb.go index e5cc6516f..1c26aa307 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -1,5 +1,6 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-gogo. // source: private.proto +// DO NOT EDIT! /* Package internal is a generated protocol buffer package. @@ -1762,6 +1763,24 @@ func (m *DeleteViewMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func encodeFixed64Private(dAtA []byte, offset int, v uint64) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + dAtA[offset+4] = uint8(v >> 32) + dAtA[offset+5] = uint8(v >> 40) + dAtA[offset+6] = uint8(v >> 48) + dAtA[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Private(dAtA []byte, offset int, v uint32) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + return offset + 4 +} func encodeVarintPrivate(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -3144,14 +3163,51 @@ func (m *MaxSlicesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var keykey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + keykey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthPrivate + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey if m.MaxSlices == nil { m.MaxSlices = make(map[string]uint64) } - var mapkey string - var mapvalue uint64 - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 + if iNdEx < postIndex { + var valuekey uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPrivate @@ -3161,69 +3217,31 @@ func (m *MaxSlicesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + valuekey |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } + var mapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthPrivate - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapvalue |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } + b := dAtA[iNdEx] + iNdEx++ + mapvalue |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break } - } else { - iNdEx = entryPreIndex - skippy, err := skipPrivate(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy } + m.MaxSlices[mapkey] = mapvalue + } else { + var mapvalue uint64 + m.MaxSlices[mapkey] = mapvalue } - m.MaxSlices[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -4555,14 +4573,51 @@ func (m *InputDefinitionAction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var keykey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + keykey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthPrivate + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey if m.ValueMap == nil { m.ValueMap = make(map[string]uint64) } - var mapkey string - var mapvalue uint64 - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 + if iNdEx < postIndex { + var valuekey uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPrivate @@ -4572,69 +4627,31 @@ func (m *InputDefinitionAction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + valuekey |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } + var mapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthPrivate - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapvalue |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } + b := dAtA[iNdEx] + iNdEx++ + mapvalue |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break } - } else { - iNdEx = entryPreIndex - skippy, err := skipPrivate(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy } + m.ValueMap[mapkey] = mapvalue + } else { + var mapvalue uint64 + m.ValueMap[mapkey] = mapvalue } - m.ValueMap[mapkey] = mapvalue iNdEx = postIndex case 4: if wireType != 0 { diff --git a/internal/public.pb.go b/internal/public.pb.go index 22afdc0f9..1676d4ae5 100644 --- a/internal/public.pb.go +++ b/internal/public.pb.go @@ -1,5 +1,6 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-gogo. // source: public.proto +// DO NOT EDIT! /* Package internal is a generated protocol buffer package. @@ -27,8 +28,6 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import encoding_binary "encoding/binary" - import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -355,6 +354,7 @@ func (m *QueryResponse) GetColumnAttrSets() []*ColumnAttrSet { } type QueryResult struct { + Type uint32 `protobuf:"varint,6,opt,name=Type,proto3" json:"Type,omitempty"` Bitmap *Bitmap `protobuf:"bytes,1,opt,name=Bitmap" json:"Bitmap,omitempty"` N uint64 `protobuf:"varint,2,opt,name=N,proto3" json:"N,omitempty"` Pairs []*Pair `protobuf:"bytes,3,rep,name=Pairs" json:"Pairs,omitempty"` @@ -367,6 +367,13 @@ func (m *QueryResult) String() string { return proto.CompactTextStrin func (*QueryResult) ProtoMessage() {} func (*QueryResult) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{9} } +func (m *QueryResult) GetType() uint32 { + if m != nil { + return m.Type + } + return 0 +} + func (m *QueryResult) GetBitmap() *Bitmap { if m != nil { return m.Bitmap @@ -776,8 +783,7 @@ func (m *Attr) MarshalTo(dAtA []byte) (int, error) { if m.FloatValue != 0 { dAtA[i] = 0x31 i++ - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.FloatValue)))) - i += 8 + i = encodeFixed64Public(dAtA, i, uint64(math.Float64bits(float64(m.FloatValue)))) } return i, nil } @@ -1003,6 +1009,11 @@ func (m *QueryResult) MarshalTo(dAtA []byte) (int, error) { } i += n6 } + if m.Type != 0 { + dAtA[i] = 0x30 + i++ + i = encodeVarintPublic(dAtA, i, uint64(m.Type)) + } return i, nil } @@ -1169,6 +1180,24 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func encodeFixed64Public(dAtA []byte, offset int, v uint64) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + dAtA[offset+4] = uint8(v >> 32) + dAtA[offset+5] = uint8(v >> 40) + dAtA[offset+6] = uint8(v >> 48) + dAtA[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Public(dAtA []byte, offset int, v uint32) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + return offset + 4 +} func encodeVarintPublic(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -1377,6 +1406,9 @@ func (m *QueryResult) Size() (n int) { l = m.SumCount.Size() n += 1 + l + sovPublic(uint64(l)) } + if m.Type != 0 { + n += 1 + sovPublic(uint64(m.Type)) + } return n } @@ -2232,8 +2264,15 @@ func (m *Attr) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 + v = uint64(dAtA[iNdEx-8]) + v |= uint64(dAtA[iNdEx-7]) << 8 + v |= uint64(dAtA[iNdEx-6]) << 16 + v |= uint64(dAtA[iNdEx-5]) << 24 + v |= uint64(dAtA[iNdEx-4]) << 32 + v |= uint64(dAtA[iNdEx-3]) << 40 + v |= uint64(dAtA[iNdEx-2]) << 48 + v |= uint64(dAtA[iNdEx-1]) << 56 m.FloatValue = float64(math.Float64frombits(v)) default: iNdEx = preIndex @@ -2864,6 +2903,25 @@ func (m *QueryResult) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + 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 ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipPublic(dAtA[iNdEx:]) @@ -3586,47 +3644,48 @@ var ( func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) } var fileDescriptorPublic = []byte{ - // 671 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbb, 0x6e, 0xd4, 0x40, - 0x14, 0x65, 0xd6, 0xde, 0xd7, 0xdd, 0x4d, 0x14, 0x8d, 0x20, 0x58, 0x08, 0xad, 0x2c, 0x8b, 0xc2, - 0xd5, 0x46, 0x5a, 0x7a, 0x10, 0x9b, 0x87, 0x64, 0x45, 0x44, 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, 0xfa, 0xe9, 0x40, 0xa9, 0x1b, 0x1c, 0x45, 0xaf, 0xb1, - 0x72, 0xfc, 0x50, 0x47, 0xef, 0x50, 0xde, 0x7b, 0x06, 0x5b, 0x75, 0xfa, 0x65, 0x9e, 0xa5, 0xa5, - 0xa0, 0x19, 0x1d, 0x16, 0x85, 0x99, 0xd1, 0x61, 0x51, 0xf0, 0x3d, 0x18, 0xa2, 0x28, 0xab, 0x58, - 0x9a, 0xc1, 0xdf, 0x6b, 0x5b, 0x61, 0xde, 0x56, 0xb1, 0x44, 0x73, 0x8b, 0x3f, 0x85, 0xed, 0x0d, - 0x23, 0xe9, 0x8d, 0x99, 0x2c, 0xee, 0xb7, 0xef, 0x36, 0x74, 0xfc, 0xed, 0xba, 0xf7, 0x85, 0xc1, - 0xa4, 0x13, 0x99, 0xfb, 0x66, 0x79, 0x55, 0x5a, 0x93, 0xc5, 0x4e, 0x1b, 0x48, 0xf3, 0x68, 0x96, - 0x7b, 0x0a, 0xec, 0xa4, 0x36, 0x13, 0x3b, 0xa1, 0x11, 0xd2, 0x72, 0x9a, 0xef, 0x77, 0x46, 0x48, - 0x34, 0x6a, 0x91, 0x3b, 0x30, 0xdc, 0x7f, 0x13, 0xa6, 0x57, 0xe2, 0x52, 0x99, 0x69, 0x84, 0x06, - 0xf2, 0x79, 0xbb, 0x9c, 0xaa, 0xfb, 0x93, 0x05, 0x6f, 0x43, 0x18, 0x05, 0x9b, 0x3b, 0xde, 0x27, - 0x06, 0x5b, 0x41, 0x92, 0x67, 0x85, 0xec, 0xb8, 0x21, 0x48, 0x2f, 0xc5, 0xb5, 0x71, 0x83, 0x02, - 0xc4, 0x1e, 0x15, 0x61, 0xa2, 0x6d, 0x3f, 0x46, 0x0d, 0x88, 0x55, 0xae, 0x50, 0x2e, 0xb0, 0x51, - 0x03, 0x35, 0x7f, 0x5a, 0xec, 0xd2, 0xb1, 0xb5, 0x73, 0x34, 0x22, 0x9f, 0x9b, 0xbd, 0x2e, 0x9d, - 0xbe, 0x92, 0x5a, 0x82, 0x7c, 0xde, 0x2c, 0x36, 0x79, 0xc3, 0xf2, 0x2d, 0xec, 0x30, 0xde, 0x47, - 0x06, 0x5c, 0x67, 0xaa, 0x7c, 0xff, 0xff, 0xd2, 0xa5, 0xbb, 0x91, 0x88, 0x75, 0x2b, 0xe9, 0x2e, - 0x81, 0xbf, 0x24, 0xbb, 0x0b, 0x03, 0x95, 0x85, 0x49, 0xb4, 0x46, 0xcb, 0x9d, 0x6f, 0x37, 0x33, - 0xf6, 0xfd, 0x66, 0xc6, 0x7e, 0xdc, 0xcc, 0xd8, 0x87, 0x9f, 0xb3, 0x3b, 0xe7, 0x03, 0xf5, 0x5b, - 0x7f, 0xfc, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xf2, 0x1f, 0x86, 0xe6, 0x05, 0x00, 0x00, + // 678 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x65, 0x62, 0xe7, 0x75, 0x93, 0x54, 0xd5, 0x08, 0x8a, 0x85, 0x50, 0x64, 0x59, 0x2c, 0xbc, + 0x4a, 0xa5, 0xb0, 0x07, 0x91, 0x3e, 0xa4, 0xa8, 0xa2, 0x82, 0x9b, 0x52, 0xd6, 0x6e, 0x3b, 0x2a, + 0x96, 0xfc, 0xc2, 0x1e, 0x8b, 0xe6, 0x3b, 0xd8, 0xb0, 0x66, 0x03, 0x1f, 0xc1, 0x07, 0xc0, 0x8e, + 0x4f, 0x40, 0xe1, 0x47, 0xd0, 0x9d, 0xf1, 0xd8, 0x0e, 0x95, 0x80, 0x05, 0xbb, 0x39, 0xe7, 0xcc, + 0x5c, 0xdf, 0xc7, 0xb9, 0x86, 0x71, 0x56, 0x5e, 0x44, 0xe1, 0xe5, 0x2c, 0xcb, 0x53, 0x99, 0xf2, + 0x41, 0x98, 0x48, 0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, 0xcd, 0x94, 0x7d, 0xdf, 0x4c, 0xd9, 0x8f, 0xcd, 0x94, 0x7d, 0xf8, + 0x39, 0xbd, 0x73, 0xd1, 0x53, 0xbf, 0xfa, 0xc7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x6f, + 0xfd, 0x3f, 0xfa, 0x05, 0x00, 0x00, } diff --git a/internal/public.proto b/internal/public.proto index 025b50baa..e5fc833fd 100644 --- a/internal/public.proto +++ b/internal/public.proto @@ -60,6 +60,7 @@ message QueryResponse { } message QueryResult { + uint32 Type = 6; Bitmap Bitmap = 1; uint64 N = 2; repeated Pair Pairs = 3; From a56410a70b28393d9726a892ef9094bd51b7fbe1 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Thu, 18 Jan 2018 16:08:02 -0600 Subject: [PATCH 3/5] WIP: Modify `pilosa import` to support string rows/columns This PR adds a flag `pilosa import --string-keys=true` which treats the payload CSV as comma separated strings. --- client.go | 85 +++++++ cmd/import.go | 1 + ctl/import.go | 104 ++++++++- internal/public.pb.go | 523 ++++++++++++++++++++++++++++++++++++------ internal/public.proto | 10 +- 5 files changed, 655 insertions(+), 68 deletions(-) diff --git a/client.go b/client.go index 8f4f282f8..073a4629c 100644 --- a/client.go +++ b/client.go @@ -303,6 +303,32 @@ func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, sl return nil } +// ImportK bulk imports bitKs to a host. +func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, bitKs []BitK) error { + if index == "" { + return ErrIndexRequired + } else if frame == "" { + return ErrFrameRequired + } + + buf, err := marshalImportKPayload(index, frame, bitKs) + if err != nil { + return fmt.Errorf("Error Creating Payload: %s", err) + } + + node := &Node{ + Scheme: c.defaultURI.Scheme(), + Host: c.defaultURI.HostPort(), + } + + // Import to node. + if err := c.importNode(ctx, node, buf); err != nil { + return fmt.Errorf("import node: host=%s, err=%s", node.Host, err) + } + + return nil +} + func (c *InternalHTTPClient) EnsureIndex(ctx context.Context, name string, options IndexOptions) error { err := c.CreateIndex(ctx, name, options) if err == nil || err == ErrIndexExists { @@ -341,6 +367,27 @@ func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte return buf, nil } +// marshalImportKPayload marshalls the import parameters into a protobuf byte slice. +func marshalImportKPayload(index, frame string, bitKs []BitK) ([]byte, error) { + // Separate row and column IDs to reduce allocations. + rowKeys := BitKs(bitKs).RowKeys() + columnKeys := BitKs(bitKs).ColumnKeys() + timestamps := BitKs(bitKs).Timestamps() + + // Marshal bits to protobufs. + buf, err := proto.Marshal(&internal.ImportKRequest{ + Index: index, + Frame: frame, + RowKeys: rowKeys, + ColumnKeys: columnKeys, + Timestamps: timestamps, + }) + if err != nil { + return nil, fmt.Errorf("marshal import request: %s", err) + } + return buf, nil +} + // importNode sends a pre-marshaled import request to a node. func (c *InternalHTTPClient) importNode(ctx context.Context, node *Node, buf []byte) error { // Create URL & HTTP request. @@ -1177,6 +1224,43 @@ func (p Bits) GroupBySlice() map[uint64][]Bit { return m } +// BitK represents the location of a single bit as string keys. +type BitK struct { + RowKey string + ColumnKey string + Timestamp int64 +} + +// BitKs represents a slice of bitKs. +type BitKs []BitK + +// RowKeys returns a slice of all the row Keys. +func (p BitKs) RowKeys() []string { + other := make([]string, len(p)) + for i := range p { + other[i] = p[i].RowKey + } + return other +} + +// ColumnKeys returns a slice of all the column Keys. +func (p BitKs) ColumnKeys() []string { + other := make([]string, len(p)) + for i := range p { + other[i] = p[i].ColumnKey + } + return other +} + +// Timestamps returns a slice of all the timestamps. +func (p BitKs) Timestamps() []int64 { + other := make([]int64, len(p)) + for i := range p { + other[i] = p[i].Timestamp + } + return other +} + // FieldValues represents the value for a column within a // range-encoded frame. type FieldValue struct { @@ -1271,6 +1355,7 @@ type InternalClient interface { FragmentNodes(ctx context.Context, index string, slice uint64) ([]*Node, error) ExecuteQuery(ctx context.Context, index string, queryRequest *internal.QueryRequest) (*internal.QueryResponse, error) Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error + ImportK(ctx context.Context, index, frame string, bitKs []BitK) error EnsureIndex(ctx context.Context, name string, options IndexOptions) error EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error ImportValue(ctx context.Context, index, frame, field string, slice uint64, vals []FieldValue) error diff --git a/cmd/import.go b/cmd/import.go index 250dccfd3..8692fa318 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -56,6 +56,7 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM. flags.StringVarP(&Importer.Index, "index", "i", "", "Pilosa index to import into.") flags.StringVarP(&Importer.Frame, "frame", "f", "", "Frame to import into.") flags.StringVarP(&Importer.Field, "field", "", "", "Field to import into.") + flags.BoolVar(&Importer.StringKeys, "string-keys", false, "Treat payload as string keys.") flags.IntVarP(&Importer.BufferSize, "buffer-size", "s", 10000000, "Number of bits to buffer/sort before importing.") flags.BoolVarP(&Importer.Sort, "sort", "", false, "Enables sorting before import.") flags.BoolVarP(&Importer.CreateSchema, "create", "e", false, "Create the schema if it does not exist before import.") diff --git a/ctl/import.go b/ctl/import.go index 179385db5..b6c1b6f50 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -48,6 +48,9 @@ type ImportCommand struct { // For Range-Encoded fields, name of the Field to import into. Field string `json:"field"` + // Indicates that the payload should be treated as string keys. + StringKeys bool `json:"StringKeys"` + // Filenames to import from. Paths []string `json:"paths"` @@ -131,7 +134,11 @@ func (cmd *ImportCommand) importPath(ctx context.Context, path string) error { if cmd.Field != "" { return cmd.bufferFieldValues(ctx, path) } else { - return cmd.bufferBits(ctx, path) + if cmd.StringKeys { + return cmd.bufferBitKs(ctx, path) + } else { + return cmd.bufferBits(ctx, path) + } } } @@ -240,7 +247,102 @@ func (cmd *ImportCommand) importBits(ctx context.Context, bits []pilosa.Bit) err } return nil +} +// bufferBitKs buffers slices of keys to be imported as a batch. +func (cmd *ImportCommand) bufferBitKs(ctx context.Context, path string) error { + a := make([]pilosa.BitK, 0, cmd.BufferSize) + + var r *csv.Reader + + if path != "-" { + // Open file for reading. + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + + // Read rows as bits. + r = csv.NewReader(f) + } else { + r = csv.NewReader(cmd.Stdin) + } + + r.FieldsPerRecord = -1 + rnum := 0 + for { + rnum++ + + // Read CSV row. + record, err := r.Read() + if err == io.EOF { + break + } else if err != nil { + return err + } + + // Ignore blank rows. + if record[0] == "" { + continue + } else if len(record) < 2 { + return fmt.Errorf("bad column count on row %d: col=%d", rnum, len(record)) + } + + var bitK pilosa.BitK + + // Parse row key. + if record[0] == "" { + return fmt.Errorf("invalid row key on row %d: %q", rnum, record[0]) + } + bitK.RowKey = record[0] + + // Parse column key. + if record[1] == "" { + return fmt.Errorf("invalid column id on row %d: %q", rnum, record[1]) + } + bitK.ColumnKey = record[1] + + // Parse time, if exists. + if len(record) > 2 && record[2] != "" { + t, err := time.Parse(pilosa.TimeFormat, record[2]) + if err != nil { + return fmt.Errorf("invalid timestamp on row %d: %q", rnum, record[2]) + } + bitK.Timestamp = t.UnixNano() + } + + a = append(a, bitK) + + // If we've reached the buffer size then import bitKs. + if len(a) == cmd.BufferSize { + if err := cmd.importBitKs(ctx, a); err != nil { + return err + } + a = a[:0] + } + } + + // If there are still bitKs in the buffer then flush them. + if err := cmd.importBitKs(ctx, a); err != nil { + return err + } + + return nil +} + +// importBitKs sends batches of bitKs to the server. +func (cmd *ImportCommand) importBitKs(ctx context.Context, bitKs []pilosa.BitK) error { + logger := log.New(cmd.Stderr, "", log.LstdFlags) + + // TODO: does it help to sort the rowKeys? + + logger.Printf("importing keys: n=%d", len(bitKs)) + if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Frame, bitKs); err != nil { + return err + } + + return nil } // bufferFieldValues buffers slices of fieldValues to be imported as a batch. diff --git a/internal/public.pb.go b/internal/public.pb.go index 1676d4ae5..83a402247 100644 --- a/internal/public.pb.go +++ b/internal/public.pb.go @@ -20,6 +20,7 @@ QueryResponse QueryResult ImportRequest + ImportKRequest ImportValueRequest */ package internal @@ -465,6 +466,54 @@ func (m *ImportRequest) GetTimestamps() []int64 { return nil } +type ImportKRequest struct { + Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` + Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` + RowKeys []string `protobuf:"bytes,3,rep,name=RowKeys" json:"RowKeys,omitempty"` + ColumnKeys []string `protobuf:"bytes,4,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` + Timestamps []int64 `protobuf:"varint,5,rep,packed,name=Timestamps" json:"Timestamps,omitempty"` +} + +func (m *ImportKRequest) Reset() { *m = ImportKRequest{} } +func (m *ImportKRequest) String() string { return proto.CompactTextString(m) } +func (*ImportKRequest) ProtoMessage() {} +func (*ImportKRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{11} } + +func (m *ImportKRequest) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *ImportKRequest) GetFrame() string { + if m != nil { + return m.Frame + } + return "" +} + +func (m *ImportKRequest) GetRowKeys() []string { + if m != nil { + return m.RowKeys + } + return nil +} + +func (m *ImportKRequest) GetColumnKeys() []string { + if m != nil { + return m.ColumnKeys + } + return nil +} + +func (m *ImportKRequest) GetTimestamps() []int64 { + if m != nil { + return m.Timestamps + } + return nil +} + type ImportValueRequest struct { Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` @@ -477,7 +526,7 @@ type ImportValueRequest struct { func (m *ImportValueRequest) Reset() { *m = ImportValueRequest{} } func (m *ImportValueRequest) String() string { return proto.CompactTextString(m) } func (*ImportValueRequest) ProtoMessage() {} -func (*ImportValueRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{11} } +func (*ImportValueRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{12} } func (m *ImportValueRequest) GetIndex() string { if m != nil { @@ -533,6 +582,7 @@ func init() { proto.RegisterType((*QueryResponse)(nil), "internal.QueryResponse") proto.RegisterType((*QueryResult)(nil), "internal.QueryResult") proto.RegisterType((*ImportRequest)(nil), "internal.ImportRequest") + proto.RegisterType((*ImportKRequest)(nil), "internal.ImportKRequest") proto.RegisterType((*ImportValueRequest)(nil), "internal.ImportValueRequest") } func (m *Bitmap) Marshal() (dAtA []byte, err error) { @@ -1104,6 +1154,84 @@ func (m *ImportRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ImportKRequest) 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 *ImportKRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Index) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintPublic(dAtA, i, uint64(len(m.Index))) + i += copy(dAtA[i:], m.Index) + } + if len(m.Frame) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintPublic(dAtA, i, uint64(len(m.Frame))) + i += copy(dAtA[i:], m.Frame) + } + if len(m.RowKeys) > 0 { + for _, s := range m.RowKeys { + dAtA[i] = 0x1a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if len(m.ColumnKeys) > 0 { + for _, s := range m.ColumnKeys { + dAtA[i] = 0x22 + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if len(m.Timestamps) > 0 { + dAtA14 := make([]byte, len(m.Timestamps)*10) + var j13 int + for _, num1 := range m.Timestamps { + num := uint64(num1) + for num >= 1<<7 { + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j13++ + } + dAtA14[j13] = uint8(num) + j13++ + } + dAtA[i] = 0x2a + i++ + i = encodeVarintPublic(dAtA, i, uint64(j13)) + i += copy(dAtA[i:], dAtA14[:j13]) + } + return i, nil +} + func (m *ImportValueRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1143,27 +1271,9 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.Field) } if len(m.ColumnIDs) > 0 { - dAtA14 := make([]byte, len(m.ColumnIDs)*10) - var j13 int - for _, num := range m.ColumnIDs { - for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j13++ - } - dAtA14[j13] = uint8(num) - j13++ - } - dAtA[i] = 0x2a - i++ - i = encodeVarintPublic(dAtA, i, uint64(j13)) - i += copy(dAtA[i:], dAtA14[:j13]) - } - if len(m.Values) > 0 { - dAtA16 := make([]byte, len(m.Values)*10) + dAtA16 := make([]byte, len(m.ColumnIDs)*10) var j15 int - for _, num1 := range m.Values { - num := uint64(num1) + for _, num := range m.ColumnIDs { for num >= 1<<7 { dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -1172,11 +1282,29 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { dAtA16[j15] = uint8(num) j15++ } - dAtA[i] = 0x32 + dAtA[i] = 0x2a i++ i = encodeVarintPublic(dAtA, i, uint64(j15)) i += copy(dAtA[i:], dAtA16[:j15]) } + if len(m.Values) > 0 { + dAtA18 := make([]byte, len(m.Values)*10) + var j17 int + for _, num1 := range m.Values { + num := uint64(num1) + for num >= 1<<7 { + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j17++ + } + dAtA18[j17] = uint8(num) + j17++ + } + dAtA[i] = 0x32 + i++ + i = encodeVarintPublic(dAtA, i, uint64(j17)) + i += copy(dAtA[i:], dAtA18[:j17]) + } return i, nil } @@ -1450,6 +1578,39 @@ func (m *ImportRequest) Size() (n int) { return n } +func (m *ImportKRequest) Size() (n int) { + var l int + _ = l + l = len(m.Index) + if l > 0 { + n += 1 + l + sovPublic(uint64(l)) + } + l = len(m.Frame) + if l > 0 { + n += 1 + l + sovPublic(uint64(l)) + } + if len(m.RowKeys) > 0 { + for _, s := range m.RowKeys { + l = len(s) + n += 1 + l + sovPublic(uint64(l)) + } + } + if len(m.ColumnKeys) > 0 { + for _, s := range m.ColumnKeys { + l = len(s) + n += 1 + l + sovPublic(uint64(l)) + } + } + if len(m.Timestamps) > 0 { + l = 0 + for _, e := range m.Timestamps { + l += sovPublic(uint64(e)) + } + n += 1 + sovPublic(uint64(l)) + l + } + return n +} + func (m *ImportValueRequest) Size() (n int) { var l int _ = l @@ -3256,6 +3417,234 @@ func (m *ImportRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *ImportKRequest) 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 ErrIntOverflowPublic + } + 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: ImportKRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ImportKRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Frame = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RowKeys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RowKeys = append(m.RowKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ColumnKeys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ColumnKeys = append(m.ColumnKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Timestamps = append(m.Timestamps, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + packedLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Timestamps = append(m.Timestamps, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamps", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipPublic(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPublic + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ImportValueRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3644,48 +4033,50 @@ var ( func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) } var fileDescriptorPublic = []byte{ - // 678 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x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xcb, 0x96, 0x43, 0x96, - 0xc9, 0x95, 0xb8, 0x31, 0x0e, 0x51, 0x80, 0xd8, 0xe3, 0x3c, 0x88, 0xf5, 0x2a, 0x0c, 0x51, 0x03, - 0x62, 0x95, 0x53, 0x94, 0x33, 0x6c, 0xd4, 0x40, 0x79, 0x82, 0x96, 0xbd, 0x70, 0x6c, 0xed, 0x26, - 0x8d, 0xc8, 0xfb, 0x66, 0xd7, 0x0b, 0xa7, 0xab, 0xa4, 0x86, 0x20, 0xef, 0xd7, 0xcb, 0x4e, 0x7e, - 0xb1, 0x7c, 0x0b, 0x5b, 0x8c, 0xf7, 0x91, 0x01, 0xd7, 0x99, 0xaa, 0x5d, 0xf8, 0x7f, 0xe9, 0xd2, - 0xdd, 0x50, 0x44, 0xba, 0xbd, 0x74, 0x97, 0xc0, 0x5f, 0x92, 0xdd, 0x83, 0x9e, 0xca, 0xc2, 0x24, - 0x5a, 0xa1, 0xc5, 0xee, 0xd7, 0xcd, 0x94, 0x7d, 0xdf, 0x4c, 0xd9, 0x8f, 0xcd, 0x94, 0x7d, 0xf8, - 0x39, 0xbd, 0x73, 0xd1, 0x53, 0xbf, 0xfa, 0xc7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x6f, - 0xfd, 0x3f, 0xfa, 0x05, 0x00, 0x00, + // 712 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcb, 0x6a, 0x14, 0x41, + 0x14, 0xb5, 0xa6, 0x7b, 0x5e, 0x77, 0x1e, 0x84, 0x42, 0x63, 0x23, 0x32, 0x34, 0x8d, 0x8b, 0x5e, + 0x4d, 0x60, 0xdc, 0x2b, 0x4e, 0x1e, 0x30, 0x04, 0x83, 0xd6, 0xc4, 0xb8, 0xee, 0x24, 0x45, 0x6c, + 0xe8, 0x97, 0xdd, 0xd5, 0x24, 0xf3, 0x1d, 0x82, 0xb8,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, 0x7f, 0xbd, 0xec, + 0xe8, 0x17, 0xcb, 0xb7, 0x44, 0x83, 0xf1, 0xde, 0x33, 0x18, 0xeb, 0x4c, 0x0f, 0xff, 0x25, 0x55, + 0x07, 0xba, 0x22, 0xbd, 0x6c, 0xfc, 0x40, 0x1a, 0x88, 0x1f, 0xd6, 0x59, 0x90, 0x68, 0x93, 0xd8, + 0x60, 0x6e, 0x24, 0xd6, 0xbe, 0x95, 0xd8, 0x47, 0x06, 0x5c, 0x27, 0x46, 0x4b, 0xfa, 0xff, 0xfa, + 0x88, 0x77, 0x43, 0x19, 0xe9, 0xb9, 0xe3, 0x5d, 0x04, 0x7f, 0xe8, 0xe2, 0x36, 0x74, 0x28, 0x0b, + 0xd3, 0xc1, 0x0a, 0xcd, 0xb7, 0xbe, 0x5e, 0x4f, 0xd8, 0xf7, 0xeb, 0x09, 0xfb, 0x71, 0x3d, 0x61, + 0x1f, 0x7e, 0x4e, 0xee, 0x9c, 0x76, 0xe8, 0x3f, 0xe8, 0xf1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xf3, 0x62, 0xbb, 0x7d, 0x93, 0x06, 0x00, 0x00, } diff --git a/internal/public.proto b/internal/public.proto index e5fc833fd..649fc0e3d 100644 --- a/internal/public.proto +++ b/internal/public.proto @@ -41,7 +41,7 @@ message Attr { } message AttrMap { - repeated Attr Attrs = 1; + repeated Attr Attrs = 1; } message QueryRequest { @@ -77,6 +77,14 @@ message ImportRequest { repeated int64 Timestamps = 6; } +message ImportKRequest { + string Index = 1; + string Frame = 2; + repeated string RowKeys = 3; + repeated string ColumnKeys = 4; + repeated int64 Timestamps = 5; +} + message ImportValueRequest { string Index = 1; string Frame = 2; From d8559ae469486064e667c6c2e23285188e70c5db Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 19 Jan 2018 17:47:03 -0600 Subject: [PATCH 4/5] refactor to remove BitK (in favor of Bit) --- client.go | 77 +++---- ctl/import.go | 32 +-- internal/public.pb.go | 511 ++++++++++++------------------------------ internal/public.proto | 11 +- 4 files changed, 197 insertions(+), 434 deletions(-) diff --git a/client.go b/client.go index 073a4629c..bbf118399 100644 --- a/client.go +++ b/client.go @@ -303,15 +303,15 @@ func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, sl return nil } -// ImportK bulk imports bitKs to a host. -func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, bitKs []BitK) error { +// ImportK bulk imports bits to a host. +func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, bits []Bit) error { if index == "" { return ErrIndexRequired } else if frame == "" { return ErrFrameRequired } - buf, err := marshalImportKPayload(index, frame, bitKs) + buf, err := marshalImportPayloadK(index, frame, bits) if err != nil { return fmt.Errorf("Error Creating Payload: %s", err) } @@ -367,15 +367,15 @@ func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte return buf, nil } -// marshalImportKPayload marshalls the import parameters into a protobuf byte slice. -func marshalImportKPayload(index, frame string, bitKs []BitK) ([]byte, error) { +// marshalImportPayloadK marshalls the import parameters into a protobuf byte slice. +func marshalImportPayloadK(index, frame string, bits []Bit) ([]byte, error) { // Separate row and column IDs to reduce allocations. - rowKeys := BitKs(bitKs).RowKeys() - columnKeys := BitKs(bitKs).ColumnKeys() - timestamps := BitKs(bitKs).Timestamps() + rowKeys := Bits(bits).RowKeys() + columnKeys := Bits(bits).ColumnKeys() + timestamps := Bits(bits).Timestamps() // Marshal bits to protobufs. - buf, err := proto.Marshal(&internal.ImportKRequest{ + buf, err := proto.Marshal(&internal.ImportRequest{ Index: index, Frame: frame, RowKeys: rowKeys, @@ -1162,6 +1162,8 @@ func (c *InternalHTTPClient) NodeID(uri *URI) (string, error) { type Bit struct { RowID uint64 ColumnID uint64 + RowKey string + ColumnKey string Timestamp int64 } @@ -1199,6 +1201,24 @@ func (p Bits) ColumnIDs() []uint64 { return other } +// RowKeys returns a slice of all the row keys. +func (p Bits) RowKeys() []string { + other := make([]string, len(p)) + for i := range p { + other[i] = p[i].RowKey + } + return other +} + +// ColumnKeys returns a slice of all the column keys. +func (p Bits) ColumnKeys() []string { + other := make([]string, len(p)) + for i := range p { + other[i] = p[i].ColumnKey + } + return other +} + // Timestamps returns a slice of all the timestamps. func (p Bits) Timestamps() []int64 { other := make([]int64, len(p)) @@ -1224,43 +1244,6 @@ func (p Bits) GroupBySlice() map[uint64][]Bit { return m } -// BitK represents the location of a single bit as string keys. -type BitK struct { - RowKey string - ColumnKey string - Timestamp int64 -} - -// BitKs represents a slice of bitKs. -type BitKs []BitK - -// RowKeys returns a slice of all the row Keys. -func (p BitKs) RowKeys() []string { - other := make([]string, len(p)) - for i := range p { - other[i] = p[i].RowKey - } - return other -} - -// ColumnKeys returns a slice of all the column Keys. -func (p BitKs) ColumnKeys() []string { - other := make([]string, len(p)) - for i := range p { - other[i] = p[i].ColumnKey - } - return other -} - -// Timestamps returns a slice of all the timestamps. -func (p BitKs) Timestamps() []int64 { - other := make([]int64, len(p)) - for i := range p { - other[i] = p[i].Timestamp - } - return other -} - // FieldValues represents the value for a column within a // range-encoded frame. type FieldValue struct { @@ -1355,7 +1338,7 @@ type InternalClient interface { FragmentNodes(ctx context.Context, index string, slice uint64) ([]*Node, error) ExecuteQuery(ctx context.Context, index string, queryRequest *internal.QueryRequest) (*internal.QueryResponse, error) Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error - ImportK(ctx context.Context, index, frame string, bitKs []BitK) error + ImportK(ctx context.Context, index, frame string, bits []Bit) error EnsureIndex(ctx context.Context, name string, options IndexOptions) error EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error ImportValue(ctx context.Context, index, frame, field string, slice uint64, vals []FieldValue) error diff --git a/ctl/import.go b/ctl/import.go index b6c1b6f50..8103bf673 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -135,7 +135,7 @@ func (cmd *ImportCommand) importPath(ctx context.Context, path string) error { return cmd.bufferFieldValues(ctx, path) } else { if cmd.StringKeys { - return cmd.bufferBitKs(ctx, path) + return cmd.bufferBitsK(ctx, path) } else { return cmd.bufferBits(ctx, path) } @@ -249,9 +249,9 @@ func (cmd *ImportCommand) importBits(ctx context.Context, bits []pilosa.Bit) err return nil } -// bufferBitKs buffers slices of keys to be imported as a batch. -func (cmd *ImportCommand) bufferBitKs(ctx context.Context, path string) error { - a := make([]pilosa.BitK, 0, cmd.BufferSize) +// bufferBitsK buffers slices of keys to be imported as a batch. +func (cmd *ImportCommand) bufferBitsK(ctx context.Context, path string) error { + a := make([]pilosa.Bit, 0, cmd.BufferSize) var r *csv.Reader @@ -289,19 +289,19 @@ func (cmd *ImportCommand) bufferBitKs(ctx context.Context, path string) error { return fmt.Errorf("bad column count on row %d: col=%d", rnum, len(record)) } - var bitK pilosa.BitK + var bit pilosa.Bit // Parse row key. if record[0] == "" { return fmt.Errorf("invalid row key on row %d: %q", rnum, record[0]) } - bitK.RowKey = record[0] + bit.RowKey = record[0] // Parse column key. if record[1] == "" { return fmt.Errorf("invalid column id on row %d: %q", rnum, record[1]) } - bitK.ColumnKey = record[1] + bit.ColumnKey = record[1] // Parse time, if exists. if len(record) > 2 && record[2] != "" { @@ -309,14 +309,14 @@ func (cmd *ImportCommand) bufferBitKs(ctx context.Context, path string) error { if err != nil { return fmt.Errorf("invalid timestamp on row %d: %q", rnum, record[2]) } - bitK.Timestamp = t.UnixNano() + bit.Timestamp = t.UnixNano() } - a = append(a, bitK) + a = append(a, bit) - // If we've reached the buffer size then import bitKs. + // If we've reached the buffer size then import bits. if len(a) == cmd.BufferSize { - if err := cmd.importBitKs(ctx, a); err != nil { + if err := cmd.importBitsK(ctx, a); err != nil { return err } a = a[:0] @@ -324,21 +324,21 @@ func (cmd *ImportCommand) bufferBitKs(ctx context.Context, path string) error { } // If there are still bitKs in the buffer then flush them. - if err := cmd.importBitKs(ctx, a); err != nil { + if err := cmd.importBitsK(ctx, a); err != nil { return err } return nil } -// importBitKs sends batches of bitKs to the server. -func (cmd *ImportCommand) importBitKs(ctx context.Context, bitKs []pilosa.BitK) error { +// importBitsK sends batches of bitKs to the server. +func (cmd *ImportCommand) importBitsK(ctx context.Context, bits []pilosa.Bit) error { logger := log.New(cmd.Stderr, "", log.LstdFlags) // TODO: does it help to sort the rowKeys? - logger.Printf("importing keys: n=%d", len(bitKs)) - if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Frame, bitKs); err != nil { + logger.Printf("importing keys: n=%d", len(bits)) + if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Frame, bits); err != nil { return err } diff --git a/internal/public.pb.go b/internal/public.pb.go index 83a402247..dfb9a819e 100644 --- a/internal/public.pb.go +++ b/internal/public.pb.go @@ -20,7 +20,6 @@ QueryResponse QueryResult ImportRequest - ImportKRequest ImportValueRequest */ package internal @@ -416,6 +415,8 @@ type ImportRequest struct { Slice uint64 `protobuf:"varint,3,opt,name=Slice,proto3" json:"Slice,omitempty"` RowIDs []uint64 `protobuf:"varint,4,rep,packed,name=RowIDs" json:"RowIDs,omitempty"` ColumnIDs []uint64 `protobuf:"varint,5,rep,packed,name=ColumnIDs" json:"ColumnIDs,omitempty"` + RowKeys []string `protobuf:"bytes,7,rep,name=RowKeys" json:"RowKeys,omitempty"` + ColumnKeys []string `protobuf:"bytes,8,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` Timestamps []int64 `protobuf:"varint,6,rep,packed,name=Timestamps" json:"Timestamps,omitempty"` } @@ -459,6 +460,20 @@ func (m *ImportRequest) GetColumnIDs() []uint64 { return nil } +func (m *ImportRequest) GetRowKeys() []string { + if m != nil { + return m.RowKeys + } + return nil +} + +func (m *ImportRequest) GetColumnKeys() []string { + if m != nil { + return m.ColumnKeys + } + return nil +} + func (m *ImportRequest) GetTimestamps() []int64 { if m != nil { return m.Timestamps @@ -466,67 +481,20 @@ func (m *ImportRequest) GetTimestamps() []int64 { return nil } -type ImportKRequest struct { +type ImportValueRequest struct { Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` - RowKeys []string `protobuf:"bytes,3,rep,name=RowKeys" json:"RowKeys,omitempty"` - ColumnKeys []string `protobuf:"bytes,4,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` - Timestamps []int64 `protobuf:"varint,5,rep,packed,name=Timestamps" json:"Timestamps,omitempty"` -} - -func (m *ImportKRequest) Reset() { *m = ImportKRequest{} } -func (m *ImportKRequest) String() string { return proto.CompactTextString(m) } -func (*ImportKRequest) ProtoMessage() {} -func (*ImportKRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{11} } - -func (m *ImportKRequest) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *ImportKRequest) GetFrame() string { - if m != nil { - return m.Frame - } - return "" -} - -func (m *ImportKRequest) GetRowKeys() []string { - if m != nil { - return m.RowKeys - } - return nil -} - -func (m *ImportKRequest) GetColumnKeys() []string { - if m != nil { - return m.ColumnKeys - } - return nil -} - -func (m *ImportKRequest) GetTimestamps() []int64 { - if m != nil { - return m.Timestamps - } - return nil -} - -type ImportValueRequest struct { - Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` - Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` - Slice uint64 `protobuf:"varint,3,opt,name=Slice,proto3" json:"Slice,omitempty"` - Field string `protobuf:"bytes,4,opt,name=Field,proto3" json:"Field,omitempty"` - ColumnIDs []uint64 `protobuf:"varint,5,rep,packed,name=ColumnIDs" json:"ColumnIDs,omitempty"` - Values []int64 `protobuf:"varint,6,rep,packed,name=Values" json:"Values,omitempty"` + Slice uint64 `protobuf:"varint,3,opt,name=Slice,proto3" json:"Slice,omitempty"` + Field string `protobuf:"bytes,4,opt,name=Field,proto3" json:"Field,omitempty"` + ColumnIDs []uint64 `protobuf:"varint,5,rep,packed,name=ColumnIDs" json:"ColumnIDs,omitempty"` + ColumnKeys []string `protobuf:"bytes,7,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` + Values []int64 `protobuf:"varint,6,rep,packed,name=Values" json:"Values,omitempty"` } func (m *ImportValueRequest) Reset() { *m = ImportValueRequest{} } func (m *ImportValueRequest) String() string { return proto.CompactTextString(m) } func (*ImportValueRequest) ProtoMessage() {} -func (*ImportValueRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{12} } +func (*ImportValueRequest) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{11} } func (m *ImportValueRequest) GetIndex() string { if m != nil { @@ -563,6 +531,13 @@ func (m *ImportValueRequest) GetColumnIDs() []uint64 { return nil } +func (m *ImportValueRequest) GetColumnKeys() []string { + if m != nil { + return m.ColumnKeys + } + return nil +} + func (m *ImportValueRequest) GetValues() []int64 { if m != nil { return m.Values @@ -582,7 +557,6 @@ func init() { proto.RegisterType((*QueryResponse)(nil), "internal.QueryResponse") proto.RegisterType((*QueryResult)(nil), "internal.QueryResult") proto.RegisterType((*ImportRequest)(nil), "internal.ImportRequest") - proto.RegisterType((*ImportKRequest)(nil), "internal.ImportKRequest") proto.RegisterType((*ImportValueRequest)(nil), "internal.ImportValueRequest") } func (m *Bitmap) Marshal() (dAtA []byte, err error) { @@ -1151,39 +1125,9 @@ func (m *ImportRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPublic(dAtA, i, uint64(j11)) i += copy(dAtA[i:], dAtA12[:j11]) } - return i, nil -} - -func (m *ImportKRequest) 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 *ImportKRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Index) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintPublic(dAtA, i, uint64(len(m.Index))) - i += copy(dAtA[i:], m.Index) - } - if len(m.Frame) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintPublic(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) - } if len(m.RowKeys) > 0 { for _, s := range m.RowKeys { - dAtA[i] = 0x1a + dAtA[i] = 0x3a i++ l = len(s) for l >= 1<<7 { @@ -1198,7 +1142,7 @@ func (m *ImportKRequest) MarshalTo(dAtA []byte) (int, error) { } if len(m.ColumnKeys) > 0 { for _, s := range m.ColumnKeys { - dAtA[i] = 0x22 + dAtA[i] = 0x42 i++ l = len(s) for l >= 1<<7 { @@ -1211,24 +1155,6 @@ func (m *ImportKRequest) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], s) } } - if len(m.Timestamps) > 0 { - dAtA14 := make([]byte, len(m.Timestamps)*10) - var j13 int - for _, num1 := range m.Timestamps { - num := uint64(num1) - for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j13++ - } - dAtA14[j13] = uint8(num) - j13++ - } - dAtA[i] = 0x2a - i++ - i = encodeVarintPublic(dAtA, i, uint64(j13)) - i += copy(dAtA[i:], dAtA14[:j13]) - } return i, nil } @@ -1271,9 +1197,27 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.Field) } if len(m.ColumnIDs) > 0 { - dAtA16 := make([]byte, len(m.ColumnIDs)*10) - var j15 int + dAtA14 := make([]byte, len(m.ColumnIDs)*10) + var j13 int for _, num := range m.ColumnIDs { + for num >= 1<<7 { + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j13++ + } + dAtA14[j13] = uint8(num) + j13++ + } + dAtA[i] = 0x2a + i++ + i = encodeVarintPublic(dAtA, i, uint64(j13)) + i += copy(dAtA[i:], dAtA14[:j13]) + } + if len(m.Values) > 0 { + dAtA16 := make([]byte, len(m.Values)*10) + var j15 int + for _, num1 := range m.Values { + num := uint64(num1) for num >= 1<<7 { dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -1282,28 +1226,25 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { dAtA16[j15] = uint8(num) j15++ } - dAtA[i] = 0x2a + dAtA[i] = 0x32 i++ i = encodeVarintPublic(dAtA, i, uint64(j15)) i += copy(dAtA[i:], dAtA16[:j15]) } - if len(m.Values) > 0 { - dAtA18 := make([]byte, len(m.Values)*10) - var j17 int - for _, num1 := range m.Values { - num := uint64(num1) - for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j17++ + if len(m.ColumnKeys) > 0 { + for _, s := range m.ColumnKeys { + dAtA[i] = 0x3a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ } - dAtA18[j17] = uint8(num) - j17++ + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) } - dAtA[i] = 0x32 - i++ - i = encodeVarintPublic(dAtA, i, uint64(j17)) - i += copy(dAtA[i:], dAtA18[:j17]) } return i, nil } @@ -1575,20 +1516,6 @@ func (m *ImportRequest) Size() (n int) { } n += 1 + sovPublic(uint64(l)) + l } - return n -} - -func (m *ImportKRequest) Size() (n int) { - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovPublic(uint64(l)) - } - l = len(m.Frame) - if l > 0 { - n += 1 + l + sovPublic(uint64(l)) - } if len(m.RowKeys) > 0 { for _, s := range m.RowKeys { l = len(s) @@ -1601,13 +1528,6 @@ func (m *ImportKRequest) Size() (n int) { n += 1 + l + sovPublic(uint64(l)) } } - if len(m.Timestamps) > 0 { - l = 0 - for _, e := range m.Timestamps { - l += sovPublic(uint64(e)) - } - n += 1 + sovPublic(uint64(l)) + l - } return n } @@ -1643,6 +1563,12 @@ func (m *ImportValueRequest) Size() (n int) { } n += 1 + sovPublic(uint64(l)) + l } + if len(m.ColumnKeys) > 0 { + for _, s := range m.ColumnKeys { + l = len(s) + n += 1 + l + sovPublic(uint64(l)) + } + } return n } @@ -3396,115 +3322,7 @@ func (m *ImportRequest) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field Timestamps", wireType) } - default: - iNdEx = preIndex - skippy, err := skipPublic(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPublic - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ImportKRequest) 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 ErrIntOverflowPublic - } - 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: ImportKRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ImportKRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPublic - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPublic - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPublic - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPublic - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Frame = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RowKeys", wireType) } @@ -3533,7 +3351,7 @@ func (m *ImportKRequest) Unmarshal(dAtA []byte) error { } m.RowKeys = append(m.RowKeys, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 4: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ColumnKeys", wireType) } @@ -3562,68 +3380,6 @@ func (m *ImportKRequest) Unmarshal(dAtA []byte) error { } m.ColumnKeys = append(m.ColumnKeys, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 5: - if wireType == 0 { - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPublic - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Timestamps = append(m.Timestamps, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPublic - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthPublic - } - postIndex := iNdEx + packedLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - for iNdEx < postIndex { - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPublic - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Timestamps = append(m.Timestamps, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamps", wireType) - } default: iNdEx = preIndex skippy, err := skipPublic(dAtA[iNdEx:]) @@ -3904,6 +3660,35 @@ func (m *ImportValueRequest) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ColumnKeys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPublic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPublic + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ColumnKeys = append(m.ColumnKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPublic(dAtA[iNdEx:]) @@ -4033,50 +3818,50 @@ var ( func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) } var fileDescriptorPublic = []byte{ - // 712 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcb, 0x6a, 0x14, 0x41, - 0x14, 0xb5, 0xa6, 0x7b, 0x5e, 0x77, 0x1e, 0x84, 0x42, 0x63, 0x23, 0x32, 0x34, 0x8d, 0x8b, 0x5e, - 0x4d, 0x60, 0xdc, 0x2b, 0x4e, 0x1e, 0x30, 0x04, 0x83, 0xd6, 0xc4, 0xb8, 0xee, 0x24, 0x45, 0x6c, - 0xe8, 0x97, 0xdd, 0xd5, 0x24, 0xf3, 0x1d, 0x82, 0xb8, 0x76, 0xa3, 0x1f, 0xe1, 0x07, 0xe8, 0xce, - 0x4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x44, 0x83, 0xf1, 0xde, 0x33, 0x18, 0xeb, 0x4c, 0x0f, 0xff, 0x25, 0x55, - 0x07, 0xba, 0x22, 0xbd, 0x6c, 0xfc, 0x40, 0x1a, 0x88, 0x1f, 0xd6, 0x59, 0x90, 0x68, 0x93, 0xd8, - 0x60, 0x6e, 0x24, 0xd6, 0xbe, 0x95, 0xd8, 0x47, 0x06, 0x5c, 0x27, 0x46, 0x4b, 0xfa, 0xff, 0xfa, - 0x88, 0x77, 0x43, 0x19, 0xe9, 0xb9, 0xe3, 0x5d, 0x04, 0x7f, 0xe8, 0xe2, 0x36, 0x74, 0x28, 0x0b, - 0xd3, 0xc1, 0x0a, 0xcd, 0xb7, 0xbe, 0x5e, 0x4f, 0xd8, 0xf7, 0xeb, 0x09, 0xfb, 0x71, 0x3d, 0x61, - 0x1f, 0x7e, 0x4e, 0xee, 0x9c, 0x76, 0xe8, 0x3f, 0xe8, 0xf1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xf3, 0x62, 0xbb, 0x7d, 0x93, 0x06, 0x00, 0x00, + // 705 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x65, 0x62, 0x27, 0x71, 0x6e, 0x92, 0xaa, 0x1a, 0x41, 0xb1, 0x10, 0x8a, 0x2c, 0x8b, 0x85, + 0x57, 0xa9, 0x14, 0xf6, 0x20, 0xd2, 0x87, 0x14, 0x55, 0x54, 0x30, 0x29, 0x65, 0xed, 0xb6, 0xa3, + 0x62, 0xc9, 0x2f, 0xec, 0xb1, 0xda, 0x7c, 0x07, 0x1b, 0x3e, 0x81, 0x8f, 0x60, 0xc5, 0x0a, 0x76, + 0x7c, 0x02, 0x94, 0x1f, 0x41, 0xf7, 0x8e, 0x27, 0x76, 0x5a, 0x09, 0x58, 0xb0, 0x9b, 0x73, 0xce, + 0xcc,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 0x21, 0xcb, 0x2a, + 0x56, 0xa6, 0xf1, 0x0f, 0x9a, 0xa7, 0x30, 0x67, 0xab, 0x58, 0x09, 0xb3, 0x8b, 0x3f, 0x87, 0xad, + 0x8d, 0x20, 0xe9, 0x89, 0x19, 0xce, 0x1e, 0x36, 0xe7, 0x36, 0x74, 0x71, 0x6b, 0xbb, 0xff, 0x8d, + 0xc1, 0xb0, 0x55, 0x99, 0x07, 0x66, 0x78, 0xe9, 0x5a, 0xc3, 0xd9, 0x76, 0x53, 0x48, 0xf3, 0xc2, + 0x0c, 0xf7, 0x08, 0xd8, 0x71, 0x1d, 0x26, 0x76, 0x8c, 0x2d, 0xc4, 0xe1, 0x34, 0xdf, 0x6f, 0xb5, + 0x10, 0x69, 0xa1, 0x45, 0xee, 0x42, 0x7f, 0xef, 0x5d, 0x98, 0x5e, 0xca, 0x0b, 0x0a, 0x93, 0x23, + 0x0c, 0xe4, 0xd3, 0x66, 0x38, 0xe9, 0xf5, 0x87, 0x33, 0xde, 0x94, 0x30, 0x8a, 0x68, 0x06, 0xd8, + 0xa4, 0x19, 0x7b, 0x31, 0xd6, 0x69, 0xf6, 0x7f, 0x32, 0x18, 0x2f, 0x92, 0x3c, 0x2b, 0x54, 0x2b, + 0x21, 0x8b, 0xf4, 0x42, 0x5e, 0x9b, 0x84, 0x10, 0x40, 0xf6, 0xb0, 0x08, 0x13, 0x3d, 0x0a, 0x03, + 0xa1, 0x01, 0xb2, 0x94, 0x14, 0x4a, 0x86, 0x2d, 0x34, 0xa0, 0x4c, 0xe0, 0xb0, 0x97, 0xae, 0xad, + 0xd3, 0xa4, 0x11, 0x66, 0xdf, 0xcc, 0x7a, 0xe9, 0x76, 0x49, 0x6a, 0x08, 0xcc, 0xfe, 0x7a, 0xd8, + 0x31, 0x2f, 0x56, 0x60, 0x89, 0x16, 0x83, 0xef, 0x20, 0xb2, 0x2b, 0xfa, 0x85, 0xeb, 0xd3, 0x2f, + 0x9c, 0x81, 0x78, 0x52, 0x97, 0x21, 0xd1, 0x21, 0xb1, 0xc5, 0xf8, 0x5f, 0x18, 0x70, 0xed, 0x91, + 0xa6, 0xe8, 0xff, 0x19, 0xc5, 0xbd, 0x91, 0x8c, 0x75, 0x63, 0x70, 0x2f, 0x82, 0xbf, 0xd8, 0xdc, + 0x81, 0x1e, 0xdd, 0xc2, 0x58, 0xac, 0xd1, 0x2d, 0x13, 0xfd, 0xdb, 0x26, 0xe6, 0xdb, 0x5f, 0x6f, + 0x26, 0xec, 0xfb, 0xcd, 0x84, 0xfd, 0xb8, 0x99, 0xb0, 0x8f, 0xbf, 0x26, 0xf7, 0xce, 0x7a, 0xf4, + 0x27, 0xf2, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xa0, 0xd2, 0x51, 0x54, 0x06, 0x00, + 0x00, } diff --git a/internal/public.proto b/internal/public.proto index 649fc0e3d..5fa40cfab 100644 --- a/internal/public.proto +++ b/internal/public.proto @@ -74,22 +74,17 @@ message ImportRequest { uint64 Slice = 3; repeated uint64 RowIDs = 4; repeated uint64 ColumnIDs = 5; + repeated string RowKeys = 7; + repeated string ColumnKeys = 8; repeated int64 Timestamps = 6; } -message ImportKRequest { - string Index = 1; - string Frame = 2; - repeated string RowKeys = 3; - repeated string ColumnKeys = 4; - repeated int64 Timestamps = 5; -} - message ImportValueRequest { string Index = 1; string Frame = 2; uint64 Slice = 3; string Field = 4; repeated uint64 ColumnIDs = 5; + repeated string ColumnKeys = 7; repeated int64 Values = 6; } From 5fa7dfd63d59c5ab092e03df1491f688e6f5f415 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 22 Jan 2018 18:04:41 -0600 Subject: [PATCH 5/5] allow for QueryResultTypeNil --- handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index b81b8e124..e5cce4648 100644 --- a/handler.go +++ b/handler.go @@ -1627,7 +1627,8 @@ func (h *Handler) logger() *log.Logger { // QueryResult types. const ( - QueryResultTypeBitmap uint32 = iota + QueryResultTypeNil uint32 = iota + QueryResultTypeBitmap QueryResultTypePairs QueryResultTypeSumCount QueryResultTypeUint64 @@ -1727,6 +1728,8 @@ func encodeQueryResponse(resp *QueryResponse) *internal.QueryResponse { case bool: pb.Results[i].Type = QueryResultTypeBool pb.Results[i].Changed = result + case nil: + pb.Results[i].Type = QueryResultTypeNil } }