From ed1890b3a2211ad991a77b68f5de3f50f92822a1 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 24 Feb 2016 14:00:41 -0600 Subject: [PATCH 1/4] adjust SetBit/ClearBit to releably report bit change --- executor.go | 7 ++-- executor_test.go | 23 +++++++++--- fragment.go | 19 +++++++--- handler.go | 2 ++ internal/internal.pb.go | 62 ++++++++++++++++++-------------- internal/internal.proto | 1 + roaring/roaring.go | 79 +++++++++++++++++++++++------------------ 7 files changed, 120 insertions(+), 73 deletions(-) diff --git a/executor.go b/executor.go index 3e419c949..caa816af1 100644 --- a/executor.go +++ b/executor.go @@ -336,10 +336,11 @@ func (e *Executor) executeSetBit(db string, c *pql.SetBit) (bool, error) { } // Forward call to remote node otherwise. - if _, err := e.exec(node, db, &pql.Query{Root: c}, nil); err != nil { + if res, err := e.exec(node, db, &pql.Query{Root: c}, nil); err != nil { return false, err + } else { + ret = res.(bool) } - fmt.Println("NEED TO IMPLEMENT REMOTE SETBIT") } return ret, nil } @@ -444,7 +445,7 @@ func (e *Executor) exec(node *Node, db string, q *pql.Query, slices []uint64) (r case *pql.Count: return pb.GetN(), nil case *pql.SetBit: - return nil, nil + return pb.GetChanged(), nil default: panic(fmt.Sprintf("invalid node for remote exec: %T", q.Root)) } diff --git a/executor_test.go b/executor_test.go index 703e16bc1..70e780c80 100644 --- a/executor_test.go +++ b/executor_test.go @@ -123,14 +123,29 @@ func TestExecutor_Execute_SetBit(t *testing.T) { defer idx.Close() e := NewExecutor(idx.Index, NewCluster(1)) - if _, err := e.Execute("d", MustParse(`SetBit(id=10, frame=f, profileID=1)`), nil); err != nil { - t.Fatal(err) + f := idx.MustCreateFragmentIfNotExists("d", "f", 0) + if n := f.Bitmap(11).Count(); n != 0 { + t.Fatalf("unexpected bitmap count: %d", n) } - f := idx.MustCreateFragmentIfNotExists("d", "f", 0) - if n := f.Bitmap(10).Count(); n != 1 { + if res, err := e.Execute("d", MustParse(`SetBit(id=11, frame=f, profileID=1)`), nil); err != nil { + t.Fatal(err) + } else { + if !res.(bool) { + t.Fatalf("expected bit changed") + } + } + + if n := f.Bitmap(11).Count(); n != 1 { t.Fatalf("unexpected bitmap count: %d", n) } + if res, err := e.Execute("d", MustParse(`SetBit(id=11, frame=f, profileID=1)`), nil); err != nil { + t.Fatal(err) + } else { + if res.(bool) { + t.Fatalf("expected bit unchanged") + } + } } // Ensure a SetBitmapAttrs() query can be executed. diff --git a/fragment.go b/fragment.go index 176585ddf..8d60c0004 100644 --- a/fragment.go +++ b/fragment.go @@ -320,18 +320,23 @@ func (f *Fragment) SetBit(bitmapID, profileID uint64) (changed bool, err error) func (f *Fragment) setBit(bitmapID, profileID uint64) (bool, error) { // Determine the position of the bit in the storage. + ret := false pos, err := f.pos(bitmapID, profileID) if err != nil { return false, err } // Write to storage. - if err := f.storage.Add(pos); err != nil { + + if ret, err = f.storage.Add(pos); err != nil { return false, err } // Update the cache. - return f.bitmap(bitmapID).setBit(profileID), nil + if f.bitmap(bitmapID).setBit(profileID) { + ret = true + } + return ret, nil } @@ -348,12 +353,16 @@ func (f *Fragment) ClearBit(bitmapID, profileID uint64) (bool, error) { } // Write to storage. - if err := f.storage.Remove(pos); err != nil { + changed, err := f.storage.Remove(pos) + if err != nil { return false, err } // Update the cache. - return f.bitmap(bitmapID).clearBit(profileID), nil + if f.bitmap(bitmapID).clearBit(profileID) { + return true, nil + } + return changed, nil } @@ -509,7 +518,7 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error { } // Write to storage. - if err := f.storage.Add(pos); err != nil { + if _, err := f.storage.Add(pos); err != nil { return err } } diff --git a/handler.go b/handler.go index c6927a14e..a1e65878f 100644 --- a/handler.go +++ b/handler.go @@ -404,6 +404,8 @@ func encodeQueryResponse(resp *QueryResponse) *internal.QueryResponse { pb.Pairs = encodePairs(result) case uint64: pb.N = proto.Uint64(result) + case bool: + pb.Changed = proto.Bool(result) default: panic(fmt.Sprintf("invalid query result type: %T", resp.Result)) } diff --git a/internal/internal.pb.go b/internal/internal.pb.go index ef49d0d53..82d20783f 100644 --- a/internal/internal.pb.go +++ b/internal/internal.pb.go @@ -25,6 +25,7 @@ It has these top-level messages: package internal import proto "github.com/gogo/protobuf/proto" + import fmt "fmt" import math "math" @@ -263,6 +264,7 @@ type QueryResponse struct { N *uint64 `protobuf:"varint,3,opt,name=N" json:"N,omitempty"` Pairs []*Pair `protobuf:"bytes,4,rep,name=Pairs" json:"Pairs,omitempty"` Profiles []*Profile `protobuf:"bytes,5,rep,name=Profiles" json:"Profiles,omitempty"` + Changed *bool `protobuf:"varint,6,opt,name=Changed" json:"Changed,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -306,6 +308,13 @@ func (m *QueryResponse) GetProfiles() []*Profile { return nil } +func (m *QueryResponse) GetChanged() bool { + if m != nil && m.Changed != nil { + return *m.Changed + } + return false +} + type ImportRequest struct { DB *string `protobuf:"bytes,1,req,name=DB" json:"DB,omitempty"` Frame *string `protobuf:"bytes,2,req,name=Frame" json:"Frame,omitempty"` @@ -405,30 +414,31 @@ func init() { } var fileDescriptor0 = []byte{ - // 398 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x52, 0x4d, 0x8f, 0xda, 0x30, - 0x14, 0x54, 0x88, 0x03, 0xe4, 0xa5, 0xa4, 0xe0, 0x5e, 0x50, 0x25, 0x54, 0x64, 0x2e, 0xa8, 0x07, - 0x0e, 0xa8, 0x7f, 0xa0, 0x40, 0xab, 0x22, 0x54, 0x44, 0x8b, 0xda, 0x73, 0x23, 0xe4, 0x96, 0xa8, - 0x21, 0xce, 0x3a, 0xce, 0x81, 0x1f, 0xb1, 0xff, 0x79, 0x9f, 0x3f, 0x12, 0xd8, 0x5d, 0x56, 0x7b, - 0x8a, 0x3c, 0x1e, 0xbf, 0x99, 0x79, 0x13, 0x88, 0xd3, 0x5c, 0x71, 0x99, 0x27, 0xd9, 0xac, 0x90, - 0x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d, 0xa4, 0x31, 0xb4, 0xf7, 0x59, 0x7a, 0xe0, 0x25, - 0xea, 0xe2, 0xea, 0xf4, 0x3e, 0x5c, 0xd4, 0xd2, 0xc9, 0xde, 0x7b, 0xd0, 0x73, 0xd3, 0xca, 0x42, - 0xe4, 0x25, 0xd7, 0x81, 0xbe, 0x48, 0x89, 0xf3, 0xb4, 0xf7, 0x71, 0x5d, 0xad, 0xc9, 0x12, 0xcd, - 0xfb, 0x17, 0x2f, 0xae, 0xf2, 0x10, 0xbc, 0xad, 0x4b, 0x85, 0xbe, 0x75, 0x31, 0x7a, 0xf4, 0x13, - 0xdf, 0xa6, 0xaf, 0xc9, 0x95, 0x78, 0x60, 0x18, 0x83, 0x2b, 0x86, 0xbd, 0x61, 0x7f, 0xa0, 0xb7, - 0x3e, 0x15, 0x42, 0xaa, 0x17, 0xd2, 0x7d, 0x95, 0xc9, 0x89, 0xbb, 0x74, 0x78, 0x34, 0xe9, 0x50, - 0xde, 0x55, 0x5b, 0x97, 0x6d, 0x2d, 0x10, 0x8a, 0xaf, 0x9b, 0xb6, 0xad, 0x28, 0x61, 0x23, 0x88, - 0x6b, 0x85, 0x1b, 0x89, 0xd9, 0x7b, 0xfc, 0x91, 0x92, 0xc3, 0x91, 0x3f, 0x1e, 0xa7, 0x9b, 0x20, - 0x0f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xbb, 0x74, 0xfe, 0x03, 0x03, 0x00, 0x00, + // 410 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x8e, 0xda, 0x30, + 0x10, 0x86, 0x15, 0xe2, 0x04, 0x32, 0x29, 0x01, 0xdc, 0x0b, 0xaa, 0x84, 0x8a, 0xcc, 0x05, 0xf5, + 0xc0, 0x01, 0xf5, 0x05, 0x0a, 0xb4, 0x2a, 0x42, 0x45, 0xb4, 0xa8, 0x3d, 0x37, 0xa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ff --git a/internal/internal.proto b/internal/internal.proto index 3fe5b6b83..91ebb3128 100644 --- a/internal/internal.proto +++ b/internal/internal.proto @@ -49,6 +49,7 @@ message QueryResponse { optional uint64 N = 3; repeated Pair Pairs = 4; repeated Profile Profiles = 5; + optional bool Changed = 6; } message ImportRequest { diff --git a/roaring/roaring.go b/roaring/roaring.go index 6aa49579c..020bbf62a 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -41,24 +41,28 @@ func NewBitmap(a ...uint64) *Bitmap { } // Add adds values to the bitmap. -func (b *Bitmap) Add(a ...uint64) error { +func (b *Bitmap) Add(a ...uint64) (bool, error) { + ret := false for _, v := range a { // Create an add operation. op := &op{typ: opTypeAdd, value: v} // Write operation to op log. if err := b.writeOp(op); err != nil { - return err + return false, err } // Apply to the in-memory bitmap. - op.apply(b) + if op.apply(b) { + ret = true + + } } - return nil + return ret, nil } -func (b *Bitmap) add(v uint64) { +func (b *Bitmap) add(v uint64) bool { hb := highbits(v) i := search64(b.keys, hb) @@ -69,7 +73,7 @@ func (b *Bitmap) add(v uint64) { i = -i - 1 } - b.containers[i].add(lowbits(v)) + return b.containers[i].add(lowbits(v)) } // Contains returns true if v is in the bitmap. @@ -82,29 +86,32 @@ func (b *Bitmap) Contains(v uint64) bool { } // Remove removes values from the bitmap. -func (b *Bitmap) Remove(a ...uint64) error { +func (b *Bitmap) Remove(a ...uint64) (bool, error) { + ret := false for _, v := range a { // Create an add operation. op := &op{typ: opTypeRemove, value: v} // Write operation to op log. if err := b.writeOp(op); err != nil { - return err + return false, err } // Apply operation to the bitmap. - op.apply(b) + if op.apply(b) { + ret = true + } } - return nil + return ret, nil } -func (b *Bitmap) remove(v uint64) { +func (b *Bitmap) remove(v uint64) bool { hb := highbits(v) i := search64(b.keys, hb) if i < 0 { - return + return false } - b.containers[i].remove(lowbits(v)) + return b.containers[i].remove(lowbits(v)) } // Slice returns a slice of all integers in the bitmap. @@ -429,34 +436,32 @@ func (c *container) unmap() { } // add adds a value to the container. -func (c *container) add(v uint16) { +func (c *container) add(v uint16) bool { if c.isArray() { - c.arrayAdd(v) - return + return c.arrayAdd(v) } - c.bitmapAdd(v) + return c.bitmapAdd(v) } -func (c *container) arrayAdd(v uint16) { +func (c *container) arrayAdd(v uint16) bool { // Optimize appending to the end of an array container. if c.n > 0 && c.n < arrayMaxSize && c.isArray() && c.array[c.n-1] < v { c.unmap() c.array = append(c.array, v) c.n++ - return + return true } // Find index of the integer in the container. Exit if it already exists. i := search16(c.array, v) if i >= 0 { - return + return false } // Convert to a bitmap container if too many values are in an array container. if c.n >= arrayMaxSize { c.convertToBitmap() - c.bitmapAdd(v) - return + return c.bitmapAdd(v) } // Otherwise insert into array. @@ -466,15 +471,17 @@ func (c *container) arrayAdd(v uint16) { copy(c.array[i+1:], c.array[i:]) c.array[i] = v c.n++ + return true } -func (c *container) bitmapAdd(v uint16) { +func (c *container) bitmapAdd(v uint16) bool { if c.bitmapContains(v) { - return + return false } c.unmap() c.bitmap[v/64] |= (1 << uint64(v%64)) c.n++ + return true } // contains returns true if v is in the container. @@ -494,28 +501,28 @@ func (c *container) bitmapContains(v uint16) bool { } // remove adds a value to the container. -func (c *container) remove(v uint16) { +func (c *container) remove(v uint16) bool { if c.isArray() { - c.arrayRemove(v) - return + return c.arrayRemove(v) } - c.bitmapRemove(v) + return c.bitmapRemove(v) } -func (c *container) arrayRemove(v uint16) { +func (c *container) arrayRemove(v uint16) bool { i := search16(c.array, v) if i < 0 { - return + return false } c.unmap() c.n-- c.array = append(c.array[:i], c.array[i+1:]...) + return true } -func (c *container) bitmapRemove(v uint16) { +func (c *container) bitmapRemove(v uint16) bool { if !c.bitmapContains(v) { - return + return false } c.unmap() @@ -527,6 +534,7 @@ func (c *container) bitmapRemove(v uint16) { if c.n == arrayMaxSize { c.convertToArray() } + return true } // convertToArray converts the values in the bitmap to array values. @@ -594,15 +602,16 @@ type op struct { } // apply executes the operation against a bitmap. -func (op *op) apply(b *Bitmap) { +func (op *op) apply(b *Bitmap) bool { switch op.typ { case opTypeAdd: - b.add(op.value) + return b.add(op.value) case opTypeRemove: - b.remove(op.value) + return b.remove(op.value) default: panic(fmt.Sprintf("invalid op type: %d", op.typ)) } + return false } // WriteTo writes op to the w. From 1aca83a546eaee1aadd2614d5a0541179dfa7acb Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 24 Feb 2016 15:02:24 -0600 Subject: [PATCH 2/4] align more with go idioms --- fragment.go | 8 ++++---- roaring/roaring.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fragment.go b/fragment.go index 6945261f5..f7b388855 100644 --- a/fragment.go +++ b/fragment.go @@ -326,7 +326,7 @@ func (f *Fragment) SetBit(bitmapID, profileID uint64, t *time.Time, q TimeQuantu func (f *Fragment) setBit(bitmapID, profileID uint64) (changed bool, bool error) { // Determine the position of the bit in the storage. - ret := false + changed = false pos, err := f.pos(bitmapID, profileID) if err != nil { return false, err @@ -334,15 +334,15 @@ func (f *Fragment) setBit(bitmapID, profileID uint64) (changed bool, bool error) // Write to storage. - if ret, err = f.storage.Add(pos); err != nil { + if changed, err = f.storage.Add(pos); err != nil { return false, err } // Update the cache. if f.bitmap(bitmapID).setBit(profileID) { - ret = true + changed = true } - return ret, nil + return changed, nil } diff --git a/roaring/roaring.go b/roaring/roaring.go index 020bbf62a..a87d4f5c1 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -41,8 +41,8 @@ func NewBitmap(a ...uint64) *Bitmap { } // Add adds values to the bitmap. -func (b *Bitmap) Add(a ...uint64) (bool, error) { - ret := false +func (b *Bitmap) Add(a ...uint64) (changed bool, err error) { + changed = false for _, v := range a { // Create an add operation. op := &op{typ: opTypeAdd, value: v} @@ -54,12 +54,12 @@ func (b *Bitmap) Add(a ...uint64) (bool, error) { // Apply to the in-memory bitmap. if op.apply(b) { - ret = true + changed = true } } - return ret, nil + return changed, nil } func (b *Bitmap) add(v uint64) bool { @@ -86,8 +86,8 @@ func (b *Bitmap) Contains(v uint64) bool { } // Remove removes values from the bitmap. -func (b *Bitmap) Remove(a ...uint64) (bool, error) { - ret := false +func (b *Bitmap) Remove(a ...uint64) (changed bool, err error) { + changed = false for _, v := range a { // Create an add operation. op := &op{typ: opTypeRemove, value: v} @@ -99,10 +99,10 @@ func (b *Bitmap) Remove(a ...uint64) (bool, error) { // Apply operation to the bitmap. if op.apply(b) { - ret = true + changed = true } } - return ret, nil + return changed, nil } func (b *Bitmap) remove(v uint64) bool { From c60773d33a0029bf6d6cd4875c0b5874324c2679 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Thu, 25 Feb 2016 15:43:52 -0600 Subject: [PATCH 3/4] issue 41 --- cmd/pilosa/main.go | 83 +++++++++++++++++++++++++++++++++++++++-- handler.go | 25 +++++++++++++ index.go | 17 ++++++--- internal/internal.pb.go | 78 ++++++++++++++++++++++++-------------- internal/internal.proto | 4 ++ 5 files changed, 170 insertions(+), 37 deletions(-) diff --git a/cmd/pilosa/main.go b/cmd/pilosa/main.go index cef5b4b6e..c15585747 100644 --- a/cmd/pilosa/main.go +++ b/cmd/pilosa/main.go @@ -5,9 +5,11 @@ import ( "flag" "fmt" "io" + "io/ioutil" "math/rand" "net" "net/http" + "net/url" "os" "os/signal" "os/user" @@ -18,7 +20,9 @@ import ( "time" "github.com/BurntSushi/toml" + "github.com/gogo/protobuf/proto" "github.com/umbel/pilosa" + "github.com/umbel/pilosa/internal" ) // Build holds the build information passed in at compile time. @@ -72,8 +76,10 @@ func main() { // Main represents the main program execution. type Main struct { - index *pilosa.Index - ln net.Listener + index *pilosa.Index + ln net.Listener + ticker *time.Ticker + pollingSecs int // Path to the configuration file. ConfigPath string @@ -94,7 +100,6 @@ type Main struct { func NewMain() *Main { return &Main{ Config: NewConfig(), - Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, @@ -176,13 +181,84 @@ func (m *Main) Run(args ...string) error { // Serve HTTP. go func() { http.Serve(ln, h) }() + //sync up max slice if more than one node + if len(cluster.Nodes) > 1 { + m.ticker = time.NewTicker(time.Second * time.Duration(m.pollingSecs)) + go func() { + for range m.ticker.C { + oldmax:= m.index.SliceN() + newmax:=oldmax + for _, node := range cluster.Nodes { + if hostname != node.Host { + newslice,_:=checkMaxSlice(node.Host) + if newslice>newmax{ + newmax= newslice + } + } + } + if newmax>oldmax{ + m.index.SetMax(newmax) + } + } + }() + } + fmt.Fprintf(m.Stderr, "Listening as http://%s\n", hostname) return nil } +func checkMaxSlice(hostport string) (uint64, error) { + + // Create HTTP request. + req, err := http.NewRequest("GET", (&url.URL{ + Scheme: "http", + Host: hostport, + Path: "/slices/max", + }).String(), nil) + + if err != nil { + return 0, err + } + + // Require protobuf encoding. + req.Header.Set("Accept", "application/x-protobuf") + req.Header.Set("Content-Type", "application/x-protobuf") + + // Send request to remote node. + resp, err := http.DefaultClient.Do(req) + if err != nil { + return 0, err + } + defer resp.Body.Close() + + // Read response into buffer. + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return 0, err + } + + // Check status code. + if resp.StatusCode != http.StatusOK { + return 0, fmt.Errorf("invalid status: code=%d, err=%s", resp.StatusCode, body) + } + + // Decode response object. + pb := internal.SliceMaxResponse{} + + if err = proto.Unmarshal(body, &pb); err != nil { + return 0, err + } + + return *pb.SliceMax, nil + +} + // Close shuts down the process. func (m *Main) Close() error { + if m.ticker != nil { + m.ticker.Stop() + } if m.ln != nil { m.ln.Close() } @@ -200,6 +276,7 @@ func (m *Main) ParseFlags(args []string) error { fs.SetOutput(m.Stderr) fs.StringVar(&m.ConfigPath, "config", "", "config path") fs.StringVar(&m.CPUProfile, "cpuprofile", "", "write cpu profile to file") + fs.IntVar(&m.pollingSecs, "pollingSecs", 60, "number of seconds to poll the cluster for maxslice") if err := fs.Parse(args); err != nil { return err } diff --git a/handler.go b/handler.go index 24201b84c..428bcdbf9 100644 --- a/handler.go +++ b/handler.go @@ -73,6 +73,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: http.Error(w, "method not allowed", http.StatusMethodNotAllowed) } + case "/slices/max": + switch r.Method { + case "GET": + h.handleGetSliceMax(w, r) + default: + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + } case "/version": h.handleVersion(w, r) @@ -135,6 +142,24 @@ func (h *Handler) handlePostQuery(w http.ResponseWriter, r *http.Request) { } } +func (h *Handler) handleGetSliceMax(w http.ResponseWriter, r *http.Request) error { + + sm := h.Index.SliceN() + if strings.Contains(r.Header.Get("Accept"), "application/x-protobuf") { + pb := &internal.SliceMaxResponse{ + SliceMax: &sm, + } + if buf, err := proto.Marshal(pb); err != nil { + return err + } else if _, err := w.Write(buf); err != nil { + return err + } + return nil + } + resp := map[string]uint64{"SliceMax": sm} + return json.NewEncoder(w).Encode(resp) +} + // readProfiles returns a list of profile objects by id. func (h *Handler) readProfiles(db *DB, ids []uint64) ([]*Profile, error) { if db == nil { diff --git a/index.go b/index.go index 8192d0010..56a2a5ef9 100644 --- a/index.go +++ b/index.go @@ -9,8 +9,9 @@ import ( // Index represents a container for fragments. type Index struct { - mu sync.Mutex - path string + mu sync.Mutex + path string + remoteMax uint64 // Databases by name. dbs map[string]*DB @@ -19,8 +20,9 @@ type Index struct { // NewIndex returns a new instance of Index. func NewIndex(path string) *Index { return &Index{ - path: path, - dbs: make(map[string]*DB), + path: path, + dbs: make(map[string]*DB), + remoteMax: 0, } } @@ -72,7 +74,7 @@ func (i *Index) SliceN() uint64 { i.mu.Lock() defer i.mu.Unlock() - var sliceN uint64 + sliceN := i.remoteMax for _, db := range i.dbs { if n := db.SliceN(); n > sliceN { sliceN = n @@ -154,3 +156,8 @@ func (i *Index) CreateFragmentIfNotExists(db, frame string, slice uint64) (*Frag } return f.CreateFragmentIfNotExists(slice) } +func (i *Index) SetMax(newmax uint64) { + i.mu.Lock() + defer i.mu.Unlock() + i.remoteMax = newmax +} diff --git a/internal/internal.pb.go b/internal/internal.pb.go index cf20adead..ae61096ca 100644 --- a/internal/internal.pb.go +++ b/internal/internal.pb.go @@ -21,6 +21,7 @@ It has these top-level messages: ImportRequest ImportResponse Cache + SliceMaxResponse */ package internal @@ -413,6 +414,23 @@ func (m *Cache) GetBitmapIDs() []uint64 { return nil } +type SliceMaxResponse struct { + SliceMax *uint64 `protobuf:"varint,1,req,name=SliceMax" json:"SliceMax,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SliceMaxResponse) Reset() { *m = SliceMaxResponse{} } +func (m *SliceMaxResponse) String() string { return proto.CompactTextString(m) } +func (*SliceMaxResponse) ProtoMessage() {} +func (*SliceMaxResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } + +func (m *SliceMaxResponse) GetSliceMax() uint64 { + if m != nil && m.SliceMax != nil { + return *m.SliceMax + } + return 0 +} + func init() { proto.RegisterType((*Bitmap)(nil), "internal.Bitmap") proto.RegisterType((*Chunk)(nil), "internal.Chunk") @@ -426,36 +444,38 @@ func init() { proto.RegisterType((*ImportRequest)(nil), "internal.ImportRequest") proto.RegisterType((*ImportResponse)(nil), "internal.ImportResponse") proto.RegisterType((*Cache)(nil), "internal.Cache") + proto.RegisterType((*SliceMaxResponse)(nil), "internal.SliceMaxResponse") } var fileDescriptor0 = []byte{ - // 436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x6e, 0xd4, 0x30, - 0x10, 0xc6, 0x95, 0x8d, 0x93, 0x4d, 0x26, 0x24, 0x6d, 0xcd, 0x25, 0x42, 0xaa, 0xa8, 0xdc, 0xcb, - 0x8a, 0x43, 0x0f, 0x15, 0x2f, 0xc0, 0x6e, 0x41, 0x54, 0x88, 0xaa, 0xa5, 0xc0, 0x19, 0xab, 0x98, - 0x6e, 0x44, 0x62, 0x07, 0xc7, 0x39, 0xf4, 0x65, 0x78, 0x56, 0xc6, 0x7f, 0x92, 0x2e, 0xb0, 0x88, - 0x53, 0x94, 0xcf, 0x63, 0x7f, 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x38, 0x03, 0x00, 0x00, + // 451 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe5, 0xf8, 0x23, 0xf6, 0x18, 0xbb, 0xe9, 0x72, 0xb1, 0x90, 0x2a, 0xaa, 0x2d, 0x87, + 0x88, 0x43, 0x0f, 0x15, 0x2f, 0x40, 0x52, 0x10, 0x15, 0x6a, 0xd5, 0x52, 0xe0, 0xcc, 0xaa, 0x2c, + 0x8d, 0x85, 0xbd, 0x6b, 0xd6, 0x6b, 0x89, 0xbe, 0x0c, 0xcf, 0xca, 0xec, 0x87, 0x9d, 0x00, 0x41, + 0x3d, 0x59, 0xfe, 0xef, 0xcc, 0xfc, 0x7f, 0xf3, 0x01, 0x65, 0x2d, 0x34, 0x57, 0x82, 0x35, 0xa7, + 0x9d, 0x92, 0x5a, 0x92, 0x74, 0xfc, 0xa7, 0xef, 0x20, 0x59, 0xd5, 0xba, 0x65, 0x1d, 0x79, 0x0e, + 0xc9, 0x7a, 0x33, 0x88, 0xef, 0x7d, 0x15, 0x1c, 0x87, 0xcb, 0xfc, 0xec, 0xe0, 0x74, 0x4a, 0xb2, + 0x3a, 0x39, 0x82, 0xf8, 0xb5, 0xd6, 0xaa, 0xaf, 0x66, 0xf6, 0xbd, 0xdc, 0xbe, 0x1b, 0x99, 0x9e, + 0x40, 0xec, 0xe2, 0x72, 0x08, 0xdf, 0xf3, 0x07, 0xac, 0x32, 0x5b, 0x46, 0xa4, 0x80, 0xf8, 0x33, + 0x6b, 0x06, 0x6e, 0x93, 0x22, 0x4a, 0x21, 0xba, 0x66, 0xb5, 0xfa, 0x27, 0x66, 0x2d, 0x07, 0xa1, + 0x31, 0x06, 0x7f, 0xe9, 0x4b, 0x08, 0x11, 0x89, 0x2c, 0x20, 0x75, 0x64, 0x17, 0xe7, 0x3e, 0xee, + 0x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, 0x4b, 0x08, 0xb8, 0xde, 0x30, 0x71, 0xcf, 0xbf, 0x5a, + 0xc0, 0x94, 0x7e, 0x81, 0xe2, 0xa2, 0xed, 0xa4, 0xd2, 0xff, 0x19, 0xc9, 0x5b, 0xc5, 0x5a, 0xee, + 0x47, 0x82, 0xbf, 0x76, 0x24, 0xc8, 0xe3, 0xef, 0x61, 0xbc, 0x10, 0xc7, 0x14, 0x11, 0xcc, 0x9e, + 0x4e, 0xc4, 0x51, 0x44, 0xf4, 0x08, 0xca, 0xd1, 0x61, 0xcf, 0x08, 0xe8, 0x33, 0xbc, 0x3e, 0x76, + 0xb7, 0xe1, 0x7f, 0x96, 0x0b, 0x6c, 0xea, 0x0b, 0x58, 0x58, 0xc3, 0x4b, 0xf6, 0x73, 0x4a, 0xc6, + 0x3d, 0x8c, 0x9a, 0xbb, 0xb6, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xf5, 0x8b, 0xab, 0x5e, + 0x03, 0x00, 0x00, } diff --git a/internal/internal.proto b/internal/internal.proto index 26a87bbf2..aaa34a6a2 100644 --- a/internal/internal.proto +++ b/internal/internal.proto @@ -69,3 +69,7 @@ message ImportResponse { message Cache { repeated uint64 BitmapIDs = 1; } + +message SliceMaxResponse { + required uint64 SliceMax = 1; +} From daf828d2a8eca25f9859ed714f59e66ae00d2bd6 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Thu, 25 Feb 2016 17:15:40 -0600 Subject: [PATCH 4/4] generated using go generate --- internal/internal.pb.go | 130 +++++++++++++--------------------------- 1 file changed, 42 insertions(+), 88 deletions(-) diff --git a/internal/internal.pb.go b/internal/internal.pb.go index ae61096ca..b28f58f3d 100644 --- a/internal/internal.pb.go +++ b/internal/internal.pb.go @@ -1,12 +1,12 @@ -// Code generated by protoc-gen-go. -// source: internal.proto +// Code generated by protoc-gen-gogo. +// source: internal/internal.proto // DO NOT EDIT! /* Package internal is a generated protocol buffer package. It is generated from these files: - internal.proto + internal/internal.proto It has these top-level messages: Bitmap @@ -40,10 +40,9 @@ type Bitmap struct { XXX_unrecognized []byte `json:"-"` } -func (m *Bitmap) Reset() { *m = Bitmap{} } -func (m *Bitmap) String() string { return proto.CompactTextString(m) } -func (*Bitmap) ProtoMessage() {} -func (*Bitmap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *Bitmap) Reset() { *m = Bitmap{} } +func (m *Bitmap) String() string { return proto.CompactTextString(m) } +func (*Bitmap) ProtoMessage() {} func (m *Bitmap) GetChunks() []*Chunk { if m != nil { @@ -65,10 +64,9 @@ type Chunk struct { XXX_unrecognized []byte `json:"-"` } -func (m *Chunk) Reset() { *m = Chunk{} } -func (m *Chunk) String() string { return proto.CompactTextString(m) } -func (*Chunk) ProtoMessage() {} -func (*Chunk) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +func (m *Chunk) Reset() { *m = Chunk{} } +func (m *Chunk) String() string { return proto.CompactTextString(m) } +func (*Chunk) ProtoMessage() {} func (m *Chunk) GetKey() uint64 { if m != nil && m.Key != nil { @@ -90,10 +88,9 @@ type Pair struct { XXX_unrecognized []byte `json:"-"` } -func (m *Pair) Reset() { *m = Pair{} } -func (m *Pair) String() string { return proto.CompactTextString(m) } -func (*Pair) ProtoMessage() {} -func (*Pair) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (m *Pair) Reset() { *m = Pair{} } +func (m *Pair) String() string { return proto.CompactTextString(m) } +func (*Pair) ProtoMessage() {} func (m *Pair) GetKey() uint64 { if m != nil && m.Key != nil { @@ -115,10 +112,9 @@ type Bit struct { XXX_unrecognized []byte `json:"-"` } -func (m *Bit) Reset() { *m = Bit{} } -func (m *Bit) String() string { return proto.CompactTextString(m) } -func (*Bit) ProtoMessage() {} -func (*Bit) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (m *Bit) Reset() { *m = Bit{} } +func (m *Bit) String() string { return proto.CompactTextString(m) } +func (*Bit) ProtoMessage() {} func (m *Bit) GetBitmapID() uint64 { if m != nil && m.BitmapID != nil { @@ -140,10 +136,9 @@ type Profile struct { XXX_unrecognized []byte `json:"-"` } -func (m *Profile) Reset() { *m = Profile{} } -func (m *Profile) String() string { return proto.CompactTextString(m) } -func (*Profile) ProtoMessage() {} -func (*Profile) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (m *Profile) Reset() { *m = Profile{} } +func (m *Profile) String() string { return proto.CompactTextString(m) } +func (*Profile) ProtoMessage() {} func (m *Profile) GetID() uint64 { if m != nil && m.ID != nil { @@ -167,10 +162,9 @@ type Attr struct { XXX_unrecognized []byte `json:"-"` } -func (m *Attr) Reset() { *m = Attr{} } -func (m *Attr) String() string { return proto.CompactTextString(m) } -func (*Attr) ProtoMessage() {} -func (*Attr) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (m *Attr) Reset() { *m = Attr{} } +func (m *Attr) String() string { return proto.CompactTextString(m) } +func (*Attr) ProtoMessage() {} func (m *Attr) GetKey() string { if m != nil && m.Key != nil { @@ -205,10 +199,9 @@ type AttrMap struct { XXX_unrecognized []byte `json:"-"` } -func (m *AttrMap) Reset() { *m = AttrMap{} } -func (m *AttrMap) String() string { return proto.CompactTextString(m) } -func (*AttrMap) ProtoMessage() {} -func (*AttrMap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } +func (m *AttrMap) Reset() { *m = AttrMap{} } +func (m *AttrMap) String() string { return proto.CompactTextString(m) } +func (*AttrMap) ProtoMessage() {} func (m *AttrMap) GetAttrs() []*Attr { if m != nil { @@ -227,10 +220,9 @@ type QueryRequest struct { XXX_unrecognized []byte `json:"-"` } -func (m *QueryRequest) Reset() { *m = QueryRequest{} } -func (m *QueryRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRequest) ProtoMessage() {} -func (*QueryRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} func (m *QueryRequest) GetDB() string { if m != nil && m.DB != nil { @@ -284,10 +276,9 @@ type QueryResponse struct { XXX_unrecognized []byte `json:"-"` } -func (m *QueryResponse) Reset() { *m = QueryResponse{} } -func (m *QueryResponse) String() string { return proto.CompactTextString(m) } -func (*QueryResponse) ProtoMessage() {} -func (*QueryResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} func (m *QueryResponse) GetErr() string { if m != nil && m.Err != nil { @@ -340,10 +331,9 @@ type ImportRequest struct { XXX_unrecognized []byte `json:"-"` } -func (m *ImportRequest) Reset() { *m = ImportRequest{} } -func (m *ImportRequest) String() string { return proto.CompactTextString(m) } -func (*ImportRequest) ProtoMessage() {} -func (*ImportRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } +func (m *ImportRequest) Reset() { *m = ImportRequest{} } +func (m *ImportRequest) String() string { return proto.CompactTextString(m) } +func (*ImportRequest) ProtoMessage() {} func (m *ImportRequest) GetDB() string { if m != nil && m.DB != nil { @@ -385,10 +375,9 @@ type ImportResponse struct { XXX_unrecognized []byte `json:"-"` } -func (m *ImportResponse) Reset() { *m = ImportResponse{} } -func (m *ImportResponse) String() string { return proto.CompactTextString(m) } -func (*ImportResponse) ProtoMessage() {} -func (*ImportResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } +func (m *ImportResponse) Reset() { *m = ImportResponse{} } +func (m *ImportResponse) String() string { return proto.CompactTextString(m) } +func (*ImportResponse) ProtoMessage() {} func (m *ImportResponse) GetErr() string { if m != nil && m.Err != nil { @@ -402,10 +391,9 @@ type Cache struct { XXX_unrecognized []byte `json:"-"` } -func (m *Cache) Reset() { *m = Cache{} } -func (m *Cache) String() string { return proto.CompactTextString(m) } -func (*Cache) ProtoMessage() {} -func (*Cache) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (m *Cache) Reset() { *m = Cache{} } +func (m *Cache) String() string { return proto.CompactTextString(m) } +func (*Cache) ProtoMessage() {} func (m *Cache) GetBitmapIDs() []uint64 { if m != nil { @@ -419,10 +407,9 @@ type SliceMaxResponse struct { XXX_unrecognized []byte `json:"-"` } -func (m *SliceMaxResponse) Reset() { *m = SliceMaxResponse{} } -func (m *SliceMaxResponse) String() string { return proto.CompactTextString(m) } -func (*SliceMaxResponse) ProtoMessage() {} -func (*SliceMaxResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } +func (m *SliceMaxResponse) Reset() { *m = SliceMaxResponse{} } +func (m *SliceMaxResponse) String() string { return proto.CompactTextString(m) } +func (*SliceMaxResponse) ProtoMessage() {} func (m *SliceMaxResponse) GetSliceMax() uint64 { if m != nil && m.SliceMax != nil { @@ -446,36 +433,3 @@ func init() { proto.RegisterType((*Cache)(nil), "internal.Cache") proto.RegisterType((*SliceMaxResponse)(nil), "internal.SliceMaxResponse") } - -var fileDescriptor0 = []byte{ - // 451 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0xe5, 0xf8, 0x23, 0xf6, 0x18, 0xbb, 0xe9, 0x72, 0xb1, 0x90, 0x2a, 0xaa, 0x2d, 0x87, - 0x88, 0x43, 0x0f, 0x15, 0x2f, 0x40, 0x52, 0x10, 0x15, 0x6a, 0xd5, 0x52, 0xe0, 0xcc, 0xaa, 0x2c, - 0x8d, 0x85, 0xbd, 0x6b, 0xd6, 0x6b, 0x89, 0xbe, 0x0c, 0xcf, 0xca, 0xec, 0x87, 0x9d, 0x00, 0x41, - 0x3d, 0x59, 0xfe, 0xef, 0xcc, 0xfc, 0x7f, 0xf3, 0x01, 0x65, 0x2d, 0x34, 0x57, 0x82, 0x35, 0xa7, - 0x9d, 0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