From 164b7619aa8353c61c85576d61d19bfa23f499ad Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Wed, 30 May 2018 16:40:21 +0300 Subject: [PATCH 01/52] Removes bench command --- cmd/bench.go | 57 --------------------- cmd/bench_test.go | 54 -------------------- ctl/bench.go | 116 ------------------------------------------- ctl/bench_test.go | 98 ------------------------------------ ctl/import_test.go | 10 ++++ docs/installation.md | 5 -- 6 files changed, 10 insertions(+), 330 deletions(-) delete mode 100644 cmd/bench.go delete mode 100644 cmd/bench_test.go delete mode 100644 ctl/bench.go delete mode 100644 ctl/bench_test.go diff --git a/cmd/bench.go b/cmd/bench.go deleted file mode 100644 index d4b2b8580..000000000 --- a/cmd/bench.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cmd - -import ( - "context" - "io" - "os" - - "github.com/spf13/cobra" - - "github.com/pilosa/pilosa/ctl" -) - -var Bencher *ctl.BenchCommand - -func NewBenchCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - Bencher = ctl.NewBenchCommand(os.Stdin, os.Stdout, os.Stderr) - benchCmd := &cobra.Command{ - Use: "bench", - Short: "Benchmark operations.", - Long: ` -Executes a benchmark for a given operation against the index. -`, - RunE: func(cmd *cobra.Command, args []string) error { - if err := Bencher.Run(context.Background()); err != nil { - return err - } - return nil - }, - } - flags := benchCmd.Flags() - flags.StringVarP(&Bencher.Host, "host", "", "localhost:10101", "host:port of Pilosa.") - flags.StringVarP(&Bencher.Index, "index", "i", "", "Pilosa index to benchmark.") - flags.StringVarP(&Bencher.Frame, "frame", "f", "", "Frame to benchmark.") - flags.StringVarP(&Bencher.Op, "operation", "o", "set-bit", "Operation to perform: choose from [set-bit]") - flags.IntVarP(&Bencher.N, "num", "n", 0, "Number of operations to perform.") - ctl.SetTLSConfig(flags, &Bencher.TLS.CertificatePath, &Bencher.TLS.CertificateKeyPath, &Bencher.TLS.SkipVerify) - - return benchCmd -} - -func init() { - subcommandFns["bench"] = NewBenchCommand -} diff --git a/cmd/bench_test.go b/cmd/bench_test.go deleted file mode 100644 index 4b94d9392..000000000 --- a/cmd/bench_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cmd_test - -import ( - "strings" - "testing" - - "github.com/pilosa/pilosa/cmd" -) - -func TestBenchHelp(t *testing.T) { - output, err := ExecNewRootCommand(t, "bench", "--help") - if !strings.Contains(output, "Usage:") || - !strings.Contains(output, "Flags:") || - !strings.Contains(output, "pilosa bench") || err != nil { - t.Fatalf("Command 'bench --help' not working, err: '%v', output: '%s'", err, output) - } -} - -func TestBenchConfig(t *testing.T) { - tests := []commandTest{ - { - args: []string{"bench", "--operation", "set-bit"}, - env: map[string]string{"PILOSA_HOST": "localhost:12345"}, - cfgFileContent: ` -index = "myindex" -frame = "f1" -`, - validation: func() error { - v := validator{} - v.Check(cmd.Bencher.Host, "localhost:12345") - v.Check(cmd.Bencher.Index, "myindex") - v.Check(cmd.Bencher.Frame, "f1") - v.Check(cmd.Bencher.Op, "set-bit") - v.Check(cmd.Bencher.N, 0) - return v.Error() - }, - }, - } - executeDry(t, tests) -} diff --git a/ctl/bench.go b/ctl/bench.go deleted file mode 100644 index 4a71169d9..000000000 --- a/ctl/bench.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ctl - -import ( - "context" - "fmt" - "io" - "math/rand" - "time" - - "github.com/pilosa/pilosa" - "github.com/pilosa/pilosa/internal" - "github.com/pilosa/pilosa/server" - "github.com/pkg/errors" -) - -// BenchCommand represents a command for benchmarking index operations. -type BenchCommand struct { - // Destination host and port. - Host string - - // Name of the index & frame to execute against. - Index string - Frame string - - // Type of operation and number to execute. - Op string - N int - - // Standard input/output - *pilosa.CmdIO - - TLS server.TLSConfig -} - -// NewBenchCommand returns a new instance of BenchCommand. -func NewBenchCommand(stdin io.Reader, stdout, stderr io.Writer) *BenchCommand { - return &BenchCommand{ - CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr), - } -} - -// Run executes the bench command. -func (cmd *BenchCommand) Run(ctx context.Context) error { - // Create a client to the server. - client, err := CommandClient(cmd) - if err != nil { - return errors.Wrap(err, "creating client") - } - - switch cmd.Op { - case "set-bit": - return cmd.runSetBit(ctx, client) - case "": - return errors.New("op required") - default: - return fmt.Errorf("unknown bench op: %q", cmd.Op) - } -} - -// runSetBit executes a benchmark of random SetBit() operations. -func (cmd *BenchCommand) runSetBit(ctx context.Context, client pilosa.InternalClient) error { - if cmd.N == 0 { - return errors.New("operation count required") - } else if cmd.Index == "" { - return pilosa.ErrIndexRequired - } else if cmd.Frame == "" { - return pilosa.ErrFrameRequired - } - - const maxRowID = 1000 - const maxColumnID = 100000 - - startTime := time.Now() - - // Execute operation continuously. - for i := 0; i < cmd.N; i++ { - rowID := rand.Intn(maxRowID) - columnID := rand.Intn(maxColumnID) - - queryRequest := &internal.QueryRequest{ - Query: fmt.Sprintf(`SetBit(row=%d, frame="%s", col=%d)`, rowID, cmd.Frame, columnID), - Remote: false, - } - if _, err := client.Query(ctx, cmd.Index, queryRequest); err != nil { - return err - } - } - - // Print results. - elapsed := time.Since(startTime) - fmt.Fprintf(cmd.Stdout, "Executed %d operations in %s (%0.3f op/sec)\n", cmd.N, elapsed, float64(cmd.N)/elapsed.Seconds()) - - return nil -} - -func (cmd *BenchCommand) TLSHost() string { - return cmd.Host -} - -func (cmd *BenchCommand) TLSConfiguration() server.TLSConfig { - return cmd.TLS -} diff --git a/ctl/bench_test.go b/ctl/bench_test.go deleted file mode 100644 index 766ec8a1a..000000000 --- a/ctl/bench_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ctl - -import ( - "bufio" - "bytes" - "context" - "fmt" - "io" - "os" - "testing" - - "github.com/pilosa/pilosa" - "github.com/pkg/errors" -) - -func TestBenchCommand_InvalidOption(t *testing.T) { - buf := bytes.Buffer{} - stdin, stdout, stderr := GetIO(buf) - - cm := NewBenchCommand(stdin, stdout, stderr) - err := cm.Run(context.Background()) - if errors.Cause(err) != pilosa.ErrHostRequired { - t.Fatalf("Expect err: %s, actual err: %s", pilosa.ErrHostRequired, err) - } - - cm.Host = "localhost:10101" - err = cm.Run(context.Background()) - if err.Error() != "op required" { - t.Fatalf("Expect err: %s, actual err: %s", "op required", err) - } - - cm.Op = "test" - err = cm.Run(context.Background()) - if err.Error() != "unknown bench op: \"test\"" { - t.Fatalf("Expect err: %s, actual err: %s", "unknown bench op: test", err) - } - -} - -func TestBenchCommand_Run(t *testing.T) { - rder := []byte{} - stdin := bytes.NewReader(rder) - r, w, _ := os.Pipe() - - cm := NewBenchCommand(stdin, w, w) - cm.Op = "set-bit" - cm.Host = "localhost:10101" - - err := cm.Run(context.Background()) - if err.Error() != "operation count required" { - t.Fatalf("Expect error: %s, actual err: %s", "operation count required", err) - } - - cm.N = 1 - err = cm.Run(context.Background()) - if err != pilosa.ErrIndexRequired { - t.Fatalf("Expect error: %s, actual err: %s", pilosa.ErrIndexRequired, err) - } - - cm.Index = "i" - err = cm.Run(context.Background()) - if err != pilosa.ErrFrameRequired { - t.Fatalf("Expect error: %s, actual err: %s", pilosa.ErrFrameRequired, err) - } - - cm.Frame = "f" - err = cm.Run(context.Background()) - w.Close() - var buf bytes.Buffer - io.Copy(&buf, r) - fmt.Println(buf.String()) - if err != nil { - fmt.Println(buf.String()) - } -} - -// declare stdin, stdout, stderr -func GetIO(buf bytes.Buffer) (io.Reader, io.Writer, io.Writer) { - rder := []byte{} - stdin := bytes.NewReader(rder) - stdout := bufio.NewWriter(&buf) - stderr := bufio.NewWriter(&buf) - return stdin, stdout, stderr -} diff --git a/ctl/import_test.go b/ctl/import_test.go index 08eea8323..a11770bd8 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -15,6 +15,7 @@ package ctl import ( + "bufio" "bytes" "context" "io" @@ -180,3 +181,12 @@ func MustNewHTTPRequest(method, urlStr string, body io.Reader) *http.Request { } return req } + +// declare stdin, stdout, stderr +func GetIO(buf bytes.Buffer) (io.Reader, io.Writer, io.Writer) { + rder := []byte{} + stdin := bytes.NewReader(rder) + stdout := bufio.NewWriter(&buf) + stderr := bufio.NewWriter(&buf) + return stdin, stdout, stderr +} diff --git a/docs/installation.md b/docs/installation.md index 039ea370d..cf743721f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -49,7 +49,6 @@ There are four ways to install Pilosa on MacOS: Use [Homebrew](https://brew.sh/) pilosa [command] Available Commands: - bench Benchmark operations. check Do a consistency check on a pilosa data file. config Print the current configuration. export Export data from pilosa. @@ -108,7 +107,6 @@ There are four ways to install Pilosa on MacOS: Use [Homebrew](https://brew.sh/) pilosa [command] Available Commands: - bench Benchmark operations. check Do a consistency check on a pilosa data file. config Print the current configuration. export Export data from pilosa. @@ -173,7 +171,6 @@ There are four ways to install Pilosa on MacOS: Use [Homebrew](https://brew.sh/) pilosa [command] Available Commands: - bench Benchmark operations. check Do a consistency check on a pilosa data file. config Print the current configuration. export Export data from pilosa. @@ -262,7 +259,6 @@ There are three ways to install Pilosa on Linux: download the binary (recommende pilosa [command] Available Commands: - bench Benchmark operations. check Do a consistency check on a pilosa data file. config Print the current configuration. export Export data from pilosa. @@ -327,7 +323,6 @@ There are three ways to install Pilosa on Linux: download the binary (recommende pilosa [command] Available Commands: - bench Benchmark operations. check Do a consistency check on a pilosa data file. config Print the current configuration. export Export data from pilosa. From 908066a650b4d599f9e8a7711793ae6a0a95637f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 30 May 2018 11:08:49 -0500 Subject: [PATCH 02/52] Exclude/remove CI matrix configurations to speed up CI process. --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fbe1e0c9b..4d413ec3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,16 @@ deploy: go: "1.10" condition: $GOARCH = amd64 matrix: + # Excluding or allowing failures on non-primary matrix configurations due to long running times. + fast_finish: true allow_failures: - go: master - fast_finish: true + - go: 1.9 + exclude: + - go: 1.9 + env: GOARCH=386 + - go: 1.9 + env: GOARCH=amd64 notifications: slack: secure: "SceWannxoGzeSu9PlEhl6icQFGuTmwax870k20nB2ZGYLjo77UEcwYoFwWvFsdYPa/HCo3JorMTYvMJ15VDJcnKEfzDr+kyXbHWBzUumclIOU/Im3ArEN6waQgyGbbWUQhvJjy4ATaxiOlmCyDV+KhKC9P3+WB33/OQtM3ngjAdTXYHAkfEcpeoOP75um+KsQgbi+hlnqfZdgDa6yIkFjaS3KZEJW1vmcOYYzNsXOA1Ip8j1NY6AjjWZlQorZJ/SYFqdhIv8ST3+a6cQk12u3t6TwZdcr3wmm1qmiW/SaK7UesWlT/YfElIuK8BBq9w1oZHxNKoAmLWTOe7MMisdItmtwgA14eMGl1rvNFlVf9sjsxs4AAzFvSZBZdDfx9XeLCBU5I2WUc/PKUgNQBPMVChxA7gEhtZLndsDdye7LsZASD2yYqjlVlgoZpzRexee/cJgCqUcNKDBHF39ZJYxV4KtZ0prjcSnVmLvuapplzTV4LZ+LyFapCyhiuM/oMJvxgmd7jTtFb5e5EkaHBPN1XwQWZw87yCjKsunTlTe1f1a5qoH/xvJHNpqE/jxOHU3DTLDgTxhb+FwC1Qj9a8bp+UYLw5F4P46ZnHlBGc2O74klv17EqvUMn3JhzASUtyxLGOgJulJ+o83rxJvhSiWt3GQIfkExVPzmz11641ElJI=" From c1c89b9ef850e82f339f81b90337505700fc2a63 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Fri, 1 Jun 2018 09:18:23 -0500 Subject: [PATCH 03/52] fix generate-config command, use single toml lib The generate-config command was printing a fixed string rather than calling NewConfig() which is the canonical source for default config. I also noticed that we were depending on two different toml libraries, and so collapsed that to a single one. We have to use pelletier rather than BurntSushi because the viper library that we use depends on pelletier. --- Gopkg.lock | 16 +++++++++------- ctl/generate_config.go | 33 +++++++++------------------------ ctl/generate_config_test.go | 2 +- server/server_test.go | 4 ++-- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 8bb1744bd..0b4a8e9ea 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,12 +1,6 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. -[[projects]] - name = "github.com/BurntSushi/toml" - packages = ["."] - revision = "b26d9c308763d68093482582cea63d69be07a0f0" - version = "v0.3.0" - [[projects]] branch = "master" name = "github.com/CAFxX/gcnotifier" @@ -212,14 +206,22 @@ [[projects]] name = "github.com/shirou/gopsutil" packages = [ + "cpu", "host", "internal/common", "mem", + "net", "process" ] revision = "bfe3c2e8f406bf352bc8df81f98c752224867349" version = "v2.17.11" +[[projects]] + branch = "master" + name = "github.com/shirou/w32" + packages = ["."] + revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b" + [[projects]] branch = "master" name = "github.com/spf13/afero" @@ -302,6 +304,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "8f633d73d966ca439d2fdf3704a41d8ea59be8ed9a2cab0ab73de4b72c5772ba" + inputs-digest = "325d0fb217ec7f1509186ff947e184f6c8e65941f06000eb110180e65816b1a4" solver-name = "gps-cdcl" solver-version = 1 diff --git a/ctl/generate_config.go b/ctl/generate_config.go index a64678475..a9429ec80 100644 --- a/ctl/generate_config.go +++ b/ctl/generate_config.go @@ -18,9 +18,11 @@ import ( "context" "fmt" "io" - "strings" + "github.com/pelletier/go-toml" "github.com/pilosa/pilosa" + "github.com/pilosa/pilosa/server" + "github.com/pkg/errors" ) // GenerateConfigCommand represents a command for printing a default config. @@ -37,28 +39,11 @@ func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *Genera // Run prints out the default config. func (cmd *GenerateConfigCommand) Run(ctx context.Context) error { - fmt.Fprintln(cmd.Stdout, strings.TrimSpace(` -data-dir = "~/.pilosa" -bind = "localhost:10101" -max-writes-per-request = 5000 - -[cluster] - replicas = 1 - hosts = [ - "localhost:10101", - ] - -[anti-entropy] - interval = "10m0s" - -[profile] - cpu = "" - cpu-time = "30s" - -[metric] - service = "statsd" - host = "127.0.0.1:8125" - poll-interval = "0m15s" -`)+"\n") + conf := server.NewConfig() + ret, err := toml.Marshal(*conf) + if err != nil { + return errors.Wrap(err, "unmarshaling default config") + } + fmt.Fprintf(cmd.Stdout, "%s\n", ret) return nil } diff --git a/ctl/generate_config_test.go b/ctl/generate_config_test.go index 56f392bba..26b531e8f 100644 --- a/ctl/generate_config_test.go +++ b/ctl/generate_config_test.go @@ -34,7 +34,7 @@ func TestGenerateConfigCommand_Run(t *testing.T) { io.Copy(&buf, r) if err != nil { t.Fatalf("Config Run doesn't work: %s", err) - } else if !strings.Contains(buf.String(), "localhost:10101") { + } else if !strings.Contains(buf.String(), ":10101") { t.Fatalf("Unexpected config: %s", buf.String()) } } diff --git a/server/server_test.go b/server/server_test.go index 9092212b2..edac4b6fd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -27,7 +27,7 @@ import ( "testing" "testing/quick" - "github.com/BurntSushi/toml" + "github.com/pelletier/go-toml" "github.com/pilosa/pilosa" "github.com/pilosa/pilosa/server" "github.com/pilosa/pilosa/test" @@ -374,7 +374,7 @@ func GenerateSetCommands(n int, rand *rand.Rand) []SetCommand { // ParseConfig parses s into a Config. func ParseConfig(s string) (server.Config, error) { var c server.Config - _, err := toml.Decode(s, &c) + err := toml.Unmarshal([]byte(s), &c) return c, err } From a6a121d19f8e1861f5c5386ebe518cdee4285637 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Sat, 2 Jun 2018 09:59:11 -0500 Subject: [PATCH 04/52] add toml tag to config.Handler --- server/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/config.go b/server/config.go index 663e9e18c..6c7db569a 100644 --- a/server/config.go +++ b/server/config.go @@ -61,7 +61,7 @@ type Config struct { Handler struct { // CORS Allowed Origins AllowedOrigins []string `toml:"allowed-origins"` - } + } `toml:"handler"` // TLS TLS TLSConfig `toml:"tls"` From 4edc80ea62181245b17c24b6991d6e7b24ef8fb2 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Thu, 31 May 2018 11:17:34 -0500 Subject: [PATCH 05/52] unexport Field --- api.go | 4 ++-- frame.go | 38 +++++++++++++++++++------------------- handler.go | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/api.go b/api.go index 252480d52..23d8db316 100644 --- a/api.go +++ b/api.go @@ -489,7 +489,7 @@ func (api *API) Schema(ctx context.Context) []*IndexInfo { } // CreateField creates a new BSI field in the given index and frame. -func (api *API) CreateField(ctx context.Context, indexName string, frameName string, field *Field) error { +func (api *API) CreateField(ctx context.Context, indexName string, frameName string, field *oField) error { if err := api.validate(apiCreateField); err != nil { return errors.Wrap(err, "validating api method") } @@ -549,7 +549,7 @@ func (api *API) DeleteField(ctx context.Context, indexName string, frameName str } // Fields returns the fields in the given frame. -func (api *API) Fields(ctx context.Context, indexName string, frameName string) ([]*Field, error) { +func (api *API) Fields(ctx context.Context, indexName string, frameName string) ([]*oField, error) { if err := api.validate(apiFields); err != nil { return nil, errors.Wrap(err, "validating api method") } diff --git a/frame.go b/frame.go index ab005edcc..c9151c21b 100644 --- a/frame.go +++ b/frame.go @@ -56,7 +56,7 @@ type Frame struct { cacheType string cacheSize uint32 timeQuantum TimeQuantum - fields []*Field + fields []*oField Logger Logger } @@ -296,7 +296,7 @@ func (f *Frame) Close() error { } // Field returns a field by name. -func (f *Frame) Field(name string) *Field { +func (f *Frame) Field(name string) *oField { f.mu.RLock() defer f.mu.RUnlock() for _, field := range f.fields { @@ -308,7 +308,7 @@ func (f *Frame) Field(name string) *Field { } // Fields returns the fields on the frame. -func (f *Frame) Fields() []*Field { +func (f *Frame) Fields() []*oField { f.mu.RLock() defer f.mu.RUnlock() return f.fields @@ -325,7 +325,7 @@ func (f *Frame) HasField(name string) bool { } // CreateField creates a new field on the frame. -func (f *Frame) CreateField(field *Field) error { +func (f *Frame) CreateField(field *oField) error { f.mu.Lock() defer f.mu.Unlock() @@ -338,7 +338,7 @@ func (f *Frame) CreateField(field *Field) error { } // addField adds a single field to fields. -func (f *Frame) addField(field *Field) error { +func (f *Frame) addField(field *oField) error { if err := ValidateField(field); err != nil { return errors.Wrap(err, "validating field") } else if f.HasField(field.Name) { @@ -357,7 +357,7 @@ func (f *Frame) addField(field *Field) error { } // GetFields returns a list of all the fields in the frame. -func (f *Frame) GetFields() ([]*Field, error) { +func (f *Frame) GetFields() ([]*oField, error) { f.mu.RLock() defer f.mu.RUnlock() @@ -950,7 +950,7 @@ type FrameOptions struct { CacheType string `json:"cacheType,omitempty"` CacheSize uint32 `json:"cacheSize,omitempty"` TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` - Fields []*Field `json:"fields,omitempty"` + Fields []*oField `json:"fields,omitempty"` } // Encode converts o into its internal representation. @@ -996,8 +996,8 @@ func IsValidFieldType(v string) bool { } } -// Field represents a range field on a frame. -type Field struct { +// oField represents a range field on a frame. +type oField struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Min int64 `json:"min,omitempty"` @@ -1005,7 +1005,7 @@ type Field struct { } // BitDepth returns the number of bits required to store a value between min & max. -func (f *Field) BitDepth() uint { +func (f *oField) BitDepth() uint { for i := uint(0); i < 63; i++ { if f.Max-f.Min < (1 << i) { return i @@ -1026,7 +1026,7 @@ func (f *Field) BitDepth() uint { // In order to make this work, we effectively need to change the operator to LTE. // Executor.executeFieldRangeSlice() takes this into account and returns // `frag.FieldNotNull(field.BitDepth())` in such instances. -func (f *Field) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { +func (f *oField) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { if op == pql.GT || op == pql.GTE { if value > f.Max { return baseValue, true @@ -1051,7 +1051,7 @@ func (f *Field) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRan } // BaseValueBetween adjusts the min/max value to align with the range for Field. -func (f *Field) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { +func (f *oField) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { if max < f.Min || min > f.Max { return baseValueMin, baseValueMax, true } @@ -1068,7 +1068,7 @@ func (f *Field) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uin return baseValueMin, baseValueMax, false } -func ValidateField(f *Field) error { +func ValidateField(f *oField) error { if f.Name == "" { return ErrFieldNameRequired } else if !IsValidFieldType(f.Type) { @@ -1079,7 +1079,7 @@ func ValidateField(f *Field) error { return nil } -func encodeFields(a []*Field) []*internal.Field { +func encodeFields(a []*oField) []*internal.Field { if len(a) == 0 { return nil } @@ -1090,18 +1090,18 @@ func encodeFields(a []*Field) []*internal.Field { return other } -func decodeFields(a []*internal.Field) []*Field { +func decodeFields(a []*internal.Field) []*oField { if len(a) == 0 { return nil } - other := make([]*Field, len(a)) + other := make([]*oField, len(a)) for i := range a { other[i] = decodeField(a[i]) } return other } -func encodeField(f *Field) *internal.Field { +func encodeField(f *oField) *internal.Field { if f == nil { return nil } @@ -1113,11 +1113,11 @@ func encodeField(f *Field) *internal.Field { } } -func decodeField(f *internal.Field) *Field { +func decodeField(f *internal.Field) *oField { if f == nil { return nil } - return &Field{ + return &oField{ Name: f.Name, Type: f.Type, Min: f.Min, diff --git a/handler.go b/handler.go index 9ddabaeeb..5b0e0cb05 100644 --- a/handler.go +++ b/handler.go @@ -621,7 +621,7 @@ func (h *Handler) handlePostFrameField(w http.ResponseWriter, r *http.Request) { return } - field := &Field{ + field := &oField{ Name: fieldName, Type: req.Type, Min: req.Min, @@ -696,7 +696,7 @@ func (h *Handler) handleGetFrameFields(w http.ResponseWriter, r *http.Request) { } type getFrameFieldsResponse struct { - Fields []*Field `json:"fields,omitempty"` + Fields []*oField `json:"fields,omitempty"` } type deleteFrameFieldResponse struct{} From a60ff2d1e07106f5014b2a83752a2c81f6e8ce81 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Thu, 31 May 2018 11:36:40 -0500 Subject: [PATCH 06/52] remove field from handler endpoints --- cluster_test.go | 2 +- handler.go | 96 ------------------------------------------------- 2 files changed, 1 insertion(+), 97 deletions(-) diff --git a/cluster_test.go b/cluster_test.go index 913cd5db3..a2570c41a 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -424,7 +424,7 @@ func TestCluster_ResizeStates(t *testing.T) { // Add Field Data to node0. if err := tc.CreateFrame("i", "fields", FrameOptions{ - Fields: []*Field{ + Fields: []*oField{ { Name: "fld0", Type: FieldTypeInt, diff --git a/handler.go b/handler.go index 5b0e0cb05..d4ed5ab37 100644 --- a/handler.go +++ b/handler.go @@ -169,9 +169,6 @@ func NewRouter(handler *Handler) *mux.Router { router.HandleFunc("/index/{index}/frame/{frame}", handler.handlePostFrame).Methods("POST") router.HandleFunc("/index/{index}/frame/{frame}", handler.handleDeleteFrame).Methods("DELETE") router.HandleFunc("/index/{index}/frame/{frame}/attr/diff", handler.handlePostFrameAttrDiff).Methods("POST") - router.HandleFunc("/index/{index}/frame/{frame}/field/{field}", handler.handlePostFrameField).Methods("POST") - router.HandleFunc("/index/{index}/frame/{frame}/fields", handler.handleGetFrameFields).Methods("GET") - router.HandleFunc("/index/{index}/frame/{frame}/field/{field}", handler.handleDeleteFrameField).Methods("DELETE") router.HandleFunc("/index/{index}/query", handler.handlePostQuery).Methods("POST").Name("PostQuery") router.HandleFunc("/recalculate-caches", handler.handleRecalculateCaches).Methods("POST") @@ -608,99 +605,6 @@ func (h *Handler) handleDeleteFrame(w http.ResponseWriter, r *http.Request) { type deleteFrameResponse struct{} -// handlePostFrameField handles POST /frame/field request. -func (h *Handler) handlePostFrameField(w http.ResponseWriter, r *http.Request) { - indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] - fieldName := mux.Vars(r)["field"] - - // Decode request. - var req postFrameFieldRequest - if err := json.NewDecoder(r.Body).Decode(&req); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - field := &oField{ - Name: fieldName, - Type: req.Type, - Min: req.Min, - Max: req.Max, - } - - if err := h.API.CreateField(r.Context(), indexName, frameName, field); err != nil { - if errors.Cause(err) == ErrFrameNotFound { - http.Error(w, err.Error(), http.StatusNotFound) - } else { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - return - } - - // Encode response. - if err := json.NewEncoder(w).Encode(postFrameFieldResponse{}); err != nil { - h.Logger.Printf("response encoding error: %s", err) - } -} - -type postFrameFieldRequest struct { - Type string `json:"type,omitempty"` - Min int64 `json:"min,omitempty"` - Max int64 `json:"max,omitempty"` -} - -type postFrameFieldResponse struct{} - -// handleDeleteFrameField handles DELETE /frame/field request. -func (h *Handler) handleDeleteFrameField(w http.ResponseWriter, r *http.Request) { - indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] - fieldName := mux.Vars(r)["field"] - - if err := h.API.DeleteField(r.Context(), indexName, frameName, fieldName); err != nil { - if errors.Cause(err) == ErrFrameNotFound { - http.Error(w, err.Error(), http.StatusNotFound) - } else { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - return - } - - // Encode response. - if err := json.NewEncoder(w).Encode(deleteFrameFieldResponse{}); err != nil { - h.Logger.Printf("response encoding error: %s", err) - } -} - -func (h *Handler) handleGetFrameFields(w http.ResponseWriter, r *http.Request) { - indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] - - fields, err := h.API.Fields(r.Context(), indexName, frameName) - if err != nil { - switch errors.Cause(err) { - case ErrIndexNotFound: - fallthrough - case ErrFrameNotFound: - http.Error(w, err.Error(), http.StatusNotFound) - default: - http.Error(w, err.Error(), http.StatusInternalServerError) - } - return - } - - // Encode response. - if err := json.NewEncoder(w).Encode(getFrameFieldsResponse{Fields: fields}); err != nil { - h.Logger.Printf("response encoding error: %s", err) - } -} - -type getFrameFieldsResponse struct { - Fields []*oField `json:"fields,omitempty"` -} - -type deleteFrameFieldResponse struct{} - // handlePostFrameAttrDiff handles POST /frame/attr/diff requests. func (h *Handler) handlePostFrameAttrDiff(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] From d799967fc60eb22a90febb0036b9f4270ce9471a Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 16:16:02 -0500 Subject: [PATCH 07/52] add Type to frame so support BSI frame type "int" --- api.go | 21 --- apimethod_string.go | 8 +- diagnostics.go | 4 +- frame.go | 200 ++++++++++++++------- index.go | 27 +-- internal/private.pb.go | 400 ++++++++++++++++++++++++----------------- internal/private.proto | 5 +- internal/public.pb.go | 35 +++- 8 files changed, 418 insertions(+), 282 deletions(-) diff --git a/api.go b/api.go index 23d8db316..c02aedbf2 100644 --- a/api.go +++ b/api.go @@ -548,25 +548,6 @@ func (api *API) DeleteField(ctx context.Context, indexName string, frameName str return errors.Wrap(err, "sending DeleteField message") } -// Fields returns the fields in the given frame. -func (api *API) Fields(ctx context.Context, indexName string, frameName string) ([]*oField, error) { - if err := api.validate(apiFields); err != nil { - return nil, errors.Wrap(err, "validating api method") - } - - index := api.Holder.index(indexName) - if index == nil { - return nil, ErrIndexNotFound - } - - frame := index.frame(frameName) - if frame == nil { - return nil, ErrFrameNotFound - } - - return frame.GetFields() -} - // Views returns the views in the given frame. func (api *API) Views(ctx context.Context, indexName string, frameName string) ([]*View, error) { if err := api.validate(apiViews); err != nil { @@ -877,7 +858,6 @@ const ( apiDeleteIndex apiDeleteView apiExportCSV - apiFields apiFragmentBlockData apiFragmentBlocks apiFrameAttrDiff @@ -923,7 +903,6 @@ var methodsNormal = map[apiMethod]struct{}{ apiDeleteIndex: struct{}{}, apiDeleteView: struct{}{}, apiExportCSV: struct{}{}, - apiFields: struct{}{}, apiFragmentBlockData: struct{}{}, apiFragmentBlocks: struct{}{}, apiFrameAttrDiff: struct{}{}, diff --git a/apimethod_string.go b/apimethod_string.go index 2eb2913ae..0fc3822d5 100644 --- a/apimethod_string.go +++ b/apimethod_string.go @@ -2,15 +2,15 @@ package pilosa -import "strconv" +import "fmt" -const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateFrameapiCreateIndexapiDeleteFieldapiDeleteFrameapiDeleteIndexapiDeleteViewapiExportCSVapiFieldsapiFragmentBlockDataapiFragmentBlocksapiFrameAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiRestoreFrameapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" +const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateFrameapiCreateIndexapiDeleteFieldapiDeleteFrameapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFrameAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" -var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 87, 101, 114, 126, 135, 155, 172, 188, 197, 211, 219, 235, 253, 261, 281, 294, 308, 323, 340, 353, 373, 381} +var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 87, 101, 114, 126, 146, 163, 179, 188, 202, 210, 226, 244, 252, 272, 285, 299, 316, 329, 349, 357} func (i apiMethod) String() string { if i < 0 || i >= apiMethod(len(_apiMethod_index)-1) { - return "apiMethod(" + strconv.FormatInt(int64(i), 10) + ")" + return fmt.Sprintf("apiMethod(%d)", i) } return _apiMethod_name[_apiMethod_index[i]:_apiMethod_index[i+1]] } diff --git a/diagnostics.go b/diagnostics.go index 9219c01ea..1968a4e74 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -227,8 +227,8 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { numIndexes += 1 for _, frame := range index.Frames() { numFrames += 1 - if fields, err := frame.GetFields(); err == nil { - bsiFieldCount += len(fields) + if frame.Type() == FrameTypeInt { + bsiFieldCount += 1 } if frame.TimeQuantum() != "" { timeQuantumEnabled = true diff --git a/frame.go b/frame.go index c9151c21b..e0765096e 100644 --- a/frame.go +++ b/frame.go @@ -31,12 +31,21 @@ import ( // Default frame settings. const ( + DefaultFrameType = FrameTypeSet + DefaultCacheType = CacheTypeRanked // Default ranked frame cache DefaultCacheSize = 50000 ) +// Frame types. +const ( + FrameTypeSet = "set" + FrameTypeInt = "int" + FrameTypeTime = "time" +) + // Frame represents a container for views. type Frame struct { mu sync.RWMutex @@ -53,10 +62,9 @@ type Frame struct { Stats StatsClient // Frame options. - cacheType string - cacheSize uint32 - timeQuantum TimeQuantum - fields []*oField + options FrameOptions + + fields []*oField Logger Logger } @@ -80,10 +88,11 @@ func NewFrame(path, index, name string) (*Frame, error) { broadcaster: NopBroadcaster, Stats: NopStatsClient, - cacheType: DefaultCacheType, - cacheSize: DefaultCacheSize, - //timeQuantum - //fields + options: FrameOptions{ + Type: DefaultFrameType, + CacheType: DefaultCacheType, + CacheSize: DefaultCacheSize, + }, Logger: NopLogger, }, nil @@ -115,9 +124,18 @@ func (f *Frame) MaxSlice() uint64 { return max } +// Type returns the frame type. +func (f *Frame) Type() string { + f.mu.RLock() + defer f.mu.RUnlock() + return f.options.Type +} + // CacheType returns the caching mode for the frame. func (f *Frame) CacheType() string { - return f.cacheType + f.mu.RLock() + defer f.mu.RUnlock() + return f.options.CacheType } // SetCacheSize sets the cache size for ranked fames. Persists to meta file on update. @@ -127,12 +145,12 @@ func (f *Frame) SetCacheSize(v uint32) error { defer f.mu.Unlock() // Ignore if no change occurred. - if v == 0 || f.cacheSize == v { + if v == 0 || f.options.CacheSize == v { return nil } // Persist meta data to disk on change. - f.cacheSize = v + f.options.CacheSize = v if err := f.saveMeta(); err != nil { return errors.Wrap(err, "saving") } @@ -142,9 +160,9 @@ func (f *Frame) SetCacheSize(v uint32) error { // CacheSize returns the ranked frame cache size. func (f *Frame) CacheSize() uint32 { - f.mu.Lock() - v := f.cacheSize - f.mu.Unlock() + f.mu.RLock() + v := f.options.CacheSize + f.mu.RUnlock() return v } @@ -152,16 +170,7 @@ func (f *Frame) CacheSize() uint32 { func (f *Frame) Options() FrameOptions { f.mu.RLock() defer f.mu.RUnlock() - return f.options() -} - -func (f *Frame) options() FrameOptions { - return FrameOptions{ - CacheType: f.cacheType, - CacheSize: f.cacheSize, - TimeQuantum: f.timeQuantum, - Fields: f.fields, - } + return f.options } // Open opens and initializes the frame. @@ -176,6 +185,11 @@ func (f *Frame) Open() error { return errors.Wrap(err, "loading meta") } + // Apply the frame options loaded from meta. + if err := f.applyOptions(f.options); err != nil { + return errors.Wrap(err, "applying options") + } + if err := f.openViews(); err != nil { return errors.Wrap(err, "opening views") } @@ -216,7 +230,7 @@ func (f *Frame) openViews() error { name := filepath.Base(fi.Name()) view := f.newView(f.ViewPath(name), name) if err := view.Open(); err != nil { - return fmt.Errorf("open view: view=%s, err=%s", view.Name(), err) + return fmt.Errorf("opening view: view=%s, err=%s", view.Name(), err) } view.RowAttrStore = f.rowAttrStore f.views[view.Name()] = view @@ -232,10 +246,6 @@ func (f *Frame) loadMeta() error { // Read data from meta file. buf, err := ioutil.ReadFile(filepath.Join(f.path, ".meta")) if os.IsNotExist(err) { - f.cacheType = DefaultCacheType - f.cacheSize = DefaultCacheSize - f.timeQuantum = "" - //f.fields return nil } else if err != nil { return errors.Wrap(err, "reading meta") @@ -246,13 +256,12 @@ func (f *Frame) loadMeta() error { } // Copy metadata fields. - f.cacheType = pb.CacheType - if f.cacheType == "" { - f.cacheType = DefaultCacheType - } - f.cacheSize = pb.CacheSize - f.timeQuantum = TimeQuantum(pb.TimeQuantum) - f.fields = decodeFields(pb.Fields) + f.options.Type = pb.Type + f.options.CacheType = pb.CacheType + f.options.CacheSize = pb.CacheSize + f.options.Min = pb.Min + f.options.Max = pb.Max + f.options.TimeQuantum = TimeQuantum(pb.TimeQuantum) return nil } @@ -260,7 +269,7 @@ func (f *Frame) loadMeta() error { // saveMeta writes meta data for the frame. func (f *Frame) saveMeta() error { // Marshal metadata. - fo := f.options() + fo := f.options buf, err := proto.Marshal(fo.Encode()) if err != nil { return errors.Wrap(err, "marshaling") @@ -274,6 +283,60 @@ func (f *Frame) saveMeta() error { return nil } +// applyOptions configures the frame based on opt. +func (f *Frame) applyOptions(opt FrameOptions) error { + switch opt.Type { + case FrameTypeSet, "": + f.options.Type = FrameTypeSet + if opt.CacheType != "" { + f.options.CacheType = opt.CacheType + } + if opt.CacheSize != 0 { + f.options.CacheSize = opt.CacheSize + } + f.options.Min = 0 + f.options.Max = 0 + f.options.TimeQuantum = "" + case FrameTypeInt: + f.options.Type = opt.Type + f.options.CacheType = "" + f.options.CacheSize = 0 + f.options.Min = opt.Min + f.options.Max = opt.Max + f.options.TimeQuantum = "" + + // Create new field. + field := &oField{ + Name: f.name, + Type: FieldTypeInt, + Min: opt.Min, + Max: opt.Max, + } + // Validate field. + if err := ValidateField(field); err != nil { + return err + } + if err := f.CreateField(field); err != nil { + return errors.Wrap(err, "creating field") + } + case FrameTypeTime: + f.options.Type = opt.Type + f.options.CacheType = "" + f.options.CacheSize = 0 + f.options.Min = 0 + f.options.Max = 0 + // Set the time quantum. + if err := f.SetTimeQuantum(opt.TimeQuantum); err != nil { + f.Close() + return errors.Wrap(err, "setting time quantum") + } + default: + return errors.New("invalid frame type") + } + + return nil +} + // Close closes the frame and its views. func (f *Frame) Close() error { f.mu.Lock() @@ -307,13 +370,6 @@ func (f *Frame) Field(name string) *oField { return nil } -// Fields returns the fields on the frame. -func (f *Frame) Fields() []*oField { - f.mu.RLock() - defer f.mu.RUnlock() - return f.fields -} - // HasField returns true if a field exists on the frame. func (f *Frame) HasField(name string) bool { for _, fld := range f.fields { @@ -356,19 +412,6 @@ func (f *Frame) addField(field *oField) error { return nil } -// GetFields returns a list of all the fields in the frame. -func (f *Frame) GetFields() ([]*oField, error) { - f.mu.RLock() - defer f.mu.RUnlock() - - err := f.loadMeta() - if err != nil { - return nil, errors.Wrap(err, "loading meta") - } - - return f.fields, nil -} - // DeleteField deletes an existing field on the schema. func (f *Frame) DeleteField(name string) error { f.mu.Lock() @@ -410,7 +453,7 @@ func (f *Frame) deleteField(name string) error { func (f *Frame) TimeQuantum() TimeQuantum { f.mu.Lock() defer f.mu.Unlock() - return f.timeQuantum + return f.options.TimeQuantum } // SetTimeQuantum sets the time quantum for the frame. @@ -424,7 +467,7 @@ func (f *Frame) SetTimeQuantum(q TimeQuantum) error { } // Update value on frame. - f.timeQuantum = q + f.options.TimeQuantum = q // Persist meta data to disk. if err := f.saveMeta(); err != nil { @@ -526,8 +569,8 @@ func (f *Frame) createViewIfNotExistsBase(name string) (*View, bool, error) { } func (f *Frame) newView(path, name string) *View { - view := NewView(path, f.index, f.name, name, f.cacheSize) - view.cacheType = f.cacheType + view := NewView(path, f.index, f.name, name, f.options.CacheSize) + view.cacheType = f.options.CacheType view.Logger = f.Logger view.RowAttrStore = f.rowAttrStore view.stats = f.Stats.WithTags(fmt.Sprintf("view:%s", name)) @@ -918,7 +961,7 @@ func encodeFrames(a []*Frame) []*internal.Frame { // encodeFrame converts f into its internal representation. func encodeFrame(f *Frame) *internal.Frame { - fo := f.options() + fo := f.options return &internal.Frame{ Name: f.name, Meta: fo.Encode(), @@ -947,10 +990,31 @@ func (p frameInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } // FrameOptions represents options to set when initializing a frame. type FrameOptions struct { + Type string `json:"type,omitempty"` CacheType string `json:"cacheType,omitempty"` CacheSize uint32 `json:"cacheSize,omitempty"` - TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` - Fields []*oField `json:"fields,omitempty"` + Min int64 `json:"min,omitempty"` + Max int64 `json:"max,omitempty"` + TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` // TODO travis: rename this Quantum? +} + +// Validate ensures that FrameOption values are valid. +func (o *FrameOptions) Validate() error { + switch o.Type { + case FrameTypeSet, "": + // TODO: cacheType, cacheSize validation + case FrameTypeInt: + if o.Min > o.Max { + return ErrInvalidFieldRange + } + case FrameTypeTime: + if o.TimeQuantum == "" || !o.TimeQuantum.Valid() { + return ErrInvalidTimeQuantum + } + default: + return errors.New("invalid frame type") + } + return nil } // Encode converts o into its internal representation. @@ -963,10 +1027,12 @@ func encodeFrameOptions(o *FrameOptions) *internal.FrameMeta { return nil } return &internal.FrameMeta{ + Type: o.Type, CacheType: o.CacheType, CacheSize: o.CacheSize, + Min: o.Min, + Max: o.Max, TimeQuantum: string(o.TimeQuantum), - Fields: encodeFields(o.Fields), } } @@ -975,10 +1041,12 @@ func decodeFrameOptions(options *internal.FrameMeta) *FrameOptions { return nil } return &FrameOptions{ + Type: options.Type, CacheType: options.CacheType, CacheSize: options.CacheSize, + Min: options.Min, + Max: options.Max, TimeQuantum: TimeQuantum(options.TimeQuantum), - Fields: decodeFields(options.Fields), } } diff --git a/index.go b/index.go index 534930cd5..7829903aa 100644 --- a/index.go +++ b/index.go @@ -299,11 +299,9 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { return nil, ErrInvalidCacheType } - // Validate fields. - for _, field := range opt.Fields { - if err := ValidateField(field); err != nil { - return nil, err - } + // Validate options. + if err := opt.Validate(); err != nil { + return nil, errors.Wrap(err, "validating options") } // Initialize frame. @@ -317,25 +315,12 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { return nil, errors.Wrap(err, "opening") } - // Set the time quantum. - if err := f.SetTimeQuantum(opt.TimeQuantum); err != nil { + // Apply frame options. + if err := f.applyOptions(opt); err != nil { f.Close() - return nil, errors.Wrap(err, "setting time quantum") + return nil, errors.Wrap(err, "applying options") } - // Set cache type. - if opt.CacheType == "" { - opt.CacheType = DefaultCacheType - } - f.cacheType = opt.CacheType - - if opt.CacheSize != 0 { - f.cacheSize = opt.CacheSize - } - - // Set fields. - f.fields = opt.Fields - if err := f.saveMeta(); err != nil { f.Close() return nil, errors.Wrap(err, "saving meta") diff --git a/internal/private.pb.go b/internal/private.pb.go index 35b452dce..20909445c 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. @@ -70,10 +71,12 @@ func (*IndexMeta) ProtoMessage() {} func (*IndexMeta) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{0} } type FrameMeta struct { - CacheType string `protobuf:"bytes,3,opt,name=CacheType,proto3" json:"CacheType,omitempty"` - CacheSize uint32 `protobuf:"varint,4,opt,name=CacheSize,proto3" json:"CacheSize,omitempty"` - TimeQuantum string `protobuf:"bytes,5,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` - Fields []*Field `protobuf:"bytes,7,rep,name=Fields" json:"Fields,omitempty"` + Type string `protobuf:"bytes,8,opt,name=Type,proto3" json:"Type,omitempty"` + CacheType string `protobuf:"bytes,3,opt,name=CacheType,proto3" json:"CacheType,omitempty"` + CacheSize uint32 `protobuf:"varint,4,opt,name=CacheSize,proto3" json:"CacheSize,omitempty"` + Min int64 `protobuf:"varint,9,opt,name=Min,proto3" json:"Min,omitempty"` + Max int64 `protobuf:"varint,10,opt,name=Max,proto3" json:"Max,omitempty"` + TimeQuantum string `protobuf:"bytes,5,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` } func (m *FrameMeta) Reset() { *m = FrameMeta{} } @@ -81,6 +84,13 @@ func (m *FrameMeta) String() string { return proto.CompactTextString( func (*FrameMeta) ProtoMessage() {} func (*FrameMeta) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{1} } +func (m *FrameMeta) GetType() string { + if m != nil { + return m.Type + } + return "" +} + func (m *FrameMeta) GetCacheType() string { if m != nil { return m.CacheType @@ -95,6 +105,20 @@ func (m *FrameMeta) GetCacheSize() uint32 { return 0 } +func (m *FrameMeta) GetMin() int64 { + if m != nil { + return m.Min + } + return 0 +} + +func (m *FrameMeta) GetMax() int64 { + if m != nil { + return m.Max + } + return 0 +} + func (m *FrameMeta) GetTimeQuantum() string { if m != nil { return m.TimeQuantum @@ -102,13 +126,6 @@ func (m *FrameMeta) GetTimeQuantum() string { return "" } -func (m *FrameMeta) GetFields() []*Field { - if m != nil { - return m.Fields - } - return nil -} - type ImportResponse struct { Err string `protobuf:"bytes,1,opt,name=Err,proto3" json:"Err,omitempty"` } @@ -1052,17 +1069,21 @@ func (m *FrameMeta) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.TimeQuantum))) i += copy(dAtA[i:], m.TimeQuantum) } - if len(m.Fields) > 0 { - for _, msg := range m.Fields { - dAtA[i] = 0x3a - i++ - i = encodeVarintPrivate(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } + if len(m.Type) > 0 { + dAtA[i] = 0x42 + i++ + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Type))) + i += copy(dAtA[i:], m.Type) + } + if m.Min != 0 { + dAtA[i] = 0x48 + i++ + i = encodeVarintPrivate(dAtA, i, uint64(m.Min)) + } + if m.Max != 0 { + dAtA[i] = 0x50 + i++ + i = encodeVarintPrivate(dAtA, i, uint64(m.Max)) } return i, nil } @@ -2228,6 +2249,24 @@ func (m *RecalculateCaches) 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) @@ -2257,11 +2296,15 @@ func (m *FrameMeta) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - if len(m.Fields) > 0 { - for _, e := range m.Fields { - l = e.Size() - n += 1 + l + sovPrivate(uint64(l)) - } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovPrivate(uint64(l)) + } + if m.Min != 0 { + n += 1 + sovPrivate(uint64(m.Min)) + } + if m.Max != 0 { + n += 1 + sovPrivate(uint64(m.Max)) } return n } @@ -2939,11 +2982,11 @@ func (m *FrameMeta) Unmarshal(dAtA []byte) error { } m.TimeQuantum = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPrivate @@ -2953,23 +2996,59 @@ func (m *FrameMeta) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthPrivate } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - m.Fields = append(m.Fields, &Field{}) - if err := m.Fields[len(m.Fields)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) + } + m.Min = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Min |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) + } + m.Max = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Max |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipPrivate(dAtA[iNdEx:]) @@ -3586,14 +3665,51 @@ func (m *MaxSlices) 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.Standard == nil { m.Standard = 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 @@ -3603,69 +3719,31 @@ func (m *MaxSlices) 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.Standard[mapkey] = mapvalue + } else { + var mapvalue uint64 + m.Standard[mapkey] = mapvalue } - m.Standard[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -6997,70 +7075,70 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1035 bytes of a gzipped FileDescriptorProto + // 1029 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6f, 0x1b, 0x45, - 0x18, 0x67, 0xbd, 0x6b, 0x27, 0xfe, 0x8c, 0x53, 0x67, 0x5a, 0xc2, 0x16, 0xa1, 0x60, 0x46, 0x45, - 0x0d, 0x1c, 0xa2, 0x92, 0x5e, 0x78, 0x55, 0x8a, 0x12, 0xa7, 0x62, 0x11, 0x89, 0x60, 0x36, 0xe9, - 0x01, 0x89, 0xc3, 0xd4, 0x1e, 0xa5, 0x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x71, 0x44, 0x9e, + 0xcc, 0xe0, 0xc8, 0x6f, 0xa1, 0xc1, 0xdb, 0x95, 0xc1, 0x0d, 0x31, 0xbb, 0xa9, 0x4d, 0x7f, 0x75, + 0xe0, 0xcd, 0x7a, 0x0a, 0xaf, 0xb4, 0x18, 0xe5, 0x44, 0x1a, 0x0b, 0x27, 0xe2, 0x2e, 0x9a, 0x88, + 0x57, 0x4d, 0xa4, 0x7a, 0x9d, 0x9b, 0xf5, 0xd7, 0xf9, 0x1c, 0xee, 0xcf, 0x8d, 0xa9, 0x2f, 0xc7, + 0x13, 0x8d, 0x87, 0xff, 0x31, 0x2e, 0x7d, 0x65, 0xa4, 0xa9, 0x1d, 0x54, 0x9b, 0x19, 0x82, 0x7e, + 0x06, 0x6f, 0x85, 0x42, 0xd5, 0x86, 0x54, 0xa0, 0xad, 0x0b, 0xee, 0xb1, 0xb8, 0x5c, 0x52, 0xbe, + 0x16, 0xd1, 0x2f, 0xc1, 0x3f, 0x9d, 0x8c, 0xb8, 0x12, 0x2b, 0x59, 0x1f, 0xc0, 0xfa, 0x89, 0x9c, + 0xc8, 0x58, 0x9e, 0x4d, 0x6f, 0x59, 0x79, 0x1f, 0xd6, 0xcc, 0xfd, 0x68, 0x3e, 0x6c, 0x6d, 0x56, + 0x90, 0xf4, 0xae, 0x06, 0xf4, 0x90, 0xc7, 0xc3, 0x3c, 0xd6, 0x69, 0xe8, 0x9f, 0x5b, 0x76, 0xb0, + 0xf5, 0xd7, 0xf5, 0xae, 0xf3, 0xf7, 0xf5, 0xae, 0xf3, 0xcf, 0xf5, 0xae, 0xf3, 0xfb, 0xbf, 0xbb, + 0x6f, 0x3c, 0x6b, 0xe1, 0x37, 0xfc, 0xf1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x97, 0x84, + 0xb1, 0x97, 0x0b, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index 52e587f4b..b530257ae 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -6,10 +6,13 @@ message IndexMeta { } message FrameMeta { + string Type = 8; string CacheType = 3; uint32 CacheSize = 4; + int64 Min = 9; + int64 Max = 10; string TimeQuantum = 5; - repeated Field Fields = 7; + //repeated Field Fields = 7; } message ImportResponse { diff --git a/internal/public.pb.go b/internal/public.pb.go index 0dab2c831..069f633c0 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 binary "encoding/binary" - import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -808,8 +807,7 @@ func (m *Attr) MarshalTo(dAtA []byte) (int, error) { if m.FloatValue != 0 { dAtA[i] = 0x31 i++ - 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 } @@ -1251,6 +1249,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) @@ -2335,8 +2351,15 @@ func (m *Attr) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint64(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 From dbb4cdf3909f08320888eb34050f1f0550fb7af1 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 21:03:18 -0500 Subject: [PATCH 08/52] adjust the tests to match the new unexported Field and FrameOptions --- client_test.go | 21 ++-- cluster_test.go | 34 ------ ctl/import_test.go | 5 +- executor_test.go | 223 ++++++++++++++++++++------------------ frame.go | 37 +++++-- frame_internal_test.go | 149 +++++++++++++++++++++++++ frame_test.go | 190 +++++--------------------------- handler_test.go | 240 ----------------------------------------- index_test.go | 156 +++++++++++++-------------- test/frame.go | 8 +- 10 files changed, 423 insertions(+), 640 deletions(-) create mode 100644 frame_internal_test.go diff --git a/client_test.go b/client_test.go index 6e5f2dc41..898869f2b 100644 --- a/client_test.go +++ b/client_test.go @@ -244,16 +244,17 @@ func TestClient_ImportValue(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() - fld := pilosa.Field{ - Name: "fld", - Type: pilosa.FieldTypeInt, + fldName := "f" + + fo := pilosa.FrameOptions{ + Type: pilosa.FrameTypeInt, Min: -100, Max: 100, } // Load bitmap into cache to ensure cache gets updated. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - frame, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{Fields: []*pilosa.Field{&fld}}) + frame, err := index.CreateFrameIfNotExists(fldName, fo) if err != nil { t.Fatal(err) } @@ -266,7 +267,7 @@ func TestClient_ImportValue(t *testing.T) { // Send import request. c := test.MustNewClient(s.Host(), defaultClient) - if err := c.ImportValue(context.Background(), "i", "f", fld.Name, 0, []pilosa.FieldValue{ + if err := c.ImportValue(context.Background(), "i", "f", fldName, 0, []pilosa.FieldValue{ {ColumnID: 1, Value: -10}, {ColumnID: 2, Value: 20}, {ColumnID: 3, Value: 40}, @@ -275,7 +276,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Sum. - sum, cnt, err := frame.FieldSum(nil, fld.Name) + sum, cnt, err := frame.FieldSum(nil, fldName) if err != nil { t.Fatal(err) } @@ -284,7 +285,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min. - min, cnt, err := frame.FieldMin(nil, fld.Name) + min, cnt, err := frame.FieldMin(nil, fldName) if err != nil { t.Fatal(err) } @@ -293,11 +294,11 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min with Filter. - filter, err := frame.FieldRange(fld.Name, pql.GT, 40) + filter, err := frame.FieldRange(fldName, pql.GT, 40) if err != nil { t.Fatal(err) } - min, cnt, err = frame.FieldMin(filter, fld.Name) + min, cnt, err = frame.FieldMin(filter, fldName) if err != nil { t.Fatal(err) } @@ -306,7 +307,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Max. - max, cnt, err := frame.FieldMax(nil, fld.Name) + max, cnt, err := frame.FieldMax(nil, fldName) if err != nil { t.Fatal(err) } diff --git a/cluster_test.go b/cluster_test.go index a2570c41a..99b322a0e 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -422,24 +422,6 @@ func TestCluster_ResizeStates(t *testing.T) { tc.SetBit("i", "f", "standard", 1, 101, nil) tc.SetBit("i", "f", "standard", 1, 1300000, nil) - // Add Field Data to node0. - if err := tc.CreateFrame("i", "fields", FrameOptions{ - Fields: []*oField{ - { - Name: "fld0", - Type: FieldTypeInt, - Min: -100, - Max: 100, - }, - }, - }); err != nil { - t.Fatal(err) - } - tc.SetFieldValue("i", "fields", 1, "fld0", -10) - tc.SetFieldValue("i", "fields", 1, "fld0", 10) - tc.SetFieldValue("i", "fields", 1300000, "fld0", -99) - tc.SetFieldValue("i", "fields", 1300000, "fld0", 99) - // Before starting the resize, get the CheckSum to use for // comparison later. node0Frame := node0.Holder.Frame("i", "f") @@ -447,11 +429,6 @@ func TestCluster_ResizeStates(t *testing.T) { node0Fragment := node0View.Fragment(1) node0Checksum := node0Fragment.Checksum() - node0Frame = node0.Holder.Frame("i", "fields") - node0View = node0Frame.View("field_fld0") - node0Fragment = node0View.Fragment(1) - node0ChecksumFld := node0Fragment.Checksum() - // AddNode needs to block until the resize process has completed. tc.AddNode(false) node1 := tc.Clusters[1] @@ -485,17 +462,6 @@ func TestCluster_ResizeStates(t *testing.T) { t.Fatalf("expected standard view checksum to match: %x - %x", chksum, node0Checksum) } - // Values - // Verify that node-1 contains the fragment (i/fields/field_fld0/1) transferred from node-0. - node1Frame = node1.Holder.Frame("i", "fields") - node1View = node1Frame.View("field_fld0") - node1Fragment = node1View.Fragment(1) - - // Ensure checksums are the same. - if chksum := node1Fragment.Checksum(); !bytes.Equal(chksum, node0ChecksumFld) { - t.Fatalf("expected checksum to match: %x - %x", chksum, node0ChecksumFld) - } - // Close TestCluster. if err := tc.Close(); err != nil { t.Fatal(err) diff --git a/ctl/import_test.go b/ctl/import_test.go index a11770bd8..7c6c02721 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -82,6 +82,7 @@ func TestImportCommand_Run(t *testing.T) { } } +// TODO: revisit this test once Frame is renamed Field // Ensure that the ImportValue path runs (note: we have specified a value // for cm.Field.) func TestImportCommand_RunValue(t *testing.T) { @@ -107,11 +108,11 @@ func TestImportCommand_RunValue(t *testing.T) { cm.Host = s.Host() http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i", strings.NewReader(""))) - http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i/frame/f", strings.NewReader(`{"options":{"fields": [{"name": "foo", "type": "int", "min": 0, "max": 100}]}}`))) + http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i/frame/f", strings.NewReader(`{"options":{"type": "int", "min": 0, "max": 100}}`))) cm.Index = "i" cm.Frame = "f" - cm.Field = "foo" + cm.Field = "f" cm.Paths = []string{file.Name()} err = cm.Run(ctx) if err != nil { diff --git a/executor_test.go b/executor_test.go index 0807228ac..fbce4d52d 100644 --- a/executor_test.go +++ b/executor_test.go @@ -272,10 +272,9 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 0, Max: 50}, - {Name: "field1", Type: pilosa.FieldTypeInt, Min: 1, Max: 2}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 50, }); err != nil { t.Fatal(err) } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FrameOptions{}); err != nil { @@ -284,14 +283,14 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { // Set field values. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, field0=25, field1=2)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, f=25)`), nil, nil); err != nil { t.Fatal(err) - } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, frame=f, field0=10)`), nil, nil); err != nil { + } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, frame=f, f=10)`), nil, nil); err != nil { t.Fatal(err) } f := hldr.Frame("i", "f") - if value, exists, err := f.FieldValue(10, "field0"); err != nil { + if value, exists, err := f.FieldValue(10, "f"); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") @@ -299,15 +298,7 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { t.Fatalf("unexpected value: %v", value) } - if value, exists, err := f.FieldValue(10, "field1"); err != nil { - t.Fatal(err) - } else if !exists { - t.Fatal("expected value to exist") - } else if value != 2 { - t.Fatalf("unexpected value: %v", value) - } - - if value, exists, err := f.FieldValue(100, "field0"); err != nil { + if value, exists, err := f.FieldValue(100, "f"); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") @@ -321,37 +312,37 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 0, Max: 100}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 100, }); err != nil { t.Fatal(err) } t.Run("ErrFrameRequired", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, field0=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() frame required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() frame required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrColumnFieldRequired", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, frame=f, field0=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, frame=f, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrColumnFieldValue", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", frame=f, field0=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", frame=f, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrInvalidFieldValueType", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, field0="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { t.Fatalf("unexpected error: %s", err) } }) @@ -588,29 +579,33 @@ func TestExecutor_Execute_MinMax(t *testing.T) { t.Fatal(err) } + if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + t.Fatal(err) + } + if _, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: -10, Max: 100}, - }, + Type: pilosa.FrameTypeInt, + Min: -10, + Max: 100, }); err != nil { t.Fatal(err) } if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=f, row=0, col=0) - SetBit(frame=f, row=0, col=3) - SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetBit(frame=f, row=1, col=1) - SetBit(frame=f, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) + SetBit(frame=x, row=0, col=0) + SetBit(frame=x, row=0, col=3) + SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) + SetBit(frame=x, row=1, col=1) + SetBit(frame=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, foo=20, col=0) - SetFieldValue(frame=f, foo=-5, col=1) - SetFieldValue(frame=f, foo=-5, col=2) - SetFieldValue(frame=f, foo=10, col=3) - SetFieldValue(frame=f, foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=f, foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=f, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(frame=f, f=20, col=0) + SetFieldValue(frame=f, f=-5, col=1) + SetFieldValue(frame=f, f=-5, col=2) + SetFieldValue(frame=f, f=10, col=3) + SetFieldValue(frame=f, f=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(frame=f, f=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(frame=f, f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(frame=f, f=60, col=`+strconv.Itoa(SliceWidth+1)+`) `), nil, nil); err != nil { t.Fatal(err) } @@ -622,16 +617,16 @@ func TestExecutor_Execute_MinMax(t *testing.T) { cnt int64 }{ {filter: ``, exp: -5, cnt: 2}, - {filter: `Bitmap(frame=f, row=0)`, exp: 10, cnt: 1}, - {filter: `Bitmap(frame=f, row=1)`, exp: -5, cnt: 1}, - {filter: `Bitmap(frame=f, row=2)`, exp: 40, cnt: 1}, + {filter: `Bitmap(frame=x, row=0)`, exp: 10, cnt: 1}, + {filter: `Bitmap(frame=x, row=1)`, exp: -5, cnt: 1}, + {filter: `Bitmap(frame=x, row=2)`, exp: 40, cnt: 1}, } for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Min(frame=f, field=foo)` + pql = `Min(frame=f, field=f)` } else { - pql = fmt.Sprintf(`Min(%s, frame=f, field=foo)`, tt.filter) + pql = fmt.Sprintf(`Min(%s, frame=f, field=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -648,16 +643,16 @@ func TestExecutor_Execute_MinMax(t *testing.T) { cnt int64 }{ {filter: ``, exp: 60, cnt: 1}, - {filter: `Bitmap(frame=f, row=0)`, exp: 60, cnt: 1}, - {filter: `Bitmap(frame=f, row=1)`, exp: -5, cnt: 1}, - {filter: `Bitmap(frame=f, row=2)`, exp: 40, cnt: 1}, + {filter: `Bitmap(frame=x, row=0)`, exp: 60, cnt: 1}, + {filter: `Bitmap(frame=x, row=1)`, exp: -5, cnt: 1}, + {filter: `Bitmap(frame=x, row=2)`, exp: 40, cnt: 1}, } for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Max(frame=f, field=foo)` + pql = `Max(frame=f, field=f)` } else { - pql = fmt.Sprintf(`Max(%s, frame=f, field=foo)`, tt.filter) + pql = fmt.Sprintf(`Max(%s, frame=f, field=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -679,39 +674,51 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: 10, Max: 100}, - {Name: "bar", Type: pilosa.FieldTypeInt, Min: 0, Max: 100000}, - }, + if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + t.Fatal(err) + } + + if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ + Type: pilosa.FrameTypeInt, + Min: 10, + Max: 100, + }); err != nil { + t.Fatal(err) + } + + if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 100000, }); err != nil { t.Fatal(err) } if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: 0, Max: 1000}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 1000, }); err != nil { t.Fatal(err) } if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=f, row=0, col=0) - SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) + SetBit(frame=x, row=0, col=0) + SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=f, foo=20, bar=2000, col=0) - SetFieldValue(frame=f, foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=f, foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=f, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=other, foo=1000, col=0) + SetFieldValue(frame=foo, foo=20, col=0) + SetFieldValue(frame=bar, bar=2000, col=0) + SetFieldValue(frame=foo, foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(frame=foo, foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(frame=foo, foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(frame=foo, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(frame=other, other=1000, col=0) `), nil, nil); err != nil { t.Fatal(err) } t.Run("NoFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(frame=f, field=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(frame=foo, field=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 200, Count: 5}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -719,7 +726,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { }) t.Run("WithFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(frame=f, row=0), frame=f, field=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(frame=x, row=0), frame=foo, field=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 80, Count: 2}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -738,6 +745,7 @@ func TestExecutor_Execute_Range(t *testing.T) { // Create frame. if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ + Type: pilosa.FrameTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }); err != nil { t.Fatal(err) @@ -766,7 +774,6 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatalf("unexpected columns: %+v", columns) } }) - } // Ensure a Range(field) query can be executed. @@ -780,27 +787,38 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: 10, Max: 100}, - {Name: "bar", Type: pilosa.FieldTypeInt, Min: 0, Max: 100000}, - }, + if _, err := idx.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + t.Fatal(err) + } + + if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ + Type: pilosa.FrameTypeInt, + Min: 10, + Max: 100, + }); err != nil { + t.Fatal(err) + } + + if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 100000, }); err != nil { t.Fatal(err) } if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: 0, Max: 1000}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 1000, }); err != nil { t.Fatal(err) } if _, err := idx.CreateFrame("edge", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "foo", Type: pilosa.FieldTypeInt, Min: -100, Max: 100}, - }, + Type: pilosa.FrameTypeInt, + Min: -100, + Max: 100, }); err != nil { t.Fatal(err) } @@ -809,20 +827,21 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { SetBit(frame=f, row=0, col=0) SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=f, foo=20, bar=2000, col=50) - SetFieldValue(frame=f, foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=f, foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=f, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=other, foo=1000, col=0) - SetFieldValue(frame=edge, foo=100, col=0) - SetFieldValue(frame=edge, foo=-100, col=1) + SetFieldValue(frame=foo, foo=20, col=50) + SetFieldValue(frame=bar, bar=2000, col=50) + SetFieldValue(frame=foo, foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(frame=foo, foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(frame=foo, foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(frame=foo, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(frame=other, other=1000, col=0) + SetFieldValue(frame=edge, edge=100, col=0) + SetFieldValue(frame=edge, edge=-100, col=1) `), nil, nil); err != nil { t.Fatal(err) } t.Run("EQ", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -831,19 +850,19 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { t.Run("NEQ", func(t *testing.T) { // NEQ null - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo != null)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other != null)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) } // NEQ - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo != 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo != 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1, SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) } // NEQ - - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo != -20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other != -20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { //t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -852,7 +871,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("LT", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo < 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo < 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -860,7 +879,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("LTE", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo <= 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo <= 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, SliceWidth + 2, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -868,7 +887,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("GT", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo > 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo > 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -876,7 +895,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("GTE", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo >= 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo >= 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, SliceWidth, SliceWidth + 1, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -884,7 +903,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("BETWEEN", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo >< [1, 1000])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other >< [1, 1000])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -893,7 +912,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { // Ensure that the FieldNotNull code path gets run. t.Run("FieldNotNull", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo >< [0, 1000])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other >< [0, 1000])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -901,7 +920,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("BelowMin", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 0)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 0)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -909,7 +928,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("AboveMax", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -917,7 +936,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("LTAboveMax", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, foo < 200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, edge < 200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns())) @@ -925,7 +944,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("GTBelowMin", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, foo > -200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, edge > -200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns())) @@ -939,7 +958,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("ErrFieldNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, bad_field >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, bad_field >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { t.Fatal(err) } }) diff --git a/frame.go b/frame.go index e0765096e..35d417136 100644 --- a/frame.go +++ b/frame.go @@ -69,14 +69,25 @@ type Frame struct { Logger Logger } +// FrameOption is a functional option type for pilosa.Frame. +type FrameOption func(f *Frame) error + +// TODO: break these out into separate Options (not a FrameOptions object) +func OptFrameFrameOptions(o FrameOptions) FrameOption { + return func(f *Frame) error { + f.options = o + return nil + } +} + // NewFrame returns a new instance of frame. -func NewFrame(path, index, name string) (*Frame, error) { +func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { err := ValidateName(name) if err != nil { return nil, err } - return &Frame{ + f := &Frame{ path: path, index: index, name: name, @@ -95,7 +106,16 @@ func NewFrame(path, index, name string) (*Frame, error) { }, Logger: NopLogger, - }, nil + } + + for _, opt := range opts { + err := opt(f) + if err != nil { + return nil, errors.Wrap(err, "applying option") + } + } + + return f, nil } // Name returns the name the frame was initialized with. @@ -299,7 +319,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { f.options.TimeQuantum = "" case FrameTypeInt: f.options.Type = opt.Type - f.options.CacheType = "" + f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 f.options.Min = opt.Min f.options.Max = opt.Max @@ -321,7 +341,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { } case FrameTypeTime: f.options.Type = opt.Type - f.options.CacheType = "" + f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 f.options.Min = 0 f.options.Max = 0 @@ -657,7 +677,7 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change // Clear non-time bit. if v, err := view.ClearBit(rowID, colID); err != nil { - return changed, errors.Wrap(err, "setting on view") + return changed, errors.Wrap(err, "clearing on view") } else if v { changed = v } @@ -675,7 +695,7 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change } if c, err := view.ClearBit(rowID, colID); err != nil { - return changed, errors.Wrapf(err, "setting on view %s", subname) + return changed, errors.Wrapf(err, "clearing on view %s", subname) } else if c { changed = true } @@ -995,7 +1015,7 @@ type FrameOptions struct { CacheSize uint32 `json:"cacheSize,omitempty"` Min int64 `json:"min,omitempty"` Max int64 `json:"max,omitempty"` - TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` // TODO travis: rename this Quantum? + TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` // TODO: rename this Quantum? } // Validate ensures that FrameOption values are valid. @@ -1064,6 +1084,7 @@ func IsValidFieldType(v string) bool { } } +// TODO: finish unexporting this. also, rename it. // oField represents a range field on a frame. type oField struct { Name string `json:"name,omitempty"` diff --git a/frame_internal_test.go b/frame_internal_test.go new file mode 100644 index 000000000..f51ad95e9 --- /dev/null +++ b/frame_internal_test.go @@ -0,0 +1,149 @@ +// Copyright 2017 Pilosa Corp. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pilosa + +import ( + "reflect" + "testing" + + "github.com/pilosa/pilosa/pql" +) + +// Ensure a field can adjust to its baseValue. +func TestField_BaseValue(t *testing.T) { + f0 := &oField{ + Name: "f0", + Type: FieldTypeInt, + Min: -100, + Max: 900, + } + f1 := &oField{ + Name: "f1", + Type: FieldTypeInt, + Min: 0, + Max: 1000, + } + + f2 := &oField{ + Name: "f2", + Type: FieldTypeInt, + Min: 100, + Max: 1100, + } + + t.Run("Normal Condition", func(t *testing.T) { + + for _, tt := range []struct { + f *oField + op pql.Token + val int64 + expBaseValue uint64 + expOutOfRange bool + }{ + // LT + {f0, pql.LT, 5, 105, false}, + {f0, pql.LT, -8, 92, false}, + {f0, pql.LT, -108, 0, true}, + {f0, pql.LT, 1005, 1000, false}, + {f0, pql.LT, 0, 100, false}, + + {f1, pql.LT, 5, 5, false}, + {f1, pql.LT, -8, 0, true}, + {f1, pql.LT, 1005, 1000, false}, + {f1, pql.LT, 0, 0, false}, + + {f2, pql.LT, 5, 0, true}, + {f2, pql.LT, -8, 0, true}, + {f2, pql.LT, 105, 5, false}, + {f2, pql.LT, 1105, 1000, false}, + + // GT + {f0, pql.GT, -105, 0, false}, + {f0, pql.GT, 5, 105, false}, + {f0, pql.GT, 905, 0, true}, + {f0, pql.GT, 0, 100, false}, + + {f1, pql.GT, 5, 5, false}, + {f1, pql.GT, -8, 0, false}, + {f1, pql.GT, 1005, 0, true}, + {f1, pql.GT, 0, 0, false}, + + {f2, pql.GT, 5, 0, false}, + {f2, pql.GT, -8, 0, false}, + {f2, pql.GT, 105, 5, false}, + {f2, pql.GT, 1105, 0, true}, + + // EQ + {f0, pql.EQ, -105, 0, true}, + {f0, pql.EQ, 5, 105, false}, + {f0, pql.EQ, 905, 0, true}, + {f0, pql.EQ, 0, 100, false}, + + {f1, pql.EQ, 5, 5, false}, + {f1, pql.EQ, -8, 0, true}, + {f1, pql.EQ, 1005, 0, true}, + {f1, pql.EQ, 0, 0, false}, + + {f2, pql.EQ, 5, 0, true}, + {f2, pql.EQ, -8, 0, true}, + {f2, pql.EQ, 105, 5, false}, + {f2, pql.EQ, 1105, 0, true}, + } { + bv, oor := tt.f.BaseValue(tt.op, tt.val) + if oor != tt.expOutOfRange { + t.Fatalf("baseValue calculation on %s op %s, expected outOfRange %v, got %v", tt.f.Name, tt.op, tt.expOutOfRange, oor) + } else if !reflect.DeepEqual(bv, tt.expBaseValue) { + t.Fatalf("baseValue calculation on %s, expected value %v, got %v", tt.f.Name, tt.expBaseValue, bv) + } + } + }) + + t.Run("Betwween Condition", func(t *testing.T) { + for _, tt := range []struct { + f *oField + predMin int64 + predMax int64 + expBaseValueMin uint64 + expBaseValueMax uint64 + expOutOfRange bool + }{ + + {f0, -205, -105, 0, 0, true}, + {f0, -105, 80, 0, 180, false}, + {f0, 5, 20, 105, 120, false}, + {f0, 20, 1005, 120, 1000, false}, + {f0, 1005, 2000, 0, 0, true}, + + {f1, -105, -5, 0, 0, true}, + {f1, -5, 20, 0, 20, false}, + {f1, 5, 20, 5, 20, false}, + {f1, 20, 1005, 20, 1000, false}, + {f1, 1005, 2000, 0, 0, true}, + + {f2, 5, 95, 0, 0, true}, + {f2, 95, 120, 0, 20, false}, + {f2, 105, 120, 5, 20, false}, + {f2, 120, 1105, 20, 1000, false}, + {f2, 1105, 2000, 0, 0, true}, + } { + min, max, oor := tt.f.BaseValueBetween(tt.predMin, tt.predMax) + if oor != tt.expOutOfRange { + t.Fatalf("baseValueBetween calculation on %s, expected outOfRange %v, got %v", tt.f.Name, tt.expOutOfRange, oor) + } else if !reflect.DeepEqual(min, tt.expBaseValueMin) || !reflect.DeepEqual(max, tt.expBaseValueMax) { + t.Fatalf("baseValueBetween calculation on %s, expected min/max %v/%v, got %v/%v", tt.f.Name, tt.expBaseValueMin, tt.expBaseValueMax, min, max) + } + } + }) +} diff --git a/frame_test.go b/frame_test.go index 78014bbce..8ad9b020a 100644 --- a/frame_test.go +++ b/frame_test.go @@ -16,11 +16,9 @@ package pilosa_test import ( "io/ioutil" - "reflect" "testing" "github.com/pilosa/pilosa" - "github.com/pilosa/pilosa/pql" "github.com/pilosa/pilosa/test" ) @@ -52,7 +50,10 @@ func TestFrame_CreateViewIfNotExists(t *testing.T) { // Ensure frame can set its time quantum. func TestFrame_SetTimeQuantum(t *testing.T) { - f := test.MustOpenFrame() + fo := pilosa.FrameOptions{ + Type: "time", + } + f := test.MustOpenFrame(pilosa.OptFrameFrameOptions(fo)) defer f.Close() // Set & retrieve time quantum. @@ -77,31 +78,23 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 0, Max: 30}, - {Name: "field1", Type: pilosa.FieldTypeInt, Min: 20, Max: 25}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 30, }) if err != nil { t.Fatal(err) } - // Set value on first field. - if changed, err := f.SetFieldValue(100, "field0", 21); err != nil { - t.Fatal(err) - } else if !changed { - t.Fatal("expected change") - } - - // Set value on same column but different field. - if changed, err := f.SetFieldValue(100, "field1", 25); err != nil { + // Set value on field. + if changed, err := f.SetFieldValue(100, "f", 21); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") } // Read value. - if value, exists, err := f.FieldValue(100, "field0"); err != nil { + if value, exists, err := f.FieldValue(100, "f"); err != nil { t.Fatal(err) } else if value != 21 { t.Fatalf("unexpected value: %d", value) @@ -110,7 +103,7 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Setting value should return no change. - if changed, err := f.SetFieldValue(100, "field0", 21); err != nil { + if changed, err := f.SetFieldValue(100, "f", 21); err != nil { t.Fatal(err) } else if changed { t.Fatal("expected no change") @@ -122,30 +115,30 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 0, Max: 30}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 30, }) if err != nil { t.Fatal(err) } // Set value. - if changed, err := f.SetFieldValue(100, "field0", 21); err != nil { + if changed, err := f.SetFieldValue(100, "f", 21); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") } // Set different value. - if changed, err := f.SetFieldValue(100, "field0", 23); err != nil { + if changed, err := f.SetFieldValue(100, "f", 23); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") } // Read value. - if value, exists, err := f.FieldValue(100, "field0"); err != nil { + if value, exists, err := f.FieldValue(100, "f"); err != nil { t.Fatal(err) } else if value != 23 { t.Fatalf("unexpected value: %d", value) @@ -159,9 +152,9 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 0, Max: 30}, - }, + Type: pilosa.FrameTypeInt, + Min: 0, + Max: 30, }) if err != nil { t.Fatal(err) @@ -178,16 +171,16 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 20, Max: 30}, - }, + Type: pilosa.FrameTypeInt, + Min: 20, + Max: 30, }) if err != nil { t.Fatal(err) } // Set value. - if _, err := f.SetFieldValue(100, "field0", 15); err != pilosa.ErrFieldValueTooLow { + if _, err := f.SetFieldValue(100, "f", 15); err != pilosa.ErrFieldValueTooLow { t.Fatalf("unexpected error: %s", err) } }) @@ -197,16 +190,16 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 20, Max: 30}, - }, + Type: pilosa.FrameTypeInt, + Min: 20, + Max: 30, }) if err != nil { t.Fatal(err) } // Set value. - if _, err := f.SetFieldValue(100, "field0", 31); err != pilosa.ErrFieldValueTooHigh { + if _, err := f.SetFieldValue(100, "f", 31); err != pilosa.ErrFieldValueTooHigh { t.Fatalf("unexpected error: %s", err) } }) @@ -294,130 +287,3 @@ func TestFrame_DeleteView(t *testing.T) { t.Fatal("failed to create new view") } } - -// Ensure a field can adjust to its baseValue. -func TestField_BaseValue(t *testing.T) { - f0 := &pilosa.Field{ - Name: "f0", - Type: pilosa.FieldTypeInt, - Min: -100, - Max: 900, - } - f1 := &pilosa.Field{ - Name: "f1", - Type: pilosa.FieldTypeInt, - Min: 0, - Max: 1000, - } - - f2 := &pilosa.Field{ - Name: "f2", - Type: pilosa.FieldTypeInt, - Min: 100, - Max: 1100, - } - - t.Run("Normal Condition", func(t *testing.T) { - - for _, tt := range []struct { - f *pilosa.Field - op pql.Token - val int64 - expBaseValue uint64 - expOutOfRange bool - }{ - // LT - {f0, pql.LT, 5, 105, false}, - {f0, pql.LT, -8, 92, false}, - {f0, pql.LT, -108, 0, true}, - {f0, pql.LT, 1005, 1000, false}, - {f0, pql.LT, 0, 100, false}, - - {f1, pql.LT, 5, 5, false}, - {f1, pql.LT, -8, 0, true}, - {f1, pql.LT, 1005, 1000, false}, - {f1, pql.LT, 0, 0, false}, - - {f2, pql.LT, 5, 0, true}, - {f2, pql.LT, -8, 0, true}, - {f2, pql.LT, 105, 5, false}, - {f2, pql.LT, 1105, 1000, false}, - - // GT - {f0, pql.GT, -105, 0, false}, - {f0, pql.GT, 5, 105, false}, - {f0, pql.GT, 905, 0, true}, - {f0, pql.GT, 0, 100, false}, - - {f1, pql.GT, 5, 5, false}, - {f1, pql.GT, -8, 0, false}, - {f1, pql.GT, 1005, 0, true}, - {f1, pql.GT, 0, 0, false}, - - {f2, pql.GT, 5, 0, false}, - {f2, pql.GT, -8, 0, false}, - {f2, pql.GT, 105, 5, false}, - {f2, pql.GT, 1105, 0, true}, - - // EQ - {f0, pql.EQ, -105, 0, true}, - {f0, pql.EQ, 5, 105, false}, - {f0, pql.EQ, 905, 0, true}, - {f0, pql.EQ, 0, 100, false}, - - {f1, pql.EQ, 5, 5, false}, - {f1, pql.EQ, -8, 0, true}, - {f1, pql.EQ, 1005, 0, true}, - {f1, pql.EQ, 0, 0, false}, - - {f2, pql.EQ, 5, 0, true}, - {f2, pql.EQ, -8, 0, true}, - {f2, pql.EQ, 105, 5, false}, - {f2, pql.EQ, 1105, 0, true}, - } { - bv, oor := tt.f.BaseValue(tt.op, tt.val) - if oor != tt.expOutOfRange { - t.Fatalf("baseValue calculation on %s op %s, expected outOfRange %v, got %v", tt.f.Name, tt.op, tt.expOutOfRange, oor) - } else if !reflect.DeepEqual(bv, tt.expBaseValue) { - t.Fatalf("baseValue calculation on %s, expected value %v, got %v", tt.f.Name, tt.expBaseValue, bv) - } - } - }) - - t.Run("Betwween Condition", func(t *testing.T) { - for _, tt := range []struct { - f *pilosa.Field - predMin int64 - predMax int64 - expBaseValueMin uint64 - expBaseValueMax uint64 - expOutOfRange bool - }{ - - {f0, -205, -105, 0, 0, true}, - {f0, -105, 80, 0, 180, false}, - {f0, 5, 20, 105, 120, false}, - {f0, 20, 1005, 120, 1000, false}, - {f0, 1005, 2000, 0, 0, true}, - - {f1, -105, -5, 0, 0, true}, - {f1, -5, 20, 0, 20, false}, - {f1, 5, 20, 5, 20, false}, - {f1, 20, 1005, 20, 1000, false}, - {f1, 1005, 2000, 0, 0, true}, - - {f2, 5, 95, 0, 0, true}, - {f2, 95, 120, 0, 20, false}, - {f2, 105, 120, 5, 20, false}, - {f2, 120, 1105, 20, 1000, false}, - {f2, 1105, 2000, 0, 0, true}, - } { - min, max, oor := tt.f.BaseValueBetween(tt.predMin, tt.predMax) - if oor != tt.expOutOfRange { - t.Fatalf("baseValueBetween calculation on %s, expected outOfRange %v, got %v", tt.f.Name, tt.expOutOfRange, oor) - } else if !reflect.DeepEqual(min, tt.expBaseValueMin) || !reflect.DeepEqual(max, tt.expBaseValueMax) { - t.Fatalf("baseValueBetween calculation on %s, expected min/max %v/%v, got %v/%v", tt.f.Name, tt.expBaseValueMin, tt.expBaseValueMax, min, max) - } - } - }) -} diff --git a/handler_test.go b/handler_test.go index a7ba8fa85..30bba9254 100644 --- a/handler_test.go +++ b/handler_test.go @@ -17,7 +17,6 @@ package pilosa_test import ( "bytes" "context" - "encoding/json" "errors" "fmt" "io" @@ -817,245 +816,6 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) { } } -// Ensure the handler can create a new field on an existing frame. -func TestHandler_Frame_AddField(t *testing.T) { - hldr := test.MustOpenHolder() - defer hldr.Close() - - s := test.NewServer() - s.Handler.API.Holder = hldr.Holder - defer s.Close() - - t.Run("OK", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) - if err != nil { - t.Fatal(err) - } - - resp, err := http.Post( - s.URL+"/index/i/frame/f/field/x", - "application/json", - strings.NewReader(`{"type":"int","min":100,"max":200}`), - ) - if err != nil { - t.Fatal(err) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusOK { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - - if field := f.Field("x"); !reflect.DeepEqual(field, &pilosa.Field{Name: "x", Type: "int", Min: 100, Max: 200}) { - t.Fatalf("unexpected field: %#v", field) - } - }) - - t.Run("ErrInvalidFieldType", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { - t.Fatal(err) - } - - resp, err := http.Post( - s.URL+"/index/i/frame/f/field/x", - "application/json", - strings.NewReader(`{"type":"bad_type","min":100,"max":200}`), - ) - if err != nil { - t.Fatal(err) - } else if body := MustReadAll(resp.Body); string(body) != `creating field: validating field: invalid field type`+"\n" { - t.Fatalf("unexpected body: %q", body) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusInternalServerError { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - }) - - t.Run("ErrInvalidFieldRange", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { - t.Fatal(err) - } - - resp, err := http.Post( - s.URL+"/index/i/frame/f/field/x", - "application/json", - strings.NewReader(`{"type":"int","min":200,"max":100}`), - ) - if err != nil { - t.Fatal(err) - } else if body := MustReadAll(resp.Body); string(body) != `creating field: validating field: invalid field range`+"\n" { - t.Fatalf("unexpected body: %q", body) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusInternalServerError { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - }) - - t.Run("ErrFieldAlreadyExists", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{{Name: "x", Type: pilosa.FieldTypeInt, Min: 0, Max: 100}}, - }); err != nil { - t.Fatal(err) - } - - resp, err := http.Post( - s.URL+"/index/i/frame/f/field/x", - "application/json", - strings.NewReader(`{"type":"int","min":0,"max":100}`), - ) - if err != nil { - t.Fatal(err) - } else if body := MustReadAll(resp.Body); string(body) != `creating field: field already exists`+"\n" { - t.Fatalf("unexpected body: %q", body) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusInternalServerError { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - }) -} - -// Ensure the handler can delete existing fields. -func TestHandler_Frame_DeleteField(t *testing.T) { - hldr := test.MustOpenHolder() - defer hldr.Close() - - s := test.NewServer() - s.Handler.API.Holder = hldr.Holder - defer s.Close() - - t.Run("OK", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) - if err != nil { - t.Fatal(err) - } else if err := f.CreateField(&pilosa.Field{Name: "x", Type: pilosa.FieldTypeInt, Min: 0, Max: 100}); err != nil { - t.Fatal(err) - } - - req, err := http.NewRequest("DELETE", s.URL+"/index/i/frame/f/field/x", nil) - if err != nil { - t.Fatal(err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusOK { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - - if field := f.Field("x"); field != nil { - t.Fatalf("expected nil field, got: %#v", field) - } - }) - - t.Run("ErrFieldNotFound", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) - if err != nil { - t.Fatal(err) - } else if err := f.CreateField(&pilosa.Field{Name: "x", Type: pilosa.FieldTypeInt, Min: 0, Max: 100}); err != nil { - t.Fatal(err) - } - - req, err := http.NewRequest("DELETE", s.URL+"/index/i/frame/f/field/y", nil) - if err != nil { - t.Fatal(err) - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } else if body, err := ioutil.ReadAll(resp.Body); err != nil { - t.Fatal(err) - } else if strings.TrimSpace(string(body)) != `deleting field: field not found` { - t.Fatalf("unexpected body: %q", body) - } else if err := resp.Body.Close(); err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusInternalServerError { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - }) -} - -func TestHandler_Frame_GetFields(t *testing.T) { - hldr := test.MustOpenHolder() - defer hldr.Close() - - s := test.NewServer() - s.Handler.API.Holder = hldr.Holder - defer s.Close() - - t.Run("OK", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) - if err != nil { - t.Fatal(err) - } else if err := f.CreateField(&pilosa.Field{Name: "x", Type: pilosa.FieldTypeInt, Min: 1, Max: 100}); err != nil { - t.Fatal(err) - } - resp, err := http.Get(s.URL + "/index/i/frame/f/fields") - if err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusOK { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } - - var fields FrameFields - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Fatal(err) - } - if err = json.Unmarshal([]byte(body), &fields); err != nil { - t.Fatal(err) - } - field := fields.Fields[0] - if field.Name != "x" { - t.Fatalf("expected field's name: x, actuall name: %v", field.Name) - } else if field.Min != 1 { - t.Fatalf("expected field's min: x, actuall min: %v", field.Min) - } else if field.Max != 100 { - t.Fatalf("expected field's max: x, actuall max: %v", field.Max) - } - - }) - - t.Run("ErrFrameFieldNotAllowed", func(t *testing.T) { - idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - _, err := idx.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}) - if err != nil { - t.Fatalf("creating frame: %v", err) - } - - resp, err := http.Get(s.URL + "/index/i/frame/f1/fields") - if err != nil { - t.Fatal(err) - } - if err != nil { - t.Fatal(err) - } else if resp.StatusCode != http.StatusOK { - t.Fatalf("unexpected status code: %d", resp.StatusCode) - } else if body, err := ioutil.ReadAll(resp.Body); err != nil { - t.Fatal(err) - } else if strings.TrimSpace(string(body)) == `frame fields not allowed` { - t.Fatalf("shouldn't get frame fields not allowed error: %q", body) - } - }) - -} - -type FrameFields struct { - Fields []pilosa.Field -} - // Ensure the handler can retrieve the version. func TestHandler_Version(t *testing.T) { hldr := test.MustOpenHolder() diff --git a/index_test.go b/index_test.go index 0a42804e2..3a4ee48bc 100644 --- a/index_test.go +++ b/index_test.go @@ -57,7 +57,10 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with explicit quantum. - f, err := index.CreateFrame("f", pilosa.FrameOptions{TimeQuantum: pilosa.TimeQuantum("YMDH")}) + f, err := index.CreateFrame("f", pilosa.FrameOptions{ + Type: pilosa.FrameTypeTime, + TimeQuantum: pilosa.TimeQuantum("YMDH"), + }) if err != nil { t.Fatal(err) } else if q := f.TimeQuantum(); q != pilosa.TimeQuantum("YMDH") { @@ -74,103 +77,100 @@ func TestIndex_CreateFrame(t *testing.T) { // Create frame with schema and verify it exists. if f, err := index.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 10, Max: 20}, - {Name: "field1", Type: pilosa.FieldTypeInt, Min: 11, Max: 21}, - }, + Type: pilosa.FrameTypeInt, + Min: 10, + Max: 20, }); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(f.Fields(), []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 10, Max: 20}, - {Name: "field1", Type: pilosa.FieldTypeInt, Min: 11, Max: 21}, - }) { - t.Fatalf("unexpected fields: %#v", f.Fields()) + } else if !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + t.Fatalf("unexpected type: %#v", f.Type()) } // Reopen the index & verify the fields are loaded. if err := index.Reopen(); err != nil { t.Fatal(err) - } else if f := index.Frame("f"); !reflect.DeepEqual(f.Fields(), []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 10, Max: 20}, - {Name: "field1", Type: pilosa.FieldTypeInt, Min: 11, Max: 21}, - }) { - t.Fatalf("unexpected fields after reopen: %#v", f.Fields()) + } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + t.Fatalf("unexpected type after reopen: %#v", f.Type()) } }) - t.Run("ErrRangeCacheAllowed", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() + // TODO: These errors don't apply here. Instead, we need these tests + // on frame creation FrameOptions validation. + /* + t.Run("ErrRangeCacheAllowed", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - CacheType: pilosa.CacheTypeRanked, - }); err != nil { - t.Fatal(err) - } - }) + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + CacheType: pilosa.CacheTypeRanked, + }); err != nil { + t.Fatal(err) + } + }) - t.Run("BSIFieldsWithCacheTypeNone", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - CacheType: pilosa.CacheTypeNone, - CacheSize: uint32(5), - }); err != nil { - t.Fatal(err) - } - }) + t.Run("BSIFieldsWithCacheTypeNone", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + CacheType: pilosa.CacheTypeNone, + CacheSize: uint32(5), + }); err != nil { + t.Fatal(err) + } + }) - t.Run("ErrFrameFieldsAllowed", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() + t.Run("ErrFrameFieldsAllowed", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt}, - }, - }); err != nil { - t.Fatal(err) - } - }) + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + Fields: []*pilosa.Field{ + {Name: "field0", Type: pilosa.FieldTypeInt}, + }, + }); err != nil { + t.Fatal(err) + } + }) - t.Run("ErrFieldNameRequired", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() + t.Run("ErrFieldNameRequired", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "", Type: pilosa.FieldTypeInt}, - }, - }); err != pilosa.ErrFieldNameRequired { - t.Fatal(err) - } - }) + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + Fields: []*pilosa.Field{ + {Name: "", Type: pilosa.FieldTypeInt}, + }, + }); err != pilosa.ErrFieldNameRequired { + t.Fatal(err) + } + }) - t.Run("ErrInvalidFieldType", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() + t.Run("ErrInvalidFieldType", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: "bad_type"}, - }, - }); err != pilosa.ErrInvalidFieldType { - t.Fatal(err) - } - }) + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + Fields: []*pilosa.Field{ + {Name: "field0", Type: "bad_type"}, + }, + }); err != pilosa.ErrInvalidFieldType { + t.Fatal(err) + } + }) - t.Run("ErrInvalidFieldRange", func(t *testing.T) { - index := test.MustOpenIndex() - defer index.Close() + t.Run("ErrInvalidFieldRange", func(t *testing.T) { + index := test.MustOpenIndex() + defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ - Fields: []*pilosa.Field{ - {Name: "field0", Type: pilosa.FieldTypeInt, Min: 100, Max: 50}, - }, - }); err != pilosa.ErrInvalidFieldRange { - t.Fatal(err) - } - }) + if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + Fields: []*pilosa.Field{ + {Name: "field0", Type: pilosa.FieldTypeInt, Min: 100, Max: 50}, + }, + }); err != pilosa.ErrInvalidFieldRange { + t.Fatal(err) + } + }) + */ }) } diff --git a/test/frame.go b/test/frame.go index e107b7d85..09503a3cf 100644 --- a/test/frame.go +++ b/test/frame.go @@ -29,12 +29,12 @@ type Frame struct { } // NewFrame returns a new instance of Frame d/0. -func NewFrame() *Frame { +func NewFrame(opt ...pilosa.FrameOption) *Frame { path, err := ioutil.TempDir("", "pilosa-frame-") if err != nil { panic(err) } - frame, err := pilosa.NewFrame(path, "i", "f") + frame, err := pilosa.NewFrame(path, "i", "f", opt...) if err != nil { panic(err) } @@ -42,8 +42,8 @@ func NewFrame() *Frame { } // MustOpenFrame returns a new, opened frame at a temporary path. Panic on error. -func MustOpenFrame() *Frame { - f := NewFrame() +func MustOpenFrame(opt ...pilosa.FrameOption) *Frame { + f := NewFrame(opt...) if err := f.Open(); err != nil { panic(err) } From 17c793447379ac3b3b4af4622feacc80685bf59e Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 14:18:40 -0500 Subject: [PATCH 09/52] un-export HasField. remove dead code --- frame.go | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/frame.go b/frame.go index 35d417136..1307df32d 100644 --- a/frame.go +++ b/frame.go @@ -390,8 +390,8 @@ func (f *Frame) Field(name string) *oField { return nil } -// HasField returns true if a field exists on the frame. -func (f *Frame) HasField(name string) bool { +// hasField returns true if a field exists on the frame. +func (f *Frame) hasField(name string) bool { for _, fld := range f.fields { if fld.Name == name { return true @@ -417,7 +417,7 @@ func (f *Frame) CreateField(field *oField) error { func (f *Frame) addField(field *oField) error { if err := ValidateField(field); err != nil { return errors.Wrap(err, "validating field") - } else if f.HasField(field.Name) { + } else if f.hasField(field.Name) { return ErrFieldExists } @@ -1168,28 +1168,6 @@ func ValidateField(f *oField) error { return nil } -func encodeFields(a []*oField) []*internal.Field { - if len(a) == 0 { - return nil - } - other := make([]*internal.Field, len(a)) - for i := range a { - other[i] = encodeField(a[i]) - } - return other -} - -func decodeFields(a []*internal.Field) []*oField { - if len(a) == 0 { - return nil - } - other := make([]*oField, len(a)) - for i := range a { - other[i] = decodeField(a[i]) - } - return other -} - func encodeField(f *oField) *internal.Field { if f == nil { return nil From 90a4d957bdc097de2171bb4f88a62f0213864ae8 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 22:06:45 -0500 Subject: [PATCH 10/52] remove `frame` argument from Frame.SetFieldValue(). Rename it to Frame.SetValue() --- executor.go | 22 ++++++---------- executor_test.go | 65 +++++++++++++++++++++--------------------------- frame.go | 8 +++--- frame_test.go | 18 ++++++-------- test/cluster.go | 3 ++- utils_test.go | 3 ++- 6 files changed, 53 insertions(+), 66 deletions(-) diff --git a/executor.go b/executor.go index 97f42acf1..c8ea9e544 100644 --- a/executor.go +++ b/executor.go @@ -1109,17 +1109,6 @@ func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.C // executeSetFieldValue executes a SetFieldValue() call. func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error { - frameName, ok := c.Args["frame"].(string) - if !ok { - return errors.New("SetFieldValue() frame required") - } - - // Retrieve frame. - frame := e.Holder.Frame(index, frameName) - if frame == nil { - return ErrFrameNotFound - } - // Parse labels. columnID, ok, err := c.UintArg(columnLabel) if err != nil { @@ -1130,23 +1119,28 @@ func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pq // Copy args and remove reserved fields. args := pql.CopyArgs(c.Args) - delete(args, "frame") // While frame could technically work as a ColumnAttr argument, we are treating it as a reserved word primarily to avoid confusion. // Also, if we ever need to make ColumnAttrs frame-specific, then having this reserved word prevents backward incompatibility. delete(args, columnLabel) // Set values. for name, value := range args { + // Retrieve frame. + frame := e.Holder.Frame(index, name) + if frame == nil { + return ErrFrameNotFound + } + switch value := value.(type) { case int64: - if _, err := frame.SetFieldValue(columnID, name, value); err != nil { + if _, err := frame.SetValue(columnID, value); err != nil { return err } default: return ErrInvalidFieldValueType } + frame.Stats.Count("SetFieldValue", 1, 1.0) } - frame.Stats.Count("SetFieldValue", 1, 1.0) // Do not forward call if this is already being forwarded. if opt.Remote { diff --git a/executor_test.go b/executor_test.go index fbce4d52d..0b70a9e16 100644 --- a/executor_test.go +++ b/executor_test.go @@ -283,9 +283,9 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { // Set field values. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, f=25)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f=25)`), nil, nil); err != nil { t.Fatal(err) - } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, frame=f, f=10)`), nil, nil); err != nil { + } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, f=10)`), nil, nil); err != nil { t.Fatal(err) } @@ -319,30 +319,23 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { t.Fatal(err) } - t.Run("ErrFrameRequired", func(t *testing.T) { - e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() frame required` { - t.Fatalf("unexpected error: %s", err) - } - }) - t.Run("ErrColumnFieldRequired", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, frame=f, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrColumnFieldValue", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", frame=f, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrInvalidFieldValueType", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, frame=f, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { t.Fatalf("unexpected error: %s", err) } }) @@ -598,14 +591,14 @@ func TestExecutor_Execute_MinMax(t *testing.T) { SetBit(frame=x, row=1, col=1) SetBit(frame=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, f=20, col=0) - SetFieldValue(frame=f, f=-5, col=1) - SetFieldValue(frame=f, f=-5, col=2) - SetFieldValue(frame=f, f=10, col=3) - SetFieldValue(frame=f, f=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=f, f=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=f, f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=f, f=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(f=20, col=0) + SetFieldValue(f=-5, col=1) + SetFieldValue(f=-5, col=2) + SetFieldValue(f=10, col=3) + SetFieldValue(f=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(f=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(f=60, col=`+strconv.Itoa(SliceWidth+1)+`) `), nil, nil); err != nil { t.Fatal(err) } @@ -706,13 +699,13 @@ func TestExecutor_Execute_Sum(t *testing.T) { SetBit(frame=x, row=0, col=0) SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=foo, foo=20, col=0) - SetFieldValue(frame=bar, bar=2000, col=0) - SetFieldValue(frame=foo, foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=foo, foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=foo, foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=foo, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=other, other=1000, col=0) + SetFieldValue(foo=20, col=0) + SetFieldValue(bar=2000, col=0) + SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(other=1000, col=0) `), nil, nil); err != nil { t.Fatal(err) } @@ -827,15 +820,15 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { SetBit(frame=f, row=0, col=0) SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=foo, foo=20, col=50) - SetFieldValue(frame=bar, bar=2000, col=50) - SetFieldValue(frame=foo, foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(frame=foo, foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(frame=foo, foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(frame=foo, foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(frame=other, other=1000, col=0) - SetFieldValue(frame=edge, edge=100, col=0) - SetFieldValue(frame=edge, edge=-100, col=1) + SetFieldValue(foo=20, col=50) + SetFieldValue(bar=2000, col=50) + SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetFieldValue(foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) + SetFieldValue(foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetFieldValue(other=1000, col=0) + SetFieldValue(edge=100, col=0) + SetFieldValue(edge=-100, col=1) `), nil, nil); err != nil { t.Fatal(err) } diff --git a/frame.go b/frame.go index 1307df32d..f460a1224 100644 --- a/frame.go +++ b/frame.go @@ -726,10 +726,10 @@ func (f *Frame) FieldValue(columnID uint64, name string) (value int64, exists bo return int64(v) + field.Min, true, nil } -// SetFieldValue sets a field value for a column. -func (f *Frame) SetFieldValue(columnID uint64, name string, value int64) (changed bool, err error) { +// SetValue sets a field value for a column. +func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) { // Fetch field and validate value. - field := f.Field(name) + field := f.Field(f.name) if field == nil { return false, ErrFieldNotFound } else if value < field.Min { @@ -739,7 +739,7 @@ func (f *Frame) SetFieldValue(columnID uint64, name string, value int64) (change } // Fetch target view. - view, err := f.CreateViewIfNotExists(ViewFieldPrefix + name) + view, err := f.CreateViewIfNotExists(ViewFieldPrefix + f.name) if err != nil { return false, errors.Wrap(err, "creating view") } diff --git a/frame_test.go b/frame_test.go index 8ad9b020a..8000886c0 100644 --- a/frame_test.go +++ b/frame_test.go @@ -87,7 +87,7 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Set value on field. - if changed, err := f.SetFieldValue(100, "f", 21); err != nil { + if changed, err := f.SetValue(100, 21); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") @@ -103,7 +103,7 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Setting value should return no change. - if changed, err := f.SetFieldValue(100, "f", 21); err != nil { + if changed, err := f.SetValue(100, 21); err != nil { t.Fatal(err) } else if changed { t.Fatal("expected no change") @@ -124,14 +124,14 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Set value. - if changed, err := f.SetFieldValue(100, "f", 21); err != nil { + if changed, err := f.SetValue(100, 21); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") } // Set different value. - if changed, err := f.SetFieldValue(100, "f", 23); err != nil { + if changed, err := f.SetValue(100, 23); err != nil { t.Fatal(err) } else if !changed { t.Fatal("expected change") @@ -152,16 +152,14 @@ func TestFrame_SetFieldValue(t *testing.T) { defer idx.Close() f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, - Min: 0, - Max: 30, + Type: pilosa.FrameTypeSet, }) if err != nil { t.Fatal(err) } // Set value. - if _, err := f.SetFieldValue(100, "no_such_field", 21); err != pilosa.ErrFieldNotFound { + if _, err := f.SetValue(100, 21); err != pilosa.ErrFieldNotFound { t.Fatalf("unexpected error: %s", err) } }) @@ -180,7 +178,7 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Set value. - if _, err := f.SetFieldValue(100, "f", 15); err != pilosa.ErrFieldValueTooLow { + if _, err := f.SetValue(100, 15); err != pilosa.ErrFieldValueTooLow { t.Fatalf("unexpected error: %s", err) } }) @@ -199,7 +197,7 @@ func TestFrame_SetFieldValue(t *testing.T) { } // Set value. - if _, err := f.SetFieldValue(100, "f", 31); err != pilosa.ErrFieldValueTooHigh { + if _, err := f.SetValue(100, 31); err != pilosa.ErrFieldValueTooHigh { t.Fatalf("unexpected error: %s", err) } }) diff --git a/test/cluster.go b/test/cluster.go index 77cf496a8..9089089a7 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -150,6 +150,7 @@ func (t *TestCluster) SetBit(index, frame, view string, rowID, colID uint64, x * return nil } +// TODO: remove `name` from this function signature func (t *TestCluster) SetFieldValue(index, frame string, columnID uint64, name string, value int64) error { // Determine which node should receive the SetFieldValue. c0 := t.Clusters[0] // use the first node's cluster to determine slice location. @@ -165,7 +166,7 @@ func (t *TestCluster) SetFieldValue(index, frame string, columnID uint64, name s if f == nil { return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) } - _, err := f.SetFieldValue(columnID, name, value) + _, err := f.SetValue(columnID, value) if err != nil { return err } diff --git a/utils_test.go b/utils_test.go index 1732522d4..26fe06890 100644 --- a/utils_test.go +++ b/utils_test.go @@ -141,6 +141,7 @@ func (t *ClusterCluster) SetBit(index, frame, view string, rowID, colID uint64, return nil } +// TODO: remove `name` from this function signature func (t *ClusterCluster) SetFieldValue(index, frame string, columnID uint64, name string, value int64) error { // Determine which node should receive the SetFieldValue. c0 := t.Clusters[0] // use the first node's cluster to determine slice location. @@ -156,7 +157,7 @@ func (t *ClusterCluster) SetFieldValue(index, frame string, columnID uint64, nam if f == nil { return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) } - _, err := f.SetFieldValue(columnID, name, value) + _, err := f.SetValue(columnID, value) if err != nil { return err } From c49fdb7b9bfb96c12cd9754393bfba84f957a8f9 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 22:11:19 -0500 Subject: [PATCH 11/52] rename executor.SetFieldValue() to executor.SetValue() --- executor.go | 14 +++++------ executor_test.go | 62 ++++++++++++++++++++++++------------------------ frame_test.go | 2 +- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/executor.go b/executor.go index c8ea9e544..589b0ace5 100644 --- a/executor.go +++ b/executor.go @@ -138,8 +138,8 @@ func (e *Executor) executeCall(ctx context.Context, index string, c *pql.Call, s return e.executeCount(ctx, index, c, slices, opt) case "SetBit": return e.executeSetBit(ctx, index, c, opt) - case "SetFieldValue": - return nil, e.executeSetFieldValue(ctx, index, c, opt) + case "SetValue": + return nil, e.executeSetValue(ctx, index, c, opt) case "SetRowAttrs": return nil, e.executeSetRowAttrs(ctx, index, c, opt) case "SetColumnAttrs": @@ -1107,14 +1107,14 @@ func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.C return ret, nil } -// executeSetFieldValue executes a SetFieldValue() call. -func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error { +// executeSetValue executes a SetValue() call. +func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error { // Parse labels. columnID, ok, err := c.UintArg(columnLabel) if err != nil { - return fmt.Errorf("reading SetFieldValue() column: %v", err) + return fmt.Errorf("reading SetValue() column: %v", err) } else if !ok { - return fmt.Errorf("SetFieldValue() column field '%v' required", columnLabel) + return fmt.Errorf("SetValue() column field '%v' required", columnLabel) } // Copy args and remove reserved fields. @@ -1139,7 +1139,7 @@ func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pq default: return ErrInvalidFieldValueType } - frame.Stats.Count("SetFieldValue", 1, 1.0) + frame.Stats.Count("SetValue", 1, 1.0) } // Do not forward call if this is already being forwarded. diff --git a/executor_test.go b/executor_test.go index 0b70a9e16..a8cce5194 100644 --- a/executor_test.go +++ b/executor_test.go @@ -263,8 +263,8 @@ func TestExecutor_Execute_SetBit(t *testing.T) { } } -// Ensure a SetFieldValue() query can be executed. -func TestExecutor_Execute_SetFieldValue(t *testing.T) { +// Ensure a SetValue() query can be executed. +func TestExecutor_Execute_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() @@ -283,9 +283,9 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { // Set field values. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f=25)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f=25)`), nil, nil); err != nil { t.Fatal(err) - } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, f=10)`), nil, nil); err != nil { + } else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=100, f=10)`), nil, nil); err != nil { t.Fatal(err) } @@ -321,21 +321,21 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) { t.Run("ErrColumnFieldRequired", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrColumnFieldValue", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) t.Run("ErrInvalidFieldValueType", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { t.Fatalf("unexpected error: %s", err) } }) @@ -591,14 +591,14 @@ func TestExecutor_Execute_MinMax(t *testing.T) { SetBit(frame=x, row=1, col=1) SetBit(frame=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(f=20, col=0) - SetFieldValue(f=-5, col=1) - SetFieldValue(f=-5, col=2) - SetFieldValue(f=10, col=3) - SetFieldValue(f=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(f=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(f=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetValue(f=20, col=0) + SetValue(f=-5, col=1) + SetValue(f=-5, col=2) + SetValue(f=10, col=3) + SetValue(f=30, col=`+strconv.Itoa(SliceWidth)+`) + SetValue(f=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetValue(f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetValue(f=60, col=`+strconv.Itoa(SliceWidth+1)+`) `), nil, nil); err != nil { t.Fatal(err) } @@ -699,13 +699,13 @@ func TestExecutor_Execute_Sum(t *testing.T) { SetBit(frame=x, row=0, col=0) SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(foo=20, col=0) - SetFieldValue(bar=2000, col=0) - SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(other=1000, col=0) + SetValue(foo=20, col=0) + SetValue(bar=2000, col=0) + SetValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetValue(foo=40, col=`+strconv.Itoa(SliceWidth+2)+`) + SetValue(foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetValue(other=1000, col=0) `), nil, nil); err != nil { t.Fatal(err) } @@ -820,15 +820,15 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { SetBit(frame=f, row=0, col=0) SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(foo=20, col=50) - SetFieldValue(bar=2000, col=50) - SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) - SetFieldValue(foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) - SetFieldValue(foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) - SetFieldValue(other=1000, col=0) - SetFieldValue(edge=100, col=0) - SetFieldValue(edge=-100, col=1) + SetValue(foo=20, col=50) + SetValue(bar=2000, col=50) + SetValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`) + SetValue(foo=10, col=`+strconv.Itoa(SliceWidth+2)+`) + SetValue(foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`) + SetValue(other=1000, col=0) + SetValue(edge=100, col=0) + SetValue(edge=-100, col=1) `), nil, nil); err != nil { t.Fatal(err) } diff --git a/frame_test.go b/frame_test.go index 8000886c0..9b7f9a336 100644 --- a/frame_test.go +++ b/frame_test.go @@ -72,7 +72,7 @@ func TestFrame_SetTimeQuantum(t *testing.T) { } // Ensure a frame can set & read a field value. -func TestFrame_SetFieldValue(t *testing.T) { +func TestFrame_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() From 17c8944685412940abeef4758f3b71e0d152e45b Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 22:14:45 -0500 Subject: [PATCH 12/52] rename view.SetFieldValue() to view.setValue() --- frame.go | 2 +- view.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame.go b/frame.go index f460a1224..ff20bddcc 100644 --- a/frame.go +++ b/frame.go @@ -747,7 +747,7 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) // Determine base value to store. baseValue := uint64(value - field.Min) - return view.SetFieldValue(columnID, field.BitDepth(), baseValue) + return view.setValue(columnID, field.BitDepth(), baseValue) } // FieldSum returns the sum and count for a field. diff --git a/view.go b/view.go index f90bf64e9..a1129c7be 100644 --- a/view.go +++ b/view.go @@ -333,8 +333,8 @@ func (v *View) FieldValue(columnID uint64, bitDepth uint) (value uint64, exists return frag.FieldValue(columnID, bitDepth) } -// SetFieldValue uses a column of bits to set a multi-bit value. -func (v *View) SetFieldValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { +// setValue uses a column of bits to set a multi-bit value. +func (v *View) setValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { slice := columnID / SliceWidth frag, err := v.CreateFragmentIfNotExists(slice) if err != nil { From dd6b80f90d604056d51fb97126417b809a203262 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 1 Jun 2018 22:25:26 -0500 Subject: [PATCH 13/52] rename fragment.SetFieldValue() to fragment.SetValue(). Still exported for tests --- fragment.go | 10 +++--- fragment_test.go | 88 ++++++++++++++++++++++++------------------------ test/cluster.go | 25 -------------- utils_test.go | 25 -------------- view.go | 2 +- 5 files changed, 50 insertions(+), 100 deletions(-) diff --git a/fragment.go b/fragment.go index 8044f579b..f2d7ad986 100644 --- a/fragment.go +++ b/fragment.go @@ -510,8 +510,8 @@ func (f *Fragment) FieldValue(columnID uint64, bitDepth uint) (value uint64, exi return value, true, nil } -// SetFieldValue uses a column of bits to set a multi-bit value. -func (f *Fragment) SetFieldValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { +// SetValue uses a column of bits to set a multi-bit value. +func (f *Fragment) SetValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { f.mu.Lock() defer f.mu.Unlock() @@ -541,8 +541,8 @@ func (f *Fragment) SetFieldValue(columnID uint64, bitDepth uint, value uint64) ( return changed, nil } -// importSetFieldValue is a more efficient SetFieldValue just for imports. -func (f *Fragment) importSetFieldValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { +// importSetValue is a more efficient SetValue just for imports. +func (f *Fragment) importSetValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) { for i := uint(0); i < bitDepth; i++ { if value&(1< Date: Mon, 4 Jun 2018 15:32:43 -0500 Subject: [PATCH 14/52] rename oField to bsiGroup --- api.go | 12 ++--- frame.go | 113 +++++++++++++++++++------------------- frame_internal_test.go | 120 ++++++++++++++++++++--------------------- 3 files changed, 122 insertions(+), 123 deletions(-) diff --git a/api.go b/api.go index c02aedbf2..9a50a3542 100644 --- a/api.go +++ b/api.go @@ -489,7 +489,7 @@ func (api *API) Schema(ctx context.Context) []*IndexInfo { } // CreateField creates a new BSI field in the given index and frame. -func (api *API) CreateField(ctx context.Context, indexName string, frameName string, field *oField) error { +func (api *API) CreateField(ctx context.Context, indexName string, frameName string, bsig *bsiGroup) error { if err := api.validate(apiCreateField); err != nil { return errors.Wrap(err, "validating api method") } @@ -500,17 +500,17 @@ func (api *API) CreateField(ctx context.Context, indexName string, frameName str return ErrFrameNotFound } - // Create new field. - if err := f.CreateField(field); err != nil { - return errors.Wrap(err, "creating field") + // Create new bsiGroup. + if err := f.CreateField(bsig); err != nil { + return errors.Wrap(err, "creating bsigroup") } - // Send the create field message to all nodes. + // Send the create bsigroup message to all nodes. err := api.Broadcaster.SendSync( &internal.CreateFieldMessage{ Index: indexName, Frame: frameName, - Field: encodeField(field), + Field: encodeField(bsig), }) if err != nil { api.Logger.Printf("problem sending CreateField message: %s", err) diff --git a/frame.go b/frame.go index ff20bddcc..4fa755e62 100644 --- a/frame.go +++ b/frame.go @@ -64,7 +64,7 @@ type Frame struct { // Frame options. options FrameOptions - fields []*oField + fields []*bsiGroup Logger Logger } @@ -325,19 +325,19 @@ func (f *Frame) applyOptions(opt FrameOptions) error { f.options.Max = opt.Max f.options.TimeQuantum = "" - // Create new field. - field := &oField{ + // Create new bsiGroup. + bsig := &bsiGroup{ Name: f.name, Type: FieldTypeInt, Min: opt.Min, Max: opt.Max, } - // Validate field. - if err := ValidateField(field); err != nil { + // Validate bsiGroup. + if err := ValidateField(bsig); err != nil { return err } - if err := f.CreateField(field); err != nil { - return errors.Wrap(err, "creating field") + if err := f.CreateField(bsig); err != nil { + return errors.Wrap(err, "creating bsigroup") } case FrameTypeTime: f.options.Type = opt.Type @@ -379,7 +379,7 @@ func (f *Frame) Close() error { } // Field returns a field by name. -func (f *Frame) Field(name string) *oField { +func (f *Frame) Field(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() for _, field := range f.fields { @@ -401,12 +401,12 @@ func (f *Frame) hasField(name string) bool { } // CreateField creates a new field on the frame. -func (f *Frame) CreateField(field *oField) error { +func (f *Frame) CreateField(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() - // Append field. - if err := f.addField(field); err != nil { + // Append bsiGroup. + if err := f.addField(bsig); err != nil { return err } f.saveMeta() @@ -414,15 +414,15 @@ func (f *Frame) CreateField(field *oField) error { } // addField adds a single field to fields. -func (f *Frame) addField(field *oField) error { - if err := ValidateField(field); err != nil { - return errors.Wrap(err, "validating field") - } else if f.hasField(field.Name) { +func (f *Frame) addField(bsig *bsiGroup) error { + if err := ValidateField(bsig); err != nil { + return errors.Wrap(err, "validating bsigroup") + } else if f.hasField(bsig.Name) { return ErrFieldExists } - // Add field to list. - f.fields = append(f.fields, field) + // Add bsiGroup to list. + f.fields = append(f.fields, bsig) // Sort fields by name. sort.Slice(f.fields, func(i, j int) bool { @@ -1084,9 +1084,8 @@ func IsValidFieldType(v string) bool { } } -// TODO: finish unexporting this. also, rename it. -// oField represents a range field on a frame. -type oField struct { +// bsiGroup represents a range field on a frame. +type bsiGroup struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Min int64 `json:"min,omitempty"` @@ -1094,9 +1093,9 @@ type oField struct { } // BitDepth returns the number of bits required to store a value between min & max. -func (f *oField) BitDepth() uint { +func (b *bsiGroup) BitDepth() uint { for i := uint(0); i < 63; i++ { - if f.Max-f.Min < (1 << i) { + if b.Max-b.Min < (1 << i) { return i } } @@ -1115,80 +1114,80 @@ func (f *oField) BitDepth() uint { // In order to make this work, we effectively need to change the operator to LTE. // Executor.executeFieldRangeSlice() takes this into account and returns // `frag.FieldNotNull(field.BitDepth())` in such instances. -func (f *oField) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { +func (b *bsiGroup) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { if op == pql.GT || op == pql.GTE { - if value > f.Max { + if value > b.Max { return baseValue, true - } else if value > f.Min { - baseValue = uint64(value - f.Min) + } else if value > b.Min { + baseValue = uint64(value - b.Min) } } else if op == pql.LT || op == pql.LTE { - if value < f.Min { + if value < b.Min { return baseValue, true - } else if value > f.Max { - baseValue = uint64(f.Max - f.Min) + } else if value > b.Max { + baseValue = uint64(b.Max - b.Min) } else { - baseValue = uint64(value - f.Min) + baseValue = uint64(value - b.Min) } } else if op == pql.EQ || op == pql.NEQ { - if value < f.Min || value > f.Max { + if value < b.Min || value > b.Max { return baseValue, true } - baseValue = uint64(value - f.Min) + baseValue = uint64(value - b.Min) } return baseValue, false } // BaseValueBetween adjusts the min/max value to align with the range for Field. -func (f *oField) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { - if max < f.Min || min > f.Max { +func (b *bsiGroup) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { + if max < b.Min || min > b.Max { return baseValueMin, baseValueMax, true } // Adjust min/max to range. - if min > f.Min { - baseValueMin = uint64(min - f.Min) + if min > b.Min { + baseValueMin = uint64(min - b.Min) } // Make sure the high value of the BETWEEN does not exceed BitDepth. - if max > f.Max { - baseValueMax = uint64(f.Max - f.Min) - } else if max > f.Min { - baseValueMax = uint64(max - f.Min) + if max > b.Max { + baseValueMax = uint64(b.Max - b.Min) + } else if max > b.Min { + baseValueMax = uint64(max - b.Min) } return baseValueMin, baseValueMax, false } -func ValidateField(f *oField) error { - if f.Name == "" { +func ValidateField(b *bsiGroup) error { + if b.Name == "" { return ErrFieldNameRequired - } else if !IsValidFieldType(f.Type) { + } else if !IsValidFieldType(b.Type) { return ErrInvalidFieldType - } else if f.Min > f.Max { + } else if b.Min > b.Max { return ErrInvalidFieldRange } return nil } -func encodeField(f *oField) *internal.Field { - if f == nil { +func encodeField(b *bsiGroup) *internal.Field { + if b == nil { return nil } return &internal.Field{ - Name: f.Name, - Type: f.Type, - Min: int64(f.Min), - Max: int64(f.Max), + Name: b.Name, + Type: b.Type, + Min: int64(b.Min), + Max: int64(b.Max), } } -func decodeField(f *internal.Field) *oField { - if f == nil { +func decodeField(b *internal.Field) *bsiGroup { + if b == nil { return nil } - return &oField{ - Name: f.Name, - Type: f.Type, - Min: f.Min, - Max: f.Max, + return &bsiGroup{ + Name: b.Name, + Type: b.Type, + Min: b.Min, + Max: b.Max, } } diff --git a/frame_internal_test.go b/frame_internal_test.go index f51ad95e9..c52b76658 100644 --- a/frame_internal_test.go +++ b/frame_internal_test.go @@ -23,21 +23,21 @@ import ( // Ensure a field can adjust to its baseValue. func TestField_BaseValue(t *testing.T) { - f0 := &oField{ - Name: "f0", + b0 := &bsiGroup{ + Name: "b0", Type: FieldTypeInt, Min: -100, Max: 900, } - f1 := &oField{ - Name: "f1", + b1 := &bsiGroup{ + Name: "b1", Type: FieldTypeInt, Min: 0, Max: 1000, } - f2 := &oField{ - Name: "f2", + b2 := &bsiGroup{ + Name: "b2", Type: FieldTypeInt, Min: 100, Max: 1100, @@ -46,60 +46,60 @@ func TestField_BaseValue(t *testing.T) { t.Run("Normal Condition", func(t *testing.T) { for _, tt := range []struct { - f *oField + f *bsiGroup op pql.Token val int64 expBaseValue uint64 expOutOfRange bool }{ // LT - {f0, pql.LT, 5, 105, false}, - {f0, pql.LT, -8, 92, false}, - {f0, pql.LT, -108, 0, true}, - {f0, pql.LT, 1005, 1000, false}, - {f0, pql.LT, 0, 100, false}, + {b0, pql.LT, 5, 105, false}, + {b0, pql.LT, -8, 92, false}, + {b0, pql.LT, -108, 0, true}, + {b0, pql.LT, 1005, 1000, false}, + {b0, pql.LT, 0, 100, false}, - {f1, pql.LT, 5, 5, false}, - {f1, pql.LT, -8, 0, true}, - {f1, pql.LT, 1005, 1000, false}, - {f1, pql.LT, 0, 0, false}, + {b1, pql.LT, 5, 5, false}, + {b1, pql.LT, -8, 0, true}, + {b1, pql.LT, 1005, 1000, false}, + {b1, pql.LT, 0, 0, false}, - {f2, pql.LT, 5, 0, true}, - {f2, pql.LT, -8, 0, true}, - {f2, pql.LT, 105, 5, false}, - {f2, pql.LT, 1105, 1000, false}, + {b2, pql.LT, 5, 0, true}, + {b2, pql.LT, -8, 0, true}, + {b2, pql.LT, 105, 5, false}, + {b2, pql.LT, 1105, 1000, false}, // GT - {f0, pql.GT, -105, 0, false}, - {f0, pql.GT, 5, 105, false}, - {f0, pql.GT, 905, 0, true}, - {f0, pql.GT, 0, 100, false}, + {b0, pql.GT, -105, 0, false}, + {b0, pql.GT, 5, 105, false}, + {b0, pql.GT, 905, 0, true}, + {b0, pql.GT, 0, 100, false}, - {f1, pql.GT, 5, 5, false}, - {f1, pql.GT, -8, 0, false}, - {f1, pql.GT, 1005, 0, true}, - {f1, pql.GT, 0, 0, false}, + {b1, pql.GT, 5, 5, false}, + {b1, pql.GT, -8, 0, false}, + {b1, pql.GT, 1005, 0, true}, + {b1, pql.GT, 0, 0, false}, - {f2, pql.GT, 5, 0, false}, - {f2, pql.GT, -8, 0, false}, - {f2, pql.GT, 105, 5, false}, - {f2, pql.GT, 1105, 0, true}, + {b2, pql.GT, 5, 0, false}, + {b2, pql.GT, -8, 0, false}, + {b2, pql.GT, 105, 5, false}, + {b2, pql.GT, 1105, 0, true}, // EQ - {f0, pql.EQ, -105, 0, true}, - {f0, pql.EQ, 5, 105, false}, - {f0, pql.EQ, 905, 0, true}, - {f0, pql.EQ, 0, 100, false}, + {b0, pql.EQ, -105, 0, true}, + {b0, pql.EQ, 5, 105, false}, + {b0, pql.EQ, 905, 0, true}, + {b0, pql.EQ, 0, 100, false}, - {f1, pql.EQ, 5, 5, false}, - {f1, pql.EQ, -8, 0, true}, - {f1, pql.EQ, 1005, 0, true}, - {f1, pql.EQ, 0, 0, false}, + {b1, pql.EQ, 5, 5, false}, + {b1, pql.EQ, -8, 0, true}, + {b1, pql.EQ, 1005, 0, true}, + {b1, pql.EQ, 0, 0, false}, - {f2, pql.EQ, 5, 0, true}, - {f2, pql.EQ, -8, 0, true}, - {f2, pql.EQ, 105, 5, false}, - {f2, pql.EQ, 1105, 0, true}, + {b2, pql.EQ, 5, 0, true}, + {b2, pql.EQ, -8, 0, true}, + {b2, pql.EQ, 105, 5, false}, + {b2, pql.EQ, 1105, 0, true}, } { bv, oor := tt.f.BaseValue(tt.op, tt.val) if oor != tt.expOutOfRange { @@ -112,7 +112,7 @@ func TestField_BaseValue(t *testing.T) { t.Run("Betwween Condition", func(t *testing.T) { for _, tt := range []struct { - f *oField + f *bsiGroup predMin int64 predMax int64 expBaseValueMin uint64 @@ -120,23 +120,23 @@ func TestField_BaseValue(t *testing.T) { expOutOfRange bool }{ - {f0, -205, -105, 0, 0, true}, - {f0, -105, 80, 0, 180, false}, - {f0, 5, 20, 105, 120, false}, - {f0, 20, 1005, 120, 1000, false}, - {f0, 1005, 2000, 0, 0, true}, + {b0, -205, -105, 0, 0, true}, + {b0, -105, 80, 0, 180, false}, + {b0, 5, 20, 105, 120, false}, + {b0, 20, 1005, 120, 1000, false}, + {b0, 1005, 2000, 0, 0, true}, - {f1, -105, -5, 0, 0, true}, - {f1, -5, 20, 0, 20, false}, - {f1, 5, 20, 5, 20, false}, - {f1, 20, 1005, 20, 1000, false}, - {f1, 1005, 2000, 0, 0, true}, + {b1, -105, -5, 0, 0, true}, + {b1, -5, 20, 0, 20, false}, + {b1, 5, 20, 5, 20, false}, + {b1, 20, 1005, 20, 1000, false}, + {b1, 1005, 2000, 0, 0, true}, - {f2, 5, 95, 0, 0, true}, - {f2, 95, 120, 0, 20, false}, - {f2, 105, 120, 5, 20, false}, - {f2, 120, 1105, 20, 1000, false}, - {f2, 1105, 2000, 0, 0, true}, + {b2, 5, 95, 0, 0, true}, + {b2, 95, 120, 0, 20, false}, + {b2, 105, 120, 5, 20, false}, + {b2, 120, 1105, 20, 1000, false}, + {b2, 1105, 2000, 0, 0, true}, } { min, max, oor := tt.f.BaseValueBetween(tt.predMin, tt.predMax) if oor != tt.expOutOfRange { From 63e41b912b253313dd57af75140520a21c6209d2 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 15:45:52 -0500 Subject: [PATCH 15/52] rename Frame.fields to Frame.bsiGroups --- frame.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frame.go b/frame.go index 4fa755e62..6ad64a352 100644 --- a/frame.go +++ b/frame.go @@ -64,7 +64,7 @@ type Frame struct { // Frame options. options FrameOptions - fields []*bsiGroup + bsiGroups []*bsiGroup Logger Logger } @@ -382,9 +382,9 @@ func (f *Frame) Close() error { func (f *Frame) Field(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() - for _, field := range f.fields { - if field.Name == name { - return field + for _, bsig := range f.bsiGroups { + if bsig.Name == name { + return bsig } } return nil @@ -392,8 +392,8 @@ func (f *Frame) Field(name string) *bsiGroup { // hasField returns true if a field exists on the frame. func (f *Frame) hasField(name string) bool { - for _, fld := range f.fields { - if fld.Name == name { + for _, bsig := range f.bsiGroups { + if bsig.Name == name { return true } } @@ -422,11 +422,11 @@ func (f *Frame) addField(bsig *bsiGroup) error { } // Add bsiGroup to list. - f.fields = append(f.fields, bsig) + f.bsiGroups = append(f.bsiGroups, bsig) // Sort fields by name. - sort.Slice(f.fields, func(i, j int) bool { - return f.fields[i].Name < f.fields[j].Name + sort.Slice(f.bsiGroups, func(i, j int) bool { + return f.bsiGroups[i].Name < f.bsiGroups[j].Name }) return nil @@ -459,10 +459,10 @@ func (f *Frame) DeleteField(name string) error { // deleteField removes a single field from fields. func (f *Frame) deleteField(name string) error { - for i, field := range f.fields { - if field.Name == name { - copy(f.fields[i:], f.fields[i+1:]) - f.fields, f.fields[len(f.fields)-1] = f.fields[:len(f.fields)-1], nil + for i, bsig := range f.bsiGroups { + if bsig.Name == name { + copy(f.bsiGroups[i:], f.bsiGroups[i+1:]) + f.bsiGroups, f.bsiGroups[len(f.bsiGroups)-1] = f.bsiGroups[:len(f.bsiGroups)-1], nil return nil } } From 5d39ba25dfac9731d79fc02c00f329ce8461ded1 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 15:49:02 -0500 Subject: [PATCH 16/52] rename FieldTypeInt to bsiGroupTypeInt --- frame.go | 8 ++++---- frame_internal_test.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frame.go b/frame.go index 6ad64a352..26d1bdf3f 100644 --- a/frame.go +++ b/frame.go @@ -328,7 +328,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { // Create new bsiGroup. bsig := &bsiGroup{ Name: f.name, - Type: FieldTypeInt, + Type: bsiGroupTypeInt, Min: opt.Min, Max: opt.Max, } @@ -1070,14 +1070,14 @@ func decodeFrameOptions(options *internal.FrameMeta) *FrameOptions { } } -// List of field data types. +// List of bsiGroup types. const ( - FieldTypeInt = "int" + bsiGroupTypeInt = "int" ) func IsValidFieldType(v string) bool { switch v { - case FieldTypeInt: + case bsiGroupTypeInt: return true default: return false diff --git a/frame_internal_test.go b/frame_internal_test.go index c52b76658..749e4e720 100644 --- a/frame_internal_test.go +++ b/frame_internal_test.go @@ -25,20 +25,20 @@ import ( func TestField_BaseValue(t *testing.T) { b0 := &bsiGroup{ Name: "b0", - Type: FieldTypeInt, + Type: bsiGroupTypeInt, Min: -100, Max: 900, } b1 := &bsiGroup{ Name: "b1", - Type: FieldTypeInt, + Type: bsiGroupTypeInt, Min: 0, Max: 1000, } b2 := &bsiGroup{ Name: "b2", - Type: FieldTypeInt, + Type: bsiGroupTypeInt, Min: 100, Max: 1100, } From 54d94f1acaf6ff60e5db769027ecd24a0fc188b6 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 16:03:42 -0500 Subject: [PATCH 17/52] rename CreateField to createBSIGroup --- api.go | 2 +- frame.go | 12 ++++++------ server.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api.go b/api.go index 9a50a3542..0dc153380 100644 --- a/api.go +++ b/api.go @@ -501,7 +501,7 @@ func (api *API) CreateField(ctx context.Context, indexName string, frameName str } // Create new bsiGroup. - if err := f.CreateField(bsig); err != nil { + if err := f.createBSIGroup(bsig); err != nil { return errors.Wrap(err, "creating bsigroup") } diff --git a/frame.go b/frame.go index 26d1bdf3f..fc52bf3d2 100644 --- a/frame.go +++ b/frame.go @@ -333,10 +333,10 @@ func (f *Frame) applyOptions(opt FrameOptions) error { Max: opt.Max, } // Validate bsiGroup. - if err := ValidateField(bsig); err != nil { + if err := bsig.validate(); err != nil { return err } - if err := f.CreateField(bsig); err != nil { + if err := f.createBSIGroup(bsig); err != nil { return errors.Wrap(err, "creating bsigroup") } case FrameTypeTime: @@ -400,8 +400,8 @@ func (f *Frame) hasField(name string) bool { return false } -// CreateField creates a new field on the frame. -func (f *Frame) CreateField(bsig *bsiGroup) error { +// createBSIGroup creates a new field on the frame. +func (f *Frame) createBSIGroup(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() @@ -415,7 +415,7 @@ func (f *Frame) CreateField(bsig *bsiGroup) error { // addField adds a single field to fields. func (f *Frame) addField(bsig *bsiGroup) error { - if err := ValidateField(bsig); err != nil { + if err := bsig.validate(); err != nil { return errors.Wrap(err, "validating bsigroup") } else if f.hasField(bsig.Name) { return ErrFieldExists @@ -1156,7 +1156,7 @@ func (b *bsiGroup) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax return baseValueMin, baseValueMax, false } -func ValidateField(b *bsiGroup) error { +func (b *bsiGroup) validate() error { if b.Name == "" { return ErrFieldNameRequired } else if !IsValidFieldType(b.Type) { diff --git a/server.go b/server.go index 320fd174c..e7c566cbf 100644 --- a/server.go +++ b/server.go @@ -473,7 +473,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { case *internal.CreateFieldMessage: f := s.Holder.Frame(obj.Index, obj.Frame) field := decodeField(obj.Field) - if err := f.CreateField(field); err != nil { + if err := f.createBSIGroup(field); err != nil { return err } case *internal.DeleteFieldMessage: From b10463485e03b04e3c0544940476cbd9ca179e9b Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 16:06:41 -0500 Subject: [PATCH 18/52] rename Frame.Field() to Frame.bsiGroup() --- executor.go | 12 ++++++------ frame.go | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/executor.go b/executor.go index 589b0ace5..25d902591 100644 --- a/executor.go +++ b/executor.go @@ -381,7 +381,7 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - field := frame.Field(fieldName) + field := frame.bsiGroup(fieldName) if field == nil { return ValCount{}, nil } @@ -420,7 +420,7 @@ func (e *Executor) executeFieldMinSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - field := frame.Field(fieldName) + field := frame.bsiGroup(fieldName) if field == nil { return ValCount{}, nil } @@ -459,7 +459,7 @@ func (e *Executor) executeFieldMaxSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - field := frame.Field(fieldName) + field := frame.bsiGroup(fieldName) if field == nil { return ValCount{}, nil } @@ -800,7 +800,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * // Handle `!= null`. if cond.Op == pql.NEQ && cond.Value == nil { // Find field. - field := f.Field(fieldName) + field := f.bsiGroup(fieldName) if field == nil { return nil, ErrFieldNotFound } @@ -830,7 +830,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * // here is because we need the call to be slice-specific. // Find field. - field := f.Field(fieldName) + field := f.bsiGroup(fieldName) if field == nil { return nil, ErrFieldNotFound } @@ -863,7 +863,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * } // Find field. - field := f.Field(fieldName) + field := f.bsiGroup(fieldName) if field == nil { return nil, ErrFieldNotFound } diff --git a/frame.go b/frame.go index fc52bf3d2..b2d893792 100644 --- a/frame.go +++ b/frame.go @@ -378,8 +378,8 @@ func (f *Frame) Close() error { return nil } -// Field returns a field by name. -func (f *Frame) Field(name string) *bsiGroup { +// bsiGroup returns a field by name. +func (f *Frame) bsiGroup(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() for _, bsig := range f.bsiGroups { @@ -706,7 +706,7 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change // FieldValue reads a field value for a column. func (f *Frame) FieldValue(columnID uint64, name string) (value int64, exists bool, err error) { - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return 0, false, ErrFieldNotFound } @@ -729,7 +729,7 @@ func (f *Frame) FieldValue(columnID uint64, name string) (value int64, exists bo // SetValue sets a field value for a column. func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) { // Fetch field and validate value. - field := f.Field(f.name) + field := f.bsiGroup(f.name) if field == nil { return false, ErrFieldNotFound } else if value < field.Min { @@ -753,7 +753,7 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) // FieldSum returns the sum and count for a field. // An optional filtering row can be provided. func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) { - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return 0, 0, ErrFieldNotFound } @@ -773,7 +773,7 @@ func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) // FieldMin returns the min for a field. // An optional filtering row can be provided. func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) { - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return 0, 0, ErrFieldNotFound } @@ -793,7 +793,7 @@ func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) // FieldMax returns the max for a field. // An optional filtering row can be provided. func (f *Frame) FieldMax(filter *Row, name string) (max, count int64, err error) { - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return 0, 0, ErrFieldNotFound } @@ -812,7 +812,7 @@ func (f *Frame) FieldMax(filter *Row, name string) (max, count int64, err error) func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, error) { // Retrieve and validate field. - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return nil, ErrFieldNotFound } else if predicate < field.Min || predicate > field.Max { @@ -835,7 +835,7 @@ func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, er func (f *Frame) FieldRangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { // Retrieve and validate field. - field := f.Field(name) + field := f.bsiGroup(name) if field == nil { return nil, ErrFieldNotFound } else if predicateMin > predicateMax { @@ -917,7 +917,7 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64) error { viewName := ViewFieldPrefix + fieldName // Get the field so we know bitDepth. - field := f.Field(fieldName) + field := f.bsiGroup(fieldName) if field == nil { return fmt.Errorf("Field does not exist: %s", fieldName) } From dcf4daf24e5285296571b5a21d09347345a2367d Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 16:47:08 -0500 Subject: [PATCH 19/52] rename a lot of *Field cases to *BSIGroup --- executor.go | 20 +++++------ executor_test.go | 2 +- frame.go | 89 ++++++++++++++++++++++++------------------------ frame_test.go | 6 ++-- pilosa.go | 20 +++++------ view.go | 4 +-- 6 files changed, 71 insertions(+), 70 deletions(-) diff --git a/executor.go b/executor.go index 25d902591..43b44c315 100644 --- a/executor.go +++ b/executor.go @@ -386,7 +386,7 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, ViewFieldPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -425,7 +425,7 @@ func (e *Executor) executeFieldMinSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, ViewFieldPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -464,7 +464,7 @@ func (e *Executor) executeFieldMaxSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, ViewFieldPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -802,11 +802,11 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * // Find field. field := f.bsiGroup(fieldName) if field == nil { - return nil, ErrFieldNotFound + return nil, ErrBSIGroupNotFound } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, ViewFieldPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -832,7 +832,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * // Find field. field := f.bsiGroup(fieldName) if field == nil { - return nil, ErrFieldNotFound + return nil, ErrBSIGroupNotFound } baseValueMin, baseValueMax, outOfRange := field.BaseValueBetween(predicates[0], predicates[1]) @@ -841,7 +841,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, ViewFieldPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -865,7 +865,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * // Find field. field := f.bsiGroup(fieldName) if field == nil { - return nil, ErrFieldNotFound + return nil, ErrBSIGroupNotFound } baseValue, outOfRange := field.BaseValue(cond.Op, value) @@ -874,7 +874,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, ViewFieldPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -1137,7 +1137,7 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal return err } default: - return ErrInvalidFieldValueType + return ErrInvalidBSIGroupValueType } frame.Stats.Count("SetValue", 1, 1.0) } diff --git a/executor_test.go b/executor_test.go index a8cce5194..3429529ee 100644 --- a/executor_test.go +++ b/executor_test.go @@ -951,7 +951,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { }) t.Run("ErrFieldNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, bad_field >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, bad_field >= 20)`), nil, nil); err != pilosa.ErrBSIGroupNotFound { t.Fatal(err) } }) diff --git a/frame.go b/frame.go index b2d893792..6e2ef0bf7 100644 --- a/frame.go +++ b/frame.go @@ -378,7 +378,7 @@ func (f *Frame) Close() error { return nil } -// bsiGroup returns a field by name. +// bsiGroup returns a bsiGroup by name. func (f *Frame) bsiGroup(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() @@ -390,8 +390,8 @@ func (f *Frame) bsiGroup(name string) *bsiGroup { return nil } -// hasField returns true if a field exists on the frame. -func (f *Frame) hasField(name string) bool { +// hasBSIGroup returns true if a bsiGroup exists on the frame. +func (f *Frame) hasBSIGroup(name string) bool { for _, bsig := range f.bsiGroups { if bsig.Name == name { return true @@ -400,25 +400,25 @@ func (f *Frame) hasField(name string) bool { return false } -// createBSIGroup creates a new field on the frame. +// createBSIGroup creates a new bsiGroup on the frame. func (f *Frame) createBSIGroup(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() // Append bsiGroup. - if err := f.addField(bsig); err != nil { + if err := f.addBSIGroup(bsig); err != nil { return err } f.saveMeta() return nil } -// addField adds a single field to fields. -func (f *Frame) addField(bsig *bsiGroup) error { +// addBSIGroup adds a single bsiGroup to bsiGroups. +func (f *Frame) addBSIGroup(bsig *bsiGroup) error { if err := bsig.validate(); err != nil { return errors.Wrap(err, "validating bsigroup") - } else if f.hasField(bsig.Name) { - return ErrFieldExists + } else if f.hasBSIGroup(bsig.Name) { + return ErrBSIGroupExists } // Add bsiGroup to list. @@ -432,18 +432,19 @@ func (f *Frame) addField(bsig *bsiGroup) error { return nil } +// TODO: merge this into the un-exported deleteBSIGroup. // DeleteField deletes an existing field on the schema. func (f *Frame) DeleteField(name string) error { f.mu.Lock() defer f.mu.Unlock() // Remove field. - if err := f.deleteField(name); err != nil { + if err := f.deleteBSIGroup(name); err != nil { return err } // Remove views. - viewName := ViewFieldPrefix + name + viewName := viewBSIGroupPrefix + name if view := f.views[viewName]; view != nil { delete(f.views, viewName) @@ -457,8 +458,8 @@ func (f *Frame) DeleteField(name string) error { return nil } -// deleteField removes a single field from fields. -func (f *Frame) deleteField(name string) error { +// deleteBSIGroup removes a single bsiGroup from bsiGroups. +func (f *Frame) deleteBSIGroup(name string) error { for i, bsig := range f.bsiGroups { if bsig.Name == name { copy(f.bsiGroups[i:], f.bsiGroups[i+1:]) @@ -466,7 +467,7 @@ func (f *Frame) deleteField(name string) error { return nil } } - return ErrFieldNotFound + return ErrBSIGroupNotFound } // TimeQuantum returns the time quantum for the frame. @@ -708,11 +709,11 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change func (f *Frame) FieldValue(columnID uint64, name string) (value int64, exists bool, err error) { field := f.bsiGroup(name) if field == nil { - return 0, false, ErrFieldNotFound + return 0, false, ErrBSIGroupNotFound } // Fetch target view. - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return 0, false, nil } @@ -731,15 +732,15 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) // Fetch field and validate value. field := f.bsiGroup(f.name) if field == nil { - return false, ErrFieldNotFound + return false, ErrBSIGroupNotFound } else if value < field.Min { - return false, ErrFieldValueTooLow + return false, ErrBSIGroupValueTooLow } else if value > field.Max { - return false, ErrFieldValueTooHigh + return false, ErrBSIGroupValueTooHigh } // Fetch target view. - view, err := f.CreateViewIfNotExists(ViewFieldPrefix + f.name) + view, err := f.CreateViewIfNotExists(viewBSIGroupPrefix + f.name) if err != nil { return false, errors.Wrap(err, "creating view") } @@ -755,10 +756,10 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) { field := f.bsiGroup(name) if field == nil { - return 0, 0, ErrFieldNotFound + return 0, 0, ErrBSIGroupNotFound } - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return 0, 0, nil } @@ -770,24 +771,24 @@ func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) return int64(vsum) + (int64(vcount) * field.Min), int64(vcount), nil } -// FieldMin returns the min for a field. +// FieldMin returns the min for a bsiGroup. // An optional filtering row can be provided. func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) { - field := f.bsiGroup(name) - if field == nil { - return 0, 0, ErrFieldNotFound + bsig := f.bsiGroup(name) + if bsig == nil { + return 0, 0, ErrBSIGroupNotFound } - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return 0, 0, nil } - vmin, vcount, err := view.FieldMin(filter, field.BitDepth()) + vmin, vcount, err := view.FieldMin(filter, bsig.BitDepth()) if err != nil { return 0, 0, err } - return int64(vmin) + field.Min, int64(vcount), nil + return int64(vmin) + bsig.Min, int64(vcount), nil } // FieldMax returns the max for a field. @@ -795,10 +796,10 @@ func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) func (f *Frame) FieldMax(filter *Row, name string) (max, count int64, err error) { field := f.bsiGroup(name) if field == nil { - return 0, 0, ErrFieldNotFound + return 0, 0, ErrBSIGroupNotFound } - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return 0, 0, nil } @@ -814,13 +815,13 @@ func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, er // Retrieve and validate field. field := f.bsiGroup(name) if field == nil { - return nil, ErrFieldNotFound + return nil, ErrBSIGroupNotFound } else if predicate < field.Min || predicate > field.Max { return nil, nil } // Retrieve field's view. - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return nil, nil } @@ -837,13 +838,13 @@ func (f *Frame) FieldRangeBetween(name string, predicateMin, predicateMax int64) // Retrieve and validate field. field := f.bsiGroup(name) if field == nil { - return nil, ErrFieldNotFound + return nil, ErrBSIGroupNotFound } else if predicateMin > predicateMax { return nil, ErrInvalidBetweenValue } // Retrieve field's view. - view := f.View(ViewFieldPrefix + name) + view := f.View(viewBSIGroupPrefix + name) if view == nil { return nil, nil } @@ -915,7 +916,7 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro // ImportValue bulk imports range-encoded value data. func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64) error { - viewName := ViewFieldPrefix + fieldName + viewName := viewBSIGroupPrefix + fieldName // Get the field so we know bitDepth. field := f.bsiGroup(fieldName) if field == nil { @@ -927,9 +928,9 @@ func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64 for i := range columnIDs { columnID, value := columnIDs[i], values[i] if int64(value) > field.Max { - return fmt.Errorf("%v, columnID=%v, value=%v", ErrFieldValueTooHigh, columnID, value) + return fmt.Errorf("%v, columnID=%v, value=%v", ErrBSIGroupValueTooHigh, columnID, value) } else if int64(value) < field.Min { - return fmt.Errorf("%v, columnID=%v, value=%v", ErrFieldValueTooLow, columnID, value) + return fmt.Errorf("%v, columnID=%v, value=%v", ErrBSIGroupValueTooLow, columnID, value) } // Attach value to each field view. @@ -1025,7 +1026,7 @@ func (o *FrameOptions) Validate() error { // TODO: cacheType, cacheSize validation case FrameTypeInt: if o.Min > o.Max { - return ErrInvalidFieldRange + return ErrInvalidBSIGroupRange } case FrameTypeTime: if o.TimeQuantum == "" || !o.TimeQuantum.Valid() { @@ -1075,7 +1076,7 @@ const ( bsiGroupTypeInt = "int" ) -func IsValidFieldType(v string) bool { +func isValidBSIGroupType(v string) bool { switch v { case bsiGroupTypeInt: return true @@ -1158,11 +1159,11 @@ func (b *bsiGroup) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax func (b *bsiGroup) validate() error { if b.Name == "" { - return ErrFieldNameRequired - } else if !IsValidFieldType(b.Type) { - return ErrInvalidFieldType + return ErrBSIGroupNameRequired + } else if !isValidBSIGroupType(b.Type) { + return ErrInvalidBSIGroupType } else if b.Min > b.Max { - return ErrInvalidFieldRange + return ErrInvalidBSIGroupRange } return nil } diff --git a/frame_test.go b/frame_test.go index 9b7f9a336..6cc75f6be 100644 --- a/frame_test.go +++ b/frame_test.go @@ -159,7 +159,7 @@ func TestFrame_SetValue(t *testing.T) { } // Set value. - if _, err := f.SetValue(100, 21); err != pilosa.ErrFieldNotFound { + if _, err := f.SetValue(100, 21); err != pilosa.ErrBSIGroupNotFound { t.Fatalf("unexpected error: %s", err) } }) @@ -178,7 +178,7 @@ func TestFrame_SetValue(t *testing.T) { } // Set value. - if _, err := f.SetValue(100, 15); err != pilosa.ErrFieldValueTooLow { + if _, err := f.SetValue(100, 15); err != pilosa.ErrBSIGroupValueTooLow { t.Fatalf("unexpected error: %s", err) } }) @@ -197,7 +197,7 @@ func TestFrame_SetValue(t *testing.T) { } // Set value. - if _, err := f.SetValue(100, 31); err != pilosa.ErrFieldValueTooHigh { + if _, err := f.SetValue(100, 31); err != pilosa.ErrBSIGroupValueTooHigh { t.Fatalf("unexpected error: %s", err) } }) diff --git a/pilosa.go b/pilosa.go index 7ddea28eb..21bfdd822 100644 --- a/pilosa.go +++ b/pilosa.go @@ -36,16 +36,16 @@ var ( ErrFrameExists = errors.New("frame already exists") ErrFrameNotFound = errors.New("frame not found") - ErrFieldNotFound = errors.New("field not found") - ErrFieldExists = errors.New("field already exists") - ErrFieldNameRequired = errors.New("field name required") - ErrInvalidFieldType = errors.New("invalid field type") - ErrInvalidFieldRange = errors.New("invalid field range") - ErrInvalidFieldValueType = errors.New("invalid field value type") - ErrFieldValueTooLow = errors.New("field value too low") - ErrFieldValueTooHigh = errors.New("field value too high") - ErrInvalidRangeOperation = errors.New("invalid range operation") - ErrInvalidBetweenValue = errors.New("invalid value for between operation") + ErrBSIGroupNotFound = errors.New("bsigroup not found") + ErrBSIGroupExists = errors.New("bsigroup already exists") + ErrBSIGroupNameRequired = errors.New("bsigroup name required") + ErrInvalidBSIGroupType = errors.New("invalid bsigroup type") + ErrInvalidBSIGroupRange = errors.New("invalid bsigroup range") + ErrInvalidBSIGroupValueType = errors.New("invalid bsigroup value type") + ErrBSIGroupValueTooLow = errors.New("bsigroup value too low") + ErrBSIGroupValueTooHigh = errors.New("bsigroup value too high") + ErrInvalidRangeOperation = errors.New("invalid range operation") + ErrInvalidBetweenValue = errors.New("invalid value for between operation") ErrInvalidView = errors.New("invalid view") ErrInvalidCacheType = errors.New("invalid cache type") diff --git a/view.go b/view.go index 0d36faf2a..994a54579 100644 --- a/view.go +++ b/view.go @@ -31,7 +31,7 @@ import ( const ( ViewStandard = "standard" - ViewFieldPrefix = "field_" + viewBSIGroupPrefix = "bsig_" ) // IsValidView returns true if name is valid. @@ -98,7 +98,7 @@ func (v *View) Path() string { return v.path } func (v *View) Open() error { // Never keep a cache for field views. - if strings.HasPrefix(v.name, ViewFieldPrefix) { + if strings.HasPrefix(v.name, viewBSIGroupPrefix) { v.cacheType = CacheTypeNone } From a6ae39d0b08d5a6c1ffbc5c359fc8c9e644f6d34 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 17:18:34 -0500 Subject: [PATCH 20/52] remove cases of Field from frame.go --- api.go | 19 +-- broadcast.go | 20 +-- client_test.go | 10 +- executor.go | 4 +- executor_test.go | 4 +- frame.go | 62 ++++----- frame_internal_test.go | 4 +- frame_test.go | 4 +- internal/private.pb.go | 276 ++++++++++++++++++++--------------------- internal/private.proto | 11 +- server.go | 8 +- 11 files changed, 211 insertions(+), 211 deletions(-) diff --git a/api.go b/api.go index 0dc153380..e34a9142b 100644 --- a/api.go +++ b/api.go @@ -507,10 +507,10 @@ func (api *API) CreateField(ctx context.Context, indexName string, frameName str // Send the create bsigroup message to all nodes. err := api.Broadcaster.SendSync( - &internal.CreateFieldMessage{ - Index: indexName, - Frame: frameName, - Field: encodeField(bsig), + &internal.CreateBSIGroupMessage{ + Index: indexName, + Frame: frameName, + BSIGroup: encodeBSIGroup(bsig), }) if err != nil { api.Logger.Printf("problem sending CreateField message: %s", err) @@ -518,6 +518,7 @@ func (api *API) CreateField(ctx context.Context, indexName string, frameName str return errors.Wrap(err, "sending CreateField message") } +// TODO: remove this from the API // DeleteField deletes the given field. func (api *API) DeleteField(ctx context.Context, indexName string, frameName string, fieldName string) error { if err := api.validate(apiDeleteField); err != nil { @@ -531,16 +532,16 @@ func (api *API) DeleteField(ctx context.Context, indexName string, frameName str } // Delete field. - if err := f.DeleteField(fieldName); err != nil { + if err := f.deleteBSIGroupAndView(fieldName); err != nil { return errors.Wrap(err, "deleting field") } // Send the delete field message to all nodes. err := api.Broadcaster.SendSync( - &internal.DeleteFieldMessage{ - Index: indexName, - Frame: frameName, - Field: fieldName, + &internal.DeleteBSIGroupMessage{ + Index: indexName, + Frame: frameName, + BSIGroup: fieldName, }) if err != nil { api.Logger.Printf("problem sending DeleteField message: %s", err) diff --git a/broadcast.go b/broadcast.go index 77b76126d..0840e8c92 100644 --- a/broadcast.go +++ b/broadcast.go @@ -127,8 +127,8 @@ const ( MessageTypeDeleteFrame MessageTypeCreateView MessageTypeDeleteView - MessageTypeCreateField - MessageTypeDeleteField + MessageTypeCreateBSIGroup + MessageTypeDeleteBSIGroup MessageTypeClusterStatus MessageTypeResizeInstruction MessageTypeResizeInstructionComplete @@ -157,10 +157,10 @@ func MarshalMessage(m proto.Message) ([]byte, error) { typ = MessageTypeCreateView case *internal.DeleteViewMessage: typ = MessageTypeDeleteView - case *internal.CreateFieldMessage: - typ = MessageTypeCreateField - case *internal.DeleteFieldMessage: - typ = MessageTypeDeleteField + case *internal.CreateBSIGroupMessage: + typ = MessageTypeCreateBSIGroup + case *internal.DeleteBSIGroupMessage: + typ = MessageTypeDeleteBSIGroup case *internal.ClusterStatus: typ = MessageTypeClusterStatus case *internal.ResizeInstruction: @@ -207,10 +207,10 @@ func UnmarshalMessage(buf []byte) (proto.Message, error) { m = &internal.CreateViewMessage{} case MessageTypeDeleteView: m = &internal.DeleteViewMessage{} - case MessageTypeCreateField: - m = &internal.CreateFieldMessage{} - case MessageTypeDeleteField: - m = &internal.DeleteFieldMessage{} + case MessageTypeCreateBSIGroup: + m = &internal.CreateBSIGroupMessage{} + case MessageTypeDeleteBSIGroup: + m = &internal.DeleteBSIGroupMessage{} case MessageTypeClusterStatus: m = &internal.ClusterStatus{} case MessageTypeResizeInstruction: diff --git a/client_test.go b/client_test.go index 898869f2b..2bb255382 100644 --- a/client_test.go +++ b/client_test.go @@ -276,7 +276,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Sum. - sum, cnt, err := frame.FieldSum(nil, fldName) + sum, cnt, err := frame.Sum(nil, fldName) if err != nil { t.Fatal(err) } @@ -285,7 +285,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min. - min, cnt, err := frame.FieldMin(nil, fldName) + min, cnt, err := frame.Min(nil, fldName) if err != nil { t.Fatal(err) } @@ -294,11 +294,11 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min with Filter. - filter, err := frame.FieldRange(fldName, pql.GT, 40) + filter, err := frame.Range(fldName, pql.GT, 40) if err != nil { t.Fatal(err) } - min, cnt, err = frame.FieldMin(filter, fldName) + min, cnt, err = frame.Min(filter, fldName) if err != nil { t.Fatal(err) } @@ -307,7 +307,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Max. - max, cnt, err := frame.FieldMax(nil, fldName) + max, cnt, err := frame.Max(nil, fldName) if err != nil { t.Fatal(err) } diff --git a/executor.go b/executor.go index 43b44c315..b5e19e5b7 100644 --- a/executor.go +++ b/executor.go @@ -835,7 +835,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * return nil, ErrBSIGroupNotFound } - baseValueMin, baseValueMax, outOfRange := field.BaseValueBetween(predicates[0], predicates[1]) + baseValueMin, baseValueMax, outOfRange := field.baseValueBetween(predicates[0], predicates[1]) if outOfRange { return NewRow(), nil } @@ -868,7 +868,7 @@ func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c * return nil, ErrBSIGroupNotFound } - baseValue, outOfRange := field.BaseValue(cond.Op, value) + baseValue, outOfRange := field.baseValue(cond.Op, value) if outOfRange && cond.Op != pql.NEQ { return NewRow(), nil } diff --git a/executor_test.go b/executor_test.go index 3429529ee..578ddc11b 100644 --- a/executor_test.go +++ b/executor_test.go @@ -290,7 +290,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { } f := hldr.Frame("i", "f") - if value, exists, err := f.FieldValue(10, "f"); err != nil { + if value, exists, err := f.Value(10, "f"); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") @@ -298,7 +298,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Fatalf("unexpected value: %v", value) } - if value, exists, err := f.FieldValue(100, "f"); err != nil { + if value, exists, err := f.Value(100, "f"); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") diff --git a/frame.go b/frame.go index 6e2ef0bf7..65d98937c 100644 --- a/frame.go +++ b/frame.go @@ -433,8 +433,8 @@ func (f *Frame) addBSIGroup(bsig *bsiGroup) error { } // TODO: merge this into the un-exported deleteBSIGroup. -// DeleteField deletes an existing field on the schema. -func (f *Frame) DeleteField(name string) error { +// deleteBSIGroupAndView deletes an existing field on the schema. +func (f *Frame) deleteBSIGroupAndView(name string) error { f.mu.Lock() defer f.mu.Unlock() @@ -705,8 +705,8 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change return changed, nil } -// FieldValue reads a field value for a column. -func (f *Frame) FieldValue(columnID uint64, name string) (value int64, exists bool, err error) { +// Value reads a bsiGroup value for a column. +func (f *Frame) Value(columnID uint64, name string) (value int64, exists bool, err error) { field := f.bsiGroup(name) if field == nil { return 0, false, ErrBSIGroupNotFound @@ -751,9 +751,9 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) return view.setValue(columnID, field.BitDepth(), baseValue) } -// FieldSum returns the sum and count for a field. +// Sum returns the sum and count for a field. // An optional filtering row can be provided. -func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) { +func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { field := f.bsiGroup(name) if field == nil { return 0, 0, ErrBSIGroupNotFound @@ -771,9 +771,9 @@ func (f *Frame) FieldSum(filter *Row, name string) (sum, count int64, err error) return int64(vsum) + (int64(vcount) * field.Min), int64(vcount), nil } -// FieldMin returns the min for a bsiGroup. +// Min returns the min for a field. // An optional filtering row can be provided. -func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) { +func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -791,9 +791,9 @@ func (f *Frame) FieldMin(filter *Row, name string) (min, count int64, err error) return int64(vmin) + bsig.Min, int64(vcount), nil } -// FieldMax returns the max for a field. +// Max returns the max for a field. // An optional filtering row can be provided. -func (f *Frame) FieldMax(filter *Row, name string) (max, count int64, err error) { +func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { field := f.bsiGroup(name) if field == nil { return 0, 0, ErrBSIGroupNotFound @@ -811,7 +811,7 @@ func (f *Frame) FieldMax(filter *Row, name string) (max, count int64, err error) return int64(vmax) + field.Min, int64(vcount), nil } -func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, error) { +func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) { // Retrieve and validate field. field := f.bsiGroup(name) if field == nil { @@ -826,7 +826,7 @@ func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, er return nil, nil } - baseValue, outOfRange := field.BaseValue(op, predicate) + baseValue, outOfRange := field.baseValue(op, predicate) if outOfRange { return NewRow(), nil } @@ -834,7 +834,7 @@ func (f *Frame) FieldRange(name string, op pql.Token, predicate int64) (*Row, er return view.FieldRange(op, field.BitDepth(), baseValue) } -func (f *Frame) FieldRangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { +func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { // Retrieve and validate field. field := f.bsiGroup(name) if field == nil { @@ -849,7 +849,7 @@ func (f *Frame) FieldRangeBetween(name string, predicateMin, predicateMax int64) return nil, nil } - baseValueMin, baseValueMax, outOfRange := field.BaseValueBetween(predicateMin, predicateMax) + baseValueMin, baseValueMax, outOfRange := field.baseValueBetween(predicateMin, predicateMax) if outOfRange { return NewRow(), nil } @@ -917,23 +917,23 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro // ImportValue bulk imports range-encoded value data. func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64) error { viewName := viewBSIGroupPrefix + fieldName - // Get the field so we know bitDepth. - field := f.bsiGroup(fieldName) - if field == nil { - return fmt.Errorf("Field does not exist: %s", fieldName) + // Get the bsiGroup so we know bitDepth. + bsig := f.bsiGroup(fieldName) + if bsig == nil { + return errors.Wrap(ErrBSIGroupNotFound, fieldName) } // Split import data by fragment. dataByFragment := make(map[importKey]importValueData) for i := range columnIDs { columnID, value := columnIDs[i], values[i] - if int64(value) > field.Max { + if int64(value) > bsig.Max { return fmt.Errorf("%v, columnID=%v, value=%v", ErrBSIGroupValueTooHigh, columnID, value) - } else if int64(value) < field.Min { + } else if int64(value) < bsig.Min { return fmt.Errorf("%v, columnID=%v, value=%v", ErrBSIGroupValueTooLow, columnID, value) } - // Attach value to each field view. + // Attach value to each bsiGroup view. for _, name := range []string{viewName} { key := importKey{View: name, Slice: columnID / SliceWidth} data := dataByFragment[key] @@ -960,10 +960,10 @@ func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64 baseValues := make([]uint64, len(data.Values)) for i, value := range data.Values { - baseValues[i] = uint64(value - field.Min) + baseValues[i] = uint64(value - bsig.Min) } - if err := frag.ImportValue(data.ColumnIDs, baseValues, field.BitDepth()); err != nil { + if err := frag.ImportValue(data.ColumnIDs, baseValues, bsig.BitDepth()); err != nil { return err } } @@ -1103,19 +1103,19 @@ func (b *bsiGroup) BitDepth() uint { return 63 } -// BaseValue adjusts the value to align with the range for Field for a certain +// baseValue adjusts the value to align with the range for Field for a certain // operation type. // Note: There is an edge case for GT and LT where this returns a baseValue // that does not fully encompass the range. // ex: Field.Min = 0, Field.Max = 1023 -// BaseValue(LT, 2000) returns 1023, which will perform "LT 1023" and effectively +// baseValue(LT, 2000) returns 1023, which will perform "LT 1023" and effectively // exclude any columns with value = 1023. // Note that in this case (because the range uses the full BitDepth 0 to 1023), // we can't simply return 1024. // In order to make this work, we effectively need to change the operator to LTE. // Executor.executeFieldRangeSlice() takes this into account and returns // `frag.FieldNotNull(field.BitDepth())` in such instances. -func (b *bsiGroup) BaseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { +func (b *bsiGroup) baseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { if op == pql.GT || op == pql.GTE { if value > b.Max { return baseValue, true @@ -1139,8 +1139,8 @@ func (b *bsiGroup) BaseValue(op pql.Token, value int64) (baseValue uint64, outOf return baseValue, false } -// BaseValueBetween adjusts the min/max value to align with the range for Field. -func (b *bsiGroup) BaseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { +// baseValueBetween adjusts the min/max value to align with the range for Field. +func (b *bsiGroup) baseValueBetween(min, max int64) (baseValueMin, baseValueMax uint64, outOfRange bool) { if max < b.Min || min > b.Max { return baseValueMin, baseValueMax, true } @@ -1168,11 +1168,11 @@ func (b *bsiGroup) validate() error { return nil } -func encodeField(b *bsiGroup) *internal.Field { +func encodeBSIGroup(b *bsiGroup) *internal.BSIGroup { if b == nil { return nil } - return &internal.Field{ + return &internal.BSIGroup{ Name: b.Name, Type: b.Type, Min: int64(b.Min), @@ -1180,7 +1180,7 @@ func encodeField(b *bsiGroup) *internal.Field { } } -func decodeField(b *internal.Field) *bsiGroup { +func decodeBSIGroup(b *internal.BSIGroup) *bsiGroup { if b == nil { return nil } diff --git a/frame_internal_test.go b/frame_internal_test.go index 749e4e720..5cba2e84b 100644 --- a/frame_internal_test.go +++ b/frame_internal_test.go @@ -101,7 +101,7 @@ func TestField_BaseValue(t *testing.T) { {b2, pql.EQ, 105, 5, false}, {b2, pql.EQ, 1105, 0, true}, } { - bv, oor := tt.f.BaseValue(tt.op, tt.val) + bv, oor := tt.f.baseValue(tt.op, tt.val) if oor != tt.expOutOfRange { t.Fatalf("baseValue calculation on %s op %s, expected outOfRange %v, got %v", tt.f.Name, tt.op, tt.expOutOfRange, oor) } else if !reflect.DeepEqual(bv, tt.expBaseValue) { @@ -138,7 +138,7 @@ func TestField_BaseValue(t *testing.T) { {b2, 120, 1105, 20, 1000, false}, {b2, 1105, 2000, 0, 0, true}, } { - min, max, oor := tt.f.BaseValueBetween(tt.predMin, tt.predMax) + min, max, oor := tt.f.baseValueBetween(tt.predMin, tt.predMax) if oor != tt.expOutOfRange { t.Fatalf("baseValueBetween calculation on %s, expected outOfRange %v, got %v", tt.f.Name, tt.expOutOfRange, oor) } else if !reflect.DeepEqual(min, tt.expBaseValueMin) || !reflect.DeepEqual(max, tt.expBaseValueMax) { diff --git a/frame_test.go b/frame_test.go index 6cc75f6be..aeae2b7ba 100644 --- a/frame_test.go +++ b/frame_test.go @@ -94,7 +94,7 @@ func TestFrame_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.FieldValue(100, "f"); err != nil { + if value, exists, err := f.Value(100, "f"); err != nil { t.Fatal(err) } else if value != 21 { t.Fatalf("unexpected value: %d", value) @@ -138,7 +138,7 @@ func TestFrame_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.FieldValue(100, "f"); err != nil { + if value, exists, err := f.Value(100, "f"); err != nil { t.Fatal(err) } else if value != 23 { t.Fatalf("unexpected value: %d", value) diff --git a/internal/private.pb.go b/internal/private.pb.go index 20909445c..4e1aa8589 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -21,8 +21,8 @@ CreateIndexMessage CreateFrameMessage DeleteFrameMessage - CreateFieldMessage - DeleteFieldMessage + CreateBSIGroupMessage + DeleteBSIGroupMessage Frame Schema Index @@ -32,7 +32,7 @@ NodeEventMessage NodeStatus ClusterStatus - Field + BSIGroup CreateViewMessage DeleteViewMessage ResizeInstruction @@ -366,66 +366,66 @@ func (m *DeleteFrameMessage) GetFrame() string { return "" } -type CreateFieldMessage 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"` - Field *Field `protobuf:"bytes,3,opt,name=Field" json:"Field,omitempty"` +type CreateBSIGroupMessage 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"` + BSIGroup *BSIGroup `protobuf:"bytes,3,opt,name=BSIGroup" json:"BSIGroup,omitempty"` } -func (m *CreateFieldMessage) Reset() { *m = CreateFieldMessage{} } -func (m *CreateFieldMessage) String() string { return proto.CompactTextString(m) } -func (*CreateFieldMessage) ProtoMessage() {} -func (*CreateFieldMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } +func (m *CreateBSIGroupMessage) Reset() { *m = CreateBSIGroupMessage{} } +func (m *CreateBSIGroupMessage) String() string { return proto.CompactTextString(m) } +func (*CreateBSIGroupMessage) ProtoMessage() {} +func (*CreateBSIGroupMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } -func (m *CreateFieldMessage) GetIndex() string { +func (m *CreateBSIGroupMessage) GetIndex() string { if m != nil { return m.Index } return "" } -func (m *CreateFieldMessage) GetFrame() string { +func (m *CreateBSIGroupMessage) GetFrame() string { if m != nil { return m.Frame } return "" } -func (m *CreateFieldMessage) GetField() *Field { +func (m *CreateBSIGroupMessage) GetBSIGroup() *BSIGroup { if m != nil { - return m.Field + return m.BSIGroup } return nil } -type DeleteFieldMessage 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"` - Field string `protobuf:"bytes,3,opt,name=Field,proto3" json:"Field,omitempty"` +type DeleteBSIGroupMessage 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"` + BSIGroup string `protobuf:"bytes,3,opt,name=BSIGroup,proto3" json:"BSIGroup,omitempty"` } -func (m *DeleteFieldMessage) Reset() { *m = DeleteFieldMessage{} } -func (m *DeleteFieldMessage) String() string { return proto.CompactTextString(m) } -func (*DeleteFieldMessage) ProtoMessage() {} -func (*DeleteFieldMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{13} } +func (m *DeleteBSIGroupMessage) Reset() { *m = DeleteBSIGroupMessage{} } +func (m *DeleteBSIGroupMessage) String() string { return proto.CompactTextString(m) } +func (*DeleteBSIGroupMessage) ProtoMessage() {} +func (*DeleteBSIGroupMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{13} } -func (m *DeleteFieldMessage) GetIndex() string { +func (m *DeleteBSIGroupMessage) GetIndex() string { if m != nil { return m.Index } return "" } -func (m *DeleteFieldMessage) GetFrame() string { +func (m *DeleteBSIGroupMessage) GetFrame() string { if m != nil { return m.Frame } return "" } -func (m *DeleteFieldMessage) GetField() string { +func (m *DeleteBSIGroupMessage) GetBSIGroup() string { if m != nil { - return m.Field + return m.BSIGroup } return "" } @@ -678,40 +678,40 @@ func (m *ClusterStatus) GetNodes() []*Node { return nil } -type Field struct { +type BSIGroup struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Type string `protobuf:"bytes,2,opt,name=Type,proto3" json:"Type,omitempty"` Min int64 `protobuf:"varint,3,opt,name=Min,proto3" json:"Min,omitempty"` Max int64 `protobuf:"varint,4,opt,name=Max,proto3" json:"Max,omitempty"` } -func (m *Field) Reset() { *m = Field{} } -func (m *Field) String() string { return proto.CompactTextString(m) } -func (*Field) ProtoMessage() {} -func (*Field) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{23} } +func (m *BSIGroup) Reset() { *m = BSIGroup{} } +func (m *BSIGroup) String() string { return proto.CompactTextString(m) } +func (*BSIGroup) ProtoMessage() {} +func (*BSIGroup) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{23} } -func (m *Field) GetName() string { +func (m *BSIGroup) GetName() string { if m != nil { return m.Name } return "" } -func (m *Field) GetType() string { +func (m *BSIGroup) GetType() string { if m != nil { return m.Type } return "" } -func (m *Field) GetMin() int64 { +func (m *BSIGroup) GetMin() int64 { if m != nil { return m.Min } return 0 } -func (m *Field) GetMax() int64 { +func (m *BSIGroup) GetMax() int64 { if m != nil { return m.Max } @@ -997,8 +997,8 @@ func init() { proto.RegisterType((*CreateIndexMessage)(nil), "internal.CreateIndexMessage") proto.RegisterType((*CreateFrameMessage)(nil), "internal.CreateFrameMessage") proto.RegisterType((*DeleteFrameMessage)(nil), "internal.DeleteFrameMessage") - proto.RegisterType((*CreateFieldMessage)(nil), "internal.CreateFieldMessage") - proto.RegisterType((*DeleteFieldMessage)(nil), "internal.DeleteFieldMessage") + proto.RegisterType((*CreateBSIGroupMessage)(nil), "internal.CreateBSIGroupMessage") + proto.RegisterType((*DeleteBSIGroupMessage)(nil), "internal.DeleteBSIGroupMessage") proto.RegisterType((*Frame)(nil), "internal.Frame") proto.RegisterType((*Schema)(nil), "internal.Schema") proto.RegisterType((*Index)(nil), "internal.Index") @@ -1008,7 +1008,7 @@ func init() { proto.RegisterType((*NodeEventMessage)(nil), "internal.NodeEventMessage") proto.RegisterType((*NodeStatus)(nil), "internal.NodeStatus") proto.RegisterType((*ClusterStatus)(nil), "internal.ClusterStatus") - proto.RegisterType((*Field)(nil), "internal.Field") + proto.RegisterType((*BSIGroup)(nil), "internal.BSIGroup") proto.RegisterType((*CreateViewMessage)(nil), "internal.CreateViewMessage") proto.RegisterType((*DeleteViewMessage)(nil), "internal.DeleteViewMessage") proto.RegisterType((*ResizeInstruction)(nil), "internal.ResizeInstruction") @@ -1436,7 +1436,7 @@ func (m *DeleteFrameMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CreateFieldMessage) Marshal() (dAtA []byte, err error) { +func (m *CreateBSIGroupMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1446,7 +1446,7 @@ func (m *CreateFieldMessage) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CreateFieldMessage) MarshalTo(dAtA []byte) (int, error) { +func (m *CreateBSIGroupMessage) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1463,11 +1463,11 @@ func (m *CreateFieldMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) i += copy(dAtA[i:], m.Frame) } - if m.Field != nil { + if m.BSIGroup != nil { dAtA[i] = 0x1a i++ - i = encodeVarintPrivate(dAtA, i, uint64(m.Field.Size())) - n9, err := m.Field.MarshalTo(dAtA[i:]) + i = encodeVarintPrivate(dAtA, i, uint64(m.BSIGroup.Size())) + n9, err := m.BSIGroup.MarshalTo(dAtA[i:]) if err != nil { return 0, err } @@ -1476,7 +1476,7 @@ func (m *CreateFieldMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *DeleteFieldMessage) Marshal() (dAtA []byte, err error) { +func (m *DeleteBSIGroupMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1486,7 +1486,7 @@ func (m *DeleteFieldMessage) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DeleteFieldMessage) MarshalTo(dAtA []byte) (int, error) { +func (m *DeleteBSIGroupMessage) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1503,11 +1503,11 @@ func (m *DeleteFieldMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) i += copy(dAtA[i:], m.Frame) } - if len(m.Field) > 0 { + if len(m.BSIGroup) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) - i += copy(dAtA[i:], m.Field) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.BSIGroup))) + i += copy(dAtA[i:], m.BSIGroup) } return i, nil } @@ -1859,7 +1859,7 @@ func (m *ClusterStatus) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Field) Marshal() (dAtA []byte, err error) { +func (m *BSIGroup) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1869,7 +1869,7 @@ func (m *Field) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Field) MarshalTo(dAtA []byte) (int, error) { +func (m *BSIGroup) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2459,7 +2459,7 @@ func (m *DeleteFrameMessage) Size() (n int) { return n } -func (m *CreateFieldMessage) Size() (n int) { +func (m *CreateBSIGroupMessage) Size() (n int) { var l int _ = l l = len(m.Index) @@ -2470,14 +2470,14 @@ func (m *CreateFieldMessage) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - if m.Field != nil { - l = m.Field.Size() + if m.BSIGroup != nil { + l = m.BSIGroup.Size() n += 1 + l + sovPrivate(uint64(l)) } return n } -func (m *DeleteFieldMessage) Size() (n int) { +func (m *DeleteBSIGroupMessage) Size() (n int) { var l int _ = l l = len(m.Index) @@ -2488,7 +2488,7 @@ func (m *DeleteFieldMessage) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Field) + l = len(m.BSIGroup) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2642,7 +2642,7 @@ func (m *ClusterStatus) Size() (n int) { return n } -func (m *Field) Size() (n int) { +func (m *BSIGroup) Size() (n int) { var l int _ = l l = len(m.Name) @@ -4304,7 +4304,7 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { +func (m *CreateBSIGroupMessage) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4327,10 +4327,10 @@ func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CreateFieldMessage: wiretype end group for non-group") + return fmt.Errorf("proto: CreateBSIGroupMessage: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CreateFieldMessage: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CreateBSIGroupMessage: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4393,7 +4393,7 @@ func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BSIGroup", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4417,10 +4417,10 @@ func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Field == nil { - m.Field = &Field{} + if m.BSIGroup == nil { + m.BSIGroup = &BSIGroup{} } - if err := m.Field.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BSIGroup.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4445,7 +4445,7 @@ func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *DeleteFieldMessage) Unmarshal(dAtA []byte) error { +func (m *DeleteBSIGroupMessage) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4468,10 +4468,10 @@ func (m *DeleteFieldMessage) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteFieldMessage: wiretype end group for non-group") + return fmt.Errorf("proto: DeleteBSIGroupMessage: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteFieldMessage: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DeleteBSIGroupMessage: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4534,7 +4534,7 @@ func (m *DeleteFieldMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BSIGroup", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4559,7 +4559,7 @@ func (m *DeleteFieldMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Field = string(dAtA[iNdEx:postIndex]) + m.BSIGroup = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -5671,7 +5671,7 @@ func (m *ClusterStatus) Unmarshal(dAtA []byte) error { } return nil } -func (m *Field) Unmarshal(dAtA []byte) error { +func (m *BSIGroup) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5694,10 +5694,10 @@ func (m *Field) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Field: wiretype end group for non-group") + return fmt.Errorf("proto: BSIGroup: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BSIGroup: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -7075,70 +7075,70 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1029 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6f, 0x1b, 0x45, - 0x18, 0x67, 0xbd, 0x6b, 0x27, 0xfe, 0x82, 0xd3, 0x64, 0x5a, 0xc2, 0x16, 0xa1, 0x60, 0x46, 0x45, - 0x18, 0x0e, 0x51, 0x69, 0x2f, 0xbc, 0x2a, 0x45, 0xb1, 0x83, 0x58, 0x44, 0x22, 0x98, 0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 0x59, 0x1f, 0xc0, 0xfa, 0x89, 0x9c, - 0xc8, 0x58, 0x9e, 0x4d, 0x6f, 0x59, 0x79, 0x1f, 0xd6, 0xcc, 0xfd, 0x68, 0x3e, 0x6c, 0x6d, 0x56, - 0x90, 0xf4, 0xae, 0x06, 0xf4, 0x90, 0xc7, 0xc3, 0x3c, 0xd6, 0x69, 0xe8, 0x9f, 0x5b, 0x76, 0xb0, - 0xf5, 0xd7, 0xf5, 0xae, 0xf3, 0xf7, 0xf5, 0xae, 0xf3, 0xcf, 0xf5, 0xae, 0xf3, 0xfb, 0xbf, 0xbb, - 0x6f, 0x3c, 0x6b, 0xe1, 0x37, 0xfc, 0xf1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x97, 0x84, - 0xb1, 0x97, 0x0b, 0x00, 0x00, + // 1038 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1b, 0xc5, + 0x1b, 0xff, 0xaf, 0x77, 0xed, 0xd8, 0x4f, 0xfe, 0x0e, 0xc9, 0x94, 0x84, 0x6d, 0x85, 0x82, 0x19, + 0x55, 0x22, 0x70, 0xb0, 0x4a, 0x7b, 0xe1, 0xad, 0x52, 0x14, 0x3b, 0xc0, 0x22, 0x12, 0xc1, 0x6c, + 0xd2, 0x03, 0x12, 0x42, 0x53, 0x7b, 0xd4, 0xae, 0xb2, 0xde, 0x31, 0xbb, 0xb3, 0x49, 0xdc, 0x03, + 0x57, 0xb8, 0x70, 0x47, 0xdc, 0xf8, 0x36, 0x1c, 0xf9, 0x08, 0x28, 0x7c, 0x11, 0x34, 0xcf, 0xcc, + 0xbe, 0xc4, 0x2f, 0x4d, 0x95, 0x72, 0x9b, 0xe7, 0xfd, 0xed, 0xf7, 0xcc, 0x0c, 0x74, 0xa7, 0x69, + 0x74, 0xce, 0x95, 0xe8, 0x4f, 0x53, 0xa9,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, 0xf7, 0xb4, 0x85, 0xdf, 0xf3, 0x47, + 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xc6, 0x83, 0xfe, 0xaf, 0x0b, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index b530257ae..df004456f 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -12,7 +12,6 @@ message FrameMeta { int64 Min = 9; int64 Max = 10; string TimeQuantum = 5; - //repeated Field Fields = 7; } message ImportResponse { @@ -65,16 +64,16 @@ message DeleteFrameMessage { string Frame = 2; } -message CreateFieldMessage { +message CreateBSIGroupMessage { string Index = 1; string Frame = 2; - Field Field = 3; + BSIGroup BSIGroup = 3; } -message DeleteFieldMessage { +message DeleteBSIGroupMessage { string Index = 1; string Frame = 2; - string Field = 3; + string BSIGroup = 3; } message Frame { @@ -126,7 +125,7 @@ message ClusterStatus { repeated Node Nodes = 3; } -message Field { +message BSIGroup { string Name = 1; string Type = 2; int64 Min = 3; diff --git a/server.go b/server.go index e7c566cbf..1e4f5a421 100644 --- a/server.go +++ b/server.go @@ -470,15 +470,15 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if err := idx.DeleteFrame(obj.Frame); err != nil { return err } - case *internal.CreateFieldMessage: + case *internal.CreateBSIGroupMessage: f := s.Holder.Frame(obj.Index, obj.Frame) - field := decodeField(obj.Field) + field := decodeBSIGroup(obj.BSIGroup) if err := f.createBSIGroup(field); err != nil { return err } - case *internal.DeleteFieldMessage: + case *internal.DeleteBSIGroupMessage: f := s.Holder.Frame(obj.Index, obj.Frame) - if err := f.DeleteField(obj.Field); err != nil { + if err := f.deleteBSIGroupAndView(obj.BSIGroup); err != nil { return err } case *internal.CreateViewMessage: From d80d3b6d5121d35b2f43a9e7896c57030e82d440 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 17:25:57 -0500 Subject: [PATCH 21/52] rename cases of Field in view.go --- executor_test.go | 2 +- frame.go | 12 ++++++------ view.go | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/executor_test.go b/executor_test.go index 578ddc11b..4b75686a4 100644 --- a/executor_test.go +++ b/executor_test.go @@ -335,7 +335,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Run("ErrInvalidFieldValueType", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f="hello")`), nil, nil); err == nil || err != pilosa.ErrInvalidBSIGroupValueType { t.Fatalf("unexpected error: %s", err) } }) diff --git a/frame.go b/frame.go index 65d98937c..15dcc03f4 100644 --- a/frame.go +++ b/frame.go @@ -718,7 +718,7 @@ func (f *Frame) Value(columnID uint64, name string) (value int64, exists bool, e return 0, false, nil } - v, exists, err := view.FieldValue(columnID, field.BitDepth()) + v, exists, err := view.value(columnID, field.BitDepth()) if err != nil { return 0, false, err } else if !exists { @@ -764,7 +764,7 @@ func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { return 0, 0, nil } - vsum, vcount, err := view.FieldSum(filter, field.BitDepth()) + vsum, vcount, err := view.sum(filter, field.BitDepth()) if err != nil { return 0, 0, err } @@ -784,7 +784,7 @@ func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { return 0, 0, nil } - vmin, vcount, err := view.FieldMin(filter, bsig.BitDepth()) + vmin, vcount, err := view.min(filter, bsig.BitDepth()) if err != nil { return 0, 0, err } @@ -804,7 +804,7 @@ func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { return 0, 0, nil } - vmax, vcount, err := view.FieldMax(filter, field.BitDepth()) + vmax, vcount, err := view.max(filter, field.BitDepth()) if err != nil { return 0, 0, err } @@ -831,7 +831,7 @@ func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) return NewRow(), nil } - return view.FieldRange(op, field.BitDepth(), baseValue) + return view.rangeOp(op, field.BitDepth(), baseValue) } func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { @@ -854,7 +854,7 @@ func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Ro return NewRow(), nil } - return view.FieldRangeBetween(field.BitDepth(), baseValueMin, baseValueMax) + return view.rangeBetween(field.BitDepth(), baseValueMin, baseValueMax) } // Import bulk imports data. diff --git a/view.go b/view.go index 994a54579..31bf9a470 100644 --- a/view.go +++ b/view.go @@ -323,8 +323,8 @@ func (v *View) ClearBit(rowID, columnID uint64) (changed bool, err error) { return frag.ClearBit(rowID, columnID) } -// FieldValue uses a column of bits to read a multi-bit value. -func (v *View) FieldValue(columnID uint64, bitDepth uint) (value uint64, exists bool, err error) { +// value uses a column of bits to read a multi-bit value. +func (v *View) value(columnID uint64, bitDepth uint) (value uint64, exists bool, err error) { slice := columnID / SliceWidth frag, err := v.CreateFragmentIfNotExists(slice) if err != nil { @@ -343,8 +343,8 @@ func (v *View) setValue(columnID uint64, bitDepth uint, value uint64) (changed b return frag.SetValue(columnID, bitDepth, value) } -// FieldSum returns the sum & count of a field. -func (v *View) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err error) { +// sum returns the sum & count of a field. +func (v *View) sum(filter *Row, bitDepth uint) (sum, count uint64, err error) { for _, f := range v.Fragments() { fsum, fcount, err := f.FieldSum(filter, bitDepth) if err != nil { @@ -356,8 +356,8 @@ func (v *View) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err erro return sum, count, nil } -// FieldMin returns the min and count of a field. -func (v *View) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err error) { +// min returns the min and count of a field. +func (v *View) min(filter *Row, bitDepth uint) (min, count uint64, err error) { var minHasValue bool for _, f := range v.Fragments() { fmin, fcount, err := f.FieldMin(filter, bitDepth) @@ -384,8 +384,8 @@ func (v *View) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err erro return min, count, nil } -// FieldMax returns the max and count of a field. -func (v *View) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err error) { +// max returns the max and count of a field. +func (v *View) max(filter *Row, bitDepth uint) (max, count uint64, err error) { for _, f := range v.Fragments() { fmax, fcount, err := f.FieldMax(filter, bitDepth) if err != nil { @@ -399,8 +399,8 @@ func (v *View) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err erro return max, count, nil } -// FieldRange returns rows with a field value encoding matching the predicate. -func (v *View) FieldRange(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) { +// rangeOp returns rows with a field value encoding matching the predicate. +func (v *View) rangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) { r := NewRow() for _, frag := range v.Fragments() { other, err := frag.FieldRange(op, bitDepth, predicate) @@ -412,9 +412,9 @@ func (v *View) FieldRange(op pql.Token, bitDepth uint, predicate uint64) (*Row, return r, nil } -// FieldRangeBetween returns bitmaps with a field value encoding matching any +// rangeBetween returns bitmaps with a field value encoding matching any // value between predicateMin and predicateMax. -func (v *View) FieldRangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) { +func (v *View) rangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) { r := NewRow() for _, frag := range v.Fragments() { other, err := frag.FieldRangeBetween(bitDepth, predicateMin, predicateMax) From 51a42d3e359b5dc03102d83c25c20252f736f0a9 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 17:40:25 -0500 Subject: [PATCH 22/52] rename test names --- frame_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame_test.go b/frame_test.go index aeae2b7ba..d3e274fe9 100644 --- a/frame_test.go +++ b/frame_test.go @@ -147,7 +147,7 @@ func TestFrame_SetValue(t *testing.T) { } }) - t.Run("ErrFieldNotFound", func(t *testing.T) { + t.Run("ErrBSIGroupNotFound", func(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() @@ -164,7 +164,7 @@ func TestFrame_SetValue(t *testing.T) { } }) - t.Run("ErrFieldValueTooLow", func(t *testing.T) { + t.Run("ErrBSIGroupValueTooLow", func(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() @@ -183,7 +183,7 @@ func TestFrame_SetValue(t *testing.T) { } }) - t.Run("ErrFieldValueTooHigh", func(t *testing.T) { + t.Run("ErrBSIGroupValueTooHigh", func(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() From b566fd278a4399229954426fc421a3bc578efdfc Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 20:00:30 -0500 Subject: [PATCH 23/52] remove field name argument from Frame.Value() --- executor_test.go | 4 ++-- frame.go | 6 +++--- frame_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/executor_test.go b/executor_test.go index 4b75686a4..095e45bf4 100644 --- a/executor_test.go +++ b/executor_test.go @@ -290,7 +290,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { } f := hldr.Frame("i", "f") - if value, exists, err := f.Value(10, "f"); err != nil { + if value, exists, err := f.Value(10); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") @@ -298,7 +298,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Fatalf("unexpected value: %v", value) } - if value, exists, err := f.Value(100, "f"); err != nil { + if value, exists, err := f.Value(100); err != nil { t.Fatal(err) } else if !exists { t.Fatal("expected value to exist") diff --git a/frame.go b/frame.go index 15dcc03f4..4d5e70510 100644 --- a/frame.go +++ b/frame.go @@ -706,14 +706,14 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change } // Value reads a bsiGroup value for a column. -func (f *Frame) Value(columnID uint64, name string) (value int64, exists bool, err error) { - field := f.bsiGroup(name) +func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { + field := f.bsiGroup(f.name) if field == nil { return 0, false, ErrBSIGroupNotFound } // Fetch target view. - view := f.View(viewBSIGroupPrefix + name) + view := f.View(viewBSIGroupPrefix + f.name) if view == nil { return 0, false, nil } diff --git a/frame_test.go b/frame_test.go index d3e274fe9..739b34ed8 100644 --- a/frame_test.go +++ b/frame_test.go @@ -94,7 +94,7 @@ func TestFrame_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.Value(100, "f"); err != nil { + if value, exists, err := f.Value(100); err != nil { t.Fatal(err) } else if value != 21 { t.Fatalf("unexpected value: %d", value) @@ -138,7 +138,7 @@ func TestFrame_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.Value(100, "f"); err != nil { + if value, exists, err := f.Value(100); err != nil { t.Fatal(err) } else if value != 23 { t.Fatalf("unexpected value: %d", value) From 28cdaa61e725f85818e620dd615e55189cf5675b Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Mon, 4 Jun 2018 20:08:24 -0500 Subject: [PATCH 24/52] rename some instances of field to bsiGroup --- frame.go | 81 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/frame.go b/frame.go index 4d5e70510..2b9e03993 100644 --- a/frame.go +++ b/frame.go @@ -424,7 +424,7 @@ func (f *Frame) addBSIGroup(bsig *bsiGroup) error { // Add bsiGroup to list. f.bsiGroups = append(f.bsiGroups, bsig) - // Sort fields by name. + // Sort bsiGroups by name. sort.Slice(f.bsiGroups, func(i, j int) bool { return f.bsiGroups[i].Name < f.bsiGroups[j].Name }) @@ -432,13 +432,12 @@ func (f *Frame) addBSIGroup(bsig *bsiGroup) error { return nil } -// TODO: merge this into the un-exported deleteBSIGroup. -// deleteBSIGroupAndView deletes an existing field on the schema. +// deleteBSIGroupAndView deletes an existing bsiGroup on the schema. func (f *Frame) deleteBSIGroupAndView(name string) error { f.mu.Lock() defer f.mu.Unlock() - // Remove field. + // Remove bsiGroup. if err := f.deleteBSIGroup(name); err != nil { return err } @@ -705,10 +704,10 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change return changed, nil } -// Value reads a bsiGroup value for a column. +// Value reads a frame value for a column. func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { - field := f.bsiGroup(f.name) - if field == nil { + bsig := f.bsiGroup(f.name) + if bsig == nil { return 0, false, ErrBSIGroupNotFound } @@ -718,24 +717,24 @@ func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { return 0, false, nil } - v, exists, err := view.value(columnID, field.BitDepth()) + v, exists, err := view.value(columnID, bsig.BitDepth()) if err != nil { return 0, false, err } else if !exists { return 0, false, nil } - return int64(v) + field.Min, true, nil + return int64(v) + bsig.Min, true, nil } -// SetValue sets a field value for a column. +// SetValue sets a frame value for a column. func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) { - // Fetch field and validate value. - field := f.bsiGroup(f.name) - if field == nil { + // Fetch bsiGroup and validate value. + bsig := f.bsiGroup(f.name) + if bsig == nil { return false, ErrBSIGroupNotFound - } else if value < field.Min { + } else if value < bsig.Min { return false, ErrBSIGroupValueTooLow - } else if value > field.Max { + } else if value > bsig.Max { return false, ErrBSIGroupValueTooHigh } @@ -746,16 +745,16 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) } // Determine base value to store. - baseValue := uint64(value - field.Min) + baseValue := uint64(value - bsig.Min) - return view.setValue(columnID, field.BitDepth(), baseValue) + return view.setValue(columnID, bsig.BitDepth(), baseValue) } -// Sum returns the sum and count for a field. +// Sum returns the sum and count for a frame. // An optional filtering row can be provided. func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { - field := f.bsiGroup(name) - if field == nil { + bsig := f.bsiGroup(name) + if bsig == nil { return 0, 0, ErrBSIGroupNotFound } @@ -764,14 +763,14 @@ func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { return 0, 0, nil } - vsum, vcount, err := view.sum(filter, field.BitDepth()) + vsum, vcount, err := view.sum(filter, bsig.BitDepth()) if err != nil { return 0, 0, err } - return int64(vsum) + (int64(vcount) * field.Min), int64(vcount), nil + return int64(vsum) + (int64(vcount) * bsig.Min), int64(vcount), nil } -// Min returns the min for a field. +// Min returns the min for a frame. // An optional filtering row can be provided. func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { bsig := f.bsiGroup(name) @@ -791,11 +790,11 @@ func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { return int64(vmin) + bsig.Min, int64(vcount), nil } -// Max returns the max for a field. +// Max returns the max for a frame. // An optional filtering row can be provided. func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { - field := f.bsiGroup(name) - if field == nil { + bsig := f.bsiGroup(name) + if bsig == nil { return 0, 0, ErrBSIGroupNotFound } @@ -804,57 +803,57 @@ func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { return 0, 0, nil } - vmax, vcount, err := view.max(filter, field.BitDepth()) + vmax, vcount, err := view.max(filter, bsig.BitDepth()) if err != nil { return 0, 0, err } - return int64(vmax) + field.Min, int64(vcount), nil + return int64(vmax) + bsig.Min, int64(vcount), nil } func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) { - // Retrieve and validate field. - field := f.bsiGroup(name) - if field == nil { + // Retrieve and validate bsiGroup. + bsig := f.bsiGroup(name) + if bsig == nil { return nil, ErrBSIGroupNotFound - } else if predicate < field.Min || predicate > field.Max { + } else if predicate < bsig.Min || predicate > bsig.Max { return nil, nil } - // Retrieve field's view. + // Retrieve bsiGroup's view. view := f.View(viewBSIGroupPrefix + name) if view == nil { return nil, nil } - baseValue, outOfRange := field.baseValue(op, predicate) + baseValue, outOfRange := bsig.baseValue(op, predicate) if outOfRange { return NewRow(), nil } - return view.rangeOp(op, field.BitDepth(), baseValue) + return view.rangeOp(op, bsig.BitDepth(), baseValue) } func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { - // Retrieve and validate field. - field := f.bsiGroup(name) - if field == nil { + // Retrieve and validate bsiGroup. + bsig := f.bsiGroup(name) + if bsig == nil { return nil, ErrBSIGroupNotFound } else if predicateMin > predicateMax { return nil, ErrInvalidBetweenValue } - // Retrieve field's view. + // Retrieve bsiGroup's view. view := f.View(viewBSIGroupPrefix + name) if view == nil { return nil, nil } - baseValueMin, baseValueMax, outOfRange := field.baseValueBetween(predicateMin, predicateMax) + baseValueMin, baseValueMax, outOfRange := bsig.baseValueBetween(predicateMin, predicateMax) if outOfRange { return NewRow(), nil } - return view.rangeBetween(field.BitDepth(), baseValueMin, baseValueMax) + return view.rangeBetween(bsig.BitDepth(), baseValueMin, baseValueMax) } // Import bulk imports data. From 2111a3d5219d18db17d0a778d6411888d5f4d051 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 11:13:51 -0500 Subject: [PATCH 25/52] more Field removal/rename --- api.go | 4 +- client.go | 9 ++- client_test.go | 2 +- ctl/import.go | 2 +- executor.go | 34 +++++----- executor_test.go | 16 ++--- fragment.go | 6 +- fragment_test.go | 2 +- frame.go | 12 ++-- frame_internal_test.go | 4 +- internal/public.pb.go | 138 ++++++++++++++--------------------------- internal/public.proto | 1 - 12 files changed, 90 insertions(+), 140 deletions(-) diff --git a/api.go b/api.go index e34a9142b..6f6123f9b 100644 --- a/api.go +++ b/api.go @@ -710,9 +710,9 @@ func (api *API) ImportValue(ctx context.Context, req internal.ImportValueRequest } // Import into fragment. - err = frame.ImportValue(req.Field, req.ColumnIDs, req.Values) + err = frame.ImportValue(req.ColumnIDs, req.Values) if err != nil { - api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, field=%s, columns=%d, err=%s", req.Index, req.Frame, req.Slice, req.Field, len(req.ColumnIDs), err) + api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Frame, req.Slice, len(req.ColumnIDs), err) } return errors.Wrap(err, "importing") } diff --git a/client.go b/client.go index f3e0e5dce..1d78dde23 100644 --- a/client.go +++ b/client.go @@ -420,14 +420,14 @@ func (c *InternalHTTPClient) importNode(ctx context.Context, node *Node, buf []b } // ImportValue bulk imports field values for a single slice to a host. -func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame, field string, slice uint64, vals []FieldValue) error { +func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error { if index == "" { return ErrIndexRequired } else if frame == "" { return ErrFrameRequired } - buf, err := marshalImportValuePayload(index, frame, field, slice, vals) + buf, err := marshalImportValuePayload(index, frame, slice, vals) if err != nil { return fmt.Errorf("Error Creating Payload: %s", err) } @@ -449,7 +449,7 @@ func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame, fiel } // marshalImportValuePayload marshalls the import parameters into a protobuf byte slice. -func marshalImportValuePayload(index, frame, field string, slice uint64, vals []FieldValue) ([]byte, error) { +func marshalImportValuePayload(index, frame string, slice uint64, vals []FieldValue) ([]byte, error) { // Separate row and column IDs to reduce allocations. columnIDs := FieldValues(vals).ColumnIDs() values := FieldValues(vals).Values() @@ -459,7 +459,6 @@ func marshalImportValuePayload(index, frame, field string, slice uint64, vals [] Index: index, Frame: frame, Slice: slice, - Field: field, ColumnIDs: columnIDs, Values: values, }) @@ -1058,7 +1057,7 @@ type InternalClient interface { 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 + ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error ExportCSV(ctx context.Context, index, frame string, slice uint64, w io.Writer) error CreateFrame(ctx context.Context, index, frame string, opt FrameOptions) error FragmentBlocks(ctx context.Context, index, frame string, slice uint64) ([]FragmentBlock, error) diff --git a/client_test.go b/client_test.go index 2bb255382..1edd37bc2 100644 --- a/client_test.go +++ b/client_test.go @@ -267,7 +267,7 @@ func TestClient_ImportValue(t *testing.T) { // Send import request. c := test.MustNewClient(s.Host(), defaultClient) - if err := c.ImportValue(context.Background(), "i", "f", fldName, 0, []pilosa.FieldValue{ + if err := c.ImportValue(context.Background(), "i", "f", 0, []pilosa.FieldValue{ {ColumnID: 1, Value: -10}, {ColumnID: 2, Value: 20}, {ColumnID: 3, Value: 40}, diff --git a/ctl/import.go b/ctl/import.go index a9d70fd7c..4fdfba444 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -435,7 +435,7 @@ func (cmd *ImportCommand) importFieldValues(ctx context.Context, vals []pilosa.F } logger.Printf("importing slice: %d, n=%d", slice, len(vals)) - if err := cmd.Client.ImportValue(ctx, cmd.Index, cmd.Frame, cmd.Field, slice, vals); err != nil { + if err := cmd.Client.ImportValue(ctx, cmd.Index, cmd.Frame, slice, vals); err != nil { return errors.Wrap(err, "importing values") } } diff --git a/executor.go b/executor.go index b5e19e5b7..e6c8ad251 100644 --- a/executor.go +++ b/executor.go @@ -127,10 +127,10 @@ func (e *Executor) executeCall(ctx context.Context, index string, c *pql.Call, s return e.executeSum(ctx, index, c, slices, opt) case "Min": e.Holder.Stats.CountWithCustomTags(c.Name, 1, 1.0, []string{indexTag}) - return e.executeFieldMin(ctx, index, c, slices, opt) + return e.executeMin(ctx, index, c, slices, opt) case "Max": e.Holder.Stats.CountWithCustomTags(c.Name, 1, 1.0, []string{indexTag}) - return e.executeFieldMax(ctx, index, c, slices, opt) + return e.executeMax(ctx, index, c, slices, opt) case "ClearBit": return e.executeClearBit(ctx, index, c, opt) case "Count": @@ -207,8 +207,8 @@ func (e *Executor) executeSum(ctx context.Context, index string, c *pql.Call, sl return other, nil } -// executeFieldMin executes a Min() call. -func (e *Executor) executeFieldMin(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { +// executeMin executes a Min() call. +func (e *Executor) executeMin(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { if frame := c.Args["frame"]; frame == "" { return ValCount{}, errors.New("Min(): frame required") } else if field := c.Args["field"]; field == "" { @@ -221,7 +221,7 @@ func (e *Executor) executeFieldMin(ctx context.Context, index string, c *pql.Cal // Execute calls in bulk on each remote node and merge. mapFn := func(slice uint64) (interface{}, error) { - return e.executeFieldMinSlice(ctx, index, c, slice) + return e.executeMinSlice(ctx, index, c, slice) } // Merge returned results at coordinating node. @@ -242,8 +242,8 @@ func (e *Executor) executeFieldMin(ctx context.Context, index string, c *pql.Cal return other, nil } -// executeFieldMax executes a Max() call. -func (e *Executor) executeFieldMax(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { +// executeMax executes a Max() call. +func (e *Executor) executeMax(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { if frame := c.Args["frame"]; frame == "" { return ValCount{}, errors.New("Max(): frame required") } else if field := c.Args["field"]; field == "" { @@ -256,7 +256,7 @@ func (e *Executor) executeFieldMax(ctx context.Context, index string, c *pql.Cal // Execute calls in bulk on each remote node and merge. mapFn := func(slice uint64) (interface{}, error) { - return e.executeFieldMaxSlice(ctx, index, c, slice) + return e.executeMaxSlice(ctx, index, c, slice) } // Merge returned results at coordinating node. @@ -401,8 +401,8 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq }, nil } -// executeFieldMinSlice calculates the min for fields on a slice. -func (e *Executor) executeFieldMinSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { +// executeMinSlice calculates the min for fields on a slice. +func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { var filter *Row if len(c.Children) == 1 { row, err := e.executeBitmapCallSlice(ctx, index, c.Children[0], slice) @@ -440,8 +440,8 @@ func (e *Executor) executeFieldMinSlice(ctx context.Context, index string, c *pq }, nil } -// executeFieldMaxSlice calculates the max for fields on a slice. -func (e *Executor) executeFieldMaxSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { +// executeMaxSlice calculates the max for fields on a slice. +func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { var filter *Row if len(c.Children) == 1 { row, err := e.executeBitmapCallSlice(ctx, index, c.Children[0], slice) @@ -552,7 +552,7 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) } - field, _ := c.Args["field"].(string) + field, _ := c.Args["field"].(string) // TODO: rename this to something other than field rowIDs, _, err := c.UintSliceArg("ids") if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) @@ -600,7 +600,7 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca N: int(n), Src: src, RowIDs: rowIDs, - FilterField: field, + FilterName: field, FilterValues: filters, MinThreshold: minThreshold, TanimotoThreshold: tanimotoThreshold, @@ -687,7 +687,7 @@ func (e *Executor) executeIntersectSlice(ctx context.Context, index string, c *p func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) { // Handle field ranges differently. if c.HasConditionArg() { - return e.executeFieldRangeSlice(ctx, index, c, slice) + return e.executeBSIGroupRangeSlice(ctx, index, c, slice) } // Parse frame, use default if unset. @@ -756,8 +756,8 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C return row, nil } -// executeFieldRangeSlice executes a range(field) call for a local slice. -func (e *Executor) executeFieldRangeSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) { +// executeBSIGroupRangeSlice executes a range(field) call for a local slice. +func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) { // Parse frame, use default if unset. frame, _ := c.Args["frame"].(string) if frame == "" { diff --git a/executor_test.go b/executor_test.go index 095e45bf4..606646a92 100644 --- a/executor_test.go +++ b/executor_test.go @@ -319,21 +319,21 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Fatal(err) } - t.Run("ErrColumnFieldRequired", func(t *testing.T) { + t.Run("ErrColumnBSIGroupRequired", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) - t.Run("ErrColumnFieldValue", func(t *testing.T) { + t.Run("ErrColumnBSIGroupValue", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` { t.Fatalf("unexpected error: %s", err) } }) - t.Run("ErrInvalidFieldValueType", func(t *testing.T) { + t.Run("ErrInvalidBSIGroupValueType", func(t *testing.T) { e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f="hello")`), nil, nil); err == nil || err != pilosa.ErrInvalidBSIGroupValueType { t.Fatalf("unexpected error: %s", err) @@ -728,7 +728,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { } // Ensure a range query can be executed. -func TestExecutor_Execute_Range(t *testing.T) { +func TestExecutor_Execute_BSIGroupRange(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) @@ -770,7 +770,7 @@ func TestExecutor_Execute_Range(t *testing.T) { } // Ensure a Range(field) query can be executed. -func TestExecutor_Execute_FieldRange(t *testing.T) { +func TestExecutor_Execute_Range(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) @@ -903,8 +903,8 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { } }) - // Ensure that the FieldNotNull code path gets run. - t.Run("FieldNotNull", func(t *testing.T) { + // Ensure that the NotNull code path gets run. + t.Run("NotNull", func(t *testing.T) { if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other >< [0, 1000])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { @@ -950,7 +950,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) { } }) - t.Run("ErrFieldNotFound", func(t *testing.T) { + t.Run("ErrBSIGroupNotFound", func(t *testing.T) { if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, bad_field >= 20)`), nil, nil); err != pilosa.ErrBSIGroupNotFound { t.Fatal(err) } diff --git a/fragment.go b/fragment.go index f2d7ad986..fe50a76f2 100644 --- a/fragment.go +++ b/fragment.go @@ -900,7 +900,7 @@ func (f *Fragment) Top(opt TopOptions) ([]Pair, error) { // Create a fast lookup of filter values. var filters map[interface{}]struct{} - if opt.FilterField != "" && len(opt.FilterValues) > 0 { + if opt.FilterName != "" && len(opt.FilterValues) > 0 { filters = make(map[interface{}]struct{}) for _, v := range opt.FilterValues { filters[v] = struct{}{} @@ -948,7 +948,7 @@ func (f *Fragment) Top(opt TopOptions) ([]Pair, error) { return nil, errors.Wrap(err, "getting attrs") } else if attr == nil { continue - } else if attrValue := attr[opt.FilterField]; attrValue == nil { + } else if attrValue := attr[opt.FilterName]; attrValue == nil { continue } else if _, ok := filters[attrValue]; !ok { continue @@ -1074,7 +1074,7 @@ type TopOptions struct { MinThreshold uint64 // Filter field name & values. - FilterField string + FilterName string FilterValues []interface{} TanimotoThreshold uint64 } diff --git a/fragment_test.go b/fragment_test.go index f5205eb73..6655f62b9 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -623,7 +623,7 @@ func TestFragment_Top_Filter(t *testing.T) { // Retrieve top rows. if pairs, err := f.Top(pilosa.TopOptions{ N: 2, - FilterField: "x", + FilterName: "x", FilterValues: []interface{}{int64(10), int64(15), int64(20)}, }); err != nil { t.Fatal(err) diff --git a/frame.go b/frame.go index 2b9e03993..a34eabf7f 100644 --- a/frame.go +++ b/frame.go @@ -914,12 +914,12 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro } // ImportValue bulk imports range-encoded value data. -func (f *Frame) ImportValue(fieldName string, columnIDs []uint64, values []int64) error { - viewName := viewBSIGroupPrefix + fieldName +func (f *Frame) ImportValue(columnIDs []uint64, values []int64) error { + viewName := viewBSIGroupPrefix + f.name // Get the bsiGroup so we know bitDepth. - bsig := f.bsiGroup(fieldName) + bsig := f.bsiGroup(f.name) if bsig == nil { - return errors.Wrap(ErrBSIGroupNotFound, fieldName) + return errors.Wrap(ErrBSIGroupNotFound, f.name) } // Split import data by fragment. @@ -1084,7 +1084,7 @@ func isValidBSIGroupType(v string) bool { } } -// bsiGroup represents a range field on a frame. +// bsiGroup represents a group of range-encoded rows on a frame. type bsiGroup struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` @@ -1113,7 +1113,7 @@ func (b *bsiGroup) BitDepth() uint { // we can't simply return 1024. // In order to make this work, we effectively need to change the operator to LTE. // Executor.executeFieldRangeSlice() takes this into account and returns -// `frag.FieldNotNull(field.BitDepth())` in such instances. +// `frag.FieldNotNull(bsig.BitDepth())` in such instances. func (b *bsiGroup) baseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { if op == pql.GT || op == pql.GTE { if value > b.Max { diff --git a/frame_internal_test.go b/frame_internal_test.go index 5cba2e84b..91b1af02c 100644 --- a/frame_internal_test.go +++ b/frame_internal_test.go @@ -21,8 +21,8 @@ import ( "github.com/pilosa/pilosa/pql" ) -// Ensure a field can adjust to its baseValue. -func TestField_BaseValue(t *testing.T) { +// Ensure a bsiGroup can adjust to its baseValue. +func TestBSIGroup_BaseValue(t *testing.T) { b0 := &bsiGroup{ Name: "b0", Type: bsiGroupTypeInt, diff --git a/internal/public.pb.go b/internal/public.pb.go index 069f633c0..2fc4b3827 100644 --- a/internal/public.pb.go +++ b/internal/public.pb.go @@ -485,7 +485,6 @@ 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"` ColumnKeys []string `protobuf:"bytes,7,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` Values []int64 `protobuf:"varint,6,rep,packed,name=Values" json:"Values,omitempty"` @@ -517,13 +516,6 @@ func (m *ImportValueRequest) GetSlice() uint64 { return 0 } -func (m *ImportValueRequest) GetField() string { - if m != nil { - return m.Field - } - return "" -} - func (m *ImportValueRequest) GetColumnIDs() []uint64 { if m != nil { return m.ColumnIDs @@ -1190,12 +1182,6 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintPublic(dAtA, i, uint64(m.Slice)) } - if len(m.Field) > 0 { - dAtA[i] = 0x22 - i++ - i = encodeVarintPublic(dAtA, i, uint64(len(m.Field))) - i += copy(dAtA[i:], m.Field) - } if len(m.ColumnIDs) > 0 { dAtA14 := make([]byte, len(m.ColumnIDs)*10) var j13 int @@ -1545,10 +1531,6 @@ func (m *ImportValueRequest) Size() (n int) { if m.Slice != 0 { n += 1 + sovPublic(uint64(m.Slice)) } - l = len(m.Field) - if l > 0 { - n += 1 + l + sovPublic(uint64(l)) - } if len(m.ColumnIDs) > 0 { l = 0 for _, e := range m.ColumnIDs { @@ -3507,35 +3489,6 @@ func (m *ImportValueRequest) Unmarshal(dAtA []byte) error { break } } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field", 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.Field = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 5: if wireType == 0 { var v uint64 @@ -3818,50 +3771,49 @@ var ( func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) } var fileDescriptorPublic = []byte{ - // 709 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0xfd, 0x26, 0x76, 0xfe, 0x6e, 0x9a, 0x7c, 0xd5, 0xe8, 0xfb, 0x8a, 0x85, 0x50, 0xb0, 0x2c, - 0x84, 0xbc, 0x4a, 0xa5, 0xb0, 0x07, 0xd1, 0x3f, 0x29, 0xaa, 0xa8, 0x60, 0x5a, 0x8a, 0x58, 0xba, - 0xed, 0xa8, 0x58, 0x72, 0x3c, 0xc6, 0x1e, 0x2b, 0xcd, 0x73, 0xb0, 0xe1, 0x11, 0x78, 0x0c, 0xc4, - 0xaa, 0x4b, 0x1e, 0x01, 0xca, 0x8b, 0xa0, 0x7b, 0xc7, 0x13, 0xbb, 0xa9, 0x04, 0x2c, 0xd8, 0xcd, - 0x39, 0x67, 0xe6, 0x66, 0xce, 0xdc, 0x73, 0x1d, 0xd8, 0xc8, 0xca, 0xb3, 0x24, 0x3e, 0x9f, 0x64, - 0xb9, 0xd2, 0x8a, 0xf7, 0xe2, 0x54, 0xcb, 0x3c, 0x8d, 0x92, 0xe0, 0x2d, 0x38, 0x42, 0x2d, 0xb8, - 0x07, 0xdd, 0x5d, 0x95, 0x94, 0xf3, 0xb4, 0xf0, 0x98, 0xef, 0x84, 0xae, 0xb0, 0x90, 0x3f, 0x82, - 0xf6, 0x73, 0xad, 0xf3, 0xc2, 0x6b, 0xf9, 0x4e, 0x38, 0x98, 0x8e, 0x26, 0xf6, 0xe8, 0x04, 0x69, - 0x61, 0x44, 0xce, 0xc1, 0x3d, 0x94, 0xcb, 0xc2, 0x73, 0x7c, 0x27, 0xec, 0x0b, 0x5a, 0x07, 0x4f, - 0xc1, 0x7d, 0x19, 0xc5, 0x39, 0x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d, - 0x94, 0x17, 0x94, 0xa7, 0x9e, 0xb0, 0x90, 0x4f, 0xea, 0xf9, 0xa4, 0x06, 0x0c, 0xa6, 0xbc, 0x2e, - 0x61, 0x15, 0x51, 0xcf, 0xb0, 0x0d, 0x34, 0xf6, 0x62, 0x68, 0x02, 0x1d, 0x7c, 0x67, 0x30, 0x9c, - 0xcd, 0x33, 0x95, 0xeb, 0x46, 0x48, 0x66, 0xe9, 0x85, 0xbc, 0xb2, 0x21, 0x21, 0x80, 0xec, 0x41, - 0x1e, 0xcd, 0xcd, 0x34, 0xf4, 0x85, 0x01, 0xc8, 0x52, 0x58, 0x28, 0x1c, 0xae, 0x30, 0x80, 0x62, - 0x81, 0xf3, 0x5e, 0x78, 0xae, 0x09, 0x94, 0x41, 0x18, 0x7f, 0x3b, 0xee, 0x85, 0xd7, 0x26, 0xa9, - 0x26, 0x30, 0xfe, 0xab, 0x79, 0xc7, 0xbc, 0x38, 0xa1, 0x23, 0x1a, 0x0c, 0xbe, 0x83, 0x50, 0x0b, - 0xfa, 0xc8, 0x75, 0xe9, 0x23, 0x67, 0x21, 0x9e, 0x34, 0x65, 0x48, 0xec, 0x91, 0xd8, 0x60, 0x82, - 0x2f, 0x0c, 0xb8, 0xf1, 0x48, 0x83, 0xf4, 0xf7, 0x8c, 0xe2, 0xde, 0x58, 0x26, 0xa6, 0x31, 0xb8, - 0x17, 0xc1, 0x6f, 0x6c, 0x6e, 0x41, 0x87, 0x6e, 0x61, 0x2d, 0x56, 0x68, 0xcd, 0x44, 0x77, 0xdd, - 0xc4, 0xce, 0xe6, 0xf5, 0xcd, 0x98, 0x7d, 0xbd, 0x19, 0xb3, 0x6f, 0x37, 0x63, 0xf6, 0xf1, 0xc7, - 0xf8, 0x9f, 0xb3, 0x0e, 0xfd, 0x95, 0x3c, 0xf9, 0x19, 0x00, 0x00, 0xff, 0xff, 0x03, 0x56, 0xc7, - 0xa4, 0x5a, 0x06, 0x00, 0x00, + // 701 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd4, 0x3c, + 0x14, 0xfd, 0x3c, 0xc9, 0xfc, 0xdd, 0xe9, 0xcc, 0x57, 0x59, 0xdf, 0x57, 0x22, 0x84, 0x86, 0x28, + 0x42, 0x28, 0xab, 0xa9, 0x34, 0xec, 0x41, 0xf4, 0x4f, 0x1a, 0x55, 0x54, 0x70, 0x5b, 0x8a, 0x58, + 0xa6, 0xad, 0x55, 0x22, 0x65, 0xe2, 0x90, 0x38, 0x9a, 0xce, 0x73, 0xb0, 0xe1, 0x11, 0x58, 0xf0, + 0x10, 0x2c, 0xbb, 0xe4, 0x11, 0xa0, 0xbc, 0x08, 0xf2, 0x75, 0x3c, 0x49, 0xa7, 0x52, 0xc5, 0x82, + 0x9d, 0xcf, 0x39, 0xf6, 0xb5, 0x8f, 0x7d, 0x6e, 0x02, 0x1b, 0x59, 0x79, 0x96, 0xc4, 0xe7, 0x93, + 0x2c, 0x97, 0x4a, 0xf2, 0x5e, 0x9c, 0x2a, 0x91, 0xa7, 0x51, 0x12, 0xbc, 0x07, 0x07, 0xe5, 0x82, + 0x7b, 0xd0, 0xdd, 0x95, 0x49, 0x39, 0x4f, 0x0b, 0x8f, 0xf9, 0x4e, 0xe8, 0xa2, 0x85, 0xfc, 0x09, + 0xb4, 0x5f, 0x2a, 0x95, 0x17, 0x5e, 0xcb, 0x77, 0xc2, 0xc1, 0x74, 0x34, 0xb1, 0x4b, 0x27, 0x9a, + 0x46, 0x23, 0x72, 0x0e, 0xee, 0xa1, 0x58, 0x16, 0x9e, 0xe3, 0x3b, 0x61, 0x1f, 0x69, 0x1c, 0x3c, + 0x07, 0xf7, 0x75, 0x14, 0xe7, 0x7c, 0x04, 0xad, 0xd9, 0x9e, 0xc7, 0x7c, 0x16, 0xba, 0xd8, 0x9a, + 0xed, 0xf1, 0xff, 0xa0, 0xbd, 0x2b, 0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7, 0x25, + 0xac, 0x82, 0x75, 0x0f, 0xdb, 0x40, 0xeb, 0xb7, 0x18, 0x9a, 0x40, 0x07, 0x3f, 0x19, 0x0c, 0x67, + 0xf3, 0x4c, 0xe6, 0xaa, 0x11, 0x92, 0x59, 0x7a, 0x21, 0xae, 0x6c, 0x48, 0x08, 0x68, 0xf6, 0x20, + 0x8f, 0xe6, 0xa6, 0x1b, 0xfa, 0x68, 0x80, 0x66, 0x29, 0x2c, 0x14, 0x0e, 0x17, 0x0d, 0xa0, 0x58, + 0xe8, 0x7e, 0x2f, 0x3c, 0xd7, 0x04, 0xca, 0x20, 0x1d, 0x7f, 0xdb, 0xee, 0x85, 0xd7, 0x26, 0xa9, + 0x26, 0x74, 0xfc, 0x57, 0xfd, 0xae, 0xf3, 0xe2, 0x84, 0x0e, 0x36, 0x18, 0x7d, 0x0f, 0x28, 0x17, + 0xf4, 0x91, 0xeb, 0xd2, 0x47, 0xce, 0x42, 0xbd, 0xd2, 0x94, 0x21, 0xb1, 0x47, 0x62, 0x83, 0x09, + 0xbe, 0x32, 0xe0, 0xc6, 0x23, 0x35, 0xd2, 0xdf, 0x33, 0x7a, 0xbf, 0xa1, 0x2d, 0xe8, 0xd0, 0x7e, + 0xd6, 0x4c, 0x85, 0xd6, 0x8e, 0xdb, 0x5d, 0x3f, 0xee, 0xce, 0xe6, 0xf5, 0xcd, 0x98, 0x7d, 0xbf, + 0x19, 0xb3, 0x1f, 0x37, 0x63, 0xf6, 0xf9, 0xd7, 0xf8, 0x9f, 0xb3, 0x0e, 0xfd, 0x34, 0x9e, 0xfd, + 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x5d, 0x77, 0x8c, 0x44, 0x06, 0x00, 0x00, } diff --git a/internal/public.proto b/internal/public.proto index 9207d3a67..b37eea98c 100644 --- a/internal/public.proto +++ b/internal/public.proto @@ -83,7 +83,6 @@ 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 207e9c2674e658a421d4fde34613956dd7dbf463 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 12:30:59 -0500 Subject: [PATCH 26/52] minor fixes --- frame.go | 2 +- index_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame.go b/frame.go index a34eabf7f..ac9eb5ee7 100644 --- a/frame.go +++ b/frame.go @@ -1112,7 +1112,7 @@ func (b *bsiGroup) BitDepth() uint { // Note that in this case (because the range uses the full BitDepth 0 to 1023), // we can't simply return 1024. // In order to make this work, we effectively need to change the operator to LTE. -// Executor.executeFieldRangeSlice() takes this into account and returns +// Executor.executeBSIGroupRangeSlice() takes this into account and returns // `frag.FieldNotNull(bsig.BitDepth())` in such instances. func (b *bsiGroup) baseValue(op pql.Token, value int64) (baseValue uint64, outOfRange bool) { if op == pql.GT || op == pql.GTE { diff --git a/index_test.go b/index_test.go index 3a4ee48bc..86d9043ce 100644 --- a/index_test.go +++ b/index_test.go @@ -158,7 +158,7 @@ func TestIndex_CreateFrame(t *testing.T) { } }) - t.Run("ErrInvalidFieldRange", func(t *testing.T) { + t.Run("ErrInvalidBSIGroupRange", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() @@ -166,7 +166,7 @@ func TestIndex_CreateFrame(t *testing.T) { Fields: []*pilosa.Field{ {Name: "field0", Type: pilosa.FieldTypeInt, Min: 100, Max: 50}, }, - }); err != pilosa.ErrInvalidFieldRange { + }); err != pilosa.ErrInvalidBSIGroupRange { t.Fatal(err) } }) From 7f1ac8fdcdbd400c8fba7db30a4962c4b3e4d869 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 12:57:15 -0500 Subject: [PATCH 27/52] remove Field* from fragment.go --- executor.go | 18 +++++++++--------- fragment.go | 46 +++++++++++++++++++++++----------------------- fragment_test.go | 44 ++++++++++++++++++++++---------------------- view.go | 12 ++++++------ 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/executor.go b/executor.go index e6c8ad251..98982606d 100644 --- a/executor.go +++ b/executor.go @@ -391,7 +391,7 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq return ValCount{}, nil } - vsum, vcount, err := fragment.FieldSum(filter, field.BitDepth()) + vsum, vcount, err := fragment.Sum(filter, field.BitDepth()) if err != nil { return ValCount{}, errors.Wrap(err, "computing sum") } @@ -430,7 +430,7 @@ func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Cal return ValCount{}, nil } - fmin, fcount, err := fragment.FieldMin(filter, field.BitDepth()) + fmin, fcount, err := fragment.Min(filter, field.BitDepth()) if err != nil { return ValCount{}, err } @@ -469,7 +469,7 @@ func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Cal return ValCount{}, nil } - fmax, fcount, err := fragment.FieldMax(filter, field.BitDepth()) + fmax, fcount, err := fragment.Max(filter, field.BitDepth()) if err != nil { return ValCount{}, err } @@ -811,7 +811,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, return NewRow(), nil } - return frag.FieldNotNull(field.BitDepth()) + return frag.NotNull(field.BitDepth()) } else if cond.Op == pql.BETWEEN { @@ -849,10 +849,10 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, // If the query is asking for the entire valid range, just return // the not-null bitmap for the field. if predicates[0] <= field.Min && predicates[1] >= field.Max { - return frag.FieldNotNull(field.BitDepth()) + return frag.NotNull(field.BitDepth()) } - return frag.FieldRangeBetween(field.BitDepth(), baseValueMin, baseValueMax) + return frag.RangeBetween(field.BitDepth(), baseValueMin, baseValueMax) } else { @@ -882,16 +882,16 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, // LT[E] and GT[E] should return all not-null if selected range fully encompasses valid field range. if (cond.Op == pql.LT && value > field.Max) || (cond.Op == pql.LTE && value >= field.Max) || (cond.Op == pql.GT && value < field.Min) || (cond.Op == pql.GTE && value <= field.Min) { - return frag.FieldNotNull(field.BitDepth()) + return frag.NotNull(field.BitDepth()) } // outOfRange for NEQ should return all not-null. if outOfRange && cond.Op == pql.NEQ { - return frag.FieldNotNull(field.BitDepth()) + return frag.NotNull(field.BitDepth()) } f.Stats.Count("range:field", 1, 1.0) - return frag.FieldRange(cond.Op, field.BitDepth(), baseValue) + return frag.RangeOp(cond.Op, field.BitDepth(), baseValue) } } diff --git a/fragment.go b/fragment.go index fe50a76f2..dd0f05ed2 100644 --- a/fragment.go +++ b/fragment.go @@ -486,8 +486,8 @@ func (f *Fragment) bit(rowID, columnID uint64) (bool, error) { return f.storage.Contains(pos), nil } -// FieldValue uses a column of bits to read a multi-bit value. -func (f *Fragment) FieldValue(columnID uint64, bitDepth uint) (value uint64, exists bool, err error) { +// Value uses a column of bits to read a multi-bit value. +func (f *Fragment) Value(columnID uint64, bitDepth uint) (value uint64, exists bool, err error) { f.mu.Lock() defer f.mu.Unlock() @@ -582,9 +582,9 @@ func (f *Fragment) importSetValue(columnID uint64, bitDepth uint, value uint64) return changed, nil } -// FieldSum returns the sum of a given field as well as the number of columns involved. +// Sum returns the sum of a given bsiGroup as well as the number of columns involved. // A bitmap can be passed in to optionally filter the computed columns. -func (f *Fragment) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err error) { +func (f *Fragment) Sum(filter *Row, bitDepth uint) (sum, count uint64, err error) { // Compute count based on the existence row. row := f.Row(uint64(bitDepth)) if filter != nil { @@ -614,9 +614,9 @@ func (f *Fragment) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err return sum, count, nil } -// FieldMin returns the min of a given field as well as the number of columns involved. +// Min returns the min of a given bsiGroup as well as the number of columns involved. // A bitmap can be passed in to optionally filter the computed columns. -func (f *Fragment) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err error) { +func (f *Fragment) Min(filter *Row, bitDepth uint) (min, count uint64, err error) { consider := f.Row(uint64(bitDepth)) if filter != nil { @@ -647,9 +647,9 @@ func (f *Fragment) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err return min, count, nil } -// FieldMax returns the max of a given field as well as the number of columns involved. +// Max returns the max of a given bsiGroup as well as the number of columns involved. // A bitmap can be passed in to optionally filter the computed columns. -func (f *Fragment) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err error) { +func (f *Fragment) Max(filter *Row, bitDepth uint) (max, count uint64, err error) { consider := f.Row(uint64(bitDepth)) if filter != nil { @@ -678,23 +678,23 @@ func (f *Fragment) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err return max, count, nil } -// FieldRange returns bitmaps with a field value encoding matching the predicate. -func (f *Fragment) FieldRange(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) { +// RangeOp returns bitmaps with a bsiGroup value encoding matching the predicate. +func (f *Fragment) RangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) { switch op { case pql.EQ: - return f.fieldRangeEQ(bitDepth, predicate) + return f.rangeEQ(bitDepth, predicate) case pql.NEQ: - return f.fieldRangeNEQ(bitDepth, predicate) + return f.rangeNEQ(bitDepth, predicate) case pql.LT, pql.LTE: - return f.fieldRangeLT(bitDepth, predicate, op == pql.LTE) + return f.rangeLT(bitDepth, predicate, op == pql.LTE) case pql.GT, pql.GTE: - return f.fieldRangeGT(bitDepth, predicate, op == pql.GTE) + return f.rangeGT(bitDepth, predicate, op == pql.GTE) default: return nil, ErrInvalidRangeOperation } } -func (f *Fragment) fieldRangeEQ(bitDepth uint, predicate uint64) (*Row, error) { +func (f *Fragment) rangeEQ(bitDepth uint, predicate uint64) (*Row, error) { // Start with set of columns with values set. b := f.Row(uint64(bitDepth)) @@ -713,12 +713,12 @@ func (f *Fragment) fieldRangeEQ(bitDepth uint, predicate uint64) (*Row, error) { return b, nil } -func (f *Fragment) fieldRangeNEQ(bitDepth uint, predicate uint64) (*Row, error) { +func (f *Fragment) rangeNEQ(bitDepth uint, predicate uint64) (*Row, error) { // Start with set of columns with values set. b := f.Row(uint64(bitDepth)) // Get the equal bitmap. - eq, err := f.fieldRangeEQ(bitDepth, predicate) + eq, err := f.rangeEQ(bitDepth, predicate) if err != nil { return nil, err } @@ -729,7 +729,7 @@ func (f *Fragment) fieldRangeNEQ(bitDepth uint, predicate uint64) (*Row, error) return b, nil } -func (f *Fragment) fieldRangeLT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) { +func (f *Fragment) rangeLT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) { keep := NewRow() // Start with set of columns with values set. @@ -777,7 +777,7 @@ func (f *Fragment) fieldRangeLT(bitDepth uint, predicate uint64, allowEquality b return b, nil } -func (f *Fragment) fieldRangeGT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) { +func (f *Fragment) rangeGT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) { b := f.Row(uint64(bitDepth)) keep := NewRow() @@ -812,13 +812,13 @@ func (f *Fragment) fieldRangeGT(bitDepth uint, predicate uint64, allowEquality b return b, nil } -// FieldNotNull returns the not-null row (stored at bitDepth). -func (f *Fragment) FieldNotNull(bitDepth uint) (*Row, error) { +// NotNull returns the not-null row (stored at bitDepth). +func (f *Fragment) NotNull(bitDepth uint) (*Row, error) { return f.Row(uint64(bitDepth)), nil } -// FieldRangeBetween returns bitmaps with a field value encoding matching any value between predicateMin and predicateMax. -func (f *Fragment) FieldRangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) { +// RangeBetween returns bitmaps with a bsiGroup value encoding matching any value between predicateMin and predicateMax. +func (f *Fragment) RangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) { b := f.Row(uint64(bitDepth)) keep1 := NewRow() // GTE keep2 := NewRow() // LTE diff --git a/fragment_test.go b/fragment_test.go index 6655f62b9..e1c9b7fd4 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -110,7 +110,7 @@ func TestFragment_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.FieldValue(100, 16); err != nil { + if value, exists, err := f.Value(100, 16); err != nil { t.Fatal(err) } else if value != 3829 { t.Fatalf("unexpected value: %d", value) @@ -145,7 +145,7 @@ func TestFragment_SetValue(t *testing.T) { } // Read value. - if value, exists, err := f.FieldValue(100, 16); err != nil { + if value, exists, err := f.Value(100, 16); err != nil { t.Fatal(err) } else if value != 2028 { t.Fatalf("unexpected value: %d", value) @@ -166,7 +166,7 @@ func TestFragment_SetValue(t *testing.T) { } // Non-existent value. - if value, exists, err := f.FieldValue(100, 11); err != nil { + if value, exists, err := f.Value(100, 11); err != nil { t.Fatal(err) } else if value != 0 { t.Fatalf("unexpected value: %d", value) @@ -202,7 +202,7 @@ func TestFragment_SetValue(t *testing.T) { // Ensure values are set. for columnID, value := range m { - v, exists, err := f.FieldValue(columnID, bitDepth) + v, exists, err := f.Value(columnID, bitDepth) if err != nil { t.Fatal(err) } else if value != int64(v) { @@ -238,7 +238,7 @@ func TestFragment_FieldSum(t *testing.T) { } t.Run("NoFilter", func(t *testing.T) { - if sum, n, err := f.FieldSum(nil, bitDepth); err != nil { + if sum, n, err := f.Sum(nil, bitDepth); err != nil { t.Fatal(err) } else if n != 4 { t.Fatalf("unexpected count: %d", n) @@ -248,7 +248,7 @@ func TestFragment_FieldSum(t *testing.T) { }) t.Run("WithFilter", func(t *testing.T) { - if sum, n, err := f.FieldSum(pilosa.NewRow(2000, 4000, 5000), bitDepth); err != nil { + if sum, n, err := f.Sum(pilosa.NewRow(2000, 4000, 5000), bitDepth); err != nil { t.Fatal(err) } else if n != 2 { t.Fatalf("unexpected count: %d", n) @@ -296,7 +296,7 @@ func TestFragment_FieldMinMax(t *testing.T) { {filter: pilosa.NewRow(7000), exp: 0, cnt: 1}, } for i, test := range tests { - if min, cnt, err := f.FieldMin(test.filter, bitDepth); err != nil { + if min, cnt, err := f.Min(test.filter, bitDepth); err != nil { t.Fatal(err) } else if min != test.exp { t.Errorf("test %d expected min: %v, but got: %v", i, test.exp, min) @@ -320,7 +320,7 @@ func TestFragment_FieldMinMax(t *testing.T) { {filter: pilosa.NewRow(7000), exp: 0, cnt: 1}, } for i, test := range tests { - if max, cnt, err := f.FieldMax(test.filter, bitDepth); err != nil { + if max, cnt, err := f.Max(test.filter, bitDepth); err != nil { t.Fatal(err) } else if max != test.exp { t.Errorf("test %d expected max: %v, but got: %v", i, test.exp, max) @@ -351,7 +351,7 @@ func TestFragment_FieldRange(t *testing.T) { } // Query for equality. - if b, err := f.FieldRange(pql.EQ, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.EQ, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) @@ -374,7 +374,7 @@ func TestFragment_FieldRange(t *testing.T) { } // Query for inequality. - if b, err := f.FieldRange(pql.NEQ, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.NEQ, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) @@ -401,28 +401,28 @@ func TestFragment_FieldRange(t *testing.T) { } // Query for fields less than (ending with set column). - if b, err := f.FieldRange(pql.LT, bitDepth, 301); err != nil { + if b, err := f.RangeOp(pql.LT, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields less than (ending with unset column). - if b, err := f.FieldRange(pql.LT, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.LT, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields less than or equal to (ending with set column). - if b, err := f.FieldRange(pql.LTE, bitDepth, 301); err != nil { + if b, err := f.RangeOp(pql.LTE, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000, 5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields less than or equal to (ending with unset column). - if b, err := f.FieldRange(pql.LTE, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.LTE, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) @@ -449,28 +449,28 @@ func TestFragment_FieldRange(t *testing.T) { } // Query for fields greater than (ending with unset bit). - if b, err := f.FieldRange(pql.GT, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.GT, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than (ending with set bit). - if b, err := f.FieldRange(pql.GT, bitDepth, 301); err != nil { + if b, err := f.RangeOp(pql.GT, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than or equal to (ending with unset bit). - if b, err := f.FieldRange(pql.GTE, bitDepth, 300); err != nil { + if b, err := f.RangeOp(pql.GTE, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than or equal to (ending with set bit). - if b, err := f.FieldRange(pql.GTE, bitDepth, 301); err != nil { + if b, err := f.RangeOp(pql.GTE, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) @@ -497,28 +497,28 @@ func TestFragment_FieldRange(t *testing.T) { } // Query for fields greater than (ending with unset column). - if b, err := f.FieldRangeBetween(bitDepth, 300, 2817); err != nil { + if b, err := f.RangeBetween(bitDepth, 300, 2817); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than (ending with set column). - if b, err := f.FieldRangeBetween(bitDepth, 301, 2817); err != nil { + if b, err := f.RangeBetween(bitDepth, 301, 2817); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than or equal to (ending with unset column). - if b, err := f.FieldRangeBetween(bitDepth, 301, 2816); err != nil { + if b, err := f.RangeBetween(bitDepth, 301, 2816); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } // Query for fields greater than or equal to (ending with set column). - if b, err := f.FieldRangeBetween(bitDepth, 300, 2816); err != nil { + if b, err := f.RangeBetween(bitDepth, 300, 2816); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) diff --git a/view.go b/view.go index 31bf9a470..38c76a162 100644 --- a/view.go +++ b/view.go @@ -330,7 +330,7 @@ func (v *View) value(columnID uint64, bitDepth uint) (value uint64, exists bool, if err != nil { return value, exists, err } - return frag.FieldValue(columnID, bitDepth) + return frag.Value(columnID, bitDepth) } // setValue uses a column of bits to set a multi-bit value. @@ -346,7 +346,7 @@ func (v *View) setValue(columnID uint64, bitDepth uint, value uint64) (changed b // sum returns the sum & count of a field. func (v *View) sum(filter *Row, bitDepth uint) (sum, count uint64, err error) { for _, f := range v.Fragments() { - fsum, fcount, err := f.FieldSum(filter, bitDepth) + fsum, fcount, err := f.Sum(filter, bitDepth) if err != nil { return sum, count, err } @@ -360,7 +360,7 @@ func (v *View) sum(filter *Row, bitDepth uint) (sum, count uint64, err error) { func (v *View) min(filter *Row, bitDepth uint) (min, count uint64, err error) { var minHasValue bool for _, f := range v.Fragments() { - fmin, fcount, err := f.FieldMin(filter, bitDepth) + fmin, fcount, err := f.Min(filter, bitDepth) if err != nil { return min, count, err } @@ -387,7 +387,7 @@ func (v *View) min(filter *Row, bitDepth uint) (min, count uint64, err error) { // max returns the max and count of a field. func (v *View) max(filter *Row, bitDepth uint) (max, count uint64, err error) { for _, f := range v.Fragments() { - fmax, fcount, err := f.FieldMax(filter, bitDepth) + fmax, fcount, err := f.Max(filter, bitDepth) if err != nil { return max, count, err } @@ -403,7 +403,7 @@ func (v *View) max(filter *Row, bitDepth uint) (max, count uint64, err error) { func (v *View) rangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) { r := NewRow() for _, frag := range v.Fragments() { - other, err := frag.FieldRange(op, bitDepth, predicate) + other, err := frag.RangeOp(op, bitDepth, predicate) if err != nil { return nil, err } @@ -417,7 +417,7 @@ func (v *View) rangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, err func (v *View) rangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) { r := NewRow() for _, frag := range v.Fragments() { - other, err := frag.FieldRangeBetween(bitDepth, predicateMin, predicateMax) + other, err := frag.RangeBetween(bitDepth, predicateMin, predicateMax) if err != nil { return nil, err } From 81a994987f12eb0ea5f13789babbb1ecf198c229 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 13:02:26 -0500 Subject: [PATCH 28/52] fixing some comments --- executor.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/executor.go b/executor.go index 98982606d..87e07c63e 100644 --- a/executor.go +++ b/executor.go @@ -790,12 +790,12 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, fieldName, cond = k, vv } - // EQ null (not implemented: flip frag.FieldNotNull with max ColumnID) - // NEQ null frag.FieldNotNull() - // BETWEEN a,b(in) BETWEEN/frag.FieldRangeBetween() - // BETWEEN a,b(out) BETWEEN/frag.FieldNotNull() - // EQ frag.FieldRange - // NEQ frag.FieldRange + // EQ null (not implemented: flip frag.NotNull with max ColumnID) + // NEQ null frag.NotNull() + // BETWEEN a,b(in) BETWEEN/frag.RangeBetween() + // BETWEEN a,b(out) BETWEEN/frag.NotNull() + // EQ frag.RangeOp + // NEQ frag.RangeOp // Handle `!= null`. if cond.Op == pql.NEQ && cond.Value == nil { @@ -826,7 +826,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // The reason we don't just call: - // return f.FieldRangeBetween(fieldName, predicates[0], predicates[1]) + // return f.RangeBetween(fieldName, predicates[0], predicates[1]) // here is because we need the call to be slice-specific. // Find field. From 50f8ea39213d1951cc7a798a1e0d6a3b4263e38f Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 13:58:28 -0500 Subject: [PATCH 29/52] remove CreateField and DeleteField from API --- api.go | 65 ---- apimethod_string.go | 4 +- broadcast.go | 10 - internal/private.pb.go | 682 +++++++---------------------------------- internal/private.proto | 12 - server.go | 11 - 6 files changed, 113 insertions(+), 671 deletions(-) diff --git a/api.go b/api.go index 6f6123f9b..e528a4b21 100644 --- a/api.go +++ b/api.go @@ -488,67 +488,6 @@ func (api *API) Schema(ctx context.Context) []*IndexInfo { return api.Holder.Schema() } -// CreateField creates a new BSI field in the given index and frame. -func (api *API) CreateField(ctx context.Context, indexName string, frameName string, bsig *bsiGroup) error { - if err := api.validate(apiCreateField); err != nil { - return errors.Wrap(err, "validating api method") - } - - // Retrieve frame by name. - f := api.Holder.Frame(indexName, frameName) - if f == nil { - return ErrFrameNotFound - } - - // Create new bsiGroup. - if err := f.createBSIGroup(bsig); err != nil { - return errors.Wrap(err, "creating bsigroup") - } - - // Send the create bsigroup message to all nodes. - err := api.Broadcaster.SendSync( - &internal.CreateBSIGroupMessage{ - Index: indexName, - Frame: frameName, - BSIGroup: encodeBSIGroup(bsig), - }) - if err != nil { - api.Logger.Printf("problem sending CreateField message: %s", err) - } - return errors.Wrap(err, "sending CreateField message") -} - -// TODO: remove this from the API -// DeleteField deletes the given field. -func (api *API) DeleteField(ctx context.Context, indexName string, frameName string, fieldName string) error { - if err := api.validate(apiDeleteField); err != nil { - return errors.Wrap(err, "validating api method") - } - - // Retrieve frame by name. - f := api.Holder.Frame(indexName, frameName) - if f == nil { - return ErrFrameNotFound - } - - // Delete field. - if err := f.deleteBSIGroupAndView(fieldName); err != nil { - return errors.Wrap(err, "deleting field") - } - - // Send the delete field message to all nodes. - err := api.Broadcaster.SendSync( - &internal.DeleteBSIGroupMessage{ - Index: indexName, - Frame: frameName, - BSIGroup: fieldName, - }) - if err != nil { - api.Logger.Printf("problem sending DeleteField message: %s", err) - } - return errors.Wrap(err, "sending DeleteField message") -} - // Views returns the views in the given frame. func (api *API) Views(ctx context.Context, indexName string, frameName string) ([]*View, error) { if err := api.validate(apiViews); err != nil { @@ -851,10 +790,8 @@ type apiMethod int // API validation constants. const ( apiClusterMessage apiMethod = iota - apiCreateField apiCreateFrame apiCreateIndex - apiDeleteField apiDeleteFrame apiDeleteIndex apiDeleteView @@ -896,10 +833,8 @@ var methodsResizing = map[apiMethod]struct{}{ } var methodsNormal = map[apiMethod]struct{}{ - apiCreateField: struct{}{}, apiCreateFrame: struct{}{}, apiCreateIndex: struct{}{}, - apiDeleteField: struct{}{}, apiDeleteFrame: struct{}{}, apiDeleteIndex: struct{}{}, apiDeleteView: struct{}{}, diff --git a/apimethod_string.go b/apimethod_string.go index 0fc3822d5..ce119196f 100644 --- a/apimethod_string.go +++ b/apimethod_string.go @@ -4,9 +4,9 @@ package pilosa import "fmt" -const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateFrameapiCreateIndexapiDeleteFieldapiDeleteFrameapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFrameAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" +const _apiMethod_name = "apiClusterMessageapiCreateFrameapiCreateIndexapiDeleteFrameapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFrameAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" -var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 87, 101, 114, 126, 146, 163, 179, 188, 202, 210, 226, 244, 252, 272, 285, 299, 316, 329, 349, 357} +var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 86, 98, 118, 135, 151, 160, 174, 182, 198, 216, 224, 244, 257, 271, 288, 301, 321, 329} func (i apiMethod) String() string { if i < 0 || i >= apiMethod(len(_apiMethod_index)-1) { diff --git a/broadcast.go b/broadcast.go index 0840e8c92..933ca05a5 100644 --- a/broadcast.go +++ b/broadcast.go @@ -127,8 +127,6 @@ const ( MessageTypeDeleteFrame MessageTypeCreateView MessageTypeDeleteView - MessageTypeCreateBSIGroup - MessageTypeDeleteBSIGroup MessageTypeClusterStatus MessageTypeResizeInstruction MessageTypeResizeInstructionComplete @@ -157,10 +155,6 @@ func MarshalMessage(m proto.Message) ([]byte, error) { typ = MessageTypeCreateView case *internal.DeleteViewMessage: typ = MessageTypeDeleteView - case *internal.CreateBSIGroupMessage: - typ = MessageTypeCreateBSIGroup - case *internal.DeleteBSIGroupMessage: - typ = MessageTypeDeleteBSIGroup case *internal.ClusterStatus: typ = MessageTypeClusterStatus case *internal.ResizeInstruction: @@ -207,10 +201,6 @@ func UnmarshalMessage(buf []byte) (proto.Message, error) { m = &internal.CreateViewMessage{} case MessageTypeDeleteView: m = &internal.DeleteViewMessage{} - case MessageTypeCreateBSIGroup: - m = &internal.CreateBSIGroupMessage{} - case MessageTypeDeleteBSIGroup: - m = &internal.DeleteBSIGroupMessage{} case MessageTypeClusterStatus: m = &internal.ClusterStatus{} case MessageTypeResizeInstruction: diff --git a/internal/private.pb.go b/internal/private.pb.go index 4e1aa8589..a4f9e0431 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -21,8 +21,6 @@ CreateIndexMessage CreateFrameMessage DeleteFrameMessage - CreateBSIGroupMessage - DeleteBSIGroupMessage Frame Schema Index @@ -366,70 +364,6 @@ func (m *DeleteFrameMessage) GetFrame() string { return "" } -type CreateBSIGroupMessage 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"` - BSIGroup *BSIGroup `protobuf:"bytes,3,opt,name=BSIGroup" json:"BSIGroup,omitempty"` -} - -func (m *CreateBSIGroupMessage) Reset() { *m = CreateBSIGroupMessage{} } -func (m *CreateBSIGroupMessage) String() string { return proto.CompactTextString(m) } -func (*CreateBSIGroupMessage) ProtoMessage() {} -func (*CreateBSIGroupMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } - -func (m *CreateBSIGroupMessage) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *CreateBSIGroupMessage) GetFrame() string { - if m != nil { - return m.Frame - } - return "" -} - -func (m *CreateBSIGroupMessage) GetBSIGroup() *BSIGroup { - if m != nil { - return m.BSIGroup - } - return nil -} - -type DeleteBSIGroupMessage 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"` - BSIGroup string `protobuf:"bytes,3,opt,name=BSIGroup,proto3" json:"BSIGroup,omitempty"` -} - -func (m *DeleteBSIGroupMessage) Reset() { *m = DeleteBSIGroupMessage{} } -func (m *DeleteBSIGroupMessage) String() string { return proto.CompactTextString(m) } -func (*DeleteBSIGroupMessage) ProtoMessage() {} -func (*DeleteBSIGroupMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{13} } - -func (m *DeleteBSIGroupMessage) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *DeleteBSIGroupMessage) GetFrame() string { - if m != nil { - return m.Frame - } - return "" -} - -func (m *DeleteBSIGroupMessage) GetBSIGroup() string { - if m != nil { - return m.BSIGroup - } - return "" -} - type Frame struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Meta *FrameMeta `protobuf:"bytes,2,opt,name=Meta" json:"Meta,omitempty"` @@ -439,7 +373,7 @@ type Frame struct { func (m *Frame) Reset() { *m = Frame{} } func (m *Frame) String() string { return proto.CompactTextString(m) } func (*Frame) ProtoMessage() {} -func (*Frame) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{14} } +func (*Frame) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } func (m *Frame) GetName() string { if m != nil { @@ -469,7 +403,7 @@ type Schema struct { func (m *Schema) Reset() { *m = Schema{} } func (m *Schema) String() string { return proto.CompactTextString(m) } func (*Schema) ProtoMessage() {} -func (*Schema) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{15} } +func (*Schema) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{13} } func (m *Schema) GetIndexes() []*Index { if m != nil { @@ -486,7 +420,7 @@ type Index struct { func (m *Index) Reset() { *m = Index{} } func (m *Index) String() string { return proto.CompactTextString(m) } func (*Index) ProtoMessage() {} -func (*Index) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{16} } +func (*Index) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{14} } func (m *Index) GetName() string { if m != nil { @@ -511,7 +445,7 @@ type URI struct { func (m *URI) Reset() { *m = URI{} } func (m *URI) String() string { return proto.CompactTextString(m) } func (*URI) ProtoMessage() {} -func (*URI) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{17} } +func (*URI) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{15} } func (m *URI) GetScheme() string { if m != nil { @@ -543,7 +477,7 @@ type Node struct { func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} -func (*Node) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{18} } +func (*Node) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{16} } func (m *Node) GetID() string { if m != nil { @@ -574,7 +508,7 @@ type NodeStateMessage struct { func (m *NodeStateMessage) Reset() { *m = NodeStateMessage{} } func (m *NodeStateMessage) String() string { return proto.CompactTextString(m) } func (*NodeStateMessage) ProtoMessage() {} -func (*NodeStateMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{19} } +func (*NodeStateMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{17} } func (m *NodeStateMessage) GetNodeID() string { if m != nil { @@ -598,7 +532,7 @@ type NodeEventMessage struct { func (m *NodeEventMessage) Reset() { *m = NodeEventMessage{} } func (m *NodeEventMessage) String() string { return proto.CompactTextString(m) } func (*NodeEventMessage) ProtoMessage() {} -func (*NodeEventMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{20} } +func (*NodeEventMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{18} } func (m *NodeEventMessage) GetEvent() uint32 { if m != nil { @@ -623,7 +557,7 @@ type NodeStatus struct { func (m *NodeStatus) Reset() { *m = NodeStatus{} } func (m *NodeStatus) String() string { return proto.CompactTextString(m) } func (*NodeStatus) ProtoMessage() {} -func (*NodeStatus) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{21} } +func (*NodeStatus) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{19} } func (m *NodeStatus) GetNode() *Node { if m != nil { @@ -655,7 +589,7 @@ type ClusterStatus struct { func (m *ClusterStatus) Reset() { *m = ClusterStatus{} } func (m *ClusterStatus) String() string { return proto.CompactTextString(m) } func (*ClusterStatus) ProtoMessage() {} -func (*ClusterStatus) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{22} } +func (*ClusterStatus) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{20} } func (m *ClusterStatus) GetClusterID() string { if m != nil { @@ -688,7 +622,7 @@ type BSIGroup struct { func (m *BSIGroup) Reset() { *m = BSIGroup{} } func (m *BSIGroup) String() string { return proto.CompactTextString(m) } func (*BSIGroup) ProtoMessage() {} -func (*BSIGroup) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{23} } +func (*BSIGroup) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{21} } func (m *BSIGroup) GetName() string { if m != nil { @@ -727,7 +661,7 @@ type CreateViewMessage struct { func (m *CreateViewMessage) Reset() { *m = CreateViewMessage{} } func (m *CreateViewMessage) String() string { return proto.CompactTextString(m) } func (*CreateViewMessage) ProtoMessage() {} -func (*CreateViewMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{24} } +func (*CreateViewMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{22} } func (m *CreateViewMessage) GetIndex() string { if m != nil { @@ -759,7 +693,7 @@ type DeleteViewMessage struct { func (m *DeleteViewMessage) Reset() { *m = DeleteViewMessage{} } func (m *DeleteViewMessage) String() string { return proto.CompactTextString(m) } func (*DeleteViewMessage) ProtoMessage() {} -func (*DeleteViewMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{25} } +func (*DeleteViewMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{23} } func (m *DeleteViewMessage) GetIndex() string { if m != nil { @@ -794,7 +728,7 @@ type ResizeInstruction struct { func (m *ResizeInstruction) Reset() { *m = ResizeInstruction{} } func (m *ResizeInstruction) String() string { return proto.CompactTextString(m) } func (*ResizeInstruction) ProtoMessage() {} -func (*ResizeInstruction) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{26} } +func (*ResizeInstruction) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{24} } func (m *ResizeInstruction) GetJobID() int64 { if m != nil { @@ -849,7 +783,7 @@ type ResizeSource struct { func (m *ResizeSource) Reset() { *m = ResizeSource{} } func (m *ResizeSource) String() string { return proto.CompactTextString(m) } func (*ResizeSource) ProtoMessage() {} -func (*ResizeSource) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{27} } +func (*ResizeSource) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{25} } func (m *ResizeSource) GetNode() *Node { if m != nil { @@ -896,7 +830,7 @@ func (m *ResizeInstructionComplete) Reset() { *m = ResizeInstructionComp func (m *ResizeInstructionComplete) String() string { return proto.CompactTextString(m) } func (*ResizeInstructionComplete) ProtoMessage() {} func (*ResizeInstructionComplete) Descriptor() ([]byte, []int) { - return fileDescriptorPrivate, []int{28} + return fileDescriptorPrivate, []int{26} } func (m *ResizeInstructionComplete) GetJobID() int64 { @@ -927,7 +861,7 @@ type SetCoordinatorMessage struct { func (m *SetCoordinatorMessage) Reset() { *m = SetCoordinatorMessage{} } func (m *SetCoordinatorMessage) String() string { return proto.CompactTextString(m) } func (*SetCoordinatorMessage) ProtoMessage() {} -func (*SetCoordinatorMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{29} } +func (*SetCoordinatorMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{27} } func (m *SetCoordinatorMessage) GetNew() *Node { if m != nil { @@ -943,7 +877,7 @@ type UpdateCoordinatorMessage struct { func (m *UpdateCoordinatorMessage) Reset() { *m = UpdateCoordinatorMessage{} } func (m *UpdateCoordinatorMessage) String() string { return proto.CompactTextString(m) } func (*UpdateCoordinatorMessage) ProtoMessage() {} -func (*UpdateCoordinatorMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{30} } +func (*UpdateCoordinatorMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{28} } func (m *UpdateCoordinatorMessage) GetNew() *Node { if m != nil { @@ -960,7 +894,7 @@ type Topology struct { func (m *Topology) Reset() { *m = Topology{} } func (m *Topology) String() string { return proto.CompactTextString(m) } func (*Topology) ProtoMessage() {} -func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{31} } +func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{29} } func (m *Topology) GetClusterID() string { if m != nil { @@ -982,7 +916,7 @@ type RecalculateCaches struct { func (m *RecalculateCaches) Reset() { *m = RecalculateCaches{} } func (m *RecalculateCaches) String() string { return proto.CompactTextString(m) } func (*RecalculateCaches) ProtoMessage() {} -func (*RecalculateCaches) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{32} } +func (*RecalculateCaches) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{30} } func init() { proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta") @@ -997,8 +931,6 @@ func init() { proto.RegisterType((*CreateIndexMessage)(nil), "internal.CreateIndexMessage") proto.RegisterType((*CreateFrameMessage)(nil), "internal.CreateFrameMessage") proto.RegisterType((*DeleteFrameMessage)(nil), "internal.DeleteFrameMessage") - proto.RegisterType((*CreateBSIGroupMessage)(nil), "internal.CreateBSIGroupMessage") - proto.RegisterType((*DeleteBSIGroupMessage)(nil), "internal.DeleteBSIGroupMessage") proto.RegisterType((*Frame)(nil), "internal.Frame") proto.RegisterType((*Schema)(nil), "internal.Schema") proto.RegisterType((*Index)(nil), "internal.Index") @@ -1436,82 +1368,6 @@ func (m *DeleteFrameMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CreateBSIGroupMessage) 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 *CreateBSIGroupMessage) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Index) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) - i += copy(dAtA[i:], m.Index) - } - if len(m.Frame) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) - } - if m.BSIGroup != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintPrivate(dAtA, i, uint64(m.BSIGroup.Size())) - n9, err := m.BSIGroup.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n9 - } - return i, nil -} - -func (m *DeleteBSIGroupMessage) 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 *DeleteBSIGroupMessage) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Index) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) - i += copy(dAtA[i:], m.Index) - } - if len(m.Frame) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) - } - if len(m.BSIGroup) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.BSIGroup))) - i += copy(dAtA[i:], m.BSIGroup) - } - return i, nil -} - func (m *Frame) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1537,11 +1393,11 @@ func (m *Frame) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Meta.Size())) - n10, err := m.Meta.MarshalTo(dAtA[i:]) + n9, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n9 } if len(m.Views) > 0 { for _, s := range m.Views { @@ -1687,11 +1543,11 @@ func (m *Node) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.URI.Size())) - n11, err := m.URI.MarshalTo(dAtA[i:]) + n10, err := m.URI.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n10 } if m.IsCoordinator { dAtA[i] = 0x18 @@ -1760,11 +1616,11 @@ func (m *NodeEventMessage) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Node.Size())) - n12, err := m.Node.MarshalTo(dAtA[i:]) + n11, err := m.Node.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n11 } return i, nil } @@ -1788,31 +1644,31 @@ func (m *NodeStatus) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Node.Size())) - n13, err := m.Node.MarshalTo(dAtA[i:]) + n12, err := m.Node.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n12 } if m.MaxSlices != nil { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.MaxSlices.Size())) - n14, err := m.MaxSlices.MarshalTo(dAtA[i:]) + n13, err := m.MaxSlices.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n13 } if m.Schema != nil { dAtA[i] = 0x1a i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Schema.Size())) - n15, err := m.Schema.MarshalTo(dAtA[i:]) + n14, err := m.Schema.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n14 } return i, nil } @@ -1995,21 +1851,21 @@ func (m *ResizeInstruction) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Node.Size())) - n16, err := m.Node.MarshalTo(dAtA[i:]) + n15, err := m.Node.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n16 + i += n15 } if m.Coordinator != nil { dAtA[i] = 0x1a i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Coordinator.Size())) - n17, err := m.Coordinator.MarshalTo(dAtA[i:]) + n16, err := m.Coordinator.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n16 } if len(m.Sources) > 0 { for _, msg := range m.Sources { @@ -2027,21 +1883,21 @@ func (m *ResizeInstruction) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Schema.Size())) - n18, err := m.Schema.MarshalTo(dAtA[i:]) + n17, err := m.Schema.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n17 } if m.ClusterStatus != nil { dAtA[i] = 0x32 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.ClusterStatus.Size())) - n19, err := m.ClusterStatus.MarshalTo(dAtA[i:]) + n18, err := m.ClusterStatus.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n18 } return i, nil } @@ -2065,11 +1921,11 @@ func (m *ResizeSource) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Node.Size())) - n20, err := m.Node.MarshalTo(dAtA[i:]) + n19, err := m.Node.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n20 + i += n19 } if len(m.Index) > 0 { dAtA[i] = 0x12 @@ -2121,11 +1977,11 @@ func (m *ResizeInstructionComplete) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintPrivate(dAtA, i, uint64(m.Node.Size())) - n21, err := m.Node.MarshalTo(dAtA[i:]) + n20, err := m.Node.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n21 + i += n20 } if len(m.Error) > 0 { dAtA[i] = 0x1a @@ -2155,11 +2011,11 @@ func (m *SetCoordinatorMessage) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintPrivate(dAtA, i, uint64(m.New.Size())) - n22, err := m.New.MarshalTo(dAtA[i:]) + n21, err := m.New.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n22 + i += n21 } return i, nil } @@ -2183,11 +2039,11 @@ func (m *UpdateCoordinatorMessage) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintPrivate(dAtA, i, uint64(m.New.Size())) - n23, err := m.New.MarshalTo(dAtA[i:]) + n22, err := m.New.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n23 + i += n22 } return i, nil } @@ -2459,42 +2315,6 @@ func (m *DeleteFrameMessage) Size() (n int) { return n } -func (m *CreateBSIGroupMessage) Size() (n int) { - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovPrivate(uint64(l)) - } - l = len(m.Frame) - if l > 0 { - n += 1 + l + sovPrivate(uint64(l)) - } - if m.BSIGroup != nil { - l = m.BSIGroup.Size() - n += 1 + l + sovPrivate(uint64(l)) - } - return n -} - -func (m *DeleteBSIGroupMessage) Size() (n int) { - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovPrivate(uint64(l)) - } - l = len(m.Frame) - if l > 0 { - n += 1 + l + sovPrivate(uint64(l)) - } - l = len(m.BSIGroup) - if l > 0 { - n += 1 + l + sovPrivate(uint64(l)) - } - return n -} - func (m *Frame) Size() (n int) { var l int _ = l @@ -4304,284 +4124,6 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *CreateBSIGroupMessage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CreateBSIGroupMessage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CreateBSIGroupMessage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Frame = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BSIGroup", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BSIGroup == nil { - m.BSIGroup = &BSIGroup{} - } - if err := m.BSIGroup.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPrivate(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteBSIGroupMessage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeleteBSIGroupMessage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteBSIGroupMessage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Frame = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BSIGroup", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BSIGroup = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPrivate(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Frame) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -7075,70 +6617,68 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1038 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1b, 0xc5, - 0x1b, 0xff, 0xaf, 0x77, 0xed, 0xd8, 0x4f, 0xfe, 0x0e, 0xc9, 0x94, 0x84, 0x6d, 0x85, 0x82, 0x19, - 0x55, 0x22, 0x70, 0xb0, 0x4a, 0x7b, 0xe1, 0xad, 0x52, 0x14, 0x3b, 0xc0, 0x22, 0x12, 0xc1, 0x6c, - 0xd2, 0x03, 0x12, 0x42, 0x53, 0x7b, 0xd4, 0xae, 0xb2, 0xde, 0x31, 0xbb, 0xb3, 0x49, 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 0xac, 0x99, 0x2b, 0xd2, 0x7c, 0xe4, 0x3a, 0xac, 0x20, 0xe9, 0x1d, 0x0d, 0xe8, 0x11, 0x8f, - 0x47, 0x79, 0xac, 0xd3, 0xd0, 0x3f, 0xba, 0xec, 0x60, 0xf3, 0xcf, 0xab, 0x5d, 0xe7, 0xaf, 0xab, - 0x5d, 0xe7, 0xef, 0xab, 0x5d, 0xe7, 0xb7, 0x7f, 0x76, 0xff, 0xf7, 0xb4, 0x85, 0xdf, 0xf3, 0x47, - 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xc6, 0x83, 0xfe, 0xaf, 0x0b, 0x00, 0x00, + // 1002 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0x67, 0xbd, 0x6b, 0xc7, 0x7e, 0xc1, 0xc1, 0x99, 0x42, 0xd8, 0x22, 0x14, 0xcc, 0xa8, 0x12, + 0x86, 0x43, 0x54, 0xda, 0x0b, 0x5f, 0x95, 0xa2, 0xd8, 0x01, 0x16, 0x91, 0x08, 0x66, 0x93, 0x1e, + 0x90, 0x38, 0x4c, 0xed, 0x51, 0xbb, 0xca, 0x7a, 0xc7, 0xec, 0xce, 0x26, 0x71, 0x0f, 0x5c, 0xe1, + 0xc2, 0x1d, 0x71, 0xe3, 0xbf, 0xe1, 0xc8, 0x9f, 0x80, 0xc2, 0x3f, 0x82, 0xe6, 0xcd, 0xec, 0x47, + 0xfc, 0xd1, 0x54, 0xa1, 0xb7, 0x79, 0xbf, 0xf7, 0xfd, 0xde, 0x6f, 0x76, 0x16, 0xba, 0xb3, 0x34, + 0x3a, 0xe7, 0x4a, 0xec, 0xcd, 0x52, 0xa9, 0x24, 0x69, 0x47, 0x89, 0x12, 0x69, 0xc2, 0x63, 0xba, + 0x09, 0x9d, 0x20, 0x99, 0x88, 0xcb, 0x23, 0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35, 0xbb, + 0x6e, 0x4d, 0x7f, 0x75, 0xe0, 0xf5, 0x7a, 0x09, 0x2f, 0x75, 0x37, 0xca, 0x8d, 0x34, 0x56, 0x6e, + 0xc4, 0x5d, 0xb5, 0x11, 0xaf, 0xda, 0x48, 0xf5, 0xbe, 0x35, 0xeb, 0xef, 0xdb, 0x19, 0xdc, 0x5d, + 0x5a, 0xd3, 0x50, 0x4e, 0x67, 0x9a, 0x0f, 0xff, 0x63, 0x5d, 0xfa, 0xab, 0x91, 0xa6, 0x76, 0x51, + 0x1d, 0x66, 0x04, 0xfa, 0x29, 0xbc, 0x15, 0x0a, 0x55, 0x5b, 0x52, 0xc1, 0xb6, 0x3e, 0xb8, 0xc7, + 0xe2, 0x62, 0x4d, 0xfb, 0x5a, 0x45, 0xbf, 0x00, 0xff, 0x74, 0x36, 0xe1, 0x4a, 0xdc, 0xca, 0xfb, + 0x00, 0xda, 0x27, 0x72, 0x26, 0x63, 0xf9, 0x74, 0x7e, 0xc3, 0xad, 0xf7, 0x61, 0xc3, 0x7c, 0x22, + 0xcd, 0x2f, 0x4f, 0x87, 0x15, 0x22, 0xbd, 0xa3, 0x09, 0x3d, 0xe6, 0xf1, 0x38, 0x8f, 0x75, 0x19, + 0xfa, 0xdf, 0x27, 0x3b, 0xe8, 0xfd, 0x75, 0xb5, 0xeb, 0xfc, 0x7d, 0xb5, 0xeb, 0xfc, 0x73, 0xb5, + 0xeb, 0xfc, 0xfe, 0xef, 0xee, 0x6b, 0x4f, 0x5a, 0xf8, 0x23, 0xfb, 0xf0, 0xbf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x93, 0x15, 0x15, 0x14, 0xd9, 0x0a, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index df004456f..d150b7802 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -64,18 +64,6 @@ message DeleteFrameMessage { string Frame = 2; } -message CreateBSIGroupMessage { - string Index = 1; - string Frame = 2; - BSIGroup BSIGroup = 3; -} - -message DeleteBSIGroupMessage { - string Index = 1; - string Frame = 2; - string BSIGroup = 3; -} - message Frame { string Name = 1; FrameMeta Meta = 2; diff --git a/server.go b/server.go index 1e4f5a421..02e56e9b0 100644 --- a/server.go +++ b/server.go @@ -470,17 +470,6 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if err := idx.DeleteFrame(obj.Frame); err != nil { return err } - case *internal.CreateBSIGroupMessage: - f := s.Holder.Frame(obj.Index, obj.Frame) - field := decodeBSIGroup(obj.BSIGroup) - if err := f.createBSIGroup(field); err != nil { - return err - } - case *internal.DeleteBSIGroupMessage: - f := s.Holder.Frame(obj.Index, obj.Frame) - if err := f.deleteBSIGroupAndView(obj.BSIGroup); err != nil { - return err - } case *internal.CreateViewMessage: f := s.Holder.Frame(obj.Index, obj.Frame) if f == nil { From 386545c67cb57aacdc4160aa9e0f543b4642cc50 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 14:33:26 -0500 Subject: [PATCH 30/52] rename TopN field/filters to attrName/attrValues --- executor.go | 8 ++++---- executor_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/executor.go b/executor.go index 87e07c63e..413be36b4 100644 --- a/executor.go +++ b/executor.go @@ -552,7 +552,7 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) } - field, _ := c.Args["field"].(string) // TODO: rename this to something other than field + attrName, _ := c.Args["attrName"].(string) rowIDs, _, err := c.UintSliceArg("ids") if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) @@ -561,7 +561,7 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) } - filters, _ := c.Args["filters"].([]interface{}) + attrValues, _ := c.Args["attrValues"].([]interface{}) tanimotoThreshold, _, err := c.UintArg("tanimotoThreshold") if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) @@ -600,8 +600,8 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca N: int(n), Src: src, RowIDs: rowIDs, - FilterName: field, - FilterValues: filters, + FilterName: attrName, + FilterValues: attrValues, MinThreshold: minThreshold, TanimotoThreshold: tanimotoThreshold, }) diff --git a/executor_test.go b/executor_test.go index 606646a92..d06a5027c 100644 --- a/executor_test.go +++ b/executor_test.go @@ -529,7 +529,7 @@ func TestExecutor_Execute_TopN_Attr(t *testing.T) { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame="f", n=1, field="category", filters=[123])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 10, Count: 1}, @@ -552,7 +552,7 @@ func TestExecutor_Execute_TopN_Attr_Src(t *testing.T) { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=10,frame=f),frame="f", n=1, field="category", filters=[123])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=10,frame=f),frame="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 10, Count: 1}, From 2802f6f469e52e6fcaf558d23a2275ededba7867 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 15:09:41 -0500 Subject: [PATCH 31/52] remove frame argument from Range() queries --- executor.go | 136 ++++++++++++++++++++--------------------------- executor_test.go | 36 ++++++------- 2 files changed, 74 insertions(+), 98 deletions(-) diff --git a/executor.go b/executor.go index 413be36b4..eee4fa0ee 100644 --- a/executor.go +++ b/executor.go @@ -176,8 +176,6 @@ func (e *Executor) validateCallArgs(c *pql.Call) error { func (e *Executor) executeSum(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { if frame := c.Args["frame"]; frame == "" { return ValCount{}, errors.New("Sum(): frame required") - } else if field := c.Args["field"]; field == "" { - return ValCount{}, errors.New("Sum(): field required") } if len(c.Children) > 1 { @@ -211,8 +209,6 @@ func (e *Executor) executeSum(ctx context.Context, index string, c *pql.Call, sl func (e *Executor) executeMin(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { if frame := c.Args["frame"]; frame == "" { return ValCount{}, errors.New("Min(): frame required") - } else if field := c.Args["field"]; field == "" { - return ValCount{}, errors.New("Min(): field required") } if len(c.Children) > 1 { @@ -246,8 +242,6 @@ func (e *Executor) executeMin(ctx context.Context, index string, c *pql.Call, sl func (e *Executor) executeMax(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { if frame := c.Args["frame"]; frame == "" { return ValCount{}, errors.New("Max(): frame required") - } else if field := c.Args["field"]; field == "" { - return ValCount{}, errors.New("Max(): field required") } if len(c.Children) > 1 { @@ -362,7 +356,7 @@ func (e *Executor) executeBitmapCallSlice(ctx context.Context, index string, c * } } -// executeSumCountSlice calculates the sum and count for fields on a slice. +// executeSumCountSlice calculates the sum and count for bsiGroups on a slice. func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { var filter *Row if len(c.Children) == 1 { @@ -374,34 +368,33 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq } frameName, _ := c.Args["frame"].(string) - fieldName, _ := c.Args["field"].(string) frame := e.Holder.Frame(index, frameName) if frame == nil { return ValCount{}, nil } - field := frame.bsiGroup(fieldName) - if field == nil { + bsig := frame.bsiGroup(frameName) + if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if fragment == nil { return ValCount{}, nil } - vsum, vcount, err := fragment.Sum(filter, field.BitDepth()) + vsum, vcount, err := fragment.Sum(filter, bsig.BitDepth()) if err != nil { return ValCount{}, errors.Wrap(err, "computing sum") } return ValCount{ - Val: int64(vsum) + (int64(vcount) * field.Min), + Val: int64(vsum) + (int64(vcount) * bsig.Min), Count: int64(vcount), }, nil } -// executeMinSlice calculates the min for fields on a slice. +// executeMinSlice calculates the min for bsiGroups on a slice. func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { var filter *Row if len(c.Children) == 1 { @@ -413,34 +406,33 @@ func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Cal } frameName, _ := c.Args["frame"].(string) - fieldName, _ := c.Args["field"].(string) frame := e.Holder.Frame(index, frameName) if frame == nil { return ValCount{}, nil } - field := frame.bsiGroup(fieldName) - if field == nil { + bsig := frame.bsiGroup(frameName) + if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if fragment == nil { return ValCount{}, nil } - fmin, fcount, err := fragment.Min(filter, field.BitDepth()) + fmin, fcount, err := fragment.Min(filter, bsig.BitDepth()) if err != nil { return ValCount{}, err } return ValCount{ - Val: int64(fmin) + field.Min, + Val: int64(fmin) + bsig.Min, Count: int64(fcount), }, nil } -// executeMaxSlice calculates the max for fields on a slice. +// executeMaxSlice calculates the max for bsiGroups on a slice. func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (ValCount, error) { var filter *Row if len(c.Children) == 1 { @@ -452,29 +444,28 @@ func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Cal } frameName, _ := c.Args["frame"].(string) - fieldName, _ := c.Args["field"].(string) frame := e.Holder.Frame(index, frameName) if frame == nil { return ValCount{}, nil } - field := frame.bsiGroup(fieldName) - if field == nil { + bsig := frame.bsiGroup(frameName) + if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+fieldName, slice) + fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if fragment == nil { return ValCount{}, nil } - fmax, fcount, err := fragment.Max(filter, field.BitDepth()) + fmax, fcount, err := fragment.Max(filter, bsig.BitDepth()) if err != nil { return ValCount{}, err } return ValCount{ - Val: int64(fmax) + field.Min, + Val: int64(fmax) + bsig.Min, Count: int64(fcount), }, nil } @@ -685,7 +676,7 @@ func (e *Executor) executeIntersectSlice(ctx context.Context, index string, c *p // executeRangeSlice executes a range() call for a local slice. func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) { - // Handle field ranges differently. + // Handle bsiGroup ranges differently. if c.HasConditionArg() { return e.executeBSIGroupRangeSlice(ctx, index, c, slice) } @@ -756,38 +747,29 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C return row, nil } -// executeBSIGroupRangeSlice executes a range(field) call for a local slice. +// executeBSIGroupRangeSlice executes a range(bsiGroup) call for a local slice. func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) { - // Parse frame, use default if unset. - frame, _ := c.Args["frame"].(string) - if frame == "" { - frame = DefaultFrame - } - f := e.Holder.Frame(index, frame) - if f == nil { - return nil, ErrFrameNotFound - } - - // Remove frame field. - args := pql.CopyArgs(c.Args) - delete(args, "frame") - - // Only one conditional field should remain. - if len(args) == 0 { + // Only one conditional should be present. + if len(c.Args) == 0 { return nil, errors.New("Range(): condition required") - } else if len(args) > 1 { + } else if len(c.Args) > 1 { return nil, errors.New("Range(): too many arguments") } - // Extract condition field. - var fieldName string + // Extract conditional. + var frameName string var cond *pql.Condition - for k, v := range args { + for k, v := range c.Args { vv, ok := v.(*pql.Condition) if !ok { return nil, fmt.Errorf("Range(): %q: expected condition argument, got %v", k, v) } - fieldName, cond = k, vv + frameName, cond = k, vv + } + + f := e.Holder.Frame(index, frameName) + if f == nil { + return nil, ErrFrameNotFound } // EQ null (not implemented: flip frag.NotNull with max ColumnID) @@ -799,19 +781,19 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, // Handle `!= null`. if cond.Op == pql.NEQ && cond.Value == nil { - // Find field. - field := f.bsiGroup(fieldName) - if field == nil { + // Find bsiGroup. + bsig := f.bsiGroup(frameName) + if bsig == nil { return nil, ErrBSIGroupNotFound } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if frag == nil { return NewRow(), nil } - return frag.NotNull(field.BitDepth()) + return frag.NotNull(bsig.BitDepth()) } else if cond.Op == pql.BETWEEN { @@ -826,33 +808,33 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // The reason we don't just call: - // return f.RangeBetween(fieldName, predicates[0], predicates[1]) + // return f.RangeBetween(frameName, predicates[0], predicates[1]) // here is because we need the call to be slice-specific. - // Find field. - field := f.bsiGroup(fieldName) - if field == nil { + // Find bsiGroup. + bsig := f.bsiGroup(frameName) + if bsig == nil { return nil, ErrBSIGroupNotFound } - baseValueMin, baseValueMax, outOfRange := field.baseValueBetween(predicates[0], predicates[1]) + baseValueMin, baseValueMax, outOfRange := bsig.baseValueBetween(predicates[0], predicates[1]) if outOfRange { return NewRow(), nil } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if frag == nil { return NewRow(), nil } // If the query is asking for the entire valid range, just return - // the not-null bitmap for the field. - if predicates[0] <= field.Min && predicates[1] >= field.Max { - return frag.NotNull(field.BitDepth()) + // the not-null bitmap for the bsiGroup. + if predicates[0] <= bsig.Min && predicates[1] >= bsig.Max { + return frag.NotNull(bsig.BitDepth()) } - return frag.RangeBetween(field.BitDepth(), baseValueMin, baseValueMax) + return frag.RangeBetween(bsig.BitDepth(), baseValueMin, baseValueMax) } else { @@ -862,36 +844,36 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, return nil, errors.New("Range(): conditions only support integer values") } - // Find field. - field := f.bsiGroup(fieldName) - if field == nil { + // Find bsiGroup. + bsig := f.bsiGroup(frameName) + if bsig == nil { return nil, ErrBSIGroupNotFound } - baseValue, outOfRange := field.baseValue(cond.Op, value) + baseValue, outOfRange := bsig.baseValue(cond.Op, value) if outOfRange && cond.Op != pql.NEQ { return NewRow(), nil } // Retrieve fragment. - frag := e.Holder.Fragment(index, frame, viewBSIGroupPrefix+fieldName, slice) + frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) if frag == nil { return NewRow(), nil } - // LT[E] and GT[E] should return all not-null if selected range fully encompasses valid field range. - if (cond.Op == pql.LT && value > field.Max) || (cond.Op == pql.LTE && value >= field.Max) || - (cond.Op == pql.GT && value < field.Min) || (cond.Op == pql.GTE && value <= field.Min) { - return frag.NotNull(field.BitDepth()) + // LT[E] and GT[E] should return all not-null if selected range fully encompasses valid bsiGroup range. + if (cond.Op == pql.LT && value > bsig.Max) || (cond.Op == pql.LTE && value >= bsig.Max) || + (cond.Op == pql.GT && value < bsig.Min) || (cond.Op == pql.GTE && value <= bsig.Min) { + return frag.NotNull(bsig.BitDepth()) } // outOfRange for NEQ should return all not-null. if outOfRange && cond.Op == pql.NEQ { - return frag.NotNull(field.BitDepth()) + return frag.NotNull(bsig.BitDepth()) } - f.Stats.Count("range:field", 1, 1.0) - return frag.RangeOp(cond.Op, field.BitDepth(), baseValue) + f.Stats.Count("range:bsigroup", 1, 1.0) + return frag.RangeOp(cond.Op, bsig.BitDepth(), baseValue) } } diff --git a/executor_test.go b/executor_test.go index d06a5027c..f042d3f8f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -834,7 +834,7 @@ func TestExecutor_Execute_Range(t *testing.T) { } t.Run("EQ", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo == 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -843,19 +843,19 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Run("NEQ", func(t *testing.T) { // NEQ null - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other != null)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other != null)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) } // NEQ - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo != 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo != 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1, SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) } // NEQ - - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other != -20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other != -20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { //t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -864,7 +864,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("LT", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo < 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo < 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -872,7 +872,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("LTE", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo <= 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo <= 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, SliceWidth + 2, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -880,7 +880,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("GT", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo > 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo > 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -888,7 +888,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("GTE", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo >= 20)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo >= 20)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{50, SliceWidth, SliceWidth + 1, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -896,7 +896,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("BETWEEN", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other >< [1, 1000])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other >< [1, 1000])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -905,7 +905,7 @@ func TestExecutor_Execute_Range(t *testing.T) { // Ensure that the NotNull code path gets run. t.Run("NotNull", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, other >< [0, 1000])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other >< [0, 1000])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -913,7 +913,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("BelowMin", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 0)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo == 0)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -921,7 +921,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("AboveMax", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, foo == 200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(foo == 200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -929,7 +929,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("LTAboveMax", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, edge < 200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(edge < 200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns())) @@ -937,7 +937,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("GTBelowMin", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, edge > -200)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(edge > -200)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) { t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns())) @@ -945,13 +945,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("ErrFrameNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=bad_frame, foo >= 20)`), nil, nil); err != pilosa.ErrFrameNotFound { - t.Fatal(err) - } - }) - - t.Run("ErrBSIGroupNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=foo, bad_field >= 20)`), nil, nil); err != pilosa.ErrBSIGroupNotFound { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(bad_frame >= 20)`), nil, nil); err != pilosa.ErrFrameNotFound { t.Fatal(err) } }) From 0d44e586cc8da3081091fa851be8cf8e5a2651ef Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 16:14:26 -0500 Subject: [PATCH 32/52] remove field flag from pilosa import command --- cmd/import.go | 1 - ctl/import.go | 27 ++++++++++++++++++++------- ctl/import_test.go | 16 +++++++++++----- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/cmd/import.go b/cmd/import.go index 8dd31181c..ea489f59d 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -55,7 +55,6 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM. flags.StringVarP(&Importer.Host, "host", "", "localhost:10101", "host:port of Pilosa.") 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.") diff --git a/ctl/import.go b/ctl/import.go index 4fdfba444..493e1429b 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -46,9 +46,6 @@ type ImportCommand struct { // CreateSchema ensures the schema exists before import CreateSchema bool - // 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"` @@ -105,10 +102,26 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } } + // Determine the frame type in order to correctly handle the input data. + frameType := pilosa.DefaultFrameType + schema, err := cmd.Client.Schema(ctx) + if err != nil { + return errors.Wrap(err, "getting schema") + } + for _, index := range schema { + if index.Name == cmd.Index { + for _, frame := range index.Frames { + if frame.Name == cmd.Frame { + frameType = frame.Options.Type + } + } + } + } + // Import each path and import by slice. for _, path := range cmd.Paths { logger.Printf("parsing: %s", path) - if err := cmd.importPath(ctx, path); err != nil { + if err := cmd.importPath(ctx, frameType, path); err != nil { return err } } @@ -129,9 +142,9 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { } // importPath parses a path into bits and imports it to the server. -func (cmd *ImportCommand) importPath(ctx context.Context, path string) error { - // If a field is provided, treat the import data as values to be range-encoded. - if cmd.Field != "" { +func (cmd *ImportCommand) importPath(ctx context.Context, frameType, path string) error { + // If frameType is `int`, treat the import data as values to be range-encoded. + if frameType == pilosa.FrameTypeInt { return cmd.bufferFieldValues(ctx, path) } else { if cmd.StringKeys { diff --git a/ctl/import_test.go b/ctl/import_test.go index 7c6c02721..7c64944f6 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -82,9 +82,7 @@ func TestImportCommand_Run(t *testing.T) { } } -// TODO: revisit this test once Frame is renamed Field -// Ensure that the ImportValue path runs (note: we have specified a value -// for cm.Field.) +// Ensure that the ImportValue path runs. func TestImportCommand_RunValue(t *testing.T) { buf := bytes.Buffer{} @@ -112,7 +110,6 @@ func TestImportCommand_RunValue(t *testing.T) { cm.Index = "i" cm.Frame = "f" - cm.Field = "f" cm.Paths = []string{file.Name()} err = cm.Run(ctx) if err != nil { @@ -122,10 +119,19 @@ func TestImportCommand_RunValue(t *testing.T) { func TestImportCommand_InvalidFile(t *testing.T) { + hldr := test.MustOpenHolder() + defer hldr.Close() + s := test.NewServer() + defer s.Close() + + s.Handler.API.Cluster = test.NewCluster(1) + s.Handler.API.Cluster.Nodes[0].URI = s.HostURI() + s.Handler.API.Holder = hldr.Holder + buf := bytes.Buffer{} stdin, stdout, stderr := GetIO(buf) cm := NewImportCommand(stdin, stdout, stderr) - cm.Host = "anyhost" + cm.Host = s.Host() cm.Index = "i" cm.Frame = "f" file, err := ioutil.TempFile("", "import.csv") From 96208283df9f749a90d1e7c41ca624102885b7bf Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 16:38:29 -0500 Subject: [PATCH 33/52] remove final instances of Field --- ctl/import.go | 14 +++++++------- fragment_test.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ctl/import.go b/ctl/import.go index 493e1429b..c6c0f0188 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -145,7 +145,7 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { func (cmd *ImportCommand) importPath(ctx context.Context, frameType, path string) error { // If frameType is `int`, treat the import data as values to be range-encoded. if frameType == pilosa.FrameTypeInt { - return cmd.bufferFieldValues(ctx, path) + return cmd.bufferValues(ctx, path) } else { if cmd.StringKeys { return cmd.bufferBitsK(ctx, path) @@ -358,8 +358,8 @@ func (cmd *ImportCommand) importBitsK(ctx context.Context, bits []pilosa.Bit) er return nil } -// bufferFieldValues buffers slices of fieldValues to be imported as a batch. -func (cmd *ImportCommand) bufferFieldValues(ctx context.Context, path string) error { +// bufferValues buffers slices of fieldValues to be imported as a batch. +func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error { a := make([]pilosa.FieldValue, 0, cmd.BufferSize) var r *csv.Reader @@ -418,7 +418,7 @@ func (cmd *ImportCommand) bufferFieldValues(ctx context.Context, path string) er // If we've reached the buffer size then import field values. if len(a) == cmd.BufferSize { - if err := cmd.importFieldValues(ctx, a); err != nil { + if err := cmd.importValues(ctx, a); err != nil { return err } a = a[:0] @@ -426,15 +426,15 @@ func (cmd *ImportCommand) bufferFieldValues(ctx context.Context, path string) er } // If there are still values in the buffer then flush them. - if err := cmd.importFieldValues(ctx, a); err != nil { + if err := cmd.importValues(ctx, a); err != nil { return err } return nil } -// importFieldValues sends batches of fieldValues to the server. -func (cmd *ImportCommand) importFieldValues(ctx context.Context, vals []pilosa.FieldValue) error { +// importValues sends batches of fieldValues to the server. +func (cmd *ImportCommand) importValues(ctx context.Context, vals []pilosa.FieldValue) error { logger := log.New(cmd.Stderr, "", log.LstdFlags) // Group vals by slice. diff --git a/fragment_test.go b/fragment_test.go index e1c9b7fd4..6a96fb677 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -220,7 +220,7 @@ func TestFragment_SetValue(t *testing.T) { } // Ensure a fragment can sum field values. -func TestFragment_FieldSum(t *testing.T) { +func TestFragment_Sum(t *testing.T) { const bitDepth = 16 f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") @@ -259,7 +259,7 @@ func TestFragment_FieldSum(t *testing.T) { } // Ensure a fragment can find the min and max of field values. -func TestFragment_FieldMinMax(t *testing.T) { +func TestFragment_MinMax(t *testing.T) { const bitDepth = 16 f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") @@ -332,7 +332,7 @@ func TestFragment_FieldMinMax(t *testing.T) { } // Ensure a fragment query for matching fields. -func TestFragment_FieldRange(t *testing.T) { +func TestFragment_Range(t *testing.T) { const bitDepth = 16 t.Run("EQ", func(t *testing.T) { From 80d656ae9c9b93c4a53996d5215190ea8bac9a82 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 16:56:16 -0500 Subject: [PATCH 34/52] final removal of field instances --- ctl/import.go | 10 +++++----- executor_test.go | 20 ++++++++++---------- fragment_test.go | 32 ++++++++++++++++---------------- frame_test.go | 4 ++-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ctl/import.go b/ctl/import.go index c6c0f0188..45bf81d42 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -358,7 +358,7 @@ func (cmd *ImportCommand) importBitsK(ctx context.Context, bits []pilosa.Bit) er return nil } -// bufferValues buffers slices of fieldValues to be imported as a batch. +// bufferValues buffers slices of FieldValues to be imported as a batch. func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error { a := make([]pilosa.FieldValue, 0, cmd.BufferSize) @@ -407,7 +407,7 @@ func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error { } val.ColumnID = columnID - // Parse field value. + // Parse FieldValue. value, err := strconv.ParseInt(record[1], 10, 64) if err != nil { return fmt.Errorf("invalid value on row %d: %q", rnum, record[1]) @@ -416,7 +416,7 @@ func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error { a = append(a, val) - // If we've reached the buffer size then import field values. + // If we've reached the buffer size then import FieldValues. if len(a) == cmd.BufferSize { if err := cmd.importValues(ctx, a); err != nil { return err @@ -433,7 +433,7 @@ func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error { return nil } -// importValues sends batches of fieldValues to the server. +// importValues sends batches of FieldValues to the server. func (cmd *ImportCommand) importValues(ctx context.Context, vals []pilosa.FieldValue) error { logger := log.New(cmd.Stderr, "", log.LstdFlags) @@ -441,7 +441,7 @@ func (cmd *ImportCommand) importValues(ctx context.Context, vals []pilosa.FieldV logger.Printf("grouping %d vals", len(vals)) valsBySlice := pilosa.FieldValues(vals).GroupBySlice() - // Parse path into field values. + // Parse path into FieldValues. for slice, vals := range valsBySlice { if cmd.Sort { sort.Sort(pilosa.FieldValues(vals)) diff --git a/executor_test.go b/executor_test.go index f042d3f8f..89e54a1de 100644 --- a/executor_test.go +++ b/executor_test.go @@ -281,7 +281,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Fatal(err) } - // Set field values. + // Set bsiGroup values. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f=25)`), nil, nil); err != nil { t.Fatal(err) @@ -355,8 +355,8 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { t.Fatal(err) } - // Set two fields on f/10. - // Also set fields on other bitmaps and frames to test isolation. + // Set two attrs on f/10. + // Also set attrs on other bitmaps and frames to test isolation. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, frame=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) @@ -617,9 +617,9 @@ func TestExecutor_Execute_MinMax(t *testing.T) { for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Min(frame=f, field=f)` + pql = `Min(frame=f)` } else { - pql = fmt.Sprintf(`Min(%s, frame=f, field=f)`, tt.filter) + pql = fmt.Sprintf(`Min(%s, frame=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -643,9 +643,9 @@ func TestExecutor_Execute_MinMax(t *testing.T) { for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Max(frame=f, field=f)` + pql = `Max(frame=f)` } else { - pql = fmt.Sprintf(`Max(%s, frame=f, field=f)`, tt.filter) + pql = fmt.Sprintf(`Max(%s, frame=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -711,7 +711,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { } t.Run("NoFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(frame=foo, field=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(frame=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 200, Count: 5}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -719,7 +719,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { }) t.Run("WithFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(frame=x, row=0), frame=foo, field=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(frame=x, row=0), frame=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 80, Count: 2}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -769,7 +769,7 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { }) } -// Ensure a Range(field) query can be executed. +// Ensure a Range(bsiGroup) query can be executed. func TestExecutor_Execute_Range(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() diff --git a/fragment_test.go b/fragment_test.go index 6a96fb677..b72450fbb 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -96,7 +96,7 @@ func TestFragment_ClearBit(t *testing.T) { } } -// Ensure a fragment can set & read a field value. +// Ensure a fragment can set & read a value. func TestFragment_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") @@ -219,7 +219,7 @@ func TestFragment_SetValue(t *testing.T) { }) } -// Ensure a fragment can sum field values. +// Ensure a fragment can sum values. func TestFragment_Sum(t *testing.T) { const bitDepth = 16 @@ -258,7 +258,7 @@ func TestFragment_Sum(t *testing.T) { }) } -// Ensure a fragment can find the min and max of field values. +// Ensure a fragment can find the min and max of values. func TestFragment_MinMax(t *testing.T) { const bitDepth = 16 @@ -331,7 +331,7 @@ func TestFragment_MinMax(t *testing.T) { }) } -// Ensure a fragment query for matching fields. +// Ensure a fragment query for matching values. func TestFragment_Range(t *testing.T) { const bitDepth = 16 @@ -400,28 +400,28 @@ func TestFragment_Range(t *testing.T) { t.Fatal(err) } - // Query for fields less than (ending with set column). + // Query for values less than (ending with set column). if b, err := f.RangeOp(pql.LT, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields less than (ending with unset column). + // Query for values less than (ending with unset column). if b, err := f.RangeOp(pql.LT, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields less than or equal to (ending with set column). + // Query for values less than or equal to (ending with set column). if b, err := f.RangeOp(pql.LTE, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000, 5000, 6000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields less than or equal to (ending with unset column). + // Query for values less than or equal to (ending with unset column). if b, err := f.RangeOp(pql.LTE, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) { @@ -448,28 +448,28 @@ func TestFragment_Range(t *testing.T) { t.Fatal(err) } - // Query for fields greater than (ending with unset bit). + // Query for values greater than (ending with unset bit). if b, err := f.RangeOp(pql.GT, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than (ending with set bit). + // Query for values greater than (ending with set bit). if b, err := f.RangeOp(pql.GT, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than or equal to (ending with unset bit). + // Query for values greater than or equal to (ending with unset bit). if b, err := f.RangeOp(pql.GTE, bitDepth, 300); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than or equal to (ending with set bit). + // Query for values greater than or equal to (ending with set bit). if b, err := f.RangeOp(pql.GTE, bitDepth, 301); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { @@ -496,28 +496,28 @@ func TestFragment_Range(t *testing.T) { t.Fatal(err) } - // Query for fields greater than (ending with unset column). + // Query for values greater than (ending with unset column). if b, err := f.RangeBetween(bitDepth, 300, 2817); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than (ending with set column). + // Query for values greater than (ending with set column). if b, err := f.RangeBetween(bitDepth, 301, 2817); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than or equal to (ending with unset column). + // Query for values greater than or equal to (ending with unset column). if b, err := f.RangeBetween(bitDepth, 301, 2816); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 4000}) { t.Fatalf("unexpected columns: %+v", b.Columns()) } - // Query for fields greater than or equal to (ending with set column). + // Query for values greater than or equal to (ending with set column). if b, err := f.RangeBetween(bitDepth, 300, 2816); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 4000}) { diff --git a/frame_test.go b/frame_test.go index 739b34ed8..3964af785 100644 --- a/frame_test.go +++ b/frame_test.go @@ -71,7 +71,7 @@ func TestFrame_SetTimeQuantum(t *testing.T) { } } -// Ensure a frame can set & read a field value. +// Ensure a frame can set & read a bsiGroup value. func TestFrame_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { idx := test.MustOpenIndex() @@ -86,7 +86,7 @@ func TestFrame_SetValue(t *testing.T) { t.Fatal(err) } - // Set value on field. + // Set value on frame. if changed, err := f.SetValue(100, 21); err != nil { t.Fatal(err) } else if !changed { From 1d3c4d6fcb50ffb1364dd2712d6df578d9b35313 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 17:52:22 -0500 Subject: [PATCH 35/52] first pass at GoRename Frame to Field in frame.go --- api.go | 4 +- client.go | 8 +- client_test.go | 4 +- cluster_internal_test.go | 2 +- cluster_test.go | 2 +- ctl/import.go | 6 +- diagnostics.go | 2 +- executor.go | 4 +- executor_test.go | 70 +++++++------- fragment_test.go | 4 +- frame.go | 194 +++++++++++++++++++-------------------- frame_test.go | 30 +++--- handler.go | 4 +- handler_internal_test.go | 4 +- handler_test.go | 16 ++-- holder.go | 8 +- holder_test.go | 16 ++-- index.go | 30 +++--- index_test.go | 22 ++--- server.go | 2 +- server/cluster_test.go | 10 +- server/server_test.go | 12 +-- server_test.go | 2 +- stats_test.go | 2 +- test/cluster.go | 2 +- test/frame.go | 16 ++-- test/holder.go | 6 +- test/index.go | 8 +- utils_test.go | 2 +- 29 files changed, 246 insertions(+), 246 deletions(-) diff --git a/api.go b/api.go index e528a4b21..fec6b3129 100644 --- a/api.go +++ b/api.go @@ -218,7 +218,7 @@ func (api *API) DeleteIndex(ctx context.Context, indexName string) error { } // CreateFrame makes the named frame in the named index with the given options. -func (api *API) CreateFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) (*Frame, error) { +func (api *API) CreateFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) (*Field, error) { if err := api.validate(apiCreateFrame); err != nil { return nil, errors.Wrap(err, "validating api method") } @@ -679,7 +679,7 @@ func (api *API) LongQueryTime() time.Duration { return api.Cluster.LongQueryTime } -func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*Index, *Frame, error) { +func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*Index, *Field, error) { // Validate that this handler owns the slice. if !api.Cluster.OwnsSlice(api.LocalID(), indexName, slice) { api.Logger.Printf("node %s does not own slice %d of index %s", api.LocalID(), slice, indexName) diff --git a/client.go b/client.go index 1d78dde23..4c8ba2157 100644 --- a/client.go +++ b/client.go @@ -330,7 +330,7 @@ func (c *InternalHTTPClient) EnsureIndex(ctx context.Context, name string, optio return err } -func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error { +func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error { err := c.CreateFrame(ctx, indexName, frameName, options) if err == nil || err == ErrFrameExists { return nil @@ -616,7 +616,7 @@ func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, frame s } // CreateFrame creates a new frame on the server. -func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame string, opt FrameOptions) error { +func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error { if index == "" { return ErrIndexRequired } @@ -1056,10 +1056,10 @@ type InternalClient interface { Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) 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 + EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error ExportCSV(ctx context.Context, index, frame string, slice uint64, w io.Writer) error - CreateFrame(ctx context.Context, index, frame string, opt FrameOptions) error + CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error FragmentBlocks(ctx context.Context, index, frame string, slice uint64) ([]FragmentBlock, error) BlockData(ctx context.Context, index, frame string, slice uint64, block int) ([]uint64, []uint64, error) ColumnAttrDiff(ctx context.Context, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) diff --git a/client_test.go b/client_test.go index 1edd37bc2..6f1931e29 100644 --- a/client_test.go +++ b/client_test.go @@ -246,8 +246,8 @@ func TestClient_ImportValue(t *testing.T) { fldName := "f" - fo := pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + fo := pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -100, Max: 100, } diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 6b1f6e72b..acccd37d3 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -145,7 +145,7 @@ func TestFragSources(t *testing.T) { c5.addNodeBasicSorted(node3) idx := newIndexWithTempPath("i") - frame, err := idx.CreateFrameIfNotExists("f", FrameOptions{}) + frame, err := idx.CreateFrameIfNotExists("f", FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/cluster_test.go b/cluster_test.go index 99b322a0e..f8903aafd 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -416,7 +416,7 @@ func TestCluster_ResizeStates(t *testing.T) { } // Add Bit Data to node0. - if err := tc.CreateFrame("i", "f", FrameOptions{}); err != nil { + if err := tc.CreateFrame("i", "f", FieldOptions{}); err != nil { t.Fatal(err) } tc.SetBit("i", "f", "standard", 1, 101, nil) diff --git a/ctl/import.go b/ctl/import.go index 45bf81d42..3a7835cb2 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -41,7 +41,7 @@ type ImportCommand struct { // Options for index & frame to be created if they don't exist IndexOptions pilosa.IndexOptions - FrameOptions pilosa.FrameOptions + FrameOptions pilosa.FieldOptions // CreateSchema ensures the schema exists before import CreateSchema bool @@ -103,7 +103,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } // Determine the frame type in order to correctly handle the input data. - frameType := pilosa.DefaultFrameType + frameType := pilosa.DefaultFieldType schema, err := cmd.Client.Schema(ctx) if err != nil { return errors.Wrap(err, "getting schema") @@ -144,7 +144,7 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { // importPath parses a path into bits and imports it to the server. func (cmd *ImportCommand) importPath(ctx context.Context, frameType, path string) error { // If frameType is `int`, treat the import data as values to be range-encoded. - if frameType == pilosa.FrameTypeInt { + if frameType == pilosa.FieldTypeInt { return cmd.bufferValues(ctx, path) } else { if cmd.StringKeys { diff --git a/diagnostics.go b/diagnostics.go index 1968a4e74..10ecfa22d 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -227,7 +227,7 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { numIndexes += 1 for _, frame := range index.Frames() { numFrames += 1 - if frame.Type() == FrameTypeInt { + if frame.Type() == FieldTypeInt { bsiFieldCount += 1 } if frame.TimeQuantum() != "" { diff --git a/executor.go b/executor.go index eee4fa0ee..fd98f7189 100644 --- a/executor.go +++ b/executor.go @@ -983,7 +983,7 @@ func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Cal } // executeClearBitView executes a ClearBit() call for a single view. -func (e *Executor) executeClearBitView(ctx context.Context, index string, c *pql.Call, f *Frame, view string, colID, rowID uint64, opt *ExecOptions) (bool, error) { +func (e *Executor) executeClearBitView(ctx context.Context, index string, c *pql.Call, f *Field, view string, colID, rowID uint64, opt *ExecOptions) (bool, error) { slice := colID / SliceWidth ret := false for _, node := range e.Cluster.SliceNodes(index, slice) { @@ -1058,7 +1058,7 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call, } // executeSetBitView executes a SetBit() call for a specific view. -func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.Call, f *Frame, view string, colID, rowID uint64, timestamp *time.Time, opt *ExecOptions) (bool, error) { +func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.Call, f *Field, view string, colID, rowID uint64, timestamp *time.Time, opt *ExecOptions) (bool, error) { slice := colID / SliceWidth ret := false diff --git a/executor_test.go b/executor_test.go index 89e54a1de..0d70ae37f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -33,7 +33,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := index.CreateFrame("f", pilosa.FrameOptions{}) + f, err := index.CreateFrame("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } @@ -83,7 +83,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -271,13 +271,13 @@ func TestExecutor_Execute_SetValue(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 50, }); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FrameOptions{}); err != nil { + } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -311,8 +311,8 @@ func TestExecutor_Execute_SetValue(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100, }); err != nil { @@ -349,9 +349,9 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FrameOptions{}); err != nil { + } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -388,9 +388,9 @@ func TestExecutor_Execute_TopN(t *testing.T) { // Set columns for rows 0, 10, & 20 across two slices. if idx, err := hldr.CreateIndex("i", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("other", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("other", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := e.Execute(context.Background(), "i", test.MustParse(` SetBit(frame=f, row=0, col=0) @@ -572,12 +572,12 @@ func TestExecutor_Execute_MinMax(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -10, Max: 100, }); err != nil { @@ -667,28 +667,28 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 100, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, }); err != nil { @@ -737,8 +737,8 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeTime, + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }); err != nil { t.Fatal(err) @@ -780,36 +780,36 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 100, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, }); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("edge", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if _, err := idx.CreateFrame("edge", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: -100, Max: 100, }); err != nil { @@ -1068,7 +1068,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -1120,7 +1120,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FrameOptions{}); err != nil { + if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := f.SetTimeQuantum("Y"); err != nil { t.Fatal(err) @@ -1223,7 +1223,7 @@ func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - index.CreateFrame("f", pilosa.FrameOptions{}) + index.CreateFrame("f", pilosa.FieldOptions{}) targetAttrs := map[string]interface{}{ "foo": "bar", } diff --git a/fragment_test.go b/fragment_test.go index b72450fbb..2d618aa81 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -754,7 +754,7 @@ func TestFragment_TopN_CacheSize(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) + frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) if err != nil { t.Fatal(err) } @@ -924,7 +924,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked}) + frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { t.Fatal(err) } diff --git a/frame.go b/frame.go index ac9eb5ee7..b69848344 100644 --- a/frame.go +++ b/frame.go @@ -31,7 +31,7 @@ import ( // Default frame settings. const ( - DefaultFrameType = FrameTypeSet + DefaultFieldType = FieldTypeSet DefaultCacheType = CacheTypeRanked @@ -39,15 +39,15 @@ const ( DefaultCacheSize = 50000 ) -// Frame types. +// Field types. const ( - FrameTypeSet = "set" - FrameTypeInt = "int" - FrameTypeTime = "time" + FieldTypeSet = "set" + FieldTypeInt = "int" + FieldTypeTime = "time" ) -// Frame represents a container for views. -type Frame struct { +// Field represents a container for views. +type Field struct { mu sync.RWMutex path string index string @@ -61,33 +61,33 @@ type Frame struct { broadcaster Broadcaster Stats StatsClient - // Frame options. - options FrameOptions + // Field options. + options FieldOptions bsiGroups []*bsiGroup Logger Logger } -// FrameOption is a functional option type for pilosa.Frame. -type FrameOption func(f *Frame) error +// FieldOption is a functional option type for pilosa.Fielde. +type FieldOption func(f *Field) error -// TODO: break these out into separate Options (not a FrameOptions object) -func OptFrameFrameOptions(o FrameOptions) FrameOption { - return func(f *Frame) error { +// TODO: break these out into separate Options (not a FieldOptions object) +func OptFieldFieldOptions(o FieldOptions) FieldOption { + return func(f *Field) error { f.options = o return nil } } -// NewFrame returns a new instance of frame. -func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { +// NewField returns a new instance of frame. +func NewField(path, index, name string, opts ...FieldOption) (*Field, error) { err := ValidateName(name) if err != nil { return nil, err } - f := &Frame{ + f := &Field{ path: path, index: index, name: name, @@ -99,8 +99,8 @@ func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { broadcaster: NopBroadcaster, Stats: NopStatsClient, - options: FrameOptions{ - Type: DefaultFrameType, + options: FieldOptions{ + Type: DefaultFieldType, CacheType: DefaultCacheType, CacheSize: DefaultCacheSize, }, @@ -119,19 +119,19 @@ func NewFrame(path, index, name string, opts ...FrameOption) (*Frame, error) { } // Name returns the name the frame was initialized with. -func (f *Frame) Name() string { return f.name } +func (f *Field) Name() string { return f.name } // Index returns the index name the frame was initialized with. -func (f *Frame) Index() string { return f.index } +func (f *Field) Index() string { return f.index } // Path returns the path the frame was initialized with. -func (f *Frame) Path() string { return f.path } +func (f *Field) Path() string { return f.path } // RowAttrStore returns the attribute storage. -func (f *Frame) RowAttrStore() AttrStore { return f.rowAttrStore } +func (f *Field) RowAttrStore() AttrStore { return f.rowAttrStore } // MaxSlice returns the max slice in the frame. -func (f *Frame) MaxSlice() uint64 { +func (f *Field) MaxSlice() uint64 { f.mu.RLock() defer f.mu.RUnlock() @@ -145,14 +145,14 @@ func (f *Frame) MaxSlice() uint64 { } // Type returns the frame type. -func (f *Frame) Type() string { +func (f *Field) Type() string { f.mu.RLock() defer f.mu.RUnlock() return f.options.Type } // CacheType returns the caching mode for the frame. -func (f *Frame) CacheType() string { +func (f *Field) CacheType() string { f.mu.RLock() defer f.mu.RUnlock() return f.options.CacheType @@ -160,7 +160,7 @@ func (f *Frame) CacheType() string { // SetCacheSize sets the cache size for ranked fames. Persists to meta file on update. // defaults to DefaultCacheSize 50000 -func (f *Frame) SetCacheSize(v uint32) error { +func (f *Field) SetCacheSize(v uint32) error { f.mu.Lock() defer f.mu.Unlock() @@ -179,7 +179,7 @@ func (f *Frame) SetCacheSize(v uint32) error { } // CacheSize returns the ranked frame cache size. -func (f *Frame) CacheSize() uint32 { +func (f *Field) CacheSize() uint32 { f.mu.RLock() v := f.options.CacheSize f.mu.RUnlock() @@ -187,14 +187,14 @@ func (f *Frame) CacheSize() uint32 { } // Options returns all options for this frame. -func (f *Frame) Options() FrameOptions { +func (f *Field) Options() FieldOptions { f.mu.RLock() defer f.mu.RUnlock() return f.options } // Open opens and initializes the frame. -func (f *Frame) Open() error { +func (f *Field) Open() error { if err := func() error { // Ensure the frame's path exists. if err := os.MkdirAll(f.path, 0777); err != nil { @@ -228,7 +228,7 @@ func (f *Frame) Open() error { } // openViews opens and initializes the views inside the frame. -func (f *Frame) openViews() error { +func (f *Field) openViews() error { file, err := os.Open(filepath.Join(f.path, "views")) if os.IsNotExist(err) { return nil @@ -260,7 +260,7 @@ func (f *Frame) openViews() error { } // loadMeta reads meta data for the frame, if any. -func (f *Frame) loadMeta() error { +func (f *Field) loadMeta() error { var pb internal.FrameMeta // Read data from meta file. @@ -287,7 +287,7 @@ func (f *Frame) loadMeta() error { } // saveMeta writes meta data for the frame. -func (f *Frame) saveMeta() error { +func (f *Field) saveMeta() error { // Marshal metadata. fo := f.options buf, err := proto.Marshal(fo.Encode()) @@ -304,10 +304,10 @@ func (f *Frame) saveMeta() error { } // applyOptions configures the frame based on opt. -func (f *Frame) applyOptions(opt FrameOptions) error { +func (f *Field) applyOptions(opt FieldOptions) error { switch opt.Type { - case FrameTypeSet, "": - f.options.Type = FrameTypeSet + case FieldTypeSet, "": + f.options.Type = FieldTypeSet if opt.CacheType != "" { f.options.CacheType = opt.CacheType } @@ -317,7 +317,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { f.options.Min = 0 f.options.Max = 0 f.options.TimeQuantum = "" - case FrameTypeInt: + case FieldTypeInt: f.options.Type = opt.Type f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 @@ -339,7 +339,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { if err := f.createBSIGroup(bsig); err != nil { return errors.Wrap(err, "creating bsigroup") } - case FrameTypeTime: + case FieldTypeTime: f.options.Type = opt.Type f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 @@ -358,7 +358,7 @@ func (f *Frame) applyOptions(opt FrameOptions) error { } // Close closes the frame and its views. -func (f *Frame) Close() error { +func (f *Field) Close() error { f.mu.Lock() defer f.mu.Unlock() @@ -379,7 +379,7 @@ func (f *Frame) Close() error { } // bsiGroup returns a bsiGroup by name. -func (f *Frame) bsiGroup(name string) *bsiGroup { +func (f *Field) bsiGroup(name string) *bsiGroup { f.mu.RLock() defer f.mu.RUnlock() for _, bsig := range f.bsiGroups { @@ -391,7 +391,7 @@ func (f *Frame) bsiGroup(name string) *bsiGroup { } // hasBSIGroup returns true if a bsiGroup exists on the frame. -func (f *Frame) hasBSIGroup(name string) bool { +func (f *Field) hasBSIGroup(name string) bool { for _, bsig := range f.bsiGroups { if bsig.Name == name { return true @@ -401,7 +401,7 @@ func (f *Frame) hasBSIGroup(name string) bool { } // createBSIGroup creates a new bsiGroup on the frame. -func (f *Frame) createBSIGroup(bsig *bsiGroup) error { +func (f *Field) createBSIGroup(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() @@ -414,7 +414,7 @@ func (f *Frame) createBSIGroup(bsig *bsiGroup) error { } // addBSIGroup adds a single bsiGroup to bsiGroups. -func (f *Frame) addBSIGroup(bsig *bsiGroup) error { +func (f *Field) addBSIGroup(bsig *bsiGroup) error { if err := bsig.validate(); err != nil { return errors.Wrap(err, "validating bsigroup") } else if f.hasBSIGroup(bsig.Name) { @@ -433,7 +433,7 @@ func (f *Frame) addBSIGroup(bsig *bsiGroup) error { } // deleteBSIGroupAndView deletes an existing bsiGroup on the schema. -func (f *Frame) deleteBSIGroupAndView(name string) error { +func (f *Field) deleteBSIGroupAndView(name string) error { f.mu.Lock() defer f.mu.Unlock() @@ -458,7 +458,7 @@ func (f *Frame) deleteBSIGroupAndView(name string) error { } // deleteBSIGroup removes a single bsiGroup from bsiGroups. -func (f *Frame) deleteBSIGroup(name string) error { +func (f *Field) deleteBSIGroup(name string) error { for i, bsig := range f.bsiGroups { if bsig.Name == name { copy(f.bsiGroups[i:], f.bsiGroups[i+1:]) @@ -470,14 +470,14 @@ func (f *Frame) deleteBSIGroup(name string) error { } // TimeQuantum returns the time quantum for the frame. -func (f *Frame) TimeQuantum() TimeQuantum { +func (f *Field) TimeQuantum() TimeQuantum { f.mu.Lock() defer f.mu.Unlock() return f.options.TimeQuantum } // SetTimeQuantum sets the time quantum for the frame. -func (f *Frame) SetTimeQuantum(q TimeQuantum) error { +func (f *Field) SetTimeQuantum(q TimeQuantum) error { f.mu.Lock() defer f.mu.Unlock() @@ -498,21 +498,21 @@ func (f *Frame) SetTimeQuantum(q TimeQuantum) error { } // ViewPath returns the path to a view in the frame. -func (f *Frame) ViewPath(name string) string { +func (f *Field) ViewPath(name string) string { return filepath.Join(f.path, "views", name) } // View returns a view in the frame by name. -func (f *Frame) View(name string) *View { +func (f *Field) View(name string) *View { f.mu.RLock() defer f.mu.RUnlock() return f.view(name) } -func (f *Frame) view(name string) *View { return f.views[name] } +func (f *Field) view(name string) *View { return f.views[name] } // Views returns a list of all views in the frame. -func (f *Frame) Views() []*View { +func (f *Field) Views() []*View { f.mu.RLock() defer f.mu.RUnlock() @@ -524,7 +524,7 @@ func (f *Frame) Views() []*View { } // viewNames returns a list of all views (as a string) in the frame. -func (f *Frame) viewNames() []string { +func (f *Field) viewNames() []string { f.mu.Lock() defer f.mu.Unlock() @@ -536,7 +536,7 @@ func (f *Frame) viewNames() []string { } // RecalculateCaches recalculates caches on every view in the frame. -func (f *Frame) RecalculateCaches() { +func (f *Field) RecalculateCaches() { for _, view := range f.Views() { view.RecalculateCaches() } @@ -544,7 +544,7 @@ func (f *Frame) RecalculateCaches() { // CreateViewIfNotExists returns the named view, creating it if necessary. // Additionally, a CreateViewMessage is sent to the cluster. -func (f *Frame) CreateViewIfNotExists(name string) (*View, error) { +func (f *Field) CreateViewIfNotExists(name string) (*View, error) { view, created, err := f.createViewIfNotExistsBase(name) if err != nil { @@ -569,7 +569,7 @@ func (f *Frame) CreateViewIfNotExists(name string) (*View, error) { // createViewIfNotExistsBase returns the named view, creating it if necessary. // The returned bool indicates whether the view was created or not. -func (f *Frame) createViewIfNotExistsBase(name string) (*View, bool, error) { +func (f *Field) createViewIfNotExistsBase(name string) (*View, bool, error) { f.mu.Lock() defer f.mu.Unlock() @@ -588,7 +588,7 @@ func (f *Frame) createViewIfNotExistsBase(name string) (*View, bool, error) { return view, true, nil } -func (f *Frame) newView(path, name string) *View { +func (f *Field) newView(path, name string) *View { view := NewView(path, f.index, f.name, name, f.options.CacheSize) view.cacheType = f.options.CacheType view.Logger = f.Logger @@ -599,7 +599,7 @@ func (f *Frame) newView(path, name string) *View { } // DeleteView removes the view from the frame. -func (f *Frame) DeleteView(name string) error { +func (f *Field) DeleteView(name string) error { view := f.views[name] if view == nil { return ErrInvalidView @@ -621,7 +621,7 @@ func (f *Frame) DeleteView(name string) error { } // SetBit sets a bit on a view within the frame. -func (f *Frame) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { +func (f *Field) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { return false, ErrInvalidView @@ -663,7 +663,7 @@ func (f *Frame) SetBit(name string, rowID, colID uint64, t *time.Time) (changed } // ClearBit clears a bit within the frame. -func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { +func (f *Field) ClearBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { return false, ErrInvalidView @@ -705,7 +705,7 @@ func (f *Frame) ClearBit(name string, rowID, colID uint64, t *time.Time) (change } // Value reads a frame value for a column. -func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { +func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) { bsig := f.bsiGroup(f.name) if bsig == nil { return 0, false, ErrBSIGroupNotFound @@ -727,7 +727,7 @@ func (f *Frame) Value(columnID uint64) (value int64, exists bool, err error) { } // SetValue sets a frame value for a column. -func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) { +func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) { // Fetch bsiGroup and validate value. bsig := f.bsiGroup(f.name) if bsig == nil { @@ -752,7 +752,7 @@ func (f *Frame) SetValue(columnID uint64, value int64) (changed bool, err error) // Sum returns the sum and count for a frame. // An optional filtering row can be provided. -func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { +func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -772,7 +772,7 @@ func (f *Frame) Sum(filter *Row, name string) (sum, count int64, err error) { // Min returns the min for a frame. // An optional filtering row can be provided. -func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { +func (f *Field) Min(filter *Row, name string) (min, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -792,7 +792,7 @@ func (f *Frame) Min(filter *Row, name string) (min, count int64, err error) { // Max returns the max for a frame. // An optional filtering row can be provided. -func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { +func (f *Field) Max(filter *Row, name string) (max, count int64, err error) { bsig := f.bsiGroup(name) if bsig == nil { return 0, 0, ErrBSIGroupNotFound @@ -810,7 +810,7 @@ func (f *Frame) Max(filter *Row, name string) (max, count int64, err error) { return int64(vmax) + bsig.Min, int64(vcount), nil } -func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) { +func (f *Field) Range(name string, op pql.Token, predicate int64) (*Row, error) { // Retrieve and validate bsiGroup. bsig := f.bsiGroup(name) if bsig == nil { @@ -833,7 +833,7 @@ func (f *Frame) Range(name string, op pql.Token, predicate int64) (*Row, error) return view.rangeOp(op, bsig.BitDepth(), baseValue) } -func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { +func (f *Field) RangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { // Retrieve and validate bsiGroup. bsig := f.bsiGroup(name) if bsig == nil { @@ -857,7 +857,7 @@ func (f *Frame) RangeBetween(name string, predicateMin, predicateMax int64) (*Ro } // Import bulk imports data. -func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) error { +func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) error { // Determine quantum if timestamps are set. q := f.TimeQuantum() if hasTime(timestamps) && q == "" { @@ -914,7 +914,7 @@ func (f *Frame) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro } // ImportValue bulk imports range-encoded value data. -func (f *Frame) ImportValue(columnIDs []uint64, values []int64) error { +func (f *Field) ImportValue(columnIDs []uint64, values []int64) error { viewName := viewBSIGroupPrefix + f.name // Get the bsiGroup so we know bitDepth. bsig := f.bsiGroup(f.name) @@ -970,17 +970,17 @@ func (f *Frame) ImportValue(columnIDs []uint64, values []int64) error { return nil } -// encodeFrames converts a into its internal representation. -func encodeFrames(a []*Frame) []*internal.Frame { +// encodeFields converts a into its internal representation. +func encodeFields(a []*Field) []*internal.Frame { other := make([]*internal.Frame, len(a)) for i := range a { - other[i] = encodeFrame(a[i]) + other[i] = encodeField(a[i]) } return other } -// encodeFrame converts f into its internal representation. -func encodeFrame(f *Frame) *internal.Frame { +// encodeField converts f into its internal representation. +func encodeField(f *Field) *internal.Frame { fo := f.options return &internal.Frame{ Name: f.name, @@ -989,45 +989,45 @@ func encodeFrame(f *Frame) *internal.Frame { } } -type frameSlice []*Frame +type fieldSlice []*Field -func (p frameSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p frameSlice) Len() int { return len(p) } -func (p frameSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } +func (p fieldSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p fieldSlice) Len() int { return len(p) } +func (p fieldSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } -// FrameInfo represents schema information for a frame. -type FrameInfo struct { +// FieldInfo represents schema information for a frame. +type FieldInfo struct { Name string `json:"name"` - Options FrameOptions `json:"options"` + Options FieldOptions `json:"options"` Views []*ViewInfo `json:"views,omitempty"` } -type frameInfoSlice []*FrameInfo +type fieldInfoSlice []*FieldInfo -func (p frameInfoSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p frameInfoSlice) Len() int { return len(p) } -func (p frameInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } +func (p fieldInfoSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p fieldInfoSlice) Len() int { return len(p) } +func (p fieldInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } -// FrameOptions represents options to set when initializing a frame. -type FrameOptions struct { +// FieldOptions represents options to set when initializing a field. +type FieldOptions struct { Type string `json:"type,omitempty"` CacheType string `json:"cacheType,omitempty"` CacheSize uint32 `json:"cacheSize,omitempty"` Min int64 `json:"min,omitempty"` Max int64 `json:"max,omitempty"` - TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` // TODO: rename this Quantum? + TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"` } -// Validate ensures that FrameOption values are valid. -func (o *FrameOptions) Validate() error { +// Validate ensures that FieldOption values are valid. +func (o *FieldOptions) Validate() error { switch o.Type { - case FrameTypeSet, "": + case FieldTypeSet, "": // TODO: cacheType, cacheSize validation - case FrameTypeInt: + case FieldTypeInt: if o.Min > o.Max { return ErrInvalidBSIGroupRange } - case FrameTypeTime: + case FieldTypeTime: if o.TimeQuantum == "" || !o.TimeQuantum.Valid() { return ErrInvalidTimeQuantum } @@ -1038,11 +1038,11 @@ func (o *FrameOptions) Validate() error { } // Encode converts o into its internal representation. -func (o *FrameOptions) Encode() *internal.FrameMeta { - return encodeFrameOptions(o) +func (o *FieldOptions) Encode() *internal.FrameMeta { + return encodeFieldOptions(o) } -func encodeFrameOptions(o *FrameOptions) *internal.FrameMeta { +func encodeFieldOptions(o *FieldOptions) *internal.FrameMeta { if o == nil { return nil } @@ -1056,11 +1056,11 @@ func encodeFrameOptions(o *FrameOptions) *internal.FrameMeta { } } -func decodeFrameOptions(options *internal.FrameMeta) *FrameOptions { +func decodeFieldOptions(options *internal.FrameMeta) *FieldOptions { if options == nil { return nil } - return &FrameOptions{ + return &FieldOptions{ Type: options.Type, CacheType: options.CacheType, CacheSize: options.CacheSize, diff --git a/frame_test.go b/frame_test.go index 3964af785..99dea0938 100644 --- a/frame_test.go +++ b/frame_test.go @@ -50,10 +50,10 @@ func TestFrame_CreateViewIfNotExists(t *testing.T) { // Ensure frame can set its time quantum. func TestFrame_SetTimeQuantum(t *testing.T) { - fo := pilosa.FrameOptions{ + fo := pilosa.FieldOptions{ Type: "time", } - f := test.MustOpenFrame(pilosa.OptFrameFrameOptions(fo)) + f := test.MustOpenFrame(pilosa.OptFieldFieldOptions(fo)) defer f.Close() // Set & retrieve time quantum. @@ -77,8 +77,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 30, }) @@ -114,8 +114,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 0, Max: 30, }) @@ -151,8 +151,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeSet, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeSet, }) if err != nil { t.Fatal(err) @@ -168,8 +168,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 20, Max: 30, }) @@ -187,8 +187,8 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 20, Max: 30, }) @@ -208,7 +208,7 @@ func TestFrame_NameRestriction(t *testing.T) { if err != nil { panic(err) } - frame, err := pilosa.NewFrame(path, "i", ".meta") + frame, err := pilosa.NewField(path, "i", ".meta") if frame != nil { t.Fatalf("unexpected frame name %s", err) } @@ -240,13 +240,13 @@ func TestFrame_NameValidation(t *testing.T) { panic(err) } for _, name := range validFrameNames { - _, err := pilosa.NewFrame(path, "i", name) + _, err := pilosa.NewField(path, "i", name) if err != nil { t.Fatalf("unexpected frame name: %s %s", name, err) } } for _, name := range invalidFrameNames { - _, err := pilosa.NewFrame(path, "i", name) + _, err := pilosa.NewField(path, "i", name) if err == nil { t.Fatalf("expected error on frame name: %s", name) } diff --git a/handler.go b/handler.go index d4ed5ab37..4cc64fbb2 100644 --- a/handler.go +++ b/handler.go @@ -546,7 +546,7 @@ func (p *postFrameRequest) UnmarshalJSON(b []byte) error { return errors.Wrap(err, "unmarshaling unexpected keys") } - validFrameOptions := getValidOptions(FrameOptions{}) + validFrameOptions := getValidOptions(FieldOptions{}) err := validateOptions(m, validFrameOptions) if err != nil { return err @@ -575,7 +575,7 @@ func getValidOptions(option interface{}) []string { } type postFrameRequest struct { - Options FrameOptions `json:"options"` + Options FieldOptions `json:"options"` } type postFrameResponse struct{} diff --git a/handler_internal_test.go b/handler_internal_test.go index ceaeb707c..9adab16ac 100644 --- a/handler_internal_test.go +++ b/handler_internal_test.go @@ -62,12 +62,12 @@ func TestPostFrameRequestUnmarshalJSON(t *testing.T) { expected postFrameRequest err string }{ - {json: `{"options": {}}`, expected: postFrameRequest{Options: FrameOptions{}}}, + {json: `{"options": {}}`, expected: postFrameRequest{Options: FieldOptions{}}}, {json: `{"options": 4}`, err: "options is not map[string]interface{}"}, {json: `{"option": {}}`, err: "Unknown key: option:map[]"}, {json: `{"options": {"badKey": "test"}}`, err: "Unknown key: badKey:test"}, {json: `{"options": {"inverseEnabled": true}}`, err: "Unknown key: inverseEnabled:true"}, - {json: `{"options": {"cacheType": "type"}}`, expected: postFrameRequest{Options: FrameOptions{CacheType: "type"}}}, + {json: `{"options": {"cacheType": "type"}}`, expected: postFrameRequest{Options: FieldOptions{CacheType: "type"}}}, {json: `{"options": {"inverse": true, "cacheType": "type"}}`, err: "Unknown key: inverse:true"}, } for _, test := range tests { diff --git a/handler_test.go b/handler_test.go index 30bba9254..c378a30cf 100644 --- a/handler_test.go +++ b/handler_test.go @@ -83,17 +83,17 @@ func TestHandler_Schema(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -120,17 +120,17 @@ func TestHandler_Status(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -699,7 +699,7 @@ func TestHandler_DeleteFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) - if _, err := i0.CreateFrameIfNotExists("f1", pilosa.FrameOptions{}); err != nil { + if _, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -777,7 +777,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) { // Set attributes on the index. idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("meta", pilosa.FrameOptions{}) + f, err := idx.CreateFrameIfNotExists("meta", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/holder.go b/holder.go index 6d13159b9..3a3bcca0c 100644 --- a/holder.go +++ b/holder.go @@ -215,14 +215,14 @@ func (h *Holder) Schema() []*IndexInfo { for _, index := range h.Indexes() { di := &IndexInfo{Name: index.Name()} for _, frame := range index.Frames() { - fi := &FrameInfo{Name: frame.Name(), Options: frame.Options()} + fi := &FieldInfo{Name: frame.Name(), Options: frame.Options()} for _, view := range frame.Views() { fi.Views = append(fi.Views, &ViewInfo{Name: view.Name()}) } sort.Sort(viewInfoSlice(fi.Views)) di.Frames = append(di.Frames, fi) } - sort.Sort(frameInfoSlice(di.Frames)) + sort.Sort(fieldInfoSlice(di.Frames)) a = append(a, di) } sort.Sort(indexInfoSlice(a)) @@ -240,7 +240,7 @@ func (h *Holder) ApplySchema(schema *internal.Schema) error { } // Create frames that don't exist. for _, f := range index.Frames { - opt := decodeFrameOptions(f.Meta) + opt := decodeFieldOptions(f.Meta) frame, err := idx.CreateFrameIfNotExists(f.Name, *opt) if err != nil { return errors.Wrap(err, "creating frame") @@ -391,7 +391,7 @@ func (h *Holder) DeleteIndex(name string) error { } // Frame returns the frame for an index and name. -func (h *Holder) Frame(index, name string) *Frame { +func (h *Holder) Frame(index, name string) *Field { idx := h.Index(index) if idx == nil { return nil diff --git a/holder_test.go b/holder_test.go index c7877e3ba..0081b105c 100644 --- a/holder_test.go +++ b/holder_test.go @@ -100,7 +100,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -119,7 +119,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -137,7 +137,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -159,7 +159,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -183,7 +183,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -208,7 +208,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -231,7 +231,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -257,7 +257,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FrameOptions{}); err != nil { + } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) diff --git a/index.go b/index.go index 7829903aa..8421f8273 100644 --- a/index.go +++ b/index.go @@ -35,7 +35,7 @@ type Index struct { name string // Frames by name. - frames map[string]*Frame + frames map[string]*Field // Max Slice on any node in the cluster, according to this node. remoteMaxSlice uint64 @@ -61,7 +61,7 @@ func NewIndex(path, name string) (*Index, error) { return &Index{ path: path, name: name, - frames: make(map[string]*Frame), + frames: make(map[string]*Field), remoteMaxSlice: 0, @@ -203,7 +203,7 @@ func (i *Index) Close() error { return errors.Wrap(err, "closing frame") } } - i.frames = make(map[string]*Frame) + i.frames = make(map[string]*Field) return nil } @@ -238,24 +238,24 @@ func (i *Index) SetRemoteMaxSlice(newmax uint64) { func (i *Index) FramePath(name string) string { return filepath.Join(i.path, name) } // Frame returns a frame in the index by name. -func (i *Index) Frame(name string) *Frame { +func (i *Index) Frame(name string) *Field { i.mu.RLock() defer i.mu.RUnlock() return i.frame(name) } -func (i *Index) frame(name string) *Frame { return i.frames[name] } +func (i *Index) frame(name string) *Field { return i.frames[name] } // Frames returns a list of all frames in the index. -func (i *Index) Frames() []*Frame { +func (i *Index) Frames() []*Field { i.mu.RLock() defer i.mu.RUnlock() - a := make([]*Frame, 0, len(i.frames)) + a := make([]*Field, 0, len(i.frames)) for _, f := range i.frames { a = append(a, f) } - sort.Sort(frameSlice(a)) + sort.Sort(fieldSlice(a)) return a } @@ -268,7 +268,7 @@ func (i *Index) RecalculateCaches() { } // CreateFrame creates a frame. -func (i *Index) CreateFrame(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) CreateFrame(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() @@ -280,7 +280,7 @@ func (i *Index) CreateFrame(name string, opt FrameOptions) (*Frame, error) { } // CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) CreateFrameIfNotExists(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() @@ -292,7 +292,7 @@ func (i *Index) CreateFrameIfNotExists(name string, opt FrameOptions) (*Frame, e return i.createFrame(name, opt) } -func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { +func (i *Index) createFrame(name string, opt FieldOptions) (*Field, error) { if name == "" { return nil, errors.New("frame name required") } else if opt.CacheType != "" && !IsValidCacheType(opt.CacheType) { @@ -332,8 +332,8 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { return f, nil } -func (i *Index) newFrame(path, name string) (*Frame, error) { - f, err := NewFrame(path, i.name, name) +func (i *Index) newFrame(path, name string) (*Field, error) { + f, err := NewField(path, i.name, name) if err != nil { return nil, err } @@ -380,7 +380,7 @@ func (p indexSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } // IndexInfo represents schema information for an index. type IndexInfo struct { Name string `json:"name"` - Frames []*FrameInfo `json:"frames"` + Frames []*FieldInfo `json:"frames"` } type indexInfoSlice []*IndexInfo @@ -402,7 +402,7 @@ func EncodeIndexes(a []*Index) []*internal.Index { func encodeIndex(d *Index) *internal.Index { return &internal.Index{ Name: d.name, - Frames: encodeFrames(d.Frames()), + Frames: encodeFields(d.Frames()), } } diff --git a/index_test.go b/index_test.go index 86d9043ce..be6288ad8 100644 --- a/index_test.go +++ b/index_test.go @@ -29,7 +29,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { defer index.Close() // Create frame. - f, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) + f, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f == nil { @@ -37,14 +37,14 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { } // Retrieve existing frame. - other, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}) + other, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) - } else if f.Frame != other.Frame { + } else if f.Field != other.Field { t.Fatal("frame mismatch") } - if f.Frame != index.Frame("f") { + if f.Field != index.Frame("f") { t.Fatal("frame mismatch") } } @@ -57,8 +57,8 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with explicit quantum. - f, err := index.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeTime, + f, err := index.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }) if err != nil { @@ -76,20 +76,20 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with schema and verify it exists. - if f, err := index.CreateFrame("f", pilosa.FrameOptions{ - Type: pilosa.FrameTypeInt, + if f, err := index.CreateFrame("f", pilosa.FieldOptions{ + Type: pilosa.FieldTypeInt, Min: 10, Max: 20, }); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + } else if !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { t.Fatalf("unexpected type: %#v", f.Type()) } // Reopen the index & verify the fields are loaded. if err := index.Reopen(); err != nil { t.Fatal(err) - } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FrameTypeInt) { + } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { t.Fatalf("unexpected type after reopen: %#v", f.Type()) } }) @@ -180,7 +180,7 @@ func TestIndex_DeleteFrame(t *testing.T) { defer index.Close() // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FrameOptions{}); err != nil { + if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/server.go b/server.go index 02e56e9b0..d0585c992 100644 --- a/server.go +++ b/server.go @@ -460,7 +460,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if idx == nil { return fmt.Errorf("Local Index not found: %s", obj.Index) } - opt := decodeFrameOptions(obj.Meta) + opt := decodeFieldOptions(obj.Meta) _, err := idx.CreateFrame(obj.Frame, *opt) if err != nil { return err diff --git a/server/cluster_test.go b/server/cluster_test.go index e6777d90c..1b4e0b807 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -54,7 +54,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -209,7 +209,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -253,7 +253,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -305,7 +305,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -458,7 +458,7 @@ func TestClusterResize_RemoveNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{}); err != nil { + } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/server/server_test.go b/server/server_test.go index edac4b6fd..920fde809 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -54,7 +54,7 @@ func TestMain_Set_Quick(t *testing.T) { if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && !strings.Contains(err.Error(), "index already exists") { t.Fatal(err) } - if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FrameOptions{}); err != nil && !strings.Contains(err.Error(), "frame already exists") { + if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && !strings.Contains(err.Error(), "frame already exists") { t.Fatal(err) } if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, frame=%q, col=%d)`, cmd.ID, cmd.Frame, cmd.ColumnID)); err != nil { @@ -123,11 +123,11 @@ func TestMain_SetRowAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "z", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "z", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "neg", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "neg", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -200,7 +200,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FrameOptions{}); err != nil { + } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -286,7 +286,7 @@ func TestMain_RecalculateHashes(t *testing.T) { if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal("create index:", err) } - if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{CacheType: "ranked"}); err != nil { + if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{CacheType: "ranked"}); err != nil { t.Fatal("create frame:", err) } diff --git a/server_test.go b/server_test.go index 9e10374d7..9b5409330 100644 --- a/server_test.go +++ b/server_test.go @@ -19,7 +19,7 @@ func TestMonitorAntiEntropy(t *testing.T) { if err != nil { t.Fatalf("creating index: %v", err) } - err = client.CreateFrame(context.Background(), "balh", "fralh", pilosa.FrameOptions{}) + err = client.CreateFrame(context.Background(), "balh", "fralh", pilosa.FieldOptions{}) if err != nil { t.Fatalf("creating frame: %v", err) } diff --git a/stats_test.go b/stats_test.go index 611b7b2b6..47521fbf8 100644 --- a/stats_test.go +++ b/stats_test.go @@ -298,7 +298,7 @@ func TestStatsCount_DeleteFrame(t *testing.T) { called := false // Create index. indx, _ := hldr.CreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := indx.CreateFrameIfNotExists("test", pilosa.FrameOptions{}); err != nil { + if _, err := indx.CreateFrameIfNotExists("test", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } s.Handler.API.Holder.Stats = &MockStats{ diff --git a/test/cluster.go b/test/cluster.go index bf6858e79..4c0bd45a0 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -114,7 +114,7 @@ func (t *TestCluster) CreateIndex(name string) error { return nil } -func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FrameOptions) error { +func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, pilosa.IndexOptions{}) if err != nil { diff --git a/test/frame.go b/test/frame.go index 09503a3cf..929070368 100644 --- a/test/frame.go +++ b/test/frame.go @@ -25,24 +25,24 @@ import ( // Frame represents a test wrapper for pilosa.Frame. type Frame struct { - *pilosa.Frame + *pilosa.Field } // NewFrame returns a new instance of Frame d/0. -func NewFrame(opt ...pilosa.FrameOption) *Frame { +func NewFrame(opt ...pilosa.FieldOption) *Frame { path, err := ioutil.TempDir("", "pilosa-frame-") if err != nil { panic(err) } - frame, err := pilosa.NewFrame(path, "i", "f", opt...) + frame, err := pilosa.NewField(path, "i", "f", opt...) if err != nil { panic(err) } - return &Frame{Frame: frame} + return &Frame{Field: frame} } // MustOpenFrame returns a new, opened frame at a temporary path. Panic on error. -func MustOpenFrame(opt ...pilosa.FrameOption) *Frame { +func MustOpenFrame(opt ...pilosa.FieldOption) *Frame { f := NewFrame(opt...) if err := f.Open(); err != nil { panic(err) @@ -53,18 +53,18 @@ func MustOpenFrame(opt ...pilosa.FrameOption) *Frame { // Close closes the frame and removes the underlying data. func (f *Frame) Close() error { defer os.RemoveAll(f.Path()) - return f.Frame.Close() + return f.Field.Close() } // Reopen closes the index and reopens it. func (f *Frame) Reopen() error { var err error - if err := f.Frame.Close(); err != nil { + if err := f.Field.Close(); err != nil { return err } path, index, name := f.Path(), f.Index(), f.Name() - f.Frame, err = pilosa.NewFrame(path, index, name) + f.Field, err = pilosa.NewField(path, index, name) if err != nil { return err } diff --git a/test/holder.go b/test/holder.go index 97b399bea..1344bd4c9 100644 --- a/test/holder.go +++ b/test/holder.go @@ -82,7 +82,7 @@ func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOption // MustCreateFrameIfNotExists returns a given frame. Panic on error. func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { - f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFrameIfNotExists(frame, pilosa.FrameOptions{}) + f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -92,7 +92,7 @@ func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { // MustCreateFragmentIfNotExists returns a given fragment. Panic on error. func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FrameOptions{}) + f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -110,7 +110,7 @@ func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice // MustCreateRankedFragmentIfNotExists returns a given fragment with a ranked cache. Panic on error. func (h *Holder) MustCreateRankedFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FrameOptions{CacheType: pilosa.CacheTypeRanked}) + f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { panic(err) } diff --git a/test/index.go b/test/index.go index 5354c85f9..5689afda3 100644 --- a/test/index.go +++ b/test/index.go @@ -74,19 +74,19 @@ func (i *Index) Reopen() error { } // CreateFrame creates a frame with the given options. -func (i *Index) CreateFrame(name string, opt pilosa.FrameOptions) (*Frame, error) { +func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error) { f, err := i.Index.CreateFrame(name, opt) if err != nil { return nil, err } - return &Frame{Frame: f}, nil + return &Frame{Field: f}, nil } // CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FrameOptions) (*Frame, error) { +func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FieldOptions) (*Frame, error) { f, err := i.Index.CreateFrameIfNotExists(name, opt) if err != nil { return nil, err } - return &Frame{Frame: f}, nil + return &Frame{Field: f}, nil } diff --git a/utils_test.go b/utils_test.go index eb4170a19..7773db06c 100644 --- a/utils_test.go +++ b/utils_test.go @@ -104,7 +104,7 @@ func (t *ClusterCluster) CreateIndex(name string) error { return nil } -func (t *ClusterCluster) CreateFrame(index, frame string, opt FrameOptions) error { +func (t *ClusterCluster) CreateFrame(index, frame string, opt FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, IndexOptions{}) if err != nil { From 3531c128c4fddaee2c16d5373fbc8925fc8e05a5 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:33:48 -0500 Subject: [PATCH 36/52] GoRename Frame to Field in index.go --- api.go | 18 ++++---- client.go | 14 +++---- cluster.go | 4 +- cluster_internal_test.go | 2 +- ctl/export.go | 2 +- ctl/export_test.go | 4 +- ctl/import.go | 4 +- ctl/import_test.go | 4 +- diagnostics.go | 2 +- executor.go | 26 ++++++------ executor_test.go | 28 ++++++------- fragment_test.go | 2 +- handler.go | 6 +-- handler_test.go | 2 +- holder.go | 20 ++++----- holder_test.go | 16 ++++---- index.go | 88 ++++++++++++++++++++-------------------- index_test.go | 10 ++--- pilosa.go | 8 ++-- server.go | 4 +- server/cluster_test.go | 4 +- stats_test.go | 2 +- test/cluster.go | 2 +- test/index.go | 4 +- utils_test.go | 2 +- 25 files changed, 139 insertions(+), 139 deletions(-) diff --git a/api.go b/api.go index fec6b3129..d47ba1ff4 100644 --- a/api.go +++ b/api.go @@ -230,7 +230,7 @@ func (api *API) CreateFrame(ctx context.Context, indexName string, frameName str } // Create frame. - frame, err := index.CreateFrame(frameName, options) + frame, err := index.CreateField(frameName, options) if err != nil { return nil, errors.Wrap(err, "creating frame") } @@ -265,7 +265,7 @@ func (api *API) DeleteFrame(ctx context.Context, indexName string, frameName str } // Delete frame from the index. - if err := index.DeleteFrame(frameName); err != nil { + if err := index.DeleteField(frameName); err != nil { return errors.Wrap(err, "deleting frame") } @@ -357,7 +357,7 @@ func (api *API) UnmarshalFragment(ctx context.Context, indexName string, frameNa // Retrieve frame. f := api.Holder.Frame(indexName, frameName) if f == nil { - return ErrFrameNotFound + return ErrFieldNotFound } // Retrieve view. @@ -497,7 +497,7 @@ func (api *API) Views(ctx context.Context, indexName string, frameName string) ( // Retrieve views. f := api.Holder.Frame(indexName, frameName) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } // Fetch views. @@ -514,7 +514,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, frameName stri // Retrieve frame. f := api.Holder.Frame(indexName, frameName) if f == nil { - return ErrFrameNotFound + return ErrFieldNotFound } // Delete the view. @@ -582,7 +582,7 @@ func (api *API) FrameAttrDiff(ctx context.Context, indexName string, frameName s // Retrieve index from holder. f := api.Holder.Frame(indexName, frameName) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } // Retrieve local blocks. @@ -695,10 +695,10 @@ func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*I } // Retrieve frame. - frame := index.Frame(frameName) + frame := index.Field(frameName) if frame == nil { - api.Logger.Printf("frame error: index=%s, frame=%s, slice=%d, err=%s", indexName, frameName, slice, ErrFrameNotFound.Error()) - return nil, nil, ErrFrameNotFound + api.Logger.Printf("frame error: index=%s, frame=%s, slice=%d, err=%s", indexName, frameName, slice, ErrFieldNotFound.Error()) + return nil, nil, ErrFieldNotFound } return index, frame, nil } diff --git a/client.go b/client.go index 4c8ba2157..d186746c7 100644 --- a/client.go +++ b/client.go @@ -273,7 +273,7 @@ func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, sl if index == "" { return ErrIndexRequired } else if frame == "" { - return ErrFrameRequired + return ErrFieldRequired } buf, err := marshalImportPayload(index, frame, slice, bits) @@ -302,7 +302,7 @@ func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, c if index == "" { return ErrIndexRequired } else if frame == "" { - return ErrFrameRequired + return ErrFieldRequired } buf, err := marshalImportPayloadK(index, frame, columns) @@ -332,7 +332,7 @@ func (c *InternalHTTPClient) EnsureIndex(ctx context.Context, name string, optio func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error { err := c.CreateFrame(ctx, indexName, frameName, options) - if err == nil || err == ErrFrameExists { + if err == nil || err == ErrFieldExists { return nil } return err @@ -424,7 +424,7 @@ func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame strin if index == "" { return ErrIndexRequired } else if frame == "" { - return ErrFrameRequired + return ErrFieldRequired } buf, err := marshalImportValuePayload(index, frame, slice, vals) @@ -511,7 +511,7 @@ func (c *InternalHTTPClient) ExportCSV(ctx context.Context, index, frame string, if index == "" { return ErrIndexRequired } else if frame == "" { - return ErrFrameRequired + return ErrFieldRequired } // Retrieve a list of nodes that own the slice. @@ -658,7 +658,7 @@ func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame strin case http.StatusOK: return nil // ok case http.StatusConflict: - return ErrFrameExists + return ErrFieldExists default: return errors.New(string(body)) } @@ -822,7 +822,7 @@ func (c *InternalHTTPClient) RowAttrDiff(ctx context.Context, index, frame strin switch resp.StatusCode { case http.StatusOK: // ok case http.StatusNotFound: - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound default: return nil, fmt.Errorf("unexpected status: code=%d", resp.StatusCode) } diff --git a/cluster.go b/cluster.go index 63f4f62b8..deabf2d06 100644 --- a/cluster.go +++ b/cluster.go @@ -627,7 +627,7 @@ func (c *Cluster) fragsByHost(idx *Index) fragsByHost { // frameViews is a map of frame to slice of views. frameViews := make(viewsByFrame) - for _, frame := range idx.Frames() { + for _, frame := range idx.Fields() { for _, view := range frame.Views() { frameViews.addView(frame.Name(), view.Name()) @@ -1242,7 +1242,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err // Retrieve frame. f := c.Holder.Frame(src.Index, src.Frame) if f == nil { - return ErrFrameNotFound + return ErrFieldNotFound } // Create view. diff --git a/cluster_internal_test.go b/cluster_internal_test.go index acccd37d3..9453fc16b 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -145,7 +145,7 @@ func TestFragSources(t *testing.T) { c5.addNodeBasicSorted(node3) idx := newIndexWithTempPath("i") - frame, err := idx.CreateFrameIfNotExists("f", FieldOptions{}) + frame, err := idx.CreateFieldIfNotExists("f", FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/ctl/export.go b/ctl/export.go index 5ee8d2120..988403272 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -58,7 +58,7 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { if cmd.Index == "" { return pilosa.ErrIndexRequired } else if cmd.Frame == "" { - return pilosa.ErrFrameRequired + return pilosa.ErrFieldRequired } // Use output file, if specified. diff --git a/ctl/export_test.go b/ctl/export_test.go index 469ca7d75..6948b810f 100644 --- a/ctl/export_test.go +++ b/ctl/export_test.go @@ -38,8 +38,8 @@ func TestExportCommand_Validation(t *testing.T) { cm.Index = "i" err = cm.Run(context.Background()) - if err != pilosa.ErrFrameRequired { - t.Fatalf("Command not working, expect: %s, actual: '%s'", pilosa.ErrFrameRequired, err) + if err != pilosa.ErrFieldRequired { + t.Fatalf("Command not working, expect: %s, actual: '%s'", pilosa.ErrFieldRequired, err) } } diff --git a/ctl/import.go b/ctl/import.go index 3a7835cb2..68229ed72 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -84,7 +84,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { if cmd.Index == "" { return pilosa.ErrIndexRequired } else if cmd.Frame == "" { - return pilosa.ErrFrameRequired + return pilosa.ErrFieldRequired } else if len(cmd.Paths) == 0 { return errors.New("path required") } @@ -110,7 +110,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } for _, index := range schema { if index.Name == cmd.Index { - for _, frame := range index.Frames { + for _, frame := range index.Fields { if frame.Name == cmd.Frame { frameType = frame.Options.Type } diff --git a/ctl/import_test.go b/ctl/import_test.go index 7c64944f6..9b6dd3c6e 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -39,8 +39,8 @@ func TestImportCommand_Validation(t *testing.T) { cm.Index = "i" err = cm.Run(context.Background()) - if err != pilosa.ErrFrameRequired { - t.Fatalf("Command not working, expect: %s, actual: '%s'", pilosa.ErrFrameRequired, err) + if err != pilosa.ErrFieldRequired { + t.Fatalf("Command not working, expect: %s, actual: '%s'", pilosa.ErrFieldRequired, err) } cm.Frame = "f" diff --git a/diagnostics.go b/diagnostics.go index 10ecfa22d..f97f5f6aa 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -225,7 +225,7 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { for _, index := range d.server.Holder.Indexes() { numSlices += index.MaxSlice() + 1 numIndexes += 1 - for _, frame := range index.Frames() { + for _, frame := range index.Fields() { numFrames += 1 if frame.Type() == FieldTypeInt { bsiFieldCount += 1 diff --git a/executor.go b/executor.go index fd98f7189..b3e4f5aad 100644 --- a/executor.go +++ b/executor.go @@ -313,7 +313,7 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C return nil, err } else { frame, _ := c.Args["frame"].(string) - if fr := idx.Frame(frame); fr != nil { + if fr := idx.Field(frame); fr != nil { rowID, _, err := c.UintArg(rowLabel) if err != nil { return nil, errors.Wrap(err, "getting row") @@ -634,7 +634,7 @@ func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql. } f := e.Holder.Frame(index, frame) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } rowID, rowOK, rowErr := c.UintArg(rowLabel) @@ -694,9 +694,9 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C } // Retrieve base frame. - f := idx.Frame(frame) + f := idx.Field(frame) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } // Read row & column id. @@ -769,7 +769,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, f := e.Holder.Frame(index, frameName) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } // EQ null (not implemented: flip frag.NotNull with max ColumnID) @@ -959,9 +959,9 @@ func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Cal if idx == nil { return false, ErrIndexNotFound } - f := idx.Frame(frame) + f := idx.Field(frame) if f == nil { - return false, ErrFrameNotFound + return false, ErrFieldNotFound } // Read fields using labels. @@ -1024,9 +1024,9 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call, if idx == nil { return false, ErrIndexNotFound } - f := idx.Frame(frame) + f := idx.Field(frame) if f == nil { - return false, ErrFrameNotFound + return false, ErrFieldNotFound } // Read fields using labels. @@ -1110,7 +1110,7 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal // Retrieve frame. frame := e.Holder.Frame(index, name) if frame == nil { - return ErrFrameNotFound + return ErrFieldNotFound } switch value := value.(type) { @@ -1159,7 +1159,7 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql. // Retrieve frame. frame := e.Holder.Frame(index, frameName) if frame == nil { - return ErrFrameNotFound + return ErrFieldNotFound } // Parse labels. @@ -1219,7 +1219,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal // Retrieve frame. f := e.Holder.Frame(index, frame) if f == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } rowID, ok, err := c.UintArg(rowLabel) @@ -1257,7 +1257,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal // Retrieve frame. frame := e.Holder.Frame(index, name) if frame == nil { - return nil, ErrFrameNotFound + return nil, ErrFieldNotFound } // Set attributes. diff --git a/executor_test.go b/executor_test.go index 0d70ae37f..b8f7aa317 100644 --- a/executor_test.go +++ b/executor_test.go @@ -388,9 +388,9 @@ func TestExecutor_Execute_TopN(t *testing.T) { // Set columns for rows 0, 10, & 20 across two slices. if idx, err := hldr.CreateIndex("i", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { + } else if _, err := idx.CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("other", pilosa.FieldOptions{}); err != nil { + } else if _, err := idx.CreateField("other", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := e.Execute(context.Background(), "i", test.MustParse(` SetBit(frame=f, row=0, col=0) @@ -572,11 +572,11 @@ func TestExecutor_Execute_MinMax(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { + if _, err := idx.CreateField("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FieldOptions{ + if _, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: -10, Max: 100, @@ -667,11 +667,11 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("x", pilosa.FieldOptions{}); err != nil { + if _, err := idx.CreateField("x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + if _, err := idx.CreateField("foo", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 10, Max: 100, @@ -679,7 +679,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + if _, err := idx.CreateField("bar", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, @@ -687,7 +687,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + if _, err := idx.CreateField("other", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, @@ -780,11 +780,11 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("f", pilosa.FieldOptions{}); err != nil { + if _, err := idx.CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - if _, err := idx.CreateFrame("foo", pilosa.FieldOptions{ + if _, err := idx.CreateField("foo", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 10, Max: 100, @@ -792,7 +792,7 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{ + if _, err := idx.CreateField("bar", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 100000, @@ -800,7 +800,7 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("other", pilosa.FieldOptions{ + if _, err := idx.CreateField("other", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 1000, @@ -808,7 +808,7 @@ func TestExecutor_Execute_Range(t *testing.T) { t.Fatal(err) } - if _, err := idx.CreateFrame("edge", pilosa.FieldOptions{ + if _, err := idx.CreateField("edge", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: -100, Max: 100, @@ -945,7 +945,7 @@ func TestExecutor_Execute_Range(t *testing.T) { }) t.Run("ErrFrameNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(bad_frame >= 20)`), nil, nil); err != pilosa.ErrFrameNotFound { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(bad_frame >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { t.Fatal(err) } }) diff --git a/fragment_test.go b/fragment_test.go index 2d618aa81..71dff2b71 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -961,7 +961,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) { } // Re-fetch fragment. - f = index.Frame("f").View(pilosa.ViewStandard).Fragment(0) + f = index.Field("f").View(pilosa.ViewStandard).Fragment(0) // Re-verify correct cache type and size. if cache, ok := f.Cache().(*pilosa.RankCache); !ok { diff --git a/handler.go b/handler.go index 4cc64fbb2..a57a40204 100644 --- a/handler.go +++ b/handler.go @@ -522,7 +522,7 @@ func (h *Handler) handlePostFrame(w http.ResponseWriter, r *http.Request) { switch errors.Cause(err) { case ErrIndexNotFound: http.Error(w, err.Error(), http.StatusNotFound) - case ErrFrameExists: + case ErrFieldExists: http.Error(w, err.Error(), http.StatusConflict) default: http.Error(w, err.Error(), http.StatusInternalServerError) @@ -749,7 +749,7 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { switch errors.Cause(err) { case ErrIndexNotFound: fallthrough - case ErrFrameNotFound: + case ErrFieldNotFound: http.Error(w, err.Error(), http.StatusNotFound) case ErrClusterDoesNotOwnSlice: http.Error(w, err.Error(), http.StatusPreconditionFailed) @@ -802,7 +802,7 @@ func (h *Handler) handlePostImportValue(w http.ResponseWriter, r *http.Request) switch errors.Cause(err) { case ErrIndexNotFound: fallthrough - case ErrFrameNotFound: + case ErrFieldNotFound: http.Error(w, err.Error(), http.StatusNotFound) case ErrClusterDoesNotOwnSlice: http.Error(w, err.Error(), http.StatusPreconditionFailed) diff --git a/handler_test.go b/handler_test.go index c378a30cf..74b1702fa 100644 --- a/handler_test.go +++ b/handler_test.go @@ -712,7 +712,7 @@ func TestHandler_DeleteFrame(t *testing.T) { t.Fatalf("unexpected status code: %d", w.Code) } else if body := w.Body.String(); body != `{}`+"\n" { t.Fatalf("unexpected body: %s", body) - } else if f := hldr.Index("i0").Frame("f1"); f != nil { + } else if f := hldr.Index("i0").Field("f1"); f != nil { t.Fatal("expected nil frame") } } diff --git a/holder.go b/holder.go index 3a3bcca0c..f0c6d027c 100644 --- a/holder.go +++ b/holder.go @@ -214,15 +214,15 @@ func (h *Holder) Schema() []*IndexInfo { var a []*IndexInfo for _, index := range h.Indexes() { di := &IndexInfo{Name: index.Name()} - for _, frame := range index.Frames() { + for _, frame := range index.Fields() { fi := &FieldInfo{Name: frame.Name(), Options: frame.Options()} for _, view := range frame.Views() { fi.Views = append(fi.Views, &ViewInfo{Name: view.Name()}) } sort.Sort(viewInfoSlice(fi.Views)) - di.Frames = append(di.Frames, fi) + di.Fields = append(di.Fields, fi) } - sort.Sort(fieldInfoSlice(di.Frames)) + sort.Sort(fieldInfoSlice(di.Fields)) a = append(a, di) } sort.Sort(indexInfoSlice(a)) @@ -241,7 +241,7 @@ func (h *Holder) ApplySchema(schema *internal.Schema) error { // Create frames that don't exist. for _, f := range index.Frames { opt := decodeFieldOptions(f.Meta) - frame, err := idx.CreateFrameIfNotExists(f.Name, *opt) + frame, err := idx.CreateFieldIfNotExists(f.Name, *opt) if err != nil { return errors.Wrap(err, "creating frame") } @@ -396,7 +396,7 @@ func (h *Holder) Frame(index, name string) *Field { if idx == nil { return nil } - return idx.Frame(name) + return idx.Field(name) } // View returns the view for an index, frame, and name. @@ -435,7 +435,7 @@ func (h *Holder) monitorCacheFlush() { func (h *Holder) flushCaches() { for _, index := range h.Indexes() { - for _, frame := range index.Frames() { + for _, frame := range index.Fields() { for _, view := range frame.Views() { for _, fragment := range view.Fragments() { select { @@ -600,7 +600,7 @@ func (s *HolderSyncer) SyncHolder() error { } tf := time.Now() - for _, fi := range di.Frames { + for _, fi := range di.Fields { // Verify syncer has not closed. if s.IsClosing() { return nil @@ -713,7 +713,7 @@ func (s *HolderSyncer) syncFrame(index, name string) error { // Retrieve attributes from differing blocks. // Skip update and recomputation if no attributes have changed. m, err := client.RowAttrDiff(context.Background(), index, name, blks) - if err == ErrFrameNotFound { + if err == ErrFieldNotFound { continue // frame not created remotely yet, skip } else if err != nil { return errors.Wrap(err, "getting differing blocks") @@ -742,7 +742,7 @@ func (s *HolderSyncer) syncFragment(index, frame, view string, slice uint64) err // Retrieve local frame. f := s.Holder.Frame(index, frame) if f == nil { - return ErrFrameNotFound + return ErrFieldNotFound } // Ensure view exists locally. @@ -806,7 +806,7 @@ func (c *HolderCleaner) CleanHolder() error { containedSlices := c.Cluster.ContainsSlices(index.Name(), index.MaxSlice(), c.Node) // Get the fragments registered in memory. - for _, frame := range index.Frames() { + for _, frame := range index.Fields() { for _, view := range frame.Views() { for _, fragment := range view.Fragments() { fragSlice := fragment.Slice() diff --git a/holder_test.go b/holder_test.go index 0081b105c..664bf16a0 100644 --- a/holder_test.go +++ b/holder_test.go @@ -100,7 +100,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if _, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -119,7 +119,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if _, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -137,7 +137,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if _, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if _, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -159,7 +159,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -183,7 +183,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -208,7 +208,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -231,7 +231,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) @@ -257,7 +257,7 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateFrame("bar", pilosa.FieldOptions{}); err != nil { + } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) diff --git a/index.go b/index.go index 8421f8273..727989914 100644 --- a/index.go +++ b/index.go @@ -34,8 +34,8 @@ type Index struct { path string name string - // Frames by name. - frames map[string]*Field + // Fields by name. + fields map[string]*Field // Max Slice on any node in the cluster, according to this node. remoteMaxSlice uint64 @@ -61,7 +61,7 @@ func NewIndex(path, name string) (*Index, error) { return &Index{ path: path, name: name, - frames: make(map[string]*Field), + fields: make(map[string]*Field), remoteMaxSlice: 0, @@ -106,7 +106,7 @@ func (i *Index) Open() error { return errors.Wrap(err, "loading meta file") } - if err := i.openFrames(); err != nil { + if err := i.openFields(); err != nil { return errors.Wrap(err, "opening frames") } @@ -117,8 +117,8 @@ func (i *Index) Open() error { return nil } -// openFrames opens and initializes the frames inside the index. -func (i *Index) openFrames() error { +// openFields opens and initializes the frames inside the index. +func (i *Index) openFields() error { f, err := os.Open(i.path) if err != nil { return errors.Wrap(err, "opening directory") @@ -135,14 +135,14 @@ func (i *Index) openFrames() error { continue } - fr, err := i.newFrame(i.FramePath(filepath.Base(fi.Name())), filepath.Base(fi.Name())) + fld, err := i.newField(i.FieldPath(filepath.Base(fi.Name())), filepath.Base(fi.Name())) if err != nil { return ErrName } - if err := fr.Open(); err != nil { - return fmt.Errorf("open frame: name=%s, err=%s", fr.Name(), err) + if err := fld.Open(); err != nil { + return fmt.Errorf("open frame: name=%s, err=%s", fld.Name(), err) } - i.frames[fr.Name()] = fr + i.fields[fld.Name()] = fld } return nil } @@ -198,12 +198,12 @@ func (i *Index) Close() error { i.columnAttrStore.Close() // Close all frames. - for _, f := range i.frames { + for _, f := range i.fields { if err := f.Close(); err != nil { return errors.Wrap(err, "closing frame") } } - i.frames = make(map[string]*Field) + i.fields = make(map[string]*Field) return nil } @@ -217,7 +217,7 @@ func (i *Index) MaxSlice() uint64 { defer i.mu.RUnlock() max := i.remoteMaxSlice - for _, f := range i.frames { + for _, f := range i.fields { if slice := f.MaxSlice(); slice > max { max = slice } @@ -234,25 +234,25 @@ func (i *Index) SetRemoteMaxSlice(newmax uint64) { i.remoteMaxSlice = newmax } -// FramePath returns the path to a frame in the index. -func (i *Index) FramePath(name string) string { return filepath.Join(i.path, name) } +// FieldPath returns the path to a field in the index. +func (i *Index) FieldPath(name string) string { return filepath.Join(i.path, name) } -// Frame returns a frame in the index by name. -func (i *Index) Frame(name string) *Field { +// Field returns a frame in the index by name. +func (i *Index) Field(name string) *Field { i.mu.RLock() defer i.mu.RUnlock() - return i.frame(name) + return i.field(name) } -func (i *Index) frame(name string) *Field { return i.frames[name] } +func (i *Index) field(name string) *Field { return i.fields[name] } -// Frames returns a list of all frames in the index. -func (i *Index) Frames() []*Field { +// Fields returns a list of all fields in the index. +func (i *Index) Fields() []*Field { i.mu.RLock() defer i.mu.RUnlock() - a := make([]*Field, 0, len(i.frames)) - for _, f := range i.frames { + a := make([]*Field, 0, len(i.fields)) + for _, f := range i.fields { a = append(a, f) } sort.Sort(fieldSlice(a)) @@ -262,37 +262,37 @@ func (i *Index) Frames() []*Field { // RecalculateCaches recalculates caches on every frame in the index. func (i *Index) RecalculateCaches() { - for _, frame := range i.Frames() { + for _, frame := range i.Fields() { frame.RecalculateCaches() } } -// CreateFrame creates a frame. -func (i *Index) CreateFrame(name string, opt FieldOptions) (*Field, error) { +// CreateField creates a field. +func (i *Index) CreateField(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() // Ensure frame doesn't already exist. - if i.frames[name] != nil { - return nil, ErrFrameExists + if i.fields[name] != nil { + return nil, ErrFieldExists } - return i.createFrame(name, opt) + return i.createField(name, opt) } -// CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt FieldOptions) (*Field, error) { +// CreateFieldIfNotExists creates a field with the given options if it doesn't exist. +func (i *Index) CreateFieldIfNotExists(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() // Find frame in cache first. - if f := i.frames[name]; f != nil { + if f := i.fields[name]; f != nil { return f, nil } - return i.createFrame(name, opt) + return i.createField(name, opt) } -func (i *Index) createFrame(name string, opt FieldOptions) (*Field, error) { +func (i *Index) createField(name string, opt FieldOptions) (*Field, error) { if name == "" { return nil, errors.New("frame name required") } else if opt.CacheType != "" && !IsValidCacheType(opt.CacheType) { @@ -305,7 +305,7 @@ func (i *Index) createFrame(name string, opt FieldOptions) (*Field, error) { } // Initialize frame. - f, err := i.newFrame(i.FramePath(name), name) + f, err := i.newField(i.FieldPath(name), name) if err != nil { return nil, errors.Wrap(err, "initializing") } @@ -327,12 +327,12 @@ func (i *Index) createFrame(name string, opt FieldOptions) (*Field, error) { } // Add to index's frame lookup. - i.frames[name] = f + i.fields[name] = f return f, nil } -func (i *Index) newFrame(path, name string) (*Field, error) { +func (i *Index) newField(path, name string) (*Field, error) { f, err := NewField(path, i.name, name) if err != nil { return nil, err @@ -344,13 +344,13 @@ func (i *Index) newFrame(path, name string) (*Field, error) { return f, nil } -// DeleteFrame removes a frame from the index. -func (i *Index) DeleteFrame(name string) error { +// DeleteField removes a field from the index. +func (i *Index) DeleteField(name string) error { i.mu.Lock() defer i.mu.Unlock() // Ignore if frame doesn't exist. - f := i.frame(name) + f := i.field(name) if f == nil { return nil } @@ -361,12 +361,12 @@ func (i *Index) DeleteFrame(name string) error { } // Delete frame directory. - if err := os.RemoveAll(i.FramePath(name)); err != nil { + if err := os.RemoveAll(i.FieldPath(name)); err != nil { return errors.Wrap(err, "removing directory") } // Remove reference. - delete(i.frames, name) + delete(i.fields, name) return nil } @@ -380,7 +380,7 @@ func (p indexSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } // IndexInfo represents schema information for an index. type IndexInfo struct { Name string `json:"name"` - Frames []*FieldInfo `json:"frames"` + Fields []*FieldInfo `json:"fields"` } type indexInfoSlice []*IndexInfo @@ -402,7 +402,7 @@ func EncodeIndexes(a []*Index) []*internal.Index { func encodeIndex(d *Index) *internal.Index { return &internal.Index{ Name: d.name, - Frames: encodeFields(d.Frames()), + Frames: encodeFields(d.Fields()), } } diff --git a/index_test.go b/index_test.go index be6288ad8..ada9be7f1 100644 --- a/index_test.go +++ b/index_test.go @@ -44,7 +44,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { t.Fatal("frame mismatch") } - if f.Field != index.Frame("f") { + if f.Field != index.Field("f") { t.Fatal("frame mismatch") } } @@ -89,7 +89,7 @@ func TestIndex_CreateFrame(t *testing.T) { // Reopen the index & verify the fields are loaded. if err := index.Reopen(); err != nil { t.Fatal(err) - } else if f := index.Frame("f"); !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { + } else if f := index.Field("f"); !reflect.DeepEqual(f.Type(), pilosa.FieldTypeInt) { t.Fatalf("unexpected type after reopen: %#v", f.Type()) } }) @@ -185,14 +185,14 @@ func TestIndex_DeleteFrame(t *testing.T) { } // Delete frame & verify it's gone. - if err := index.DeleteFrame("f"); err != nil { + if err := index.DeleteField("f"); err != nil { t.Fatal(err) - } else if index.Frame("f") != nil { + } else if index.Field("f") != nil { t.Fatal("expected nil frame") } // Delete again to make sure it doesn't error. - if err := index.DeleteFrame("f"); err != nil { + if err := index.DeleteField("f"); err != nil { t.Fatal(err) } } diff --git a/pilosa.go b/pilosa.go index 21bfdd822..2c0a8502d 100644 --- a/pilosa.go +++ b/pilosa.go @@ -31,10 +31,10 @@ var ( ErrIndexExists = errors.New("index already exists") ErrIndexNotFound = errors.New("index not found") - // ErrFrameRequired is returned when no frame is specified. - ErrFrameRequired = errors.New("frame required") - ErrFrameExists = errors.New("frame already exists") - ErrFrameNotFound = errors.New("frame not found") + // ErrFieldRequired is returned when no field is specified. + ErrFieldRequired = errors.New("field required") + ErrFieldExists = errors.New("field already exists") + ErrFieldNotFound = errors.New("field not found") ErrBSIGroupNotFound = errors.New("bsigroup not found") ErrBSIGroupExists = errors.New("bsigroup already exists") diff --git a/server.go b/server.go index d0585c992..d92c5949e 100644 --- a/server.go +++ b/server.go @@ -461,13 +461,13 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { return fmt.Errorf("Local Index not found: %s", obj.Index) } opt := decodeFieldOptions(obj.Meta) - _, err := idx.CreateFrame(obj.Frame, *opt) + _, err := idx.CreateField(obj.Frame, *opt) if err != nil { return err } case *internal.DeleteFrameMessage: idx := s.Holder.Index(obj.Index) - if err := idx.DeleteFrame(obj.Frame); err != nil { + if err := idx.DeleteField(obj.Frame); err != nil { return err } case *internal.CreateViewMessage: diff --git a/server/cluster_test.go b/server/cluster_test.go index 1b4e0b807..f445ce415 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -66,7 +66,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { received0 := map[string][]string{} for _, idx := range schema0 { received0[idx.Name] = []string{} - for _, frame := range idx.Frames { + for _, frame := range idx.Fields { received0[idx.Name] = append(received0[idx.Name], frame.Name) } } @@ -82,7 +82,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { received1 := map[string][]string{} for _, idx := range schema1 { received1[idx.Name] = []string{} - for _, frame := range idx.Frames { + for _, frame := range idx.Fields { received1[idx.Name] = append(received1[idx.Name], frame.Name) } } diff --git a/stats_test.go b/stats_test.go index 47521fbf8..992055166 100644 --- a/stats_test.go +++ b/stats_test.go @@ -298,7 +298,7 @@ func TestStatsCount_DeleteFrame(t *testing.T) { called := false // Create index. indx, _ := hldr.CreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := indx.CreateFrameIfNotExists("test", pilosa.FieldOptions{}); err != nil { + if _, err := indx.CreateFieldIfNotExists("test", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } s.Handler.API.Holder.Stats = &MockStats{ diff --git a/test/cluster.go b/test/cluster.go index 4c0bd45a0..e293764ad 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -120,7 +120,7 @@ func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FieldOptions) if err != nil { return err } - if _, err := idx.CreateFrame(frame, opt); err != nil { + if _, err := idx.CreateField(frame, opt); err != nil { return err } } diff --git a/test/index.go b/test/index.go index 5689afda3..93fa99cad 100644 --- a/test/index.go +++ b/test/index.go @@ -75,7 +75,7 @@ func (i *Index) Reopen() error { // CreateFrame creates a frame with the given options. func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error) { - f, err := i.Index.CreateFrame(name, opt) + f, err := i.Index.CreateField(name, opt) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error // CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FieldOptions) (*Frame, error) { - f, err := i.Index.CreateFrameIfNotExists(name, opt) + f, err := i.Index.CreateFieldIfNotExists(name, opt) if err != nil { return nil, err } diff --git a/utils_test.go b/utils_test.go index 7773db06c..ccb39ef54 100644 --- a/utils_test.go +++ b/utils_test.go @@ -110,7 +110,7 @@ func (t *ClusterCluster) CreateFrame(index, frame string, opt FieldOptions) erro if err != nil { return err } - if _, err := idx.CreateFrame(frame, opt); err != nil { + if _, err := idx.CreateField(frame, opt); err != nil { return err } } From 9db359d34ac36896a2cf541db3abdc628b99ffef Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:36:19 -0500 Subject: [PATCH 37/52] GoRename Frame to Field in holder.go --- api.go | 8 ++++---- cluster.go | 2 +- cluster_test.go | 4 ++-- executor.go | 18 +++++++++--------- executor_test.go | 8 ++++---- holder.go | 18 +++++++++--------- server.go | 4 ++-- stats_test.go | 2 +- test/cluster.go | 4 ++-- utils_test.go | 4 ++-- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/api.go b/api.go index d47ba1ff4..9bd3abdf4 100644 --- a/api.go +++ b/api.go @@ -355,7 +355,7 @@ func (api *API) UnmarshalFragment(ctx context.Context, indexName string, frameNa } // Retrieve frame. - f := api.Holder.Frame(indexName, frameName) + f := api.Holder.Field(indexName, frameName) if f == nil { return ErrFieldNotFound } @@ -495,7 +495,7 @@ func (api *API) Views(ctx context.Context, indexName string, frameName string) ( } // Retrieve views. - f := api.Holder.Frame(indexName, frameName) + f := api.Holder.Field(indexName, frameName) if f == nil { return nil, ErrFieldNotFound } @@ -512,7 +512,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, frameName stri } // Retrieve frame. - f := api.Holder.Frame(indexName, frameName) + f := api.Holder.Field(indexName, frameName) if f == nil { return ErrFieldNotFound } @@ -580,7 +580,7 @@ func (api *API) FrameAttrDiff(ctx context.Context, indexName string, frameName s } // Retrieve index from holder. - f := api.Holder.Frame(indexName, frameName) + f := api.Holder.Field(indexName, frameName) if f == nil { return nil, ErrFieldNotFound } diff --git a/cluster.go b/cluster.go index deabf2d06..a8f3573c5 100644 --- a/cluster.go +++ b/cluster.go @@ -1240,7 +1240,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err srcURI := decodeURI(src.Node.URI) // Retrieve frame. - f := c.Holder.Frame(src.Index, src.Frame) + f := c.Holder.Field(src.Index, src.Frame) if f == nil { return ErrFieldNotFound } diff --git a/cluster_test.go b/cluster_test.go index f8903aafd..c0de34250 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -424,7 +424,7 @@ func TestCluster_ResizeStates(t *testing.T) { // Before starting the resize, get the CheckSum to use for // comparison later. - node0Frame := node0.Holder.Frame("i", "f") + node0Frame := node0.Holder.Field("i", "f") node0View := node0Frame.View("standard") node0Fragment := node0View.Fragment(1) node0Checksum := node0Fragment.Checksum() @@ -453,7 +453,7 @@ func TestCluster_ResizeStates(t *testing.T) { // Bits // Verify that node-1 contains the fragment (i/f/standard/1) transferred from node-0. - node1Frame := node1.Holder.Frame("i", "f") + node1Frame := node1.Holder.Field("i", "f") node1View := node1Frame.View("standard") node1Fragment := node1View.Fragment(1) diff --git a/executor.go b/executor.go index b3e4f5aad..d1e40d808 100644 --- a/executor.go +++ b/executor.go @@ -369,7 +369,7 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq frameName, _ := c.Args["frame"].(string) - frame := e.Holder.Frame(index, frameName) + frame := e.Holder.Field(index, frameName) if frame == nil { return ValCount{}, nil } @@ -407,7 +407,7 @@ func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Cal frameName, _ := c.Args["frame"].(string) - frame := e.Holder.Frame(index, frameName) + frame := e.Holder.Field(index, frameName) if frame == nil { return ValCount{}, nil } @@ -445,7 +445,7 @@ func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Cal frameName, _ := c.Args["frame"].(string) - frame := e.Holder.Frame(index, frameName) + frame := e.Holder.Field(index, frameName) if frame == nil { return ValCount{}, nil } @@ -632,7 +632,7 @@ func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql. if frame == "" { frame = DefaultFrame } - f := e.Holder.Frame(index, frame) + f := e.Holder.Field(index, frame) if f == nil { return nil, ErrFieldNotFound } @@ -767,7 +767,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, frameName, cond = k, vv } - f := e.Holder.Frame(index, frameName) + f := e.Holder.Field(index, frameName) if f == nil { return nil, ErrFieldNotFound } @@ -1108,7 +1108,7 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal // Set values. for name, value := range args { // Retrieve frame. - frame := e.Holder.Frame(index, name) + frame := e.Holder.Field(index, name) if frame == nil { return ErrFieldNotFound } @@ -1157,7 +1157,7 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql. } // Retrieve frame. - frame := e.Holder.Frame(index, frameName) + frame := e.Holder.Field(index, frameName) if frame == nil { return ErrFieldNotFound } @@ -1217,7 +1217,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal } // Retrieve frame. - f := e.Holder.Frame(index, frame) + f := e.Holder.Field(index, frame) if f == nil { return nil, ErrFieldNotFound } @@ -1255,7 +1255,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal // Bulk insert attributes by frame. for name, frameMap := range m { // Retrieve frame. - frame := e.Holder.Frame(index, name) + frame := e.Holder.Field(index, name) if frame == nil { return nil, ErrFieldNotFound } diff --git a/executor_test.go b/executor_test.go index b8f7aa317..af4278849 100644 --- a/executor_test.go +++ b/executor_test.go @@ -289,7 +289,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { t.Fatal(err) } - f := hldr.Frame("i", "f") + f := hldr.Field("i", "f") if value, exists, err := f.Value(10); err != nil { t.Fatal(err) } else if !exists { @@ -371,7 +371,7 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { t.Fatal(err) } - f := hldr.Frame("i", "f") + f := hldr.Field("i", "f") if m, err := f.RowAttrStore().Attrs(10); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(m, map[string]interface{}{"foo": "bar", "baz": int64(123), "bat": true}) { @@ -525,7 +525,7 @@ func TestExecutor_Execute_TopN_Attr(t *testing.T) { hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1) hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth) - if err := hldr.Frame("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": int64(123)}); err != nil { + if err := hldr.Field("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": int64(123)}); err != nil { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) @@ -548,7 +548,7 @@ func TestExecutor_Execute_TopN_Attr_Src(t *testing.T) { hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1) hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth) - if err := hldr.Frame("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": uint64(123)}); err != nil { + if err := hldr.Field("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": uint64(123)}); err != nil { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) diff --git a/holder.go b/holder.go index f0c6d027c..f4e47e3d0 100644 --- a/holder.go +++ b/holder.go @@ -390,8 +390,8 @@ func (h *Holder) DeleteIndex(name string) error { return nil } -// Frame returns the frame for an index and name. -func (h *Holder) Frame(index, name string) *Field { +// Field returns the field for an index and name. +func (h *Holder) Field(index, name string) *Field { idx := h.Index(index) if idx == nil { return nil @@ -401,7 +401,7 @@ func (h *Holder) Frame(index, name string) *Field { // View returns the view for an index, frame, and name. func (h *Holder) View(index, frame, name string) *View { - f := h.Frame(index, frame) + f := h.Field(index, frame) if f == nil { return nil } @@ -607,7 +607,7 @@ func (s *HolderSyncer) SyncHolder() error { } // Sync frame row attributes. - if err := s.syncFrame(di.Name, fi.Name); err != nil { + if err := s.syncField(di.Name, fi.Name); err != nil { return fmt.Errorf("frame sync error: index=%s, frame=%s, err=%s", di.Name, fi.Name, err) } @@ -634,7 +634,7 @@ func (s *HolderSyncer) SyncHolder() error { } } } - s.Stats.Histogram("syncFrame", float64(time.Since(tf)), 1.0) + s.Stats.Histogram("syncField", float64(time.Since(tf)), 1.0) tf = time.Now() // reset tf } s.Stats.Histogram("syncIndex", float64(time.Since(ti)), 1.0) @@ -689,10 +689,10 @@ func (s *HolderSyncer) syncIndex(index string) error { return nil } -// syncFrame synchronizes frame attributes with the rest of the cluster. -func (s *HolderSyncer) syncFrame(index, name string) error { +// syncField synchronizes field attributes with the rest of the cluster. +func (s *HolderSyncer) syncField(index, name string) error { // Retrieve frame reference. - f := s.Holder.Frame(index, name) + f := s.Holder.Field(index, name) if f == nil { return nil } @@ -740,7 +740,7 @@ func (s *HolderSyncer) syncFrame(index, name string) error { // syncFragment synchronizes a fragment with the rest of the cluster. func (s *HolderSyncer) syncFragment(index, frame, view string, slice uint64) error { // Retrieve local frame. - f := s.Holder.Frame(index, frame) + f := s.Holder.Field(index, frame) if f == nil { return ErrFieldNotFound } diff --git a/server.go b/server.go index d92c5949e..541ff12c6 100644 --- a/server.go +++ b/server.go @@ -471,7 +471,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { return err } case *internal.CreateViewMessage: - f := s.Holder.Frame(obj.Index, obj.Frame) + f := s.Holder.Field(obj.Index, obj.Frame) if f == nil { return fmt.Errorf("Local Frame not found: %s", obj.Frame) } @@ -480,7 +480,7 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { return err } case *internal.DeleteViewMessage: - f := s.Holder.Frame(obj.Index, obj.Frame) + f := s.Holder.Field(obj.Index, obj.Frame) if f == nil { return fmt.Errorf("Local Frame not found: %s", obj.Frame) } diff --git a/stats_test.go b/stats_test.go index 992055166..7f71cfabb 100644 --- a/stats_test.go +++ b/stats_test.go @@ -155,7 +155,7 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) { called := false e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - frame := e.Holder.Frame("d", "f") + frame := e.Holder.Field("d", "f") if frame == nil { t.Fatal("frame not found") } diff --git a/test/cluster.go b/test/cluster.go index e293764ad..26ef44d30 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -137,7 +137,7 @@ func (t *TestCluster) SetBit(index, frame, view string, rowID, colID uint64, x * if c == nil { continue } - f := c.Holder.Frame(index, frame) + f := c.Holder.Field(index, frame) if f == nil { return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) } @@ -384,7 +384,7 @@ func (t *TestCluster) FollowResizeInstruction(instr *internal.ResizeInstruction) destFragment := destCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) if destFragment == nil { // Create fragment on destination if it doesn't exist. - f := destCluster.Holder.Frame(src.Index, src.Frame) + f := destCluster.Holder.Field(src.Index, src.Frame) v := f.View(src.View) var err error destFragment, err = v.CreateFragmentIfNotExists(src.Slice) diff --git a/utils_test.go b/utils_test.go index ccb39ef54..34b4f2967 100644 --- a/utils_test.go +++ b/utils_test.go @@ -128,7 +128,7 @@ func (t *ClusterCluster) SetBit(index, frame, view string, rowID, colID uint64, if c == nil { continue } - f := c.Holder.Frame(index, frame) + f := c.Holder.Field(index, frame) if f == nil { return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) } @@ -373,7 +373,7 @@ func (t *ClusterCluster) FollowResizeInstruction(instr *internal.ResizeInstructi destFragment := destCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) if destFragment == nil { // Create fragment on destination if it doesn't exist. - f := destCluster.Holder.Frame(src.Index, src.Frame) + f := destCluster.Holder.Field(src.Index, src.Frame) v := f.View(src.View) var err error destFragment, err = v.CreateFragmentIfNotExists(src.Slice) From bcec20525b91ccb197f469859078b17b8f605122 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:38:52 -0500 Subject: [PATCH 38/52] GoRename Frame to Field in view.go --- view.go | 18 +++++++++--------- view_test.go | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/view.go b/view.go index 38c76a162..d76f33d59 100644 --- a/view.go +++ b/view.go @@ -39,18 +39,18 @@ func IsValidView(name string) bool { return name == ViewStandard } -// View represents a container for frame data. +// View represents a container for field data. type View struct { mu sync.RWMutex path string index string - frame string + field string name string cacheSize uint32 // Fragments by slice. - cacheType string // passed in by frame + cacheType string // passed in by field fragments map[uint64]*Fragment // maxSlice maintains this view's max slice in order to @@ -65,11 +65,11 @@ type View struct { } // NewView returns a new instance of View. -func NewView(path, index, frame, name string, cacheSize uint32) *View { +func NewView(path, index, field, name string, cacheSize uint32) *View { return &View{ path: path, index: index, - frame: frame, + field: field, name: name, cacheSize: cacheSize, @@ -88,8 +88,8 @@ func (v *View) Name() string { return v.name } // Index returns the index name the view was initialized with. func (v *View) Index() string { return v.index } -// Frame returns the frame name the view was initialized with. -func (v *View) Frame() string { return v.frame } +// Field returns the field name the view was initialized with. +func (v *View) Field() string { return v.field } // Path returns the path the view was initialized with. func (v *View) Path() string { return v.path } @@ -265,7 +265,7 @@ func (v *View) createFragmentIfNotExists(slice uint64) (*Fragment, error) { } func (v *View) newFragment(path string, slice uint64) *Fragment { - frag := NewFragment(path, v.index, v.frame, v.name, slice) + frag := NewFragment(path, v.index, v.field, v.name, slice) frag.CacheType = v.cacheType frag.CacheSize = v.cacheSize frag.Logger = v.Logger @@ -281,7 +281,7 @@ func (v *View) DeleteFragment(slice uint64) error { return ErrFragmentNotFound } - v.Logger.Printf("delete fragment: (%s/%s/%s) %d", v.index, v.frame, v.name, slice) + v.Logger.Printf("delete fragment: (%s/%s/%s) %d", v.index, v.field, v.name, slice) // Close data files before deletion. if err := fragment.Close(); err != nil { diff --git a/view_test.go b/view_test.go index 21834113d..5bef29ddd 100644 --- a/view_test.go +++ b/view_test.go @@ -67,7 +67,7 @@ func (v *View) Reopen() error { return err } - v.View = pilosa.NewView(path, v.Index(), v.Frame(), v.Name(), pilosa.DefaultCacheSize) + v.View = pilosa.NewView(path, v.Index(), v.Field(), v.Name(), pilosa.DefaultCacheSize) v.View.RowAttrStore = v.RowAttrStore return v.Open() } From bbf3e529dc479cce0b16206b2be8c8586a3068a4 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:42:21 -0500 Subject: [PATCH 39/52] GoRename Frame to Field in cluster.go --- cluster.go | 36 ++++++++++++++++++------------------ cluster_internal_test.go | 6 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cluster.go b/cluster.go index a8f3573c5..9a467c284 100644 --- a/cluster.go +++ b/cluster.go @@ -584,7 +584,7 @@ func (c *Cluster) removeNodeBasicSorted(node *Node) bool { // frag is a struct of basic fragment information. type frag struct { - frame string + field string view string slice uint64 } @@ -617,36 +617,36 @@ func (a fragsByHost) add(b fragsByHost) fragsByHost { return a } -type viewsByFrame map[string][]string +type viewsByField map[string][]string -func (a viewsByFrame) addView(frame, view string) { - a[frame] = append(a[frame], view) +func (a viewsByField) addView(field, view string) { + a[field] = append(a[field], view) } func (c *Cluster) fragsByHost(idx *Index) fragsByHost { - // frameViews is a map of frame to slice of views. - frameViews := make(viewsByFrame) + // fieldViews is a map of field to slice of views. + fieldViews := make(viewsByField) - for _, frame := range idx.Fields() { - for _, view := range frame.Views() { - frameViews.addView(frame.Name(), view.Name()) + for _, field := range idx.Fields() { + for _, view := range field.Views() { + fieldViews.addView(field.Name(), view.Name()) } } - return c.fragCombos(idx.Name(), idx.MaxSlice(), frameViews) + return c.fragCombos(idx.Name(), idx.MaxSlice(), fieldViews) } // fragCombos returns a map (by uri) of lists of fragments for a given index -// by creating every combination of frame/view specified in `frameViews` up to maxSlice. -func (c *Cluster) fragCombos(idx string, maxSlice uint64, frameViews viewsByFrame) fragsByHost { +// by creating every combination of field/view specified in `fieldViews` up to maxSlice. +func (c *Cluster) fragCombos(idx string, maxSlice uint64, fieldViews viewsByField) fragsByHost { t := make(fragsByHost) for i := uint64(0); i <= maxSlice; i++ { nodes := c.SliceNodes(idx, i) for _, n := range nodes { - // for each frame/view combination: - for frame, views := range frameViews { + // for each field/view combination: + for field, views := range fieldViews { for _, view := range views { - t[n.ID] = append(t[n.ID], frag{frame, view, i}) + t[n.ID] = append(t[n.ID], frag{field, view, i}) } } } @@ -770,7 +770,7 @@ func (c *Cluster) fragSources(to *Cluster, idx *Index) (map[string][]*internal.R src := &internal.ResizeSource{ Node: EncodeNode(c.nodeByID(srcNodeID)), Index: idx.Name(), - Frame: frag.frame, + Frame: frag.field, View: frag.view, Slice: frag.slice, } @@ -1239,7 +1239,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err srcURI := decodeURI(src.Node.URI) - // Retrieve frame. + // Retrieve field. f := c.Holder.Field(src.Index, src.Frame) if f == nil { return ErrFieldNotFound @@ -1275,7 +1275,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err return fmt.Errorf("slice %v doesn't exist on host: %s", src.Slice, src.Node.URI) } - // Write to local frame and always close reader. + // Write to local field and always close reader. if err := func() error { defer rd.Close() _, err := frag.ReadFrom(rd) diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 9453fc16b..4b3a159f8 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -45,13 +45,13 @@ func TestFragCombos(t *testing.T) { tests := []struct { idx string maxSlice uint64 - frameViews viewsByFrame + frameViews viewsByField expected fragsByHost }{ { idx: "i", maxSlice: uint64(2), - frameViews: viewsByFrame{"f": []string{"v1", "v2"}}, + frameViews: viewsByField{"f": []string{"v1", "v2"}}, expected: fragsByHost{ "node0": []frag{{"f", "v1", uint64(0)}, {"f", "v2", uint64(0)}}, "node1": []frag{{"f", "v1", uint64(1)}, {"f", "v2", uint64(1)}, {"f", "v1", uint64(2)}, {"f", "v2", uint64(2)}}, @@ -60,7 +60,7 @@ func TestFragCombos(t *testing.T) { { idx: "foo", maxSlice: uint64(3), - frameViews: viewsByFrame{"f": []string{"v0"}}, + frameViews: viewsByField{"f": []string{"v0"}}, expected: fragsByHost{ "node0": []frag{{"f", "v0", uint64(1)}, {"f", "v0", uint64(2)}}, "node1": []frag{{"f", "v0", uint64(0)}, {"f", "v0", uint64(3)}}, From 7bb6d2b7893a0d626972512824154cfaa145ca04 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:45:15 -0500 Subject: [PATCH 40/52] GoRename Frame to Field in fragment.go --- fragment.go | 30 +++++++++++++++--------------- test/fragment.go | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fragment.go b/fragment.go index dd0f05ed2..94232bfa0 100644 --- a/fragment.go +++ b/fragment.go @@ -66,13 +66,13 @@ const ( DefaultFragmentMaxOpN = 2000 ) -// Fragment represents the intersection of a frame and slice in an index. +// Fragment represents the intersection of a field and slice in an index. type Fragment struct { mu sync.RWMutex // Composite identifiers index string - frame string + field string view string slice uint64 @@ -84,7 +84,7 @@ type Fragment struct { opN int // number of ops since snapshot // Cache for row counts. - CacheType string // passed in by frame + CacheType string // passed in by field cache Cache CacheSize uint32 @@ -106,18 +106,18 @@ type Fragment struct { Logger Logger // Row attribute storage. - // This is set by the parent frame unless overridden for testing. + // This is set by the parent field unless overridden for testing. RowAttrStore AttrStore stats StatsClient } // NewFragment returns a new instance of Fragment. -func NewFragment(path, index, frame, view string, slice uint64) *Fragment { +func NewFragment(path, index, field, view string, slice uint64) *Fragment { return &Fragment{ path: path, index: index, - frame: frame, + field: field, view: view, slice: slice, CacheType: DefaultCacheType, @@ -139,8 +139,8 @@ func (f *Fragment) CachePath() string { return f.path + CacheExt } // Index returns the index that the fragment was initialized with. func (f *Fragment) Index() string { return f.index } -// Frame returns the frame the fragment was initialized with. -func (f *Fragment) Frame() string { return f.frame } +// Field returns the field the fragment was initialized with. +func (f *Fragment) Field() string { return f.field } // View returns the view the fragment was initialized with. func (f *Fragment) View() string { return f.view } @@ -247,7 +247,7 @@ func (f *Fragment) openStorage() error { // openCache initializes the cache from row ids persisted to disk. func (f *Fragment) openCache() error { - // Determine cache type from frame name. + // Determine cache type from field name. switch f.CacheType { case CacheTypeRanked: f.cache = NewRankCache(f.CacheSize) @@ -1452,8 +1452,8 @@ func track(start time.Time, message string, stats StatsClient, logger Logger) { } func (f *Fragment) snapshot() error { - f.Logger.Printf("fragment: snapshotting %s/%s/%s/%d", f.index, f.frame, f.view, f.slice) - completeMessage := fmt.Sprintf("fragment: snapshot complete %s/%s/%s/%d", f.index, f.frame, f.view, f.slice) + f.Logger.Printf("fragment: snapshotting %s/%s/%s/%d", f.index, f.field, f.view, f.slice) + completeMessage := fmt.Sprintf("fragment: snapshot complete %s/%s/%s/%d", f.index, f.field, f.view, f.slice) start := time.Now() defer track(start, completeMessage, f.stats, f.Logger) @@ -1783,7 +1783,7 @@ func (s *FragmentSyncer) SyncFragment() error { // Retrieve remote blocks. client := NewInternalHTTPClientFromURI(&node.URI, s.RemoteClient) - blocks, err := client.FragmentBlocks(context.Background(), s.Fragment.Index(), s.Fragment.Frame(), s.Fragment.Slice()) + blocks, err := client.FragmentBlocks(context.Background(), s.Fragment.Index(), s.Fragment.Field(), s.Fragment.Slice()) if err != nil && err != ErrFragmentNotFound { return errors.Wrap(err, "getting blocks") } @@ -1862,7 +1862,7 @@ func (s *FragmentSyncer) syncBlock(id int) error { clients = append(clients, client) // Only sync the standard block. - rowIDs, columnIDs, err := client.BlockData(context.Background(), f.Index(), f.Frame(), f.Slice(), id) + rowIDs, columnIDs, err := client.BlockData(context.Background(), f.Index(), f.Field(), f.Slice(), id) if err != nil { return errors.Wrap(err, "getting block") } @@ -1904,11 +1904,11 @@ func (s *FragmentSyncer) syncBlock(id int) error { // Only sync the standard block. for j := 0; j < len(set.ColumnIDs); j++ { - fmt.Fprintf(&(buffers[count/maxWrites]), "SetBit(frame=%q, row=%d, col=%d)\n", f.Frame(), set.RowIDs[j], (f.Slice()*SliceWidth)+set.ColumnIDs[j]) + fmt.Fprintf(&(buffers[count/maxWrites]), "SetBit(frame=%q, row=%d, col=%d)\n", f.Field(), set.RowIDs[j], (f.Slice()*SliceWidth)+set.ColumnIDs[j]) count++ } for j := 0; j < len(clear.ColumnIDs); j++ { - fmt.Fprintf(&(buffers[count/maxWrites]), "ClearBit(frame=%q, row=%d, col=%d)\n", f.Frame(), clear.RowIDs[j], (f.Slice()*SliceWidth)+clear.ColumnIDs[j]) + fmt.Fprintf(&(buffers[count/maxWrites]), "ClearBit(frame=%q, row=%d, col=%d)\n", f.Field(), clear.RowIDs[j], (f.Slice()*SliceWidth)+clear.ColumnIDs[j]) count++ } diff --git a/test/fragment.go b/test/fragment.go index cd1111750..2e97d6f5d 100644 --- a/test/fragment.go +++ b/test/fragment.go @@ -76,7 +76,7 @@ func (f *Fragment) Reopen() error { return err } - f.Fragment = pilosa.NewFragment(path, f.Index(), f.Frame(), f.View(), f.Slice()) + f.Fragment = pilosa.NewFragment(path, f.Index(), f.Field(), f.View(), f.Slice()) f.Fragment.CacheType = cacheType f.Fragment.RowAttrStore = f.RowAttrStore if err := f.Open(); err != nil { From b88ebfb75445c2df7f7aa391a1b1c2a5473929d3 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 22:52:57 -0500 Subject: [PATCH 41/52] GoRename Frame to Field in diagnostics.go --- diagnostics.go | 12 ++++++------ server/server_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/diagnostics.go b/diagnostics.go index f97f5f6aa..e4067c6e3 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -217,7 +217,7 @@ func (d *DiagnosticsCollector) EnrichWithMemoryInfo() { // EnrichWithSchemaProperties adds schema info to the diagnostics payload. func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { var numSlices uint64 - numFrames := 0 + numFields := 0 numIndexes := 0 bsiFieldCount := 0 timeQuantumEnabled := false @@ -225,19 +225,19 @@ func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { for _, index := range d.server.Holder.Indexes() { numSlices += index.MaxSlice() + 1 numIndexes += 1 - for _, frame := range index.Fields() { - numFrames += 1 - if frame.Type() == FieldTypeInt { + for _, field := range index.Fields() { + numFields += 1 + if field.Type() == FieldTypeInt { bsiFieldCount += 1 } - if frame.TimeQuantum() != "" { + if field.TimeQuantum() != "" { timeQuantumEnabled = true } } } d.Set("NumIndexes", numIndexes) - d.Set("NumFrames", numFrames) + d.Set("NumFields", numFields) d.Set("NumSlices", numSlices) d.Set("BSIFieldCount", bsiFieldCount) d.Set("TimeQuantumEnabled", timeQuantumEnabled) diff --git a/server/server_test.go b/server/server_test.go index 920fde809..0fa45619f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -51,10 +51,10 @@ func TestMain_Set_Quick(t *testing.T) { // Execute SetBit() commands. for _, cmd := range cmds { - if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && !strings.Contains(err.Error(), "index already exists") { + if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } - if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && !strings.Contains(err.Error(), "frame already exists") { + if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists { t.Fatal(err) } if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, frame=%q, col=%d)`, cmd.ID, cmd.Frame, cmd.ColumnID)); err != nil { From 6dbe80350f0064671dc2db107c648664ad546bd3 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:02:15 -0500 Subject: [PATCH 42/52] GoRename Frame to Field in client.go --- client.go | 92 +++++++++++++++++++++++++-------------------------- ctl/import.go | 2 +- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/client.go b/client.go index d186746c7..e293c14af 100644 --- a/client.go +++ b/client.go @@ -107,7 +107,7 @@ func (c *InternalHTTPClient) maxSliceByIndex(ctx context.Context) (map[string]ui return rsp.Standard, nil } -// Schema returns all index and frame schema information. +// Schema returns all index and field schema information. func (c *InternalHTTPClient) Schema(ctx context.Context) ([]*IndexInfo, error) { // Execute request against the host. u := c.defaultURI.Path("/schema") @@ -269,14 +269,14 @@ func (c *InternalHTTPClient) QueryNode(ctx context.Context, uri *URI, index stri } // Import bulk imports bits for a single slice to a host. -func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error { +func (c *InternalHTTPClient) Import(ctx context.Context, index, field string, slice uint64, bits []Bit) error { if index == "" { return ErrIndexRequired - } else if frame == "" { + } else if field == "" { return ErrFieldRequired } - buf, err := marshalImportPayload(index, frame, slice, bits) + buf, err := marshalImportPayload(index, field, slice, bits) if err != nil { return fmt.Errorf("Error Creating Payload: %s", err) } @@ -298,14 +298,14 @@ func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, sl } // ImportK bulk imports bits specified by string keys to a host. -func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, columns []Bit) error { +func (c *InternalHTTPClient) ImportK(ctx context.Context, index, field string, columns []Bit) error { if index == "" { return ErrIndexRequired - } else if frame == "" { + } else if field == "" { return ErrFieldRequired } - buf, err := marshalImportPayloadK(index, frame, columns) + buf, err := marshalImportPayloadK(index, field, columns) if err != nil { return fmt.Errorf("Error Creating Payload: %s", err) } @@ -330,8 +330,8 @@ func (c *InternalHTTPClient) EnsureIndex(ctx context.Context, name string, optio return err } -func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error { - err := c.CreateFrame(ctx, indexName, frameName, options) +func (c *InternalHTTPClient) EnsureField(ctx context.Context, indexName string, fieldName string, options FieldOptions) error { + err := c.CreateField(ctx, indexName, fieldName, options) if err == nil || err == ErrFieldExists { return nil } @@ -339,7 +339,7 @@ func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string, } // marshalImportPayload marshalls the import parameters into a protobuf byte slice. -func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte, error) { +func marshalImportPayload(index, field string, slice uint64, bits []Bit) ([]byte, error) { // Separate row and column IDs to reduce allocations. rowIDs := Bits(bits).RowIDs() columnIDs := Bits(bits).ColumnIDs() @@ -348,7 +348,7 @@ func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportRequest{ Index: index, - Frame: frame, + Frame: field, Slice: slice, RowIDs: rowIDs, ColumnIDs: columnIDs, @@ -361,7 +361,7 @@ func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte } // marshalImportPayloadK marshalls the import parameters into a protobuf byte slice. -func marshalImportPayloadK(index, frame string, bits []Bit) ([]byte, error) { +func marshalImportPayloadK(index, field string, bits []Bit) ([]byte, error) { // Separate row and column IDs to reduce allocations. rowKeys := Bits(bits).RowKeys() columnKeys := Bits(bits).ColumnKeys() @@ -370,7 +370,7 @@ func marshalImportPayloadK(index, frame string, bits []Bit) ([]byte, error) { // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportRequest{ Index: index, - Frame: frame, + Frame: field, RowKeys: rowKeys, ColumnKeys: columnKeys, Timestamps: timestamps, @@ -420,14 +420,14 @@ func (c *InternalHTTPClient) importNode(ctx context.Context, node *Node, buf []b } // ImportValue bulk imports field values for a single slice to a host. -func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error { +func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, field string, slice uint64, vals []FieldValue) error { if index == "" { return ErrIndexRequired - } else if frame == "" { + } else if field == "" { return ErrFieldRequired } - buf, err := marshalImportValuePayload(index, frame, slice, vals) + buf, err := marshalImportValuePayload(index, field, slice, vals) if err != nil { return fmt.Errorf("Error Creating Payload: %s", err) } @@ -449,7 +449,7 @@ func (c *InternalHTTPClient) ImportValue(ctx context.Context, index, frame strin } // marshalImportValuePayload marshalls the import parameters into a protobuf byte slice. -func marshalImportValuePayload(index, frame string, slice uint64, vals []FieldValue) ([]byte, error) { +func marshalImportValuePayload(index, field string, slice uint64, vals []FieldValue) ([]byte, error) { // Separate row and column IDs to reduce allocations. columnIDs := FieldValues(vals).ColumnIDs() values := FieldValues(vals).Values() @@ -457,7 +457,7 @@ func marshalImportValuePayload(index, frame string, slice uint64, vals []FieldVa // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportValueRequest{ Index: index, - Frame: frame, + Frame: field, Slice: slice, ColumnIDs: columnIDs, Values: values, @@ -507,10 +507,10 @@ func (c *InternalHTTPClient) importValueNode(ctx context.Context, node *Node, bu } // ExportCSV bulk exports data for a single slice from a host to CSV format. -func (c *InternalHTTPClient) ExportCSV(ctx context.Context, index, frame string, slice uint64, w io.Writer) error { +func (c *InternalHTTPClient) ExportCSV(ctx context.Context, index, field string, slice uint64, w io.Writer) error { if index == "" { return ErrIndexRequired - } else if frame == "" { + } else if field == "" { return ErrFieldRequired } @@ -525,7 +525,7 @@ func (c *InternalHTTPClient) ExportCSV(ctx context.Context, index, frame string, for _, i := range rand.Perm(len(nodes)) { node := nodes[i] - if err := c.exportNodeCSV(ctx, node, index, frame, slice, w); err != nil { + if err := c.exportNodeCSV(ctx, node, index, field, slice, w); err != nil { e = fmt.Errorf("export node: host=%s, err=%s", node.URI, err) continue } else { @@ -537,12 +537,12 @@ func (c *InternalHTTPClient) ExportCSV(ctx context.Context, index, frame string, } // exportNode copies a CSV export from a node to w. -func (c *InternalHTTPClient) exportNodeCSV(ctx context.Context, node *Node, index, frame string, slice uint64, w io.Writer) error { +func (c *InternalHTTPClient) exportNodeCSV(ctx context.Context, node *Node, index, field string, slice uint64, w io.Writer) error { // Create URL. u := nodePathToURL(node, "/export") u.RawQuery = url.Values{ "index": {index}, - "frame": {frame}, + "frame": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -574,18 +574,18 @@ func (c *InternalHTTPClient) exportNodeCSV(ctx context.Context, node *Node, inde return nil } -func (c *InternalHTTPClient) RetrieveSliceFromURI(ctx context.Context, index, frame string, slice uint64, uri URI) (io.ReadCloser, error) { +func (c *InternalHTTPClient) RetrieveSliceFromURI(ctx context.Context, index, field string, slice uint64, uri URI) (io.ReadCloser, error) { node := &Node{ URI: uri, } - return c.backupSliceNode(ctx, index, frame, slice, node) + return c.backupSliceNode(ctx, index, field, slice, node) } -func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, frame string, slice uint64, node *Node) (io.ReadCloser, error) { +func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, field string, slice uint64, node *Node) (io.ReadCloser, error) { u := nodePathToURL(node, "/fragment/data") u.RawQuery = url.Values{ "index": {index}, - "frame": {frame}, + "frame": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -615,8 +615,8 @@ func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, frame s return resp.Body, nil } -// CreateFrame creates a new frame on the server. -func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error { +// CreateField creates a new field on the server. +func (c *InternalHTTPClient) CreateField(ctx context.Context, index, field string, opt FieldOptions) error { if index == "" { return ErrIndexRequired } @@ -630,7 +630,7 @@ func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame strin } // Create URL & HTTP request. - u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s", index, frame)) + u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s", index, field)) req, err := http.NewRequest("POST", u.String(), bytes.NewReader(buf)) if err != nil { return errors.Wrap(err, "creating request") @@ -666,11 +666,11 @@ func (c *InternalHTTPClient) CreateFrame(ctx context.Context, index, frame strin // FragmentBlocks returns a list of block checksums for a fragment on a host. // Only returns blocks which contain data. -func (c *InternalHTTPClient) FragmentBlocks(ctx context.Context, index, frame string, slice uint64) ([]FragmentBlock, error) { +func (c *InternalHTTPClient) FragmentBlocks(ctx context.Context, index, field string, slice uint64) ([]FragmentBlock, error) { u := uriPathToURL(c.defaultURI, "/fragment/blocks") u.RawQuery = url.Values{ "index": {index}, - "frame": {frame}, + "frame": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -707,10 +707,10 @@ func (c *InternalHTTPClient) FragmentBlocks(ctx context.Context, index, frame st } // BlockData returns row/column id pairs for a block. -func (c *InternalHTTPClient) BlockData(ctx context.Context, index, frame string, slice uint64, block int) ([]uint64, []uint64, error) { +func (c *InternalHTTPClient) BlockData(ctx context.Context, index, field string, slice uint64, block int) ([]uint64, []uint64, error) { buf, err := proto.Marshal(&internal.BlockDataRequest{ Index: index, - Frame: frame, + Frame: field, Slice: slice, Block: uint64(block), }) @@ -794,8 +794,8 @@ func (c *InternalHTTPClient) ColumnAttrDiff(ctx context.Context, index string, b } // RowAttrDiff returns data from differing blocks on a remote host. -func (c *InternalHTTPClient) RowAttrDiff(ctx context.Context, index, frame string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { - u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s/attr/diff", index, frame)) +func (c *InternalHTTPClient) RowAttrDiff(ctx context.Context, index, field string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { + u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s/attr/diff", index, field)) // Encode request. buf, err := json.Marshal(postFrameAttrDiffRequest{Blocks: blks}) @@ -961,7 +961,7 @@ func (p Bits) GroupBySlice() map[uint64][]Bit { } // FieldValues represents the value for a column within a -// range-encoded frame. +// range-encoded field. type FieldValue struct { ColumnID uint64 Value int64 @@ -1053,16 +1053,16 @@ type InternalClient interface { FragmentNodes(ctx context.Context, index string, slice uint64) ([]*Node, error) Query(ctx context.Context, index string, queryRequest *internal.QueryRequest) (*internal.QueryResponse, error) QueryNode(ctx context.Context, uri *URI, 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, bits []Bit) error + Import(ctx context.Context, index, field string, slice uint64, bits []Bit) error + ImportK(ctx context.Context, index, field string, bits []Bit) error EnsureIndex(ctx context.Context, name string, options IndexOptions) error - EnsureFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) error - ImportValue(ctx context.Context, index, frame string, slice uint64, vals []FieldValue) error - ExportCSV(ctx context.Context, index, frame string, slice uint64, w io.Writer) error - CreateFrame(ctx context.Context, index, frame string, opt FieldOptions) error - FragmentBlocks(ctx context.Context, index, frame string, slice uint64) ([]FragmentBlock, error) - BlockData(ctx context.Context, index, frame string, slice uint64, block int) ([]uint64, []uint64, error) + EnsureField(ctx context.Context, indexName string, fieldName string, options FieldOptions) error + ImportValue(ctx context.Context, index, field string, slice uint64, vals []FieldValue) error + ExportCSV(ctx context.Context, index, field string, slice uint64, w io.Writer) error + CreateField(ctx context.Context, index, field string, opt FieldOptions) error + FragmentBlocks(ctx context.Context, index, field string, slice uint64) ([]FragmentBlock, error) + BlockData(ctx context.Context, index, field string, slice uint64, block int) ([]uint64, []uint64, error) ColumnAttrDiff(ctx context.Context, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) - RowAttrDiff(ctx context.Context, index, frame string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) + RowAttrDiff(ctx context.Context, index, field string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) SendMessage(ctx context.Context, uri *URI, pb proto.Message) error } diff --git a/ctl/import.go b/ctl/import.go index 68229ed72..0bc3d093c 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -134,7 +134,7 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { if err != nil { return fmt.Errorf("Error Creating Index: %s", err) } - err = cmd.Client.EnsureFrame(ctx, cmd.Index, cmd.Frame, cmd.FrameOptions) + err = cmd.Client.EnsureField(ctx, cmd.Index, cmd.Frame, cmd.FrameOptions) if err != nil { return fmt.Errorf("Error Creating Frame: %s", err) } From 4254eb1d1140d732772e64fe9b66bd6d6b560812 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:10:59 -0500 Subject: [PATCH 43/52] rename internal FrameMeta to FieldOptions --- frame.go | 10 +-- holder_test.go | 2 +- internal/private.pb.go | 187 +++++++++++++++++++++-------------------- internal/private.proto | 6 +- 4 files changed, 103 insertions(+), 102 deletions(-) diff --git a/frame.go b/frame.go index b69848344..c830213f7 100644 --- a/frame.go +++ b/frame.go @@ -261,7 +261,7 @@ func (f *Field) openViews() error { // loadMeta reads meta data for the frame, if any. func (f *Field) loadMeta() error { - var pb internal.FrameMeta + var pb internal.FieldOptions // Read data from meta file. buf, err := ioutil.ReadFile(filepath.Join(f.path, ".meta")) @@ -1038,15 +1038,15 @@ func (o *FieldOptions) Validate() error { } // Encode converts o into its internal representation. -func (o *FieldOptions) Encode() *internal.FrameMeta { +func (o *FieldOptions) Encode() *internal.FieldOptions { return encodeFieldOptions(o) } -func encodeFieldOptions(o *FieldOptions) *internal.FrameMeta { +func encodeFieldOptions(o *FieldOptions) *internal.FieldOptions { if o == nil { return nil } - return &internal.FrameMeta{ + return &internal.FieldOptions{ Type: o.Type, CacheType: o.CacheType, CacheSize: o.CacheSize, @@ -1056,7 +1056,7 @@ func encodeFieldOptions(o *FieldOptions) *internal.FrameMeta { } } -func decodeFieldOptions(options *internal.FrameMeta) *FieldOptions { +func decodeFieldOptions(options *internal.FieldOptions) *FieldOptions { if options == nil { return nil } diff --git a/holder_test.go b/holder_test.go index 664bf16a0..35e3b8e26 100644 --- a/holder_test.go +++ b/holder_test.go @@ -113,7 +113,7 @@ func TestHolder_Open(t *testing.T) { t.Fatalf("unexpected error: %s", err) } }) - t.Run("ErrFrameMetaCorrupt", func(t *testing.T) { + t.Run("ErrFieldOptionsCorrupt", func(t *testing.T) { h := test.MustOpenHolder() defer h.Close() diff --git a/internal/private.pb.go b/internal/private.pb.go index a4f9e0431..56c8eba81 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -10,7 +10,7 @@ It has these top-level messages: IndexMeta - FrameMeta + FieldOptions ImportResponse BlockDataRequest BlockDataResponse @@ -68,7 +68,7 @@ func (m *IndexMeta) String() string { return proto.CompactTextString( func (*IndexMeta) ProtoMessage() {} func (*IndexMeta) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{0} } -type FrameMeta struct { +type FieldOptions struct { Type string `protobuf:"bytes,8,opt,name=Type,proto3" json:"Type,omitempty"` CacheType string `protobuf:"bytes,3,opt,name=CacheType,proto3" json:"CacheType,omitempty"` CacheSize uint32 `protobuf:"varint,4,opt,name=CacheSize,proto3" json:"CacheSize,omitempty"` @@ -77,47 +77,47 @@ type FrameMeta struct { TimeQuantum string `protobuf:"bytes,5,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` } -func (m *FrameMeta) Reset() { *m = FrameMeta{} } -func (m *FrameMeta) String() string { return proto.CompactTextString(m) } -func (*FrameMeta) ProtoMessage() {} -func (*FrameMeta) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{1} } +func (m *FieldOptions) Reset() { *m = FieldOptions{} } +func (m *FieldOptions) String() string { return proto.CompactTextString(m) } +func (*FieldOptions) ProtoMessage() {} +func (*FieldOptions) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{1} } -func (m *FrameMeta) GetType() string { +func (m *FieldOptions) GetType() string { if m != nil { return m.Type } return "" } -func (m *FrameMeta) GetCacheType() string { +func (m *FieldOptions) GetCacheType() string { if m != nil { return m.CacheType } return "" } -func (m *FrameMeta) GetCacheSize() uint32 { +func (m *FieldOptions) GetCacheSize() uint32 { if m != nil { return m.CacheSize } return 0 } -func (m *FrameMeta) GetMin() int64 { +func (m *FieldOptions) GetMin() int64 { if m != nil { return m.Min } return 0 } -func (m *FrameMeta) GetMax() int64 { +func (m *FieldOptions) GetMax() int64 { if m != nil { return m.Max } return 0 } -func (m *FrameMeta) GetTimeQuantum() string { +func (m *FieldOptions) GetTimeQuantum() string { if m != nil { return m.TimeQuantum } @@ -309,9 +309,9 @@ func (m *CreateIndexMessage) GetMeta() *IndexMeta { } type CreateFrameMessage 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"` - Meta *FrameMeta `protobuf:"bytes,3,opt,name=Meta" json:"Meta,omitempty"` + Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` + Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` + Meta *FieldOptions `protobuf:"bytes,3,opt,name=Meta" json:"Meta,omitempty"` } func (m *CreateFrameMessage) Reset() { *m = CreateFrameMessage{} } @@ -333,7 +333,7 @@ func (m *CreateFrameMessage) GetFrame() string { return "" } -func (m *CreateFrameMessage) GetMeta() *FrameMeta { +func (m *CreateFrameMessage) GetMeta() *FieldOptions { if m != nil { return m.Meta } @@ -365,9 +365,9 @@ func (m *DeleteFrameMessage) GetFrame() string { } type Frame struct { - Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` - Meta *FrameMeta `protobuf:"bytes,2,opt,name=Meta" json:"Meta,omitempty"` - Views []string `protobuf:"bytes,3,rep,name=Views" json:"Views,omitempty"` + Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` + Meta *FieldOptions `protobuf:"bytes,2,opt,name=Meta" json:"Meta,omitempty"` + Views []string `protobuf:"bytes,3,rep,name=Views" json:"Views,omitempty"` } func (m *Frame) Reset() { *m = Frame{} } @@ -382,7 +382,7 @@ func (m *Frame) GetName() string { return "" } -func (m *Frame) GetMeta() *FrameMeta { +func (m *Frame) GetMeta() *FieldOptions { if m != nil { return m.Meta } @@ -920,7 +920,7 @@ func (*RecalculateCaches) Descriptor() ([]byte, []int) { return fileDescriptorPr func init() { proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta") - proto.RegisterType((*FrameMeta)(nil), "internal.FrameMeta") + proto.RegisterType((*FieldOptions)(nil), "internal.FieldOptions") proto.RegisterType((*ImportResponse)(nil), "internal.ImportResponse") proto.RegisterType((*BlockDataRequest)(nil), "internal.BlockDataRequest") proto.RegisterType((*BlockDataResponse)(nil), "internal.BlockDataResponse") @@ -969,7 +969,7 @@ func (m *IndexMeta) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *FrameMeta) Marshal() (dAtA []byte, err error) { +func (m *FieldOptions) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -979,7 +979,7 @@ func (m *FrameMeta) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *FrameMeta) MarshalTo(dAtA []byte) (int, error) { +func (m *FieldOptions) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2138,7 +2138,7 @@ func (m *IndexMeta) Size() (n int) { return n } -func (m *FrameMeta) Size() (n int) { +func (m *FieldOptions) Size() (n int) { var l int _ = l l = len(m.CacheType) @@ -2696,7 +2696,7 @@ func (m *IndexMeta) Unmarshal(dAtA []byte) error { } return nil } -func (m *FrameMeta) Unmarshal(dAtA []byte) error { +func (m *FieldOptions) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2719,10 +2719,10 @@ func (m *FrameMeta) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: FrameMeta: wiretype end group for non-group") + return fmt.Errorf("proto: FieldOptions: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: FrameMeta: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: FieldOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 3: @@ -3989,7 +3989,7 @@ func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Meta == nil { - m.Meta = &FrameMeta{} + m.Meta = &FieldOptions{} } if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4209,7 +4209,7 @@ func (m *Frame) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Meta == nil { - m.Meta = &FrameMeta{} + m.Meta = &FieldOptions{} } if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6617,68 +6617,69 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1002 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0x67, 0xbd, 0x6b, 0xc7, 0x7e, 0xc1, 0xc1, 0x99, 0x42, 0xd8, 0x22, 0x14, 0xcc, 0xa8, 0x12, - 0x86, 0x43, 0x54, 0xda, 0x0b, 0x5f, 0x95, 0xa2, 0xd8, 0x01, 0x16, 0x91, 0x08, 0x66, 0x93, 0x1e, - 0x90, 0x38, 0x4c, 0xed, 0x51, 0xbb, 0xca, 0x7a, 0xc7, 0xec, 0xce, 0x26, 0x71, 0x0f, 0x5c, 0xe1, - 0xc2, 0x1d, 0x71, 0xe3, 0xbf, 0xe1, 0xc8, 0x9f, 0x80, 0xc2, 0x3f, 0x82, 0xe6, 0xcd, 0xec, 0x47, - 0xfc, 0xd1, 0x54, 0xa1, 0xb7, 0x79, 0xbf, 0xf7, 0xfd, 0xde, 0x6f, 0x76, 0x16, 0xba, 0xb3, 0x34, - 0x3a, 0xe7, 0x4a, 0xec, 0xcd, 0x52, 0xa9, 0x24, 0x69, 0x47, 0x89, 0x12, 0x69, 0xc2, 0x63, 0xba, - 0x09, 0x9d, 0x20, 0x99, 0x88, 0xcb, 0x23, 0xa1, 0x38, 0xfd, 0xd3, 0x81, 0xce, 0x97, 0x29, 0x9f, - 0x0a, 0x2d, 0x91, 0x77, 0xa1, 0x33, 0xe4, 0xe3, 0x67, 0xe2, 0x64, 0x3e, 0x13, 0xbe, 0xdb, 0x77, - 0x06, 0x1d, 0x56, 0x01, 0xa5, 0x36, 0x8c, 0x9e, 0x0b, 0xdf, 0xeb, 0x3b, 0x83, 0x2e, 0xab, 0x00, - 0xd2, 0x87, 0xcd, 0x93, 0x68, 0x2a, 0xbe, 0xcf, 0x79, 0xa2, 0xf2, 0xa9, 0xdf, 0x44, 0xef, 0x3a, - 0x44, 0x08, 0x78, 0x18, 0xb8, 0x8d, 0x2a, 0x3c, 0x93, 0x1e, 0xb8, 0x47, 0x51, 0xe2, 0x77, 0xfa, - 0xce, 0xc0, 0x65, 0xfa, 0x88, 0x08, 0xbf, 0xf4, 0xc1, 0x22, 0xfc, 0x92, 0x52, 0xd8, 0x0a, 0xa6, - 0x33, 0x99, 0x2a, 0x26, 0xb2, 0x99, 0x4c, 0x32, 0xf4, 0x3a, 0x4c, 0x53, 0xdf, 0xc1, 0x40, 0xfa, - 0x48, 0x7f, 0x86, 0xde, 0x41, 0x2c, 0xc7, 0x67, 0x23, 0xae, 0x38, 0x13, 0x3f, 0xe5, 0x22, 0x53, - 0xe4, 0x4d, 0x68, 0x62, 0xa3, 0xd6, 0xce, 0x08, 0x1a, 0xc5, 0x86, 0xfd, 0x86, 0x41, 0x51, 0xd0, - 0x28, 0xfa, 0x63, 0xd7, 0x1e, 0x33, 0x82, 0x46, 0xc3, 0x38, 0x1a, 0x9b, 0x6e, 0x3d, 0x66, 0x04, - 0xdd, 0xc7, 0xe3, 0x48, 0x5c, 0xd8, 0x16, 0xf1, 0x4c, 0x03, 0xd8, 0xae, 0xe5, 0xb7, 0x65, 0xee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 0x8b, 0xa9, 0x44, 0x1e, 0x2d, 0x50, 0xc9, 0x6f, 0xa1, 0xc3, 0xdb, 0x95, 0xc3, 0x35, 0x35, 0xbb, - 0x6e, 0x4d, 0x7f, 0x75, 0xe0, 0xf5, 0x7a, 0x09, 0x2f, 0x75, 0x37, 0xca, 0x8d, 0x34, 0x56, 0x6e, - 0xc4, 0x5d, 0xb5, 0x11, 0xaf, 0xda, 0x48, 0xf5, 0xbe, 0x35, 0xeb, 0xef, 0xdb, 0x19, 0xdc, 0x5d, - 0x5a, 0xd3, 0x50, 0x4e, 0x67, 0x9a, 0x0f, 0xff, 0x63, 0x5d, 0xfa, 0xab, 0x91, 0xa6, 0x76, 0x51, - 0x1d, 0x66, 0x04, 0xfa, 0x29, 0xbc, 0x15, 0x0a, 0x55, 0x5b, 0x52, 0xc1, 0xb6, 0x3e, 0xb8, 0xc7, - 0xe2, 0x62, 0x4d, 0xfb, 0x5a, 0x45, 0xbf, 0x00, 0xff, 0x74, 0x36, 0xe1, 0x4a, 0xdc, 0xca, 0xfb, - 0x00, 0xda, 0x27, 0x72, 0x26, 0x63, 0xf9, 0x74, 0x7e, 0xc3, 0xad, 0xf7, 0x61, 0xc3, 0x7c, 0x22, - 0xcd, 0x2f, 0x4f, 0x87, 0x15, 0x22, 0xbd, 0xa3, 0x09, 0x3d, 0xe6, 0xf1, 0x38, 0x8f, 0x75, 0x19, - 0xfa, 0xdf, 0x27, 0x3b, 0xe8, 0xfd, 0x75, 0xb5, 0xeb, 0xfc, 0x7d, 0xb5, 0xeb, 0xfc, 0x73, 0xb5, - 0xeb, 0xfc, 0xfe, 0xef, 0xee, 0x6b, 0x4f, 0x5a, 0xf8, 0x23, 0xfb, 0xf0, 0xbf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x93, 0x15, 0x15, 0x14, 0xd9, 0x0a, 0x00, 0x00, + // 1011 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,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 0xf0, 0x0e, 0xc4, 0xe9, 0x15, 0xe5, 0x6b, 0x11, + 0xfd, 0x12, 0x82, 0xa3, 0x6c, 0xc2, 0x95, 0xb8, 0x91, 0xf5, 0x0e, 0xf4, 0x0e, 0x65, 0x26, 0x13, + 0xf9, 0x62, 0x76, 0xcd, 0xd6, 0x07, 0xb0, 0x64, 0xae, 0x48, 0xf3, 0xf1, 0xe9, 0xb3, 0x8a, 0xa4, + 0xb7, 0x35, 0xa0, 0xc7, 0x3c, 0x19, 0x97, 0x89, 0x4e, 0x43, 0xff, 0x80, 0x8a, 0x9d, 0xd5, 0x3f, + 0xcf, 0x37, 0x9c, 0xbf, 0xce, 0x37, 0x9c, 0xbf, 0xcf, 0x37, 0x9c, 0xdf, 0xfe, 0xd9, 0x78, 0xeb, + 0x79, 0x17, 0x7f, 0xb4, 0x8f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x4d, 0xbe, 0x70, 0xe2, + 0x0a, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index d150b7802..bf846f01c 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -5,7 +5,7 @@ package internal; message IndexMeta { } -message FrameMeta { +message FieldOptions { string Type = 8; string CacheType = 3; uint32 CacheSize = 4; @@ -56,7 +56,7 @@ message CreateIndexMessage { message CreateFrameMessage { string Index = 1; string Frame = 2; - FrameMeta Meta = 3; + FieldOptions Meta = 3; } message DeleteFrameMessage { @@ -66,7 +66,7 @@ message DeleteFrameMessage { message Frame { string Name = 1; - FrameMeta Meta = 2; + FieldOptions Meta = 2; repeated string Views = 3; } From 636bf252adbe57f9b476087ac78bda15488d4695 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:13:49 -0500 Subject: [PATCH 44/52] rename internal Frame to Field --- frame.go | 8 +-- internal/private.pb.go | 110 ++++++++++++++++++++--------------------- internal/private.proto | 4 +- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/frame.go b/frame.go index c830213f7..1cd94cc83 100644 --- a/frame.go +++ b/frame.go @@ -971,8 +971,8 @@ func (f *Field) ImportValue(columnIDs []uint64, values []int64) error { } // encodeFields converts a into its internal representation. -func encodeFields(a []*Field) []*internal.Frame { - other := make([]*internal.Frame, len(a)) +func encodeFields(a []*Field) []*internal.Field { + other := make([]*internal.Field, len(a)) for i := range a { other[i] = encodeField(a[i]) } @@ -980,9 +980,9 @@ func encodeFields(a []*Field) []*internal.Frame { } // encodeField converts f into its internal representation. -func encodeField(f *Field) *internal.Frame { +func encodeField(f *Field) *internal.Field { fo := f.options - return &internal.Frame{ + return &internal.Field{ Name: f.name, Meta: fo.Encode(), Views: f.viewNames(), diff --git a/internal/private.pb.go b/internal/private.pb.go index 56c8eba81..ebeda0e6b 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -21,7 +21,7 @@ CreateIndexMessage CreateFrameMessage DeleteFrameMessage - Frame + Field Schema Index URI @@ -364,32 +364,32 @@ func (m *DeleteFrameMessage) GetFrame() string { return "" } -type Frame struct { +type Field struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Meta *FieldOptions `protobuf:"bytes,2,opt,name=Meta" json:"Meta,omitempty"` Views []string `protobuf:"bytes,3,rep,name=Views" json:"Views,omitempty"` } -func (m *Frame) Reset() { *m = Frame{} } -func (m *Frame) String() string { return proto.CompactTextString(m) } -func (*Frame) ProtoMessage() {} -func (*Frame) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } +func (m *Field) Reset() { *m = Field{} } +func (m *Field) String() string { return proto.CompactTextString(m) } +func (*Field) ProtoMessage() {} +func (*Field) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{12} } -func (m *Frame) GetName() string { +func (m *Field) GetName() string { if m != nil { return m.Name } return "" } -func (m *Frame) GetMeta() *FieldOptions { +func (m *Field) GetMeta() *FieldOptions { if m != nil { return m.Meta } return nil } -func (m *Frame) GetViews() []string { +func (m *Field) GetViews() []string { if m != nil { return m.Views } @@ -414,7 +414,7 @@ func (m *Schema) GetIndexes() []*Index { type Index struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` - Frames []*Frame `protobuf:"bytes,4,rep,name=Frames" json:"Frames,omitempty"` + Frames []*Field `protobuf:"bytes,4,rep,name=Frames" json:"Frames,omitempty"` } func (m *Index) Reset() { *m = Index{} } @@ -429,7 +429,7 @@ func (m *Index) GetName() string { return "" } -func (m *Index) GetFrames() []*Frame { +func (m *Index) GetFrames() []*Field { if m != nil { return m.Frames } @@ -931,7 +931,7 @@ func init() { proto.RegisterType((*CreateIndexMessage)(nil), "internal.CreateIndexMessage") proto.RegisterType((*CreateFrameMessage)(nil), "internal.CreateFrameMessage") proto.RegisterType((*DeleteFrameMessage)(nil), "internal.DeleteFrameMessage") - proto.RegisterType((*Frame)(nil), "internal.Frame") + proto.RegisterType((*Field)(nil), "internal.Field") proto.RegisterType((*Schema)(nil), "internal.Schema") proto.RegisterType((*Index)(nil), "internal.Index") proto.RegisterType((*URI)(nil), "internal.URI") @@ -1368,7 +1368,7 @@ func (m *DeleteFrameMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Frame) Marshal() (dAtA []byte, err error) { +func (m *Field) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1378,7 +1378,7 @@ func (m *Frame) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Frame) MarshalTo(dAtA []byte) (int, error) { +func (m *Field) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2315,7 +2315,7 @@ func (m *DeleteFrameMessage) Size() (n int) { return n } -func (m *Frame) Size() (n int) { +func (m *Field) Size() (n int) { var l int _ = l l = len(m.Name) @@ -4124,7 +4124,7 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *Frame) Unmarshal(dAtA []byte) error { +func (m *Field) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4147,10 +4147,10 @@ func (m *Frame) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Frame: wiretype end group for non-group") + return fmt.Errorf("proto: Field: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Frame: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4430,7 +4430,7 @@ func (m *Index) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frames = append(m.Frames, &Frame{}) + m.Frames = append(m.Frames, &Field{}) if err := m.Frames[len(m.Frames)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6617,7 +6617,7 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1011 bytes of a gzipped FileDescriptorProto + // 1013 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6f, 0x1c, 0x35, 0x18, 0x67, 0x1e, 0xbb, 0xd9, 0xfd, 0xd2, 0x0d, 0x89, 0x0b, 0x61, 0x8a, 0x50, 0x58, 0xac, 0x4a, 0x0d, 0x3d, 0x44, 0xa5, 0xbd, 0xf0, 0xaa, 0x14, 0x25, 0x9b, 0xc2, 0x20, 0x12, 0xc0, 0x93, 0xf4, @@ -6647,39 +6647,39 @@ var fileDescriptorPrivate = []byte{ 0xef, 0x03, 0x19, 0x89, 0x44, 0x28, 0x61, 0xf1, 0xf8, 0x1a, 0x0f, 0x34, 0xaa, 0xa2, 0x5d, 0xaf, 0x4b, 0xee, 0x81, 0xaf, 0xc1, 0x8d, 0xc1, 0x96, 0x1f, 0xde, 0x6e, 0x3a, 0x52, 0xe3, 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bc, 0xf5, 0xbc, 0x8b, 0x3f, 0xda, 0x47, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xab, 0x64, 0x15, + 0x6e, 0xe2, 0x0a, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index bf846f01c..30d41205b 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -64,7 +64,7 @@ message DeleteFrameMessage { string Frame = 2; } -message Frame { +message Field { string Name = 1; FieldOptions Meta = 2; repeated string Views = 3; @@ -76,7 +76,7 @@ message Schema { message Index { string Name = 1; - repeated Frame Frames = 4; + repeated Field Frames = 4; } message URI { From cb7487e34d534735ad1395705339bb70a7160586 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:24:24 -0500 Subject: [PATCH 45/52] change all instances of internal Frame to Field --- api.go | 32 ++--- broadcast.go | 20 +-- client.go | 8 +- cluster.go | 6 +- frame.go | 2 +- holder.go | 2 +- index.go | 2 +- internal/private.pb.go | 310 ++++++++++++++++++++--------------------- internal/private.proto | 18 +-- internal/public.pb.go | 126 ++++++++--------- internal/public.proto | 4 +- server.go | 16 +-- 12 files changed, 273 insertions(+), 273 deletions(-) diff --git a/api.go b/api.go index 9bd3abdf4..ae010e4f1 100644 --- a/api.go +++ b/api.go @@ -237,16 +237,16 @@ func (api *API) CreateFrame(ctx context.Context, indexName string, frameName str // Send the create frame message to all nodes. err = api.Broadcaster.SendSync( - &internal.CreateFrameMessage{ + &internal.CreateFieldMessage{ Index: indexName, - Frame: frameName, + Field: frameName, Meta: options.Encode(), }) if err != nil { - api.Logger.Printf("problem sending CreateFrame message: %s", err) - return nil, errors.Wrap(err, "sending CreateFrame message") + api.Logger.Printf("problem sending CreateField message: %s", err) + return nil, errors.Wrap(err, "sending CreateField message") } - api.Holder.Stats.CountWithCustomTags("createFrame", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) + api.Holder.Stats.CountWithCustomTags("createField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return frame, nil } @@ -271,15 +271,15 @@ func (api *API) DeleteFrame(ctx context.Context, indexName string, frameName str // Send the delete frame message to all nodes. err := api.Broadcaster.SendSync( - &internal.DeleteFrameMessage{ + &internal.DeleteFieldMessage{ Index: indexName, - Frame: frameName, + Field: frameName, }) if err != nil { - api.Logger.Printf("problem sending DeleteFrame message: %s", err) - return errors.Wrap(err, "sending DeleteFrame message") + api.Logger.Printf("problem sending DeleteField message: %s", err) + return errors.Wrap(err, "sending DeleteField message") } - api.Holder.Stats.CountWithCustomTags("deleteFrame", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) + api.Holder.Stats.CountWithCustomTags("deleteField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) return nil } @@ -397,7 +397,7 @@ func (api *API) FragmentBlockData(ctx context.Context, body io.Reader) ([]byte, } // Retrieve fragment from holder. - f := api.Holder.Fragment(req.Index, req.Frame, ViewStandard, req.Slice) + f := api.Holder.Fragment(req.Index, req.Field, ViewStandard, req.Slice) if f == nil { return nil, ErrFragmentNotFound } @@ -529,7 +529,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, frameName stri err := api.Broadcaster.SendSync( &internal.DeleteViewMessage{ Index: indexName, - Frame: frameName, + Field: frameName, View: viewName, }) if err != nil { @@ -614,7 +614,7 @@ func (api *API) Import(ctx context.Context, req internal.ImportRequest) error { return errors.Wrap(err, "validating api method") } - _, frame, err := api.indexFrame(req.Index, req.Frame, req.Slice) + _, frame, err := api.indexFrame(req.Index, req.Field, req.Slice) if err != nil { return errors.Wrap(err, "getting frame") } @@ -632,7 +632,7 @@ func (api *API) Import(ctx context.Context, req internal.ImportRequest) error { // Import into fragment. err = frame.Import(req.RowIDs, req.ColumnIDs, timestamps) if err != nil { - api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Frame, req.Slice, len(req.ColumnIDs), err) + api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) } return errors.Wrap(err, "importing") } @@ -643,7 +643,7 @@ func (api *API) ImportValue(ctx context.Context, req internal.ImportValueRequest return errors.Wrap(err, "validating api method") } - _, frame, err := api.indexFrame(req.Index, req.Frame, req.Slice) + _, frame, err := api.indexFrame(req.Index, req.Field, req.Slice) if err != nil { return errors.Wrap(err, "getting frame") } @@ -651,7 +651,7 @@ func (api *API) ImportValue(ctx context.Context, req internal.ImportValueRequest // Import into fragment. err = frame.ImportValue(req.ColumnIDs, req.Values) if err != nil { - api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Frame, req.Slice, len(req.ColumnIDs), err) + api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) } return errors.Wrap(err, "importing") } diff --git a/broadcast.go b/broadcast.go index 933ca05a5..6b26b5d58 100644 --- a/broadcast.go +++ b/broadcast.go @@ -123,8 +123,8 @@ const ( MessageTypeCreateSlice = iota MessageTypeCreateIndex MessageTypeDeleteIndex - MessageTypeCreateFrame - MessageTypeDeleteFrame + MessageTypeCreateField + MessageTypeDeleteField MessageTypeCreateView MessageTypeDeleteView MessageTypeClusterStatus @@ -147,10 +147,10 @@ func MarshalMessage(m proto.Message) ([]byte, error) { typ = MessageTypeCreateIndex case *internal.DeleteIndexMessage: typ = MessageTypeDeleteIndex - case *internal.CreateFrameMessage: - typ = MessageTypeCreateFrame - case *internal.DeleteFrameMessage: - typ = MessageTypeDeleteFrame + case *internal.CreateFieldMessage: + typ = MessageTypeCreateField + case *internal.DeleteFieldMessage: + typ = MessageTypeDeleteField case *internal.CreateViewMessage: typ = MessageTypeCreateView case *internal.DeleteViewMessage: @@ -193,10 +193,10 @@ func UnmarshalMessage(buf []byte) (proto.Message, error) { m = &internal.CreateIndexMessage{} case MessageTypeDeleteIndex: m = &internal.DeleteIndexMessage{} - case MessageTypeCreateFrame: - m = &internal.CreateFrameMessage{} - case MessageTypeDeleteFrame: - m = &internal.DeleteFrameMessage{} + case MessageTypeCreateField: + m = &internal.CreateFieldMessage{} + case MessageTypeDeleteField: + m = &internal.DeleteFieldMessage{} case MessageTypeCreateView: m = &internal.CreateViewMessage{} case MessageTypeDeleteView: diff --git a/client.go b/client.go index e293c14af..ae536f2c4 100644 --- a/client.go +++ b/client.go @@ -348,7 +348,7 @@ func marshalImportPayload(index, field string, slice uint64, bits []Bit) ([]byte // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportRequest{ Index: index, - Frame: field, + Field: field, Slice: slice, RowIDs: rowIDs, ColumnIDs: columnIDs, @@ -370,7 +370,7 @@ func marshalImportPayloadK(index, field string, bits []Bit) ([]byte, error) { // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportRequest{ Index: index, - Frame: field, + Field: field, RowKeys: rowKeys, ColumnKeys: columnKeys, Timestamps: timestamps, @@ -457,7 +457,7 @@ func marshalImportValuePayload(index, field string, slice uint64, vals []FieldVa // Marshal data to protobuf. buf, err := proto.Marshal(&internal.ImportValueRequest{ Index: index, - Frame: field, + Field: field, Slice: slice, ColumnIDs: columnIDs, Values: values, @@ -710,7 +710,7 @@ func (c *InternalHTTPClient) FragmentBlocks(ctx context.Context, index, field st func (c *InternalHTTPClient) BlockData(ctx context.Context, index, field string, slice uint64, block int) ([]uint64, []uint64, error) { buf, err := proto.Marshal(&internal.BlockDataRequest{ Index: index, - Frame: field, + Field: field, Slice: slice, Block: uint64(block), }) diff --git a/cluster.go b/cluster.go index 9a467c284..9723e5bce 100644 --- a/cluster.go +++ b/cluster.go @@ -770,7 +770,7 @@ func (c *Cluster) fragSources(to *Cluster, idx *Index) (map[string][]*internal.R src := &internal.ResizeSource{ Node: EncodeNode(c.nodeByID(srcNodeID)), Index: idx.Name(), - Frame: frag.field, + Field: frag.field, View: frag.view, Slice: frag.slice, } @@ -1240,7 +1240,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err srcURI := decodeURI(src.Node.URI) // Retrieve field. - f := c.Holder.Field(src.Index, src.Frame) + f := c.Holder.Field(src.Index, src.Field) if f == nil { return ErrFieldNotFound } @@ -1259,7 +1259,7 @@ func (c *Cluster) FollowResizeInstruction(instr *internal.ResizeInstruction) err // Stream slice from remote node. c.Logger.Printf("retrieve slice %d for index %s from host %s", src.Slice, src.Index, src.Node.URI) - rd, err := client.RetrieveSliceFromURI(context.Background(), src.Index, src.Frame, src.Slice, srcURI) + rd, err := client.RetrieveSliceFromURI(context.Background(), src.Index, src.Field, src.Slice, srcURI) if err != nil { // For now it is an acceptable error if the fragment is not found // on the remote node. This occurs when a slice has been skipped and diff --git a/frame.go b/frame.go index 1cd94cc83..60e41e265 100644 --- a/frame.go +++ b/frame.go @@ -556,7 +556,7 @@ func (f *Field) CreateViewIfNotExists(name string) (*View, error) { err = f.broadcaster.SendSync( &internal.CreateViewMessage{ Index: f.index, - Frame: f.name, + Field: f.name, View: name, }) if err != nil { diff --git a/holder.go b/holder.go index f4e47e3d0..bbff69927 100644 --- a/holder.go +++ b/holder.go @@ -239,7 +239,7 @@ func (h *Holder) ApplySchema(schema *internal.Schema) error { return errors.Wrap(err, "creating index") } // Create frames that don't exist. - for _, f := range index.Frames { + for _, f := range index.Fields { opt := decodeFieldOptions(f.Meta) frame, err := idx.CreateFieldIfNotExists(f.Name, *opt) if err != nil { diff --git a/index.go b/index.go index 727989914..72b9cc1e7 100644 --- a/index.go +++ b/index.go @@ -402,7 +402,7 @@ func EncodeIndexes(a []*Index) []*internal.Index { func encodeIndex(d *Index) *internal.Index { return &internal.Index{ Name: d.name, - Frames: encodeFields(d.Fields()), + Fields: encodeFields(d.Fields()), } } diff --git a/internal/private.pb.go b/internal/private.pb.go index ebeda0e6b..1e2b34f38 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -19,8 +19,8 @@ CreateSliceMessage DeleteIndexMessage CreateIndexMessage - CreateFrameMessage - DeleteFrameMessage + CreateFieldMessage + DeleteFieldMessage Field Schema Index @@ -142,7 +142,7 @@ func (m *ImportResponse) GetErr() string { type BlockDataRequest 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` View string `protobuf:"bytes,5,opt,name=View,proto3" json:"View,omitempty"` Slice uint64 `protobuf:"varint,4,opt,name=Slice,proto3" json:"Slice,omitempty"` Block uint64 `protobuf:"varint,3,opt,name=Block,proto3" json:"Block,omitempty"` @@ -160,9 +160,9 @@ func (m *BlockDataRequest) GetIndex() string { return "" } -func (m *BlockDataRequest) GetFrame() string { +func (m *BlockDataRequest) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -308,58 +308,58 @@ func (m *CreateIndexMessage) GetMeta() *IndexMeta { return nil } -type CreateFrameMessage struct { +type CreateFieldMessage 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` Meta *FieldOptions `protobuf:"bytes,3,opt,name=Meta" json:"Meta,omitempty"` } -func (m *CreateFrameMessage) Reset() { *m = CreateFrameMessage{} } -func (m *CreateFrameMessage) String() string { return proto.CompactTextString(m) } -func (*CreateFrameMessage) ProtoMessage() {} -func (*CreateFrameMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{10} } +func (m *CreateFieldMessage) Reset() { *m = CreateFieldMessage{} } +func (m *CreateFieldMessage) String() string { return proto.CompactTextString(m) } +func (*CreateFieldMessage) ProtoMessage() {} +func (*CreateFieldMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{10} } -func (m *CreateFrameMessage) GetIndex() string { +func (m *CreateFieldMessage) GetIndex() string { if m != nil { return m.Index } return "" } -func (m *CreateFrameMessage) GetFrame() string { +func (m *CreateFieldMessage) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } -func (m *CreateFrameMessage) GetMeta() *FieldOptions { +func (m *CreateFieldMessage) GetMeta() *FieldOptions { if m != nil { return m.Meta } return nil } -type DeleteFrameMessage struct { +type DeleteFieldMessage 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` } -func (m *DeleteFrameMessage) Reset() { *m = DeleteFrameMessage{} } -func (m *DeleteFrameMessage) String() string { return proto.CompactTextString(m) } -func (*DeleteFrameMessage) ProtoMessage() {} -func (*DeleteFrameMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{11} } +func (m *DeleteFieldMessage) Reset() { *m = DeleteFieldMessage{} } +func (m *DeleteFieldMessage) String() string { return proto.CompactTextString(m) } +func (*DeleteFieldMessage) ProtoMessage() {} +func (*DeleteFieldMessage) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{11} } -func (m *DeleteFrameMessage) GetIndex() string { +func (m *DeleteFieldMessage) GetIndex() string { if m != nil { return m.Index } return "" } -func (m *DeleteFrameMessage) GetFrame() string { +func (m *DeleteFieldMessage) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -414,7 +414,7 @@ func (m *Schema) GetIndexes() []*Index { type Index struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` - Frames []*Field `protobuf:"bytes,4,rep,name=Frames" json:"Frames,omitempty"` + Fields []*Field `protobuf:"bytes,4,rep,name=Fields" json:"Fields,omitempty"` } func (m *Index) Reset() { *m = Index{} } @@ -429,9 +429,9 @@ func (m *Index) GetName() string { return "" } -func (m *Index) GetFrames() []*Field { +func (m *Index) GetFields() []*Field { if m != nil { - return m.Frames + return m.Fields } return nil } @@ -654,7 +654,7 @@ func (m *BSIGroup) GetMax() int64 { type CreateViewMessage 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` View string `protobuf:"bytes,3,opt,name=View,proto3" json:"View,omitempty"` } @@ -670,9 +670,9 @@ func (m *CreateViewMessage) GetIndex() string { return "" } -func (m *CreateViewMessage) GetFrame() string { +func (m *CreateViewMessage) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -686,7 +686,7 @@ func (m *CreateViewMessage) GetView() string { type DeleteViewMessage struct { Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"` - Frame string `protobuf:"bytes,2,opt,name=Frame,proto3" json:"Frame,omitempty"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` View string `protobuf:"bytes,3,opt,name=View,proto3" json:"View,omitempty"` } @@ -702,9 +702,9 @@ func (m *DeleteViewMessage) GetIndex() string { return "" } -func (m *DeleteViewMessage) GetFrame() string { +func (m *DeleteViewMessage) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -775,7 +775,7 @@ func (m *ResizeInstruction) GetClusterStatus() *ClusterStatus { type ResizeSource struct { Node *Node `protobuf:"bytes,1,opt,name=Node" json:"Node,omitempty"` Index string `protobuf:"bytes,2,opt,name=Index,proto3" json:"Index,omitempty"` - Frame string `protobuf:"bytes,3,opt,name=Frame,proto3" json:"Frame,omitempty"` + Field string `protobuf:"bytes,3,opt,name=Field,proto3" json:"Field,omitempty"` View string `protobuf:"bytes,4,opt,name=View,proto3" json:"View,omitempty"` Slice uint64 `protobuf:"varint,5,opt,name=Slice,proto3" json:"Slice,omitempty"` } @@ -799,9 +799,9 @@ func (m *ResizeSource) GetIndex() string { return "" } -func (m *ResizeSource) GetFrame() string { +func (m *ResizeSource) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -929,8 +929,8 @@ func init() { proto.RegisterType((*CreateSliceMessage)(nil), "internal.CreateSliceMessage") proto.RegisterType((*DeleteIndexMessage)(nil), "internal.DeleteIndexMessage") proto.RegisterType((*CreateIndexMessage)(nil), "internal.CreateIndexMessage") - proto.RegisterType((*CreateFrameMessage)(nil), "internal.CreateFrameMessage") - proto.RegisterType((*DeleteFrameMessage)(nil), "internal.DeleteFrameMessage") + proto.RegisterType((*CreateFieldMessage)(nil), "internal.CreateFieldMessage") + proto.RegisterType((*DeleteFieldMessage)(nil), "internal.DeleteFieldMessage") proto.RegisterType((*Field)(nil), "internal.Field") proto.RegisterType((*Schema)(nil), "internal.Schema") proto.RegisterType((*Index)(nil), "internal.Index") @@ -1065,11 +1065,11 @@ func (m *BlockDataRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if m.Block != 0 { dAtA[i] = 0x18 @@ -1298,7 +1298,7 @@ func (m *CreateIndexMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CreateFrameMessage) Marshal() (dAtA []byte, err error) { +func (m *CreateFieldMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1308,7 +1308,7 @@ func (m *CreateFrameMessage) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CreateFrameMessage) MarshalTo(dAtA []byte) (int, error) { +func (m *CreateFieldMessage) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1319,11 +1319,11 @@ func (m *CreateFrameMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if m.Meta != nil { dAtA[i] = 0x1a @@ -1338,7 +1338,7 @@ func (m *CreateFrameMessage) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *DeleteFrameMessage) Marshal() (dAtA []byte, err error) { +func (m *DeleteFieldMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1348,7 +1348,7 @@ func (m *DeleteFrameMessage) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DeleteFrameMessage) MarshalTo(dAtA []byte) (int, error) { +func (m *DeleteFieldMessage) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1359,11 +1359,11 @@ func (m *DeleteFrameMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } return i, nil } @@ -1468,8 +1468,8 @@ func (m *Index) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Name))) i += copy(dAtA[i:], m.Name) } - if len(m.Frames) > 0 { - for _, msg := range m.Frames { + if len(m.Fields) > 0 { + for _, msg := range m.Fields { dAtA[i] = 0x22 i++ i = encodeVarintPrivate(dAtA, i, uint64(msg.Size())) @@ -1776,11 +1776,11 @@ func (m *CreateViewMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if len(m.View) > 0 { dAtA[i] = 0x1a @@ -1812,11 +1812,11 @@ func (m *DeleteViewMessage) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if len(m.View) > 0 { dAtA[i] = 0x1a @@ -1933,11 +1933,11 @@ func (m *ResizeSource) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPrivate(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintPrivate(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPrivate(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if len(m.View) > 0 { dAtA[i] = 0x22 @@ -2182,7 +2182,7 @@ func (m *BlockDataRequest) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2283,14 +2283,14 @@ func (m *CreateIndexMessage) Size() (n int) { return n } -func (m *CreateFrameMessage) Size() (n int) { +func (m *CreateFieldMessage) Size() (n int) { var l int _ = l l = len(m.Index) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2301,14 +2301,14 @@ func (m *CreateFrameMessage) Size() (n int) { return n } -func (m *DeleteFrameMessage) Size() (n int) { +func (m *DeleteFieldMessage) Size() (n int) { var l int _ = l l = len(m.Index) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2354,8 +2354,8 @@ func (m *Index) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - if len(m.Frames) > 0 { - for _, e := range m.Frames { + if len(m.Fields) > 0 { + for _, e := range m.Fields { l = e.Size() n += 1 + l + sovPrivate(uint64(l)) } @@ -2489,7 +2489,7 @@ func (m *CreateViewMessage) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2507,7 +2507,7 @@ func (m *DeleteViewMessage) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -2560,7 +2560,7 @@ func (m *ResizeSource) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } @@ -3029,7 +3029,7 @@ func (m *BlockDataRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3054,7 +3054,7 @@ func (m *BlockDataRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { @@ -3875,7 +3875,7 @@ func (m *CreateIndexMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { +func (m *CreateFieldMessage) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3898,10 +3898,10 @@ func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CreateFrameMessage: wiretype end group for non-group") + return fmt.Errorf("proto: CreateFieldMessage: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CreateFrameMessage: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CreateFieldMessage: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3935,7 +3935,7 @@ func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3960,7 +3960,7 @@ func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -4016,7 +4016,7 @@ func (m *CreateFrameMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { +func (m *DeleteFieldMessage) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4039,10 +4039,10 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteFrameMessage: wiretype end group for non-group") + return fmt.Errorf("proto: DeleteFieldMessage: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteFrameMessage: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DeleteFieldMessage: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4076,7 +4076,7 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4101,7 +4101,7 @@ func (m *DeleteFrameMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -4406,7 +4406,7 @@ func (m *Index) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frames", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4430,8 +4430,8 @@ func (m *Index) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frames = append(m.Frames, &Field{}) - if err := m.Frames[len(m.Frames)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Fields = append(m.Fields, &Field{}) + if err := m.Fields[len(m.Fields)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -5419,7 +5419,7 @@ func (m *CreateViewMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5444,7 +5444,7 @@ func (m *CreateViewMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -5556,7 +5556,7 @@ func (m *DeleteViewMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5581,7 +5581,7 @@ func (m *DeleteViewMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -5958,7 +5958,7 @@ func (m *ResizeSource) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5983,7 +5983,7 @@ func (m *ResizeSource) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -6617,69 +6617,69 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1013 bytes of a gzipped FileDescriptorProto + // 1011 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6f, 0x1c, 0x35, 0x18, 0x67, 0x1e, 0xbb, 0xd9, 0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76, 0x8f, 0x04, 0x7d, 0x04, 0xdd, 0x68, 0xfc, 0x52, 0x4c, - 0x39, 0xf9, 0x18, 0x96, 0x30, 0x0f, 0x51, 0x58, 0x58, 0xbd, 0x7d, 0xa9, 0x89, 0xac, 0x92, 0xd3, - 0x91, 0xcd, 0x7f, 0x61, 0x4e, 0xf7, 0xa0, 0x8b, 0x99, 0x17, 0x81, 0x7f, 0xd9, 0x0d, 0x66, 0xc5, - 0xac, 0x98, 0xee, 0x81, 0x77, 0xc4, 0x42, 0xbd, 0x2e, 0x98, 0x41, 0xe5, 0xc5, 0x52, 0xda, 0xf7, - 0xd7, 0xb2, 0x50, 0xb6, 0x1b, 0x78, 0xd6, 0xbc, 0xef, 0x65, 0xae, 0xb0, 0xf5, 0x03, 0x86, 0x67, - 0xfa, 0x0c, 0xfc, 0x03, 0x39, 0x11, 0x64, 0x05, 0xdc, 0x70, 0x64, 0x7d, 0xb8, 0xe1, 0x88, 0x7c, - 0x88, 0xee, 0x6d, 0x6b, 0x06, 0x4d, 0x12, 0x47, 0x2c, 0x64, 0x18, 0xf8, 0x2e, 0x0c, 0xc2, 0x62, - 0x57, 0xca, 0x7c, 0x12, 0xa7, 0x5c, 0xc9, 0x1c, 0xbd, 0xf6, 0xd8, 0x45, 0x26, 0xdd, 0x86, 0x55, - 0xed, 0x3e, 0x52, 0x5c, 0xd5, 0xf3, 0x5b, 0x87, 0xae, 0xe6, 0xd5, 0xe1, 0x2c, 0x85, 0x90, 0xd7, - 0x7a, 0xd5, 0x04, 0x91, 0xa0, 0xdf, 0x1a, 0x0f, 0x7b, 0x27, 0x22, 0x55, 0x2d, 0x04, 0x20, 0x8d, - 0x0e, 0x06, 0xcc, 0x10, 0x84, 0x9a, 0x52, 0x6c, 0xce, 0x2b, 0x4d, 0xce, 0x9a, 0xcb, 0x50, 0x46, - 0x7f, 0x75, 0x00, 0xaa, 0x84, 0xca, 0xa2, 0x36, 0x71, 0xae, 0x36, 0x21, 0x9f, 0xb4, 0xae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09, 0xf3, 0x10, 0x85, 0x85, 0xd5, 0xdb, 0x97, 0x9a, 0xc8, 0x2a, 0x39, 0x1d, 0xd9, 0xfc, + 0x17, 0xe6, 0x74, 0x0f, 0xba, 0x18, 0xbd, 0x08, 0xfc, 0xcb, 0x6e, 0x90, 0xcf, 0xac, 0x98, 0xee, + 0x81, 0x77, 0xc4, 0x42, 0xbd, 0x2e, 0x98, 0x41, 0xe5, 0xc5, 0x52, 0xda, 0xf7, 0x37, 0xb2, 0x50, + 0xb6, 0x1b, 0x78, 0xd6, 0xbc, 0x1f, 0x64, 0xae, 0xb0, 0xf5, 0x03, 0x86, 0x67, 0xfa, 0x14, 0xfc, + 0x03, 0x39, 0x11, 0x64, 0x05, 0xdc, 0x70, 0x64, 0x7d, 0xb8, 0xe1, 0x88, 0x7c, 0x88, 0xee, 0x6d, + 0x6b, 0x06, 0x4d, 0x12, 0x47, 0x2c, 0x64, 0x18, 0xf8, 0x2e, 0x0c, 0xc2, 0x62, 0x57, 0xca, 0x7c, + 0x12, 0xa7, 0x5c, 0xc9, 0x1c, 0xbd, 0xf6, 0xd8, 0x45, 0x26, 0xdd, 0x86, 0x55, 0xed, 0x3e, 0x52, + 0x5c, 0xd5, 0x80, 0x5f, 0x87, 0xae, 0xe6, 0xd5, 0xe1, 0x2c, 0x85, 0x90, 0xd7, 0x7a, 0xd5, 0x04, + 0x91, 0xa0, 0xdf, 0x19, 0x0f, 0x7b, 0x27, 0x22, 0x55, 0x2d, 0x04, 0x20, 0x8d, 0x0e, 0x06, 0xcc, + 0x10, 0x84, 0x9a, 0x52, 0x6c, 0xce, 0x2b, 0x4d, 0xce, 0x9a, 0xcb, 0x50, 0x46, 0x7f, 0x73, 0x00, + 0xaa, 0x84, 0xca, 0xa2, 0x36, 0x71, 0xae, 0x36, 0x21, 0x9f, 0xb4, 0xae, 0x8f, 0xf9, 0x05, 0xa9, + 0x45, 0xac, 0x75, 0xc9, 0x6c, 0x56, 0xb0, 0xb0, 0x28, 0x5f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0x48, 0xf3, 0xca, 0x75, 0xda, 0xaf, 0xdc, 0x31, 0xdc, 0x99, 0x1b, 0xd3, 0xae, 0x9c, 0x66, 0x1a, + 0x0f, 0xff, 0x63, 0x5c, 0xfa, 0xd6, 0xc8, 0x73, 0x3b, 0xa8, 0x3e, 0x33, 0x04, 0xfd, 0x0c, 0xde, + 0x8d, 0x84, 0x6a, 0x0d, 0xa9, 0x42, 0xdb, 0x10, 0xbc, 0x03, 0x71, 0x7a, 0x45, 0xf9, 0x5a, 0x44, + 0xbf, 0x84, 0xe0, 0x28, 0x9b, 0x70, 0x25, 0x6e, 0x64, 0xbd, 0x03, 0xbd, 0x43, 0x99, 0xc9, 0x44, + 0x3e, 0x9f, 0x5d, 0xb3, 0xf5, 0x01, 0x2c, 0x99, 0x2b, 0xd2, 0x7c, 0x7c, 0xfa, 0xac, 0x22, 0xe9, + 0x6d, 0x0d, 0xe8, 0x31, 0x4f, 0xc6, 0x65, 0xa2, 0xd3, 0xd0, 0x3f, 0xa0, 0x62, 0x67, 0xf5, 0xaf, + 0xf3, 0x0d, 0xe7, 0xef, 0xf3, 0x0d, 0xe7, 0x9f, 0xf3, 0x0d, 0xe7, 0xf7, 0x7f, 0x37, 0xde, 0x7a, + 0xd6, 0xc5, 0x1f, 0xed, 0xa3, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x97, 0xf0, 0x12, 0xfd, 0xe2, + 0x0a, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index 30d41205b..9cab31828 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -20,7 +20,7 @@ message ImportResponse { message BlockDataRequest { string Index = 1; - string Frame = 2; + string Field = 2; string View = 5; uint64 Slice = 4; uint64 Block = 3; @@ -53,15 +53,15 @@ message CreateIndexMessage { IndexMeta Meta = 2; } -message CreateFrameMessage { +message CreateFieldMessage { string Index = 1; - string Frame = 2; + string Field = 2; FieldOptions Meta = 3; } -message DeleteFrameMessage { +message DeleteFieldMessage { string Index = 1; - string Frame = 2; + string Field = 2; } message Field { @@ -76,7 +76,7 @@ message Schema { message Index { string Name = 1; - repeated Field Frames = 4; + repeated Field Fields = 4; } message URI { @@ -122,13 +122,13 @@ message BSIGroup { message CreateViewMessage { string Index = 1; - string Frame = 2; + string Field = 2; string View = 3; } message DeleteViewMessage { string Index = 1; - string Frame = 2; + string Field = 2; string View = 3; } @@ -144,7 +144,7 @@ message ResizeInstruction { message ResizeSource { Node Node = 1; string Index = 2; - string Frame = 3; + string Field = 3; string View = 4; uint64 Slice = 5; } diff --git a/internal/public.pb.go b/internal/public.pb.go index 2fc4b3827..76266d2db 100644 --- a/internal/public.pb.go +++ b/internal/public.pb.go @@ -411,7 +411,7 @@ func (m *QueryResult) GetChanged() bool { type ImportRequest 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` 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"` @@ -432,9 +432,9 @@ func (m *ImportRequest) GetIndex() string { return "" } -func (m *ImportRequest) GetFrame() string { +func (m *ImportRequest) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -483,7 +483,7 @@ func (m *ImportRequest) GetTimestamps() []int64 { 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"` + Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"` Slice uint64 `protobuf:"varint,3,opt,name=Slice,proto3" json:"Slice,omitempty"` ColumnIDs []uint64 `protobuf:"varint,5,rep,packed,name=ColumnIDs" json:"ColumnIDs,omitempty"` ColumnKeys []string `protobuf:"bytes,7,rep,name=ColumnKeys" json:"ColumnKeys,omitempty"` @@ -502,9 +502,9 @@ func (m *ImportValueRequest) GetIndex() string { return "" } -func (m *ImportValueRequest) GetFrame() string { +func (m *ImportValueRequest) GetField() string { if m != nil { - return m.Frame + return m.Field } return "" } @@ -1054,11 +1054,11 @@ func (m *ImportRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPublic(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPublic(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPublic(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if m.Slice != 0 { dAtA[i] = 0x18 @@ -1171,11 +1171,11 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintPublic(dAtA, i, uint64(len(m.Index))) i += copy(dAtA[i:], m.Index) } - if len(m.Frame) > 0 { + if len(m.Field) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintPublic(dAtA, i, uint64(len(m.Frame))) - i += copy(dAtA[i:], m.Frame) + i = encodeVarintPublic(dAtA, i, uint64(len(m.Field))) + i += copy(dAtA[i:], m.Field) } if m.Slice != 0 { dAtA[i] = 0x18 @@ -1474,7 +1474,7 @@ func (m *ImportRequest) Size() (n int) { if l > 0 { n += 1 + l + sovPublic(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPublic(uint64(l)) } @@ -1524,7 +1524,7 @@ func (m *ImportValueRequest) Size() (n int) { if l > 0 { n += 1 + l + sovPublic(uint64(l)) } - l = len(m.Frame) + l = len(m.Field) if l > 0 { n += 1 + l + sovPublic(uint64(l)) } @@ -3072,7 +3072,7 @@ func (m *ImportRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3097,7 +3097,7 @@ func (m *ImportRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { @@ -3443,7 +3443,7 @@ func (m *ImportValueRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Frame", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3468,7 +3468,7 @@ func (m *ImportValueRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Frame = string(dAtA[iNdEx:postIndex]) + m.Field = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { @@ -3771,49 +3771,49 @@ var ( func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) } var fileDescriptorPublic = []byte{ - // 701 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd4, 0x3c, - 0x14, 0xfd, 0x3c, 0xc9, 0xfc, 0xdd, 0xe9, 0xcc, 0x57, 0x59, 0xdf, 0x57, 0x22, 0x84, 0x86, 0x28, - 0x42, 0x28, 0xab, 0xa9, 0x34, 0xec, 0x41, 0xf4, 0x4f, 0x1a, 0x55, 0x54, 0x70, 0x5b, 0x8a, 0x58, - 0xa6, 0xad, 0x55, 0x22, 0x65, 0xe2, 0x90, 0x38, 0x9a, 0xce, 0x73, 0xb0, 0xe1, 0x11, 0x58, 0xf0, - 0x10, 0x2c, 0xbb, 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74, 0xfc, 0x57, 0xfd, 0xae, 0xf3, 0xe2, 0x84, 0x0e, 0x36, 0x18, 0x7d, 0x0f, 0x28, 0x17, - 0xf4, 0x91, 0xeb, 0xd2, 0x47, 0xce, 0x42, 0xbd, 0xd2, 0x94, 0x21, 0xb1, 0x47, 0x62, 0x83, 0x09, - 0xbe, 0x32, 0xe0, 0xc6, 0x23, 0x35, 0xd2, 0xdf, 0x33, 0x7a, 0xbf, 0xa1, 0x2d, 0xe8, 0xd0, 0x7e, - 0xd6, 0x4c, 0x85, 0xd6, 0x8e, 0xdb, 0x5d, 0x3f, 0xee, 0xce, 0xe6, 0xf5, 0xcd, 0x98, 0x7d, 0xbf, - 0x19, 0xb3, 0x1f, 0x37, 0x63, 0xf6, 0xf9, 0xd7, 0xf8, 0x9f, 0xb3, 0x0e, 0xfd, 0x34, 0x9e, 0xfd, - 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x5d, 0x77, 0x8c, 0x44, 0x06, 0x00, 0x00, + // 699 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x65, 0x62, 0xe7, 0x75, 0xd3, 0x84, 0x6a, 0x04, 0xc5, 0x42, 0x28, 0x58, 0x16, 0x42, 0x5e, + 0xa5, 0x52, 0xd8, 0x83, 0xe8, 0x4b, 0x8a, 0x2a, 0x2a, 0xb8, 0x2d, 0x45, 0x2c, 0xdd, 0x66, 0x54, + 0x2c, 0x39, 0x9e, 0x60, 0x8f, 0x95, 0xe6, 0x3b, 0xd8, 0xf0, 0x09, 0x2c, 0xf8, 0x08, 0x96, 0x5d, + 0xf2, 0x09, 0x50, 0x7e, 0x04, 0xcd, 0x1d, 0x4f, 0xec, 0xa6, 0x52, 0xc5, 0x82, 0xdd, 0x9c, 0x73, + 0x66, 0xee, 0xcc, 0x99, 0x39, 0xd7, 0x86, 0x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 0x0c, 0x89, 0x1d, 0x12, 0x6b, 0x4c, 0xf0, 0x9d, + 0x01, 0x37, 0x1e, 0xa9, 0x91, 0xfe, 0x9f, 0xd1, 0xbb, 0x0d, 0x6d, 0x41, 0x8b, 0xf6, 0xb3, 0x66, + 0x4a, 0xb4, 0x76, 0xdc, 0xf6, 0xfa, 0x71, 0x77, 0x36, 0xaf, 0xae, 0x87, 0xec, 0xe7, 0xf5, 0x90, + 0xfd, 0xba, 0x1e, 0xb2, 0xaf, 0x7f, 0x86, 0xf7, 0xce, 0x5a, 0xf4, 0xd3, 0x78, 0xf1, 0x37, 0x00, + 0x00, 0xff, 0xff, 0x71, 0x71, 0xa2, 0x0c, 0x44, 0x06, 0x00, 0x00, } diff --git a/internal/public.proto b/internal/public.proto index b37eea98c..cd34b88ff 100644 --- a/internal/public.proto +++ b/internal/public.proto @@ -70,7 +70,7 @@ message QueryResult { message ImportRequest { string Index = 1; - string Frame = 2; + string Field = 2; uint64 Slice = 3; repeated uint64 RowIDs = 4; repeated uint64 ColumnIDs = 5; @@ -81,7 +81,7 @@ message ImportRequest { message ImportValueRequest { string Index = 1; - string Frame = 2; + string Field = 2; uint64 Slice = 3; repeated uint64 ColumnIDs = 5; repeated string ColumnKeys = 7; diff --git a/server.go b/server.go index 541ff12c6..471319dd7 100644 --- a/server.go +++ b/server.go @@ -455,34 +455,34 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if err := s.Holder.DeleteIndex(obj.Index); err != nil { return err } - case *internal.CreateFrameMessage: + case *internal.CreateFieldMessage: idx := s.Holder.Index(obj.Index) if idx == nil { return fmt.Errorf("Local Index not found: %s", obj.Index) } opt := decodeFieldOptions(obj.Meta) - _, err := idx.CreateField(obj.Frame, *opt) + _, err := idx.CreateField(obj.Field, *opt) if err != nil { return err } - case *internal.DeleteFrameMessage: + case *internal.DeleteFieldMessage: idx := s.Holder.Index(obj.Index) - if err := idx.DeleteField(obj.Frame); err != nil { + if err := idx.DeleteField(obj.Field); err != nil { return err } case *internal.CreateViewMessage: - f := s.Holder.Field(obj.Index, obj.Frame) + f := s.Holder.Field(obj.Index, obj.Field) if f == nil { - return fmt.Errorf("Local Frame not found: %s", obj.Frame) + return fmt.Errorf("Local Field not found: %s", obj.Field) } _, _, err := f.createViewIfNotExistsBase(obj.View) if err != nil { return err } case *internal.DeleteViewMessage: - f := s.Holder.Field(obj.Index, obj.Frame) + f := s.Holder.Field(obj.Index, obj.Field) if f == nil { - return fmt.Errorf("Local Frame not found: %s", obj.Frame) + return fmt.Errorf("Local Field not found: %s", obj.Field) } err := f.DeleteView(obj.View) if err != nil { From 4c44c5f33a06ffa2f7b03be764f623a14d806fd4 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:33:00 -0500 Subject: [PATCH 46/52] fix Frame to Field in tests --- server/cluster_test.go | 10 +++++----- server/server_test.go | 12 ++++++------ server_test.go | 2 +- stats_test.go | 8 ++++---- test/cluster.go | 8 ++++---- utils_test.go | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/server/cluster_test.go b/server/cluster_test.go index f445ce415..9327befc0 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -54,7 +54,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { + } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -209,7 +209,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { + } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -253,7 +253,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { + } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -305,7 +305,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { + } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -458,7 +458,7 @@ func TestClusterResize_RemoveNode(t *testing.T) { // Create indexes and frames on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { + } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/server/server_test.go b/server/server_test.go index 0fa45619f..495812cdf 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -54,7 +54,7 @@ func TestMain_Set_Quick(t *testing.T) { if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } - if err := client.CreateFrame(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists { + if err := client.CreateField(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists { t.Fatal(err) } if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, frame=%q, col=%d)`, cmd.ID, cmd.Frame, cmd.ColumnID)); err != nil { @@ -123,11 +123,11 @@ func TestMain_SetRowAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { + } else if err := client.CreateField(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "z", pilosa.FieldOptions{}); err != nil { + } else if err := client.CreateField(context.Background(), "i", "z", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "neg", pilosa.FieldOptions{}); err != nil { + } else if err := client.CreateField(context.Background(), "i", "neg", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -200,7 +200,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) - } else if err := client.CreateFrame(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { + } else if err := client.CreateField(context.Background(), "i", "x", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -286,7 +286,7 @@ func TestMain_RecalculateHashes(t *testing.T) { if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal("create index:", err) } - if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FieldOptions{CacheType: "ranked"}); err != nil { + if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{CacheType: "ranked"}); err != nil { t.Fatal("create frame:", err) } diff --git a/server_test.go b/server_test.go index 9b5409330..5ea5653cc 100644 --- a/server_test.go +++ b/server_test.go @@ -19,7 +19,7 @@ func TestMonitorAntiEntropy(t *testing.T) { if err != nil { t.Fatalf("creating index: %v", err) } - err = client.CreateFrame(context.Background(), "balh", "fralh", pilosa.FieldOptions{}) + err = client.CreateField(context.Background(), "balh", "fralh", pilosa.FieldOptions{}) if err != nil { t.Fatalf("creating frame: %v", err) } diff --git a/stats_test.go b/stats_test.go index 7f71cfabb..806baa738 100644 --- a/stats_test.go +++ b/stats_test.go @@ -272,8 +272,8 @@ func TestStatsCount_CreateFrame(t *testing.T) { called := false s.Handler.API.Holder.Stats = &MockStats{ mockCountWithTags: func(name string, value int64, rate float64, index []string) { - if name != "createFrame" { - t.Errorf("Expected createFrame, Results %s", name) + if name != "createField" { + t.Errorf("Expected createField, Results %s", name) } if index[0] != "index:i" { t.Errorf("Expected index:i, Results %s", index) @@ -303,8 +303,8 @@ func TestStatsCount_DeleteFrame(t *testing.T) { } s.Handler.API.Holder.Stats = &MockStats{ mockCountWithTags: func(name string, value int64, rate float64, index []string) { - if name != "deleteFrame" { - t.Errorf("Expected deleteFrame, Results %s", name) + if name != "deleteField" { + t.Errorf("Expected deleteField, Results %s", name) } if index[0] != "index:i" { t.Errorf("Expected index:i, Results %s", index) diff --git a/test/cluster.go b/test/cluster.go index 26ef44d30..ee87d51a2 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -367,7 +367,7 @@ func (t *TestCluster) FollowResizeInstruction(instr *internal.ResizeInstruction) if err := func() error { // figure out which node it was meant for, then call the operation on that cluster - // basically need to mimic this: client.RetrieveSliceFromURI(context.Background(), src.Index, src.Frame, src.View, src.Slice, srcURI) + // basically need to mimic this: client.RetrieveSliceFromURI(context.Background(), src.Index, src.Field, src.View, src.Slice, srcURI) instrNode := pilosa.DecodeNode(instr.Node) destCluster := t.clusterByID(instrNode.ID) @@ -380,11 +380,11 @@ func (t *TestCluster) FollowResizeInstruction(instr *internal.ResizeInstruction) srcNode := pilosa.DecodeNode(src.Node) srcCluster := t.clusterByID(srcNode.ID) - srcFragment := srcCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) - destFragment := destCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) + srcFragment := srcCluster.Holder.Fragment(src.Index, src.Field, src.View, src.Slice) + destFragment := destCluster.Holder.Fragment(src.Index, src.Field, src.View, src.Slice) if destFragment == nil { // Create fragment on destination if it doesn't exist. - f := destCluster.Holder.Field(src.Index, src.Frame) + f := destCluster.Holder.Field(src.Index, src.Field) v := f.View(src.View) var err error destFragment, err = v.CreateFragmentIfNotExists(src.Slice) diff --git a/utils_test.go b/utils_test.go index 34b4f2967..15053cd2b 100644 --- a/utils_test.go +++ b/utils_test.go @@ -356,7 +356,7 @@ func (t *ClusterCluster) FollowResizeInstruction(instr *internal.ResizeInstructi if err := func() error { // figure out which node it was meant for, then call the operation on that cluster - // basically need to mimic this: client.RetrieveSliceFromURI(context.Background(), src.Index, src.Frame, src.View, src.Slice, srcURI) + // basically need to mimic this: client.RetrieveSliceFromURI(context.Background(), src.Index, src.Field, src.View, src.Slice, srcURI) instrNode := DecodeNode(instr.Node) destCluster := t.clusterByID(instrNode.ID) @@ -369,11 +369,11 @@ func (t *ClusterCluster) FollowResizeInstruction(instr *internal.ResizeInstructi srcNode := DecodeNode(src.Node) srcCluster := t.clusterByID(srcNode.ID) - srcFragment := srcCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) - destFragment := destCluster.Holder.Fragment(src.Index, src.Frame, src.View, src.Slice) + srcFragment := srcCluster.Holder.Fragment(src.Index, src.Field, src.View, src.Slice) + destFragment := destCluster.Holder.Fragment(src.Index, src.Field, src.View, src.Slice) if destFragment == nil { // Create fragment on destination if it doesn't exist. - f := destCluster.Holder.Field(src.Index, src.Frame) + f := destCluster.Holder.Field(src.Index, src.Field) v := f.View(src.View) var err error destFragment, err = v.CreateFragmentIfNotExists(src.Slice) From 4e0aff0ca2a5c3a70bf0b5efc1c6b1e1e5e51b73 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:43:01 -0500 Subject: [PATCH 47/52] finish frame to field in api.go --- api.go | 126 ++++++++++++++++++++++++++--------------------------- handler.go | 6 +-- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/api.go b/api.go index ae010e4f1..56eaece56 100644 --- a/api.go +++ b/api.go @@ -217,9 +217,9 @@ func (api *API) DeleteIndex(ctx context.Context, indexName string) error { return nil } -// CreateFrame makes the named frame in the named index with the given options. -func (api *API) CreateFrame(ctx context.Context, indexName string, frameName string, options FieldOptions) (*Field, error) { - if err := api.validate(apiCreateFrame); err != nil { +// CreateField makes the named field in the named index with the given options. +func (api *API) CreateField(ctx context.Context, indexName string, fieldName string, options FieldOptions) (*Field, error) { + if err := api.validate(apiCreateField); err != nil { return nil, errors.Wrap(err, "validating api method") } @@ -229,17 +229,17 @@ func (api *API) CreateFrame(ctx context.Context, indexName string, frameName str return nil, ErrIndexNotFound } - // Create frame. - frame, err := index.CreateField(frameName, options) + // Create field. + field, err := index.CreateField(fieldName, options) if err != nil { - return nil, errors.Wrap(err, "creating frame") + return nil, errors.Wrap(err, "creating field") } - // Send the create frame message to all nodes. + // Send the create field message to all nodes. err = api.Broadcaster.SendSync( &internal.CreateFieldMessage{ Index: indexName, - Field: frameName, + Field: fieldName, Meta: options.Encode(), }) if err != nil { @@ -247,14 +247,14 @@ func (api *API) CreateFrame(ctx context.Context, indexName string, frameName str return nil, errors.Wrap(err, "sending CreateField message") } api.Holder.Stats.CountWithCustomTags("createField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)}) - return frame, nil + return field, nil } -// DeleteFrame removes the named frame from the named index. If the index is not -// found, an error is returned. If the frame is not found, it is ignored and no +// DeleteField removes the named field from the named index. If the index is not +// found, an error is returned. If the field is not found, it is ignored and no // action is taken. -func (api *API) DeleteFrame(ctx context.Context, indexName string, frameName string) error { - if err := api.validate(apiDeleteFrame); err != nil { +func (api *API) DeleteField(ctx context.Context, indexName string, fieldName string) error { + if err := api.validate(apiDeleteField); err != nil { return errors.Wrap(err, "validating api method") } @@ -264,16 +264,16 @@ func (api *API) DeleteFrame(ctx context.Context, indexName string, frameName str return ErrIndexNotFound } - // Delete frame from the index. - if err := index.DeleteField(frameName); err != nil { - return errors.Wrap(err, "deleting frame") + // Delete field from the index. + if err := index.DeleteField(fieldName); err != nil { + return errors.Wrap(err, "deleting field") } - // Send the delete frame message to all nodes. + // Send the delete field message to all nodes. err := api.Broadcaster.SendSync( &internal.DeleteFieldMessage{ Index: indexName, - Field: frameName, + Field: fieldName, }) if err != nil { api.Logger.Printf("problem sending DeleteField message: %s", err) @@ -283,9 +283,9 @@ func (api *API) DeleteFrame(ctx context.Context, indexName string, frameName str return nil } -// ExportCSV encodes the fragment designated by the index,frame,slice as +// ExportCSV encodes the fragment designated by the index,field,slice as // CSV of the form , -func (api *API) ExportCSV(ctx context.Context, indexName string, frameName string, slice uint64, w io.Writer) error { +func (api *API) ExportCSV(ctx context.Context, indexName string, fieldName string, slice uint64, w io.Writer) error { if err := api.validate(apiExportCSV); err != nil { return errors.Wrap(err, "validating api method") } @@ -297,7 +297,7 @@ func (api *API) ExportCSV(ctx context.Context, indexName string, frameName strin } // Find the fragment. - f := api.Holder.Fragment(indexName, frameName, ViewStandard, slice) + f := api.Holder.Fragment(indexName, fieldName, ViewStandard, slice) if f == nil { return ErrFragmentNotFound } @@ -333,13 +333,13 @@ func (api *API) SliceNodes(ctx context.Context, indexName string, slice uint64) // MarshalFragment returns an object which can write the specified fragment's data // to an io.Writer. The serialized data can be read back into a fragment with // the UnmarshalFragment API call. -func (api *API) MarshalFragment(ctx context.Context, indexName string, frameName string, slice uint64) (io.WriterTo, error) { +func (api *API) MarshalFragment(ctx context.Context, indexName string, fieldName string, slice uint64) (io.WriterTo, error) { if err := api.validate(apiMarshalFragment); err != nil { return nil, errors.Wrap(err, "validating api method") } // Retrieve fragment from holder. - f := api.Holder.Fragment(indexName, frameName, ViewStandard, slice) + f := api.Holder.Fragment(indexName, fieldName, ViewStandard, slice) if f == nil { return nil, ErrFragmentNotFound } @@ -349,13 +349,13 @@ func (api *API) MarshalFragment(ctx context.Context, indexName string, frameName // UnmarshalFragment creates a new fragment (if necessary) and reads data from a // Reader which was previously written by MarshalFragment to populate the // fragment's data. -func (api *API) UnmarshalFragment(ctx context.Context, indexName string, frameName string, slice uint64, reader io.ReadCloser) error { +func (api *API) UnmarshalFragment(ctx context.Context, indexName string, fieldName string, slice uint64, reader io.ReadCloser) error { if err := api.validate(apiUnmarshalFragment); err != nil { return errors.Wrap(err, "validating api method") } - // Retrieve frame. - f := api.Holder.Field(indexName, frameName) + // Retrieve field. + f := api.Holder.Field(indexName, fieldName) if f == nil { return ErrFieldNotFound } @@ -366,7 +366,7 @@ func (api *API) UnmarshalFragment(ctx context.Context, indexName string, frameNa return errors.Wrap(err, "creating view") } - // Retrieve fragment from frame. + // Retrieve fragment from field. frag, err := view.CreateFragmentIfNotExists(slice) if err != nil { return errors.Wrap(err, "creating fragment") @@ -415,13 +415,13 @@ func (api *API) FragmentBlockData(ctx context.Context, body io.Reader) ([]byte, } // FragmentBlocks returns the checksums and block ids for all blocks in the specified fragment. -func (api *API) FragmentBlocks(ctx context.Context, indexName string, frameName string, slice uint64) ([]FragmentBlock, error) { +func (api *API) FragmentBlocks(ctx context.Context, indexName string, fieldName string, slice uint64) ([]FragmentBlock, error) { if err := api.validate(apiFragmentBlocks); err != nil { return nil, errors.Wrap(err, "validating api method") } // Retrieve fragment from holder. - f := api.Holder.Fragment(indexName, frameName, ViewStandard, slice) + f := api.Holder.Fragment(indexName, fieldName, ViewStandard, slice) if f == nil { return nil, ErrFragmentNotFound } @@ -482,20 +482,20 @@ func (api *API) LocalID() string { return api.Cluster.Node.ID } -// Schema returns information about each index in Pilosa including which frames +// Schema returns information about each index in Pilosa including which fields // and views they contain. func (api *API) Schema(ctx context.Context) []*IndexInfo { return api.Holder.Schema() } -// Views returns the views in the given frame. -func (api *API) Views(ctx context.Context, indexName string, frameName string) ([]*View, error) { +// Views returns the views in the given field. +func (api *API) Views(ctx context.Context, indexName string, fieldName string) ([]*View, error) { if err := api.validate(apiViews); err != nil { return nil, errors.Wrap(err, "validating api method") } // Retrieve views. - f := api.Holder.Field(indexName, frameName) + f := api.Holder.Field(indexName, fieldName) if f == nil { return nil, ErrFieldNotFound } @@ -506,13 +506,13 @@ func (api *API) Views(ctx context.Context, indexName string, frameName string) ( } // DeleteView removes the given view. -func (api *API) DeleteView(ctx context.Context, indexName string, frameName string, viewName string) error { +func (api *API) DeleteView(ctx context.Context, indexName string, fieldName string, viewName string) error { if err := api.validate(apiDeleteView); err != nil { return errors.Wrap(err, "validating api method") } - // Retrieve frame. - f := api.Holder.Field(indexName, frameName) + // Retrieve field. + f := api.Holder.Field(indexName, fieldName) if f == nil { return ErrFieldNotFound } @@ -529,7 +529,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, frameName stri err := api.Broadcaster.SendSync( &internal.DeleteViewMessage{ Index: indexName, - Field: frameName, + Field: fieldName, View: viewName, }) if err != nil { @@ -574,13 +574,13 @@ func (api *API) IndexAttrDiff(ctx context.Context, indexName string, blocks []At return attrs, nil } -func (api *API) FrameAttrDiff(ctx context.Context, indexName string, frameName string, blocks []AttrBlock) (map[uint64]map[string]interface{}, error) { - if err := api.validate(apiFrameAttrDiff); err != nil { +func (api *API) FieldAttrDiff(ctx context.Context, indexName string, fieldName string, blocks []AttrBlock) (map[uint64]map[string]interface{}, error) { + if err := api.validate(apiFieldAttrDiff); err != nil { return nil, errors.Wrap(err, "validating api method") } // Retrieve index from holder. - f := api.Holder.Field(indexName, frameName) + f := api.Holder.Field(indexName, fieldName) if f == nil { return nil, ErrFieldNotFound } @@ -608,15 +608,15 @@ func (api *API) FrameAttrDiff(ctx context.Context, indexName string, frameName s return attrs, nil } -// Import bulk imports data into a particular index,frame,slice. +// Import bulk imports data into a particular index,field,slice. func (api *API) Import(ctx context.Context, req internal.ImportRequest) error { if err := api.validate(apiImport); err != nil { return errors.Wrap(err, "validating api method") } - _, frame, err := api.indexFrame(req.Index, req.Field, req.Slice) + _, field, err := api.indexField(req.Index, req.Field, req.Slice) if err != nil { - return errors.Wrap(err, "getting frame") + return errors.Wrap(err, "getting field") } // Convert timestamps to time.Time. @@ -630,9 +630,9 @@ func (api *API) Import(ctx context.Context, req internal.ImportRequest) error { } // Import into fragment. - err = frame.Import(req.RowIDs, req.ColumnIDs, timestamps) + err = field.Import(req.RowIDs, req.ColumnIDs, timestamps) if err != nil { - api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) + api.Logger.Printf("import error: index=%s, field=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) } return errors.Wrap(err, "importing") } @@ -643,15 +643,15 @@ func (api *API) ImportValue(ctx context.Context, req internal.ImportValueRequest return errors.Wrap(err, "validating api method") } - _, frame, err := api.indexFrame(req.Index, req.Field, req.Slice) + _, field, err := api.indexField(req.Index, req.Field, req.Slice) if err != nil { - return errors.Wrap(err, "getting frame") + return errors.Wrap(err, "getting field") } // Import into fragment. - err = frame.ImportValue(req.ColumnIDs, req.Values) + err = field.ImportValue(req.ColumnIDs, req.Values) if err != nil { - api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) + api.Logger.Printf("import error: index=%s, field=%s, slice=%d, columns=%d, err=%s", req.Index, req.Field, req.Slice, len(req.ColumnIDs), err) } return errors.Wrap(err, "importing") } @@ -679,7 +679,7 @@ func (api *API) LongQueryTime() time.Duration { return api.Cluster.LongQueryTime } -func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*Index, *Field, error) { +func (api *API) indexField(indexName string, fieldName string, slice uint64) (*Index, *Field, error) { // Validate that this handler owns the slice. if !api.Cluster.OwnsSlice(api.LocalID(), indexName, slice) { api.Logger.Printf("node %s does not own slice %d of index %s", api.LocalID(), slice, indexName) @@ -687,20 +687,20 @@ func (api *API) indexFrame(indexName string, frameName string, slice uint64) (*I } // Find the Index. - api.Logger.Printf("importing: %v %v %v", indexName, frameName, slice) + api.Logger.Printf("importing: %v %v %v", indexName, fieldName, slice) index := api.Holder.Index(indexName) if index == nil { - api.Logger.Printf("fragment error: index=%s, frame=%s, slice=%d, err=%s", indexName, frameName, slice, ErrIndexNotFound.Error()) + api.Logger.Printf("fragment error: index=%s, field=%s, slice=%d, err=%s", indexName, fieldName, slice, ErrIndexNotFound.Error()) return nil, nil, ErrIndexNotFound } - // Retrieve frame. - frame := index.Field(frameName) - if frame == nil { - api.Logger.Printf("frame error: index=%s, frame=%s, slice=%d, err=%s", indexName, frameName, slice, ErrFieldNotFound.Error()) + // Retrieve field. + field := index.Field(fieldName) + if field == nil { + api.Logger.Printf("field error: index=%s, field=%s, slice=%d, err=%s", indexName, fieldName, slice, ErrFieldNotFound.Error()) return nil, nil, ErrFieldNotFound } - return index, frame, nil + return index, field, nil } // SetCoordinator makes a new Node the cluster coordinator. @@ -790,15 +790,15 @@ type apiMethod int // API validation constants. const ( apiClusterMessage apiMethod = iota - apiCreateFrame + apiCreateField apiCreateIndex - apiDeleteFrame + apiDeleteField apiDeleteIndex apiDeleteView apiExportCSV apiFragmentBlockData apiFragmentBlocks - apiFrameAttrDiff + apiFieldAttrDiff //apiHosts // not implemented apiImport apiImportValue @@ -833,15 +833,15 @@ var methodsResizing = map[apiMethod]struct{}{ } var methodsNormal = map[apiMethod]struct{}{ - apiCreateFrame: struct{}{}, + apiCreateField: struct{}{}, apiCreateIndex: struct{}{}, - apiDeleteFrame: struct{}{}, + apiDeleteField: struct{}{}, apiDeleteIndex: struct{}{}, apiDeleteView: struct{}{}, apiExportCSV: struct{}{}, apiFragmentBlockData: struct{}{}, apiFragmentBlocks: struct{}{}, - apiFrameAttrDiff: struct{}{}, + apiFieldAttrDiff: struct{}{}, apiImport: struct{}{}, apiImportValue: struct{}{}, apiIndex: struct{}{}, diff --git a/handler.go b/handler.go index a57a40204..dca880aba 100644 --- a/handler.go +++ b/handler.go @@ -517,7 +517,7 @@ func (h *Handler) handlePostFrame(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } - _, err = h.API.CreateFrame(r.Context(), indexName, frameName, req.Options) + _, err = h.API.CreateField(r.Context(), indexName, frameName, req.Options) if err != nil { switch errors.Cause(err) { case ErrIndexNotFound: @@ -585,7 +585,7 @@ func (h *Handler) handleDeleteFrame(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] frameName := mux.Vars(r)["frame"] - err := h.API.DeleteFrame(r.Context(), indexName, frameName) + err := h.API.DeleteField(r.Context(), indexName, frameName) if err != nil { if errors.Cause(err) == ErrIndexNotFound { if err := json.NewEncoder(w).Encode(deleteIndexResponse{}); err != nil { @@ -617,7 +617,7 @@ func (h *Handler) handlePostFrameAttrDiff(w http.ResponseWriter, r *http.Request return } - attrs, err := h.API.FrameAttrDiff(r.Context(), indexName, frameName, req.Blocks) + attrs, err := h.API.FieldAttrDiff(r.Context(), indexName, frameName, req.Blocks) if err != nil { switch errors.Cause(err) { case ErrFragmentNotFound: From ba5d687ee0b44cce3f2ee30d218356c517116f36 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:46:17 -0500 Subject: [PATCH 48/52] finish frame to field in frame.go --- frame.go | 86 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/frame.go b/frame.go index 60e41e265..0e1f79d66 100644 --- a/frame.go +++ b/frame.go @@ -29,13 +29,13 @@ import ( "github.com/pkg/errors" ) -// Default frame settings. +// Default field settings. const ( DefaultFieldType = FieldTypeSet DefaultCacheType = CacheTypeRanked - // Default ranked frame cache + // Default ranked field cache DefaultCacheSize = 50000 ) @@ -80,7 +80,7 @@ func OptFieldFieldOptions(o FieldOptions) FieldOption { } } -// NewField returns a new instance of frame. +// NewField returns a new instance of field. func NewField(path, index, name string, opts ...FieldOption) (*Field, error) { err := ValidateName(name) if err != nil { @@ -118,19 +118,19 @@ func NewField(path, index, name string, opts ...FieldOption) (*Field, error) { return f, nil } -// Name returns the name the frame was initialized with. +// Name returns the name the field was initialized with. func (f *Field) Name() string { return f.name } -// Index returns the index name the frame was initialized with. +// Index returns the index name the field was initialized with. func (f *Field) Index() string { return f.index } -// Path returns the path the frame was initialized with. +// Path returns the path the field was initialized with. func (f *Field) Path() string { return f.path } // RowAttrStore returns the attribute storage. func (f *Field) RowAttrStore() AttrStore { return f.rowAttrStore } -// MaxSlice returns the max slice in the frame. +// MaxSlice returns the max slice in the field. func (f *Field) MaxSlice() uint64 { f.mu.RLock() defer f.mu.RUnlock() @@ -144,14 +144,14 @@ func (f *Field) MaxSlice() uint64 { return max } -// Type returns the frame type. +// Type returns the field type. func (f *Field) Type() string { f.mu.RLock() defer f.mu.RUnlock() return f.options.Type } -// CacheType returns the caching mode for the frame. +// CacheType returns the caching mode for the field. func (f *Field) CacheType() string { f.mu.RLock() defer f.mu.RUnlock() @@ -178,7 +178,7 @@ func (f *Field) SetCacheSize(v uint32) error { return nil } -// CacheSize returns the ranked frame cache size. +// CacheSize returns the ranked field cache size. func (f *Field) CacheSize() uint32 { f.mu.RLock() v := f.options.CacheSize @@ -186,26 +186,26 @@ func (f *Field) CacheSize() uint32 { return v } -// Options returns all options for this frame. +// Options returns all options for this field. func (f *Field) Options() FieldOptions { f.mu.RLock() defer f.mu.RUnlock() return f.options } -// Open opens and initializes the frame. +// Open opens and initializes the field. func (f *Field) Open() error { if err := func() error { - // Ensure the frame's path exists. + // Ensure the field's path exists. if err := os.MkdirAll(f.path, 0777); err != nil { - return errors.Wrap(err, "creating frame dir") + return errors.Wrap(err, "creating field dir") } if err := f.loadMeta(); err != nil { return errors.Wrap(err, "loading meta") } - // Apply the frame options loaded from meta. + // Apply the field options loaded from meta. if err := f.applyOptions(f.options); err != nil { return errors.Wrap(err, "applying options") } @@ -227,7 +227,7 @@ func (f *Field) Open() error { return nil } -// openViews opens and initializes the views inside the frame. +// openViews opens and initializes the views inside the field. func (f *Field) openViews() error { file, err := os.Open(filepath.Join(f.path, "views")) if os.IsNotExist(err) { @@ -259,7 +259,7 @@ func (f *Field) openViews() error { return nil } -// loadMeta reads meta data for the frame, if any. +// loadMeta reads meta data for the field, if any. func (f *Field) loadMeta() error { var pb internal.FieldOptions @@ -286,7 +286,7 @@ func (f *Field) loadMeta() error { return nil } -// saveMeta writes meta data for the frame. +// saveMeta writes meta data for the field. func (f *Field) saveMeta() error { // Marshal metadata. fo := f.options @@ -303,7 +303,7 @@ func (f *Field) saveMeta() error { return nil } -// applyOptions configures the frame based on opt. +// applyOptions configures the field based on opt. func (f *Field) applyOptions(opt FieldOptions) error { switch opt.Type { case FieldTypeSet, "": @@ -351,13 +351,13 @@ func (f *Field) applyOptions(opt FieldOptions) error { return errors.Wrap(err, "setting time quantum") } default: - return errors.New("invalid frame type") + return errors.New("invalid field type") } return nil } -// Close closes the frame and its views. +// Close closes the field and its views. func (f *Field) Close() error { f.mu.Lock() defer f.mu.Unlock() @@ -390,7 +390,7 @@ func (f *Field) bsiGroup(name string) *bsiGroup { return nil } -// hasBSIGroup returns true if a bsiGroup exists on the frame. +// hasBSIGroup returns true if a bsiGroup exists on the field. func (f *Field) hasBSIGroup(name string) bool { for _, bsig := range f.bsiGroups { if bsig.Name == name { @@ -400,7 +400,7 @@ func (f *Field) hasBSIGroup(name string) bool { return false } -// createBSIGroup creates a new bsiGroup on the frame. +// createBSIGroup creates a new bsiGroup on the field. func (f *Field) createBSIGroup(bsig *bsiGroup) error { f.mu.Lock() defer f.mu.Unlock() @@ -469,14 +469,14 @@ func (f *Field) deleteBSIGroup(name string) error { return ErrBSIGroupNotFound } -// TimeQuantum returns the time quantum for the frame. +// TimeQuantum returns the time quantum for the field. func (f *Field) TimeQuantum() TimeQuantum { f.mu.Lock() defer f.mu.Unlock() return f.options.TimeQuantum } -// SetTimeQuantum sets the time quantum for the frame. +// SetTimeQuantum sets the time quantum for the field. func (f *Field) SetTimeQuantum(q TimeQuantum) error { f.mu.Lock() defer f.mu.Unlock() @@ -486,7 +486,7 @@ func (f *Field) SetTimeQuantum(q TimeQuantum) error { return ErrInvalidTimeQuantum } - // Update value on frame. + // Update value on field. f.options.TimeQuantum = q // Persist meta data to disk. @@ -497,12 +497,12 @@ func (f *Field) SetTimeQuantum(q TimeQuantum) error { return nil } -// ViewPath returns the path to a view in the frame. +// ViewPath returns the path to a view in the field. func (f *Field) ViewPath(name string) string { return filepath.Join(f.path, "views", name) } -// View returns a view in the frame by name. +// View returns a view in the field by name. func (f *Field) View(name string) *View { f.mu.RLock() defer f.mu.RUnlock() @@ -511,7 +511,7 @@ func (f *Field) View(name string) *View { func (f *Field) view(name string) *View { return f.views[name] } -// Views returns a list of all views in the frame. +// Views returns a list of all views in the field. func (f *Field) Views() []*View { f.mu.RLock() defer f.mu.RUnlock() @@ -523,7 +523,7 @@ func (f *Field) Views() []*View { return other } -// viewNames returns a list of all views (as a string) in the frame. +// viewNames returns a list of all views (as a string) in the field. func (f *Field) viewNames() []string { f.mu.Lock() defer f.mu.Unlock() @@ -535,7 +535,7 @@ func (f *Field) viewNames() []string { return other } -// RecalculateCaches recalculates caches on every view in the frame. +// RecalculateCaches recalculates caches on every view in the field. func (f *Field) RecalculateCaches() { for _, view := range f.Views() { view.RecalculateCaches() @@ -598,7 +598,7 @@ func (f *Field) newView(path, name string) *View { return view } -// DeleteView removes the view from the frame. +// DeleteView removes the view from the field. func (f *Field) DeleteView(name string) error { view := f.views[name] if view == nil { @@ -620,7 +620,7 @@ func (f *Field) DeleteView(name string) error { return nil } -// SetBit sets a bit on a view within the frame. +// SetBit sets a bit on a view within the field. func (f *Field) SetBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { @@ -662,7 +662,7 @@ func (f *Field) SetBit(name string, rowID, colID uint64, t *time.Time) (changed return changed, nil } -// ClearBit clears a bit within the frame. +// ClearBit clears a bit within the field. func (f *Field) ClearBit(name string, rowID, colID uint64, t *time.Time) (changed bool, err error) { // Validate view name. if !IsValidView(name) { @@ -704,7 +704,7 @@ func (f *Field) ClearBit(name string, rowID, colID uint64, t *time.Time) (change return changed, nil } -// Value reads a frame value for a column. +// Value reads a field value for a column. func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) { bsig := f.bsiGroup(f.name) if bsig == nil { @@ -726,7 +726,7 @@ func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) { return int64(v) + bsig.Min, true, nil } -// SetValue sets a frame value for a column. +// SetValue sets a field value for a column. func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) { // Fetch bsiGroup and validate value. bsig := f.bsiGroup(f.name) @@ -750,7 +750,7 @@ func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) return view.setValue(columnID, bsig.BitDepth(), baseValue) } -// Sum returns the sum and count for a frame. +// Sum returns the sum and count for a field. // An optional filtering row can be provided. func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) { bsig := f.bsiGroup(name) @@ -770,7 +770,7 @@ func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) { return int64(vsum) + (int64(vcount) * bsig.Min), int64(vcount), nil } -// Min returns the min for a frame. +// Min returns the min for a field. // An optional filtering row can be provided. func (f *Field) Min(filter *Row, name string) (min, count int64, err error) { bsig := f.bsiGroup(name) @@ -790,7 +790,7 @@ func (f *Field) Min(filter *Row, name string) (min, count int64, err error) { return int64(vmin) + bsig.Min, int64(vcount), nil } -// Max returns the max for a frame. +// Max returns the max for a field. // An optional filtering row can be provided. func (f *Field) Max(filter *Row, name string) (max, count int64, err error) { bsig := f.bsiGroup(name) @@ -861,7 +861,7 @@ func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro // Determine quantum if timestamps are set. q := f.TimeQuantum() if hasTime(timestamps) && q == "" { - return errors.New("time quantum not set in either index or frame") + return errors.New("time quantum not set in field") } // Split import data by fragment. @@ -995,7 +995,7 @@ func (p fieldSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p fieldSlice) Len() int { return len(p) } func (p fieldSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } -// FieldInfo represents schema information for a frame. +// FieldInfo represents schema information for a field. type FieldInfo struct { Name string `json:"name"` Options FieldOptions `json:"options"` @@ -1032,7 +1032,7 @@ func (o *FieldOptions) Validate() error { return ErrInvalidTimeQuantum } default: - return errors.New("invalid frame type") + return errors.New("invalid field type") } return nil } @@ -1084,7 +1084,7 @@ func isValidBSIGroupType(v string) bool { } } -// bsiGroup represents a group of range-encoded rows on a frame. +// bsiGroup represents a group of range-encoded rows on a field. type bsiGroup struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` From 0f8bd62e3354ea8896c68faf9686e62497b51e00 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 5 Jun 2018 23:58:46 -0500 Subject: [PATCH 49/52] more Frame to Field in tests. move frame*.go files to field*.go --- client_test.go | 2 +- executor_test.go | 22 +++---- frame.go => field.go | 0 ...internal_test.go => field_internal_test.go | 0 frame_test.go => field_test.go | 66 +++++++++---------- fragment_test.go | 4 +- handler_test.go | 16 ++--- index_test.go | 10 +-- test/frame.go | 44 ++++++------- test/holder.go | 8 +-- test/index.go | 12 ++-- 11 files changed, 92 insertions(+), 92 deletions(-) rename frame.go => field.go (100%) rename frame_internal_test.go => field_internal_test.go (100%) rename frame_test.go => field_test.go (77%) diff --git a/client_test.go b/client_test.go index 6f1931e29..9091c8200 100644 --- a/client_test.go +++ b/client_test.go @@ -254,7 +254,7 @@ func TestClient_ImportValue(t *testing.T) { // Load bitmap into cache to ensure cache gets updated. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - frame, err := index.CreateFrameIfNotExists(fldName, fo) + frame, err := index.CreateFieldIfNotExists(fldName, fo) if err != nil { t.Fatal(err) } diff --git a/executor_test.go b/executor_test.go index af4278849..bd965c325 100644 --- a/executor_test.go +++ b/executor_test.go @@ -33,7 +33,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := index.CreateFrame("f", pilosa.FieldOptions{}) + f, err := index.CreateField("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } @@ -83,7 +83,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrame("f", pilosa.FieldOptions{}); err != nil { + if _, err := index.CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -271,13 +271,13 @@ func TestExecutor_Execute_SetValue(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 50, }); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { + } else if _, err := index.CreateFieldIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -311,7 +311,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 100, @@ -349,9 +349,9 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { // Create frames. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { + if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := index.CreateFrameIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { + } else if _, err := index.CreateFieldIfNotExists("xxx", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -737,7 +737,7 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{ + if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }); err != nil { @@ -1068,7 +1068,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { + if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -1120,7 +1120,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { s.Handler.API.Holder = hldr.Holder // Create frame. - if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateFrame("f", pilosa.FieldOptions{}); err != nil { + if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := f.SetTimeQuantum("Y"); err != nil { t.Fatal(err) @@ -1223,7 +1223,7 @@ func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - index.CreateFrame("f", pilosa.FieldOptions{}) + index.CreateField("f", pilosa.FieldOptions{}) targetAttrs := map[string]interface{}{ "foo": "bar", } diff --git a/frame.go b/field.go similarity index 100% rename from frame.go rename to field.go diff --git a/frame_internal_test.go b/field_internal_test.go similarity index 100% rename from frame_internal_test.go rename to field_internal_test.go diff --git a/frame_test.go b/field_test.go similarity index 77% rename from frame_test.go rename to field_test.go index 99dea0938..10e4d9a97 100644 --- a/frame_test.go +++ b/field_test.go @@ -22,9 +22,9 @@ import ( "github.com/pilosa/pilosa/test" ) -// Ensure frame can open and retrieve a view. -func TestFrame_CreateViewIfNotExists(t *testing.T) { - f := test.MustOpenFrame() +// Ensure field can open and retrieve a view. +func TestField_CreateViewIfNotExists(t *testing.T) { + f := test.MustOpenField() defer f.Close() // Create view. @@ -48,12 +48,12 @@ func TestFrame_CreateViewIfNotExists(t *testing.T) { } } -// Ensure frame can set its time quantum. -func TestFrame_SetTimeQuantum(t *testing.T) { +// Ensure field can set its time quantum. +func TestField_SetTimeQuantum(t *testing.T) { fo := pilosa.FieldOptions{ Type: "time", } - f := test.MustOpenFrame(pilosa.OptFieldFieldOptions(fo)) + f := test.MustOpenField(pilosa.OptFieldFieldOptions(fo)) defer f.Close() // Set & retrieve time quantum. @@ -63,7 +63,7 @@ func TestFrame_SetTimeQuantum(t *testing.T) { t.Fatalf("unexpected quantum: %s", q) } - // Reload frame and verify that it is persisted. + // Reload field and verify that it is persisted. if err := f.Reopen(); err != nil { t.Fatal(err) } else if q := f.TimeQuantum(); q != pilosa.TimeQuantum("YMDH") { @@ -71,13 +71,13 @@ func TestFrame_SetTimeQuantum(t *testing.T) { } } -// Ensure a frame can set & read a bsiGroup value. -func TestFrame_SetValue(t *testing.T) { +// Ensure a field can set & read a bsiGroup value. +func TestField_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + f, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 30, @@ -86,7 +86,7 @@ func TestFrame_SetValue(t *testing.T) { t.Fatal(err) } - // Set value on frame. + // Set value on field. if changed, err := f.SetValue(100, 21); err != nil { t.Fatal(err) } else if !changed { @@ -114,7 +114,7 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + f, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 0, Max: 30, @@ -151,7 +151,7 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + f, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeSet, }) if err != nil { @@ -168,7 +168,7 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + f, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 20, Max: 30, @@ -187,7 +187,7 @@ func TestFrame_SetValue(t *testing.T) { idx := test.MustOpenIndex() defer idx.Close() - f, err := idx.CreateFrame("f", pilosa.FieldOptions{ + f, err := idx.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 20, Max: 30, @@ -203,27 +203,27 @@ func TestFrame_SetValue(t *testing.T) { }) } -func TestFrame_NameRestriction(t *testing.T) { - path, err := ioutil.TempDir("", "pilosa-frame-") +func TestField_NameRestriction(t *testing.T) { + path, err := ioutil.TempDir("", "pilosa-field-") if err != nil { panic(err) } - frame, err := pilosa.NewField(path, "i", ".meta") - if frame != nil { - t.Fatalf("unexpected frame name %s", err) + field, err := pilosa.NewField(path, "i", ".meta") + if field != nil { + t.Fatalf("unexpected field name %s", err) } } -// Ensure that frame name validation is consistent. -func TestFrame_NameValidation(t *testing.T) { - validFrameNames := []string{ +// Ensure that field name validation is consistent. +func TestField_NameValidation(t *testing.T) { + validFieldNames := []string{ "foo", "hyphen-ated", "under_score", "abc123", "trailing_", } - invalidFrameNames := []string{ + invalidFieldNames := []string{ "", "123abc", "x.y", @@ -235,27 +235,27 @@ func TestFrame_NameValidation(t *testing.T) { "a12345678901234567890123456789012345678901234567890123456789012345", } - path, err := ioutil.TempDir("", "pilosa-frame-") + path, err := ioutil.TempDir("", "pilosa-field-") if err != nil { panic(err) } - for _, name := range validFrameNames { + for _, name := range validFieldNames { _, err := pilosa.NewField(path, "i", name) if err != nil { - t.Fatalf("unexpected frame name: %s %s", name, err) + t.Fatalf("unexpected field name: %s %s", name, err) } } - for _, name := range invalidFrameNames { + for _, name := range invalidFieldNames { _, err := pilosa.NewField(path, "i", name) if err == nil { - t.Fatalf("expected error on frame name: %s", name) + t.Fatalf("expected error on field name: %s", name) } } } -// Ensure frame can open and retrieve a view. -func TestFrame_DeleteView(t *testing.T) { - f := test.MustOpenFrame() +// Ensure field can open and retrieve a view. +func TestField_DeleteView(t *testing.T) { + f := test.MustOpenField() defer f.Close() viewName := pilosa.ViewStandard + "_v" @@ -274,7 +274,7 @@ func TestFrame_DeleteView(t *testing.T) { } if f.View(viewName) != nil { - t.Fatal("view still exists in frame") + t.Fatal("view still exists in field") } // Recreate view with same name, verify that the old view was not reused. diff --git a/fragment_test.go b/fragment_test.go index 71dff2b71..7f140e907 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -754,7 +754,7 @@ func TestFragment_TopN_CacheSize(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) + frame, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) if err != nil { t.Fatal(err) } @@ -924,7 +924,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) { defer index.Close() // Create frame. - frame, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) + frame, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { t.Fatal(err) } diff --git a/handler_test.go b/handler_test.go index 74b1702fa..bd6449862 100644 --- a/handler_test.go +++ b/handler_test.go @@ -83,17 +83,17 @@ func TestHandler_Schema(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { + if f, err := i0.CreateFieldIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { + if f, err := i1.CreateFieldIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { + if _, err := i0.CreateFieldIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -120,17 +120,17 @@ func TestHandler_Status(t *testing.T) { i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) i1 := hldr.MustCreateIndexIfNotExists("i1", pilosa.IndexOptions{}) - if f, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { + if f, err := i0.CreateFieldIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if f, err := i1.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { + if f, err := i1.CreateFieldIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := f.SetBit(pilosa.ViewStandard, 0, 0, nil); err != nil { t.Fatal(err) } - if _, err := i0.CreateFrameIfNotExists("f0", pilosa.FieldOptions{}); err != nil { + if _, err := i0.CreateFieldIfNotExists("f0", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -699,7 +699,7 @@ func TestHandler_DeleteFrame(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) - if _, err := i0.CreateFrameIfNotExists("f1", pilosa.FieldOptions{}); err != nil { + if _, err := i0.CreateFieldIfNotExists("f1", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } @@ -777,7 +777,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) { // Set attributes on the index. idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists("meta", pilosa.FieldOptions{}) + f, err := idx.CreateFieldIfNotExists("meta", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } diff --git a/index_test.go b/index_test.go index ada9be7f1..2272fd5bd 100644 --- a/index_test.go +++ b/index_test.go @@ -29,7 +29,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { defer index.Close() // Create frame. - f, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) + f, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f == nil { @@ -37,7 +37,7 @@ func TestIndex_CreateFrameIfNotExists(t *testing.T) { } // Retrieve existing frame. - other, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}) + other, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f.Field != other.Field { @@ -57,7 +57,7 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with explicit quantum. - f, err := index.CreateFrame("f", pilosa.FieldOptions{ + f, err := index.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), }) @@ -76,7 +76,7 @@ func TestIndex_CreateFrame(t *testing.T) { defer index.Close() // Create frame with schema and verify it exists. - if f, err := index.CreateFrame("f", pilosa.FieldOptions{ + if f, err := index.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 10, Max: 20, @@ -180,7 +180,7 @@ func TestIndex_DeleteFrame(t *testing.T) { defer index.Close() // Create frame. - if _, err := index.CreateFrameIfNotExists("f", pilosa.FieldOptions{}); err != nil { + if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } diff --git a/test/frame.go b/test/frame.go index 929070368..75dc5800d 100644 --- a/test/frame.go +++ b/test/frame.go @@ -23,41 +23,41 @@ import ( "github.com/pilosa/pilosa" ) -// Frame represents a test wrapper for pilosa.Frame. -type Frame struct { +// Field represents a test wrapper for pilosa.Field. +type Field struct { *pilosa.Field } -// NewFrame returns a new instance of Frame d/0. -func NewFrame(opt ...pilosa.FieldOption) *Frame { - path, err := ioutil.TempDir("", "pilosa-frame-") +// NewField returns a new instance of Field d/0. +func NewField(opt ...pilosa.FieldOption) *Field { + path, err := ioutil.TempDir("", "pilosa-field-") if err != nil { panic(err) } - frame, err := pilosa.NewField(path, "i", "f", opt...) + field, err := pilosa.NewField(path, "i", "f", opt...) if err != nil { panic(err) } - return &Frame{Field: frame} + return &Field{Field: field} } -// MustOpenFrame returns a new, opened frame at a temporary path. Panic on error. -func MustOpenFrame(opt ...pilosa.FieldOption) *Frame { - f := NewFrame(opt...) +// MustOpenField returns a new, opened field at a temporary path. Panic on error. +func MustOpenField(opt ...pilosa.FieldOption) *Field { + f := NewField(opt...) if err := f.Open(); err != nil { panic(err) } return f } -// Close closes the frame and removes the underlying data. -func (f *Frame) Close() error { +// Close closes the field and removes the underlying data. +func (f *Field) Close() error { defer os.RemoveAll(f.Path()) return f.Field.Close() } // Reopen closes the index and reopens it. -func (f *Frame) Reopen() error { +func (f *Field) Reopen() error { var err error if err := f.Field.Close(); err != nil { return err @@ -75,8 +75,8 @@ func (f *Frame) Reopen() error { return nil } -// MustSetBit sets a bit on the frame. Panic on error. -func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool) { +// MustSetBit sets a bit on the field. Panic on error. +func (f *Field) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool) { changed, err := f.SetBit(view, rowID, columnID, t) if err != nil { panic(err) @@ -84,23 +84,23 @@ func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (c return changed } -// Ensure frame can set its cache -func TestFrame_SetCacheSize(t *testing.T) { - f := MustOpenFrame() +// Ensure field can set its cache +func TestField_SetCacheSize(t *testing.T) { + f := MustOpenField() defer f.Close() cacheSize := uint32(100) - // Set & retrieve frame cache size. + // Set & retrieve field cache size. if err := f.SetCacheSize(cacheSize); err != nil { t.Fatal(err) } else if q := f.CacheSize(); q != cacheSize { - t.Fatalf("unexpected frame cache size: %d", q) + t.Fatalf("unexpected field cache size: %d", q) } - // Reload frame and verify that it is persisted. + // Reload field and verify that it is persisted. if err := f.Reopen(); err != nil { t.Fatal(err) } else if q := f.CacheSize(); q != cacheSize { - t.Fatalf("unexpected frame cache size (reopen): %d", q) + t.Fatalf("unexpected field cache size (reopen): %d", q) } } diff --git a/test/holder.go b/test/holder.go index 1344bd4c9..c0e8f1233 100644 --- a/test/holder.go +++ b/test/holder.go @@ -81,8 +81,8 @@ func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOption } // MustCreateFrameIfNotExists returns a given frame. Panic on error. -func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { - f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) +func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Field { + f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFieldIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -92,7 +92,7 @@ func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame { // MustCreateFragmentIfNotExists returns a given fragment. Panic on error. func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{}) + f, err := idx.CreateFieldIfNotExists(frame, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -110,7 +110,7 @@ func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice // MustCreateRankedFragmentIfNotExists returns a given fragment with a ranked cache. Panic on error. func (h *Holder) MustCreateRankedFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFrameIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) + f, err := idx.CreateFieldIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { panic(err) } diff --git a/test/index.go b/test/index.go index 93fa99cad..69c18682c 100644 --- a/test/index.go +++ b/test/index.go @@ -73,20 +73,20 @@ func (i *Index) Reopen() error { return nil } -// CreateFrame creates a frame with the given options. -func (i *Index) CreateFrame(name string, opt pilosa.FieldOptions) (*Frame, error) { +// CreateField creates a field with the given options. +func (i *Index) CreateField(name string, opt pilosa.FieldOptions) (*Field, error) { f, err := i.Index.CreateField(name, opt) if err != nil { return nil, err } - return &Frame{Field: f}, nil + return &Field{Field: f}, nil } -// CreateFrameIfNotExists creates a frame with the given options if it doesn't exist. -func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FieldOptions) (*Frame, error) { +// CreateFieldIfNotExists creates a field with the given options if it doesn't exist. +func (i *Index) CreateFieldIfNotExists(name string, opt pilosa.FieldOptions) (*Field, error) { f, err := i.Index.CreateFieldIfNotExists(name, opt) if err != nil { return nil, err } - return &Frame{Field: f}, nil + return &Field{Field: f}, nil } From 2a9b1e9e5b30a67211eae42b1be0dfd009285d81 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Wed, 6 Jun 2018 01:27:12 -0500 Subject: [PATCH 50/52] final Frame to Field rename --- apimethod_string.go | 2 +- client.go | 16 ++-- client_test.go | 14 +-- cluster_internal_test.go | 18 ++-- cluster_test.go | 10 +- cmd/export.go | 2 +- cmd/export_test.go | 4 +- cmd/import.go | 10 +- cmd/import_test.go | 4 +- ctl/export.go | 8 +- ctl/export_test.go | 4 +- ctl/import.go | 40 ++++---- ctl/import_test.go | 10 +- executor.go | 196 +++++++++++++++++++-------------------- executor_test.go | 174 +++++++++++++++++----------------- fragment.go | 4 +- fragment_test.go | 12 +-- handler.go | 84 ++++++++--------- handler_internal_test.go | 12 +-- handler_test.go | 24 ++--- holder.go | 58 ++++++------ holder_test.go | 44 ++++----- index.go | 44 ++++----- index_test.go | 54 +++++------ pilosa.go | 4 +- pql/ast_test.go | 4 +- pql/parser_test.go | 10 +- server/cluster_test.go | 38 ++++---- server/server_test.go | 88 +++++++++--------- server_test.go | 2 +- stats_test.go | 36 +++---- test/cluster.go | 10 +- test/fragment.go | 8 +- test/holder.go | 14 +-- time_test.go | 24 ++--- utils_test.go | 10 +- view_test.go | 8 +- 37 files changed, 552 insertions(+), 552 deletions(-) diff --git a/apimethod_string.go b/apimethod_string.go index ce119196f..a2b934e0f 100644 --- a/apimethod_string.go +++ b/apimethod_string.go @@ -4,7 +4,7 @@ package pilosa import "fmt" -const _apiMethod_name = "apiClusterMessageapiCreateFrameapiCreateIndexapiDeleteFrameapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFrameAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" +const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateIndexapiDeleteFieldapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFieldAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiSliceNodesapiUnmarshalFragmentapiViews" var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 86, 98, 118, 135, 151, 160, 174, 182, 198, 216, 224, 244, 257, 271, 288, 301, 321, 329} diff --git a/client.go b/client.go index ae536f2c4..81f750a39 100644 --- a/client.go +++ b/client.go @@ -542,7 +542,7 @@ func (c *InternalHTTPClient) exportNodeCSV(ctx context.Context, node *Node, inde u := nodePathToURL(node, "/export") u.RawQuery = url.Values{ "index": {index}, - "frame": {field}, + "field": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -585,7 +585,7 @@ func (c *InternalHTTPClient) backupSliceNode(ctx context.Context, index, field s u := nodePathToURL(node, "/fragment/data") u.RawQuery = url.Values{ "index": {index}, - "frame": {field}, + "field": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -622,7 +622,7 @@ func (c *InternalHTTPClient) CreateField(ctx context.Context, index, field strin } // Encode query request. - buf, err := json.Marshal(&postFrameRequest{ + buf, err := json.Marshal(&postFieldRequest{ Options: opt, }) if err != nil { @@ -630,7 +630,7 @@ func (c *InternalHTTPClient) CreateField(ctx context.Context, index, field strin } // Create URL & HTTP request. - u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s", index, field)) + u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/field/%s", index, field)) req, err := http.NewRequest("POST", u.String(), bytes.NewReader(buf)) if err != nil { return errors.Wrap(err, "creating request") @@ -670,7 +670,7 @@ func (c *InternalHTTPClient) FragmentBlocks(ctx context.Context, index, field st u := uriPathToURL(c.defaultURI, "/fragment/blocks") u.RawQuery = url.Values{ "index": {index}, - "frame": {field}, + "field": {field}, "slice": {strconv.FormatUint(slice, 10)}, }.Encode() @@ -795,10 +795,10 @@ func (c *InternalHTTPClient) ColumnAttrDiff(ctx context.Context, index string, b // RowAttrDiff returns data from differing blocks on a remote host. func (c *InternalHTTPClient) RowAttrDiff(ctx context.Context, index, field string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { - u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/frame/%s/attr/diff", index, field)) + u := uriPathToURL(c.defaultURI, fmt.Sprintf("/index/%s/field/%s/attr/diff", index, field)) // Encode request. - buf, err := json.Marshal(postFrameAttrDiffRequest{Blocks: blks}) + buf, err := json.Marshal(postFieldAttrDiffRequest{Blocks: blks}) if err != nil { return nil, errors.Wrap(err, "marshaling") } @@ -828,7 +828,7 @@ func (c *InternalHTTPClient) RowAttrDiff(ctx context.Context, index, field strin } // Decode response object. - var rsp postFrameAttrDiffResponse + var rsp postFieldAttrDiffResponse if err := json.NewDecoder(resp.Body).Decode(&rsp); err != nil { return nil, errors.Wrap(err, "decoding") } diff --git a/client_test.go b/client_test.go index 9091c8200..d2e194805 100644 --- a/client_test.go +++ b/client_test.go @@ -145,7 +145,7 @@ func TestClient_MultiNode(t *testing.T) { topN := 4 queryRequest := &internal.QueryRequest{ - Query: fmt.Sprintf(`TopN(frame="%s", n=%d)`, "f", topN), + Query: fmt.Sprintf(`TopN(field="%s", n=%d)`, "f", topN), Remote: false, } result, err := client[0].Query(context.Background(), "i", queryRequest) @@ -254,7 +254,7 @@ func TestClient_ImportValue(t *testing.T) { // Load bitmap into cache to ensure cache gets updated. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - frame, err := index.CreateFieldIfNotExists(fldName, fo) + field, err := index.CreateFieldIfNotExists(fldName, fo) if err != nil { t.Fatal(err) } @@ -276,7 +276,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Sum. - sum, cnt, err := frame.Sum(nil, fldName) + sum, cnt, err := field.Sum(nil, fldName) if err != nil { t.Fatal(err) } @@ -285,7 +285,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min. - min, cnt, err := frame.Min(nil, fldName) + min, cnt, err := field.Min(nil, fldName) if err != nil { t.Fatal(err) } @@ -294,11 +294,11 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Min with Filter. - filter, err := frame.Range(fldName, pql.GT, 40) + filter, err := field.Range(fldName, pql.GT, 40) if err != nil { t.Fatal(err) } - min, cnt, err = frame.Min(filter, fldName) + min, cnt, err = field.Min(filter, fldName) if err != nil { t.Fatal(err) } @@ -307,7 +307,7 @@ func TestClient_ImportValue(t *testing.T) { } // Verify Max. - max, cnt, err := frame.Max(nil, fldName) + max, cnt, err := field.Max(nil, fldName) if err != nil { t.Fatal(err) } diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 4b3a159f8..f97775b96 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -45,13 +45,13 @@ func TestFragCombos(t *testing.T) { tests := []struct { idx string maxSlice uint64 - frameViews viewsByField + fieldViews viewsByField expected fragsByHost }{ { idx: "i", maxSlice: uint64(2), - frameViews: viewsByField{"f": []string{"v1", "v2"}}, + fieldViews: viewsByField{"f": []string{"v1", "v2"}}, expected: fragsByHost{ "node0": []frag{{"f", "v1", uint64(0)}, {"f", "v2", uint64(0)}}, "node1": []frag{{"f", "v1", uint64(1)}, {"f", "v2", uint64(1)}, {"f", "v1", uint64(2)}, {"f", "v2", uint64(2)}}, @@ -60,7 +60,7 @@ func TestFragCombos(t *testing.T) { { idx: "foo", maxSlice: uint64(3), - frameViews: viewsByField{"f": []string{"v0"}}, + fieldViews: viewsByField{"f": []string{"v0"}}, expected: fragsByHost{ "node0": []frag{{"f", "v0", uint64(1)}, {"f", "v0", uint64(2)}}, "node1": []frag{{"f", "v0", uint64(0)}, {"f", "v0", uint64(3)}}, @@ -69,7 +69,7 @@ func TestFragCombos(t *testing.T) { } for _, test := range tests { - actual := c.fragCombos(test.idx, test.maxSlice, test.frameViews) + actual := c.fragCombos(test.idx, test.maxSlice, test.fieldViews) if !reflect.DeepEqual(actual, test.expected) { t.Errorf("expected: %v, but got: %v", test.expected, actual) } @@ -145,23 +145,23 @@ func TestFragSources(t *testing.T) { c5.addNodeBasicSorted(node3) idx := newIndexWithTempPath("i") - frame, err := idx.CreateFieldIfNotExists("f", FieldOptions{}) + field, err := idx.CreateFieldIfNotExists("f", FieldOptions{}) if err != nil { t.Fatal(err) } - _, err = frame.SetBit("standard", 1, 101, nil) + _, err = field.SetBit("standard", 1, 101, nil) if err != nil { t.Fatal(err) } - _, err = frame.SetBit("standard", 1, 1300000, nil) + _, err = field.SetBit("standard", 1, 1300000, nil) if err != nil { t.Fatal(err) } - _, err = frame.SetBit("standard", 1, 2600000, nil) + _, err = field.SetBit("standard", 1, 2600000, nil) if err != nil { t.Fatal(err) } - _, err = frame.SetBit("standard", 1, 3900000, nil) + _, err = field.SetBit("standard", 1, 3900000, nil) if err != nil { t.Fatal(err) } diff --git a/cluster_test.go b/cluster_test.go index c0de34250..a977b3536 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -416,7 +416,7 @@ func TestCluster_ResizeStates(t *testing.T) { } // Add Bit Data to node0. - if err := tc.CreateFrame("i", "f", FieldOptions{}); err != nil { + if err := tc.CreateField("i", "f", FieldOptions{}); err != nil { t.Fatal(err) } tc.SetBit("i", "f", "standard", 1, 101, nil) @@ -424,8 +424,8 @@ func TestCluster_ResizeStates(t *testing.T) { // Before starting the resize, get the CheckSum to use for // comparison later. - node0Frame := node0.Holder.Field("i", "f") - node0View := node0Frame.View("standard") + node0Field := node0.Holder.Field("i", "f") + node0View := node0Field.View("standard") node0Fragment := node0View.Fragment(1) node0Checksum := node0Fragment.Checksum() @@ -453,8 +453,8 @@ func TestCluster_ResizeStates(t *testing.T) { // Bits // Verify that node-1 contains the fragment (i/f/standard/1) transferred from node-0. - node1Frame := node1.Holder.Field("i", "f") - node1View := node1Frame.View("standard") + node1Field := node1.Holder.Field("i", "f") + node1View := node1Field.View("standard") node1Fragment := node1View.Fragment(1) // Ensure checksums are the same. diff --git a/cmd/export.go b/cmd/export.go index 951c4a0a9..9613d9544 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -52,7 +52,7 @@ The file does not contain any headers. flags.StringVarP(&Exporter.Host, "host", "", "localhost:10101", "host:port of Pilosa.") flags.StringVarP(&Exporter.Index, "index", "i", "", "Pilosa index to export") - flags.StringVarP(&Exporter.Frame, "frame", "f", "", "Frame to export") + flags.StringVarP(&Exporter.Field, "field", "f", "", "Field to export") flags.StringVarP(&Exporter.Path, "output-file", "o", "", "File to write export to - default stdout") ctl.SetTLSConfig(flags, &Exporter.TLS.CertificatePath, &Exporter.TLS.CertificateKeyPath, &Exporter.TLS.SkipVerify) diff --git a/cmd/export_test.go b/cmd/export_test.go index 2b30116c6..6f7a49b8f 100644 --- a/cmd/export_test.go +++ b/cmd/export_test.go @@ -37,13 +37,13 @@ func TestExportConfig(t *testing.T) { env: map[string]string{"PILOSA_HOST": "localhost:12345"}, cfgFileContent: ` index = "myindex" -frame = "f1" +field = "f1" `, validation: func() error { v := validator{} v.Check(cmd.Exporter.Host, "localhost:12345") v.Check(cmd.Exporter.Index, "myindex") - v.Check(cmd.Exporter.Frame, "f1") + v.Check(cmd.Exporter.Field, "f1") v.Check(cmd.Exporter.Path, "/somefile") return v.Error() }, diff --git a/cmd/import.go b/cmd/import.go index ea489f59d..db5cebf8d 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -32,7 +32,7 @@ func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command importCmd := &cobra.Command{ Use: "import", Short: "Bulk load data into pilosa.", - Long: `Bulk imports one or more CSV files to a host's index and frame. The data + Long: `Bulk imports one or more CSV files to a host's index and field. The data of the CSV file are grouped by slice for the most efficient import. The format of the CSV file is: @@ -54,14 +54,14 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM. flags := importCmd.Flags() flags.StringVarP(&Importer.Host, "host", "", "localhost:10101", "host:port of Pilosa.") 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", "f", "", "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.") - flags.Var(&Importer.FrameOptions.TimeQuantum, "frame-time-quantum", "Time quantum for the frame") - flags.StringVar(&Importer.FrameOptions.CacheType, "frame-cache-type", pilosa.CacheTypeRanked, "Cache type for the frame; valid values: none, lru, ranked") - flags.Uint32Var(&Importer.FrameOptions.CacheSize, "frame-cache-size", 50000, "Cache size for the frame") + flags.Var(&Importer.FieldOptions.TimeQuantum, "field-time-quantum", "Time quantum for the field") + flags.StringVar(&Importer.FieldOptions.CacheType, "field-cache-type", pilosa.CacheTypeRanked, "Cache type for the field; valid values: none, lru, ranked") + flags.Uint32Var(&Importer.FieldOptions.CacheSize, "field-cache-size", 50000, "Cache size for the field") ctl.SetTLSConfig(flags, &Importer.TLS.CertificatePath, &Importer.TLS.CertificateKeyPath, &Importer.TLS.SkipVerify) return importCmd diff --git a/cmd/import_test.go b/cmd/import_test.go index 8117d46fa..e8e5d61f4 100644 --- a/cmd/import_test.go +++ b/cmd/import_test.go @@ -37,13 +37,13 @@ func TestImportConfig(t *testing.T) { env: map[string]string{"PILOSA_HOST": "localhost:12345"}, cfgFileContent: ` index = "myindex" -frame = "f1" +field = "f1" `, validation: func() error { v := validator{} v.Check(cmd.Importer.Host, "localhost:12345") v.Check(cmd.Importer.Index, "myindex") - v.Check(cmd.Importer.Frame, "f1") + v.Check(cmd.Importer.Field, "f1") return v.Error() }, }, diff --git a/ctl/export.go b/ctl/export.go index 988403272..090904807 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -30,9 +30,9 @@ type ExportCommand struct { // Remote host and port. Host string - // Name of the index & frame to export from. + // Name of the index & field to export from. Index string - Frame string + Field string // Filename to export to. Path string @@ -57,7 +57,7 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { // Validate arguments. if cmd.Index == "" { return pilosa.ErrIndexRequired - } else if cmd.Frame == "" { + } else if cmd.Field == "" { return pilosa.ErrFieldRequired } @@ -89,7 +89,7 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { // Export each slice. for slice := uint64(0); slice <= maxSlices[cmd.Index]; slice++ { logger.Printf("exporting slice: %d", slice) - if err := client.ExportCSV(ctx, cmd.Index, cmd.Frame, slice, w); err != nil { + if err := client.ExportCSV(ctx, cmd.Index, cmd.Field, slice, w); err != nil { return errors.Wrap(err, "exporting") } } diff --git a/ctl/export_test.go b/ctl/export_test.go index 6948b810f..5e87334d9 100644 --- a/ctl/export_test.go +++ b/ctl/export_test.go @@ -59,10 +59,10 @@ func TestExportCommand_Run(t *testing.T) { cm.Host = s.Host() http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i", strings.NewReader(""))) - http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i/frame/f", strings.NewReader(""))) + http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i/field/f", strings.NewReader(""))) cm.Index = "i" - cm.Frame = "f" + cm.Field = "f" if err := cm.Run(context.Background()); err != nil { t.Fatalf("Export Run doesn't work: %s", err) } diff --git a/ctl/import.go b/ctl/import.go index 0bc3d093c..9383c300f 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -35,13 +35,13 @@ type ImportCommand struct { // Destination host and port. Host string `json:"host"` - // Name of the index & frame to import into. + // Name of the index & field to import into. Index string `json:"index"` - Frame string `json:"frame"` + Field string `json:"field"` - // Options for index & frame to be created if they don't exist + // Options for index & field to be created if they don't exist IndexOptions pilosa.IndexOptions - FrameOptions pilosa.FieldOptions + FieldOptions pilosa.FieldOptions // CreateSchema ensures the schema exists before import CreateSchema bool @@ -80,10 +80,10 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { logger := log.New(cmd.Stderr, "", log.LstdFlags) // Validate arguments. - // Index and frame are validated early before the files are parsed. + // Index and field are validated early before the files are parsed. if cmd.Index == "" { return pilosa.ErrIndexRequired - } else if cmd.Frame == "" { + } else if cmd.Field == "" { return pilosa.ErrFieldRequired } else if len(cmd.Paths) == 0 { return errors.New("path required") @@ -102,17 +102,17 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } } - // Determine the frame type in order to correctly handle the input data. - frameType := pilosa.DefaultFieldType + // Determine the field type in order to correctly handle the input data. + fieldType := pilosa.DefaultFieldType schema, err := cmd.Client.Schema(ctx) if err != nil { return errors.Wrap(err, "getting schema") } for _, index := range schema { if index.Name == cmd.Index { - for _, frame := range index.Fields { - if frame.Name == cmd.Frame { - frameType = frame.Options.Type + for _, field := range index.Fields { + if field.Name == cmd.Field { + fieldType = field.Options.Type } } } @@ -121,7 +121,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { // Import each path and import by slice. for _, path := range cmd.Paths { logger.Printf("parsing: %s", path) - if err := cmd.importPath(ctx, frameType, path); err != nil { + if err := cmd.importPath(ctx, fieldType, path); err != nil { return err } } @@ -134,17 +134,17 @@ func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { if err != nil { return fmt.Errorf("Error Creating Index: %s", err) } - err = cmd.Client.EnsureField(ctx, cmd.Index, cmd.Frame, cmd.FrameOptions) + err = cmd.Client.EnsureField(ctx, cmd.Index, cmd.Field, cmd.FieldOptions) if err != nil { - return fmt.Errorf("Error Creating Frame: %s", err) + return fmt.Errorf("Error Creating Field: %s", err) } return nil } // importPath parses a path into bits and imports it to the server. -func (cmd *ImportCommand) importPath(ctx context.Context, frameType, path string) error { - // If frameType is `int`, treat the import data as values to be range-encoded. - if frameType == pilosa.FieldTypeInt { +func (cmd *ImportCommand) importPath(ctx context.Context, fieldType, path string) error { + // If fieldType is `int`, treat the import data as values to be range-encoded. + if fieldType == pilosa.FieldTypeInt { return cmd.bufferValues(ctx, path) } else { if cmd.StringKeys { @@ -254,7 +254,7 @@ func (cmd *ImportCommand) importBits(ctx context.Context, bits []pilosa.Bit) err } logger.Printf("importing slice: %d, n=%d", slice, len(chunk)) - if err := cmd.Client.Import(ctx, cmd.Index, cmd.Frame, slice, chunk); err != nil { + if err := cmd.Client.Import(ctx, cmd.Index, cmd.Field, slice, chunk); err != nil { return errors.Wrap(err, "importing") } } @@ -351,7 +351,7 @@ func (cmd *ImportCommand) importBitsK(ctx context.Context, bits []pilosa.Bit) er // TODO: does it help to sort the rowKeys? logger.Printf("importing keys: n=%d", len(bits)) - if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Frame, bits); err != nil { + if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Field, bits); err != nil { return errors.Wrap(err, "importing keys") } @@ -448,7 +448,7 @@ func (cmd *ImportCommand) importValues(ctx context.Context, vals []pilosa.FieldV } logger.Printf("importing slice: %d, n=%d", slice, len(vals)) - if err := cmd.Client.ImportValue(ctx, cmd.Index, cmd.Frame, slice, vals); err != nil { + if err := cmd.Client.ImportValue(ctx, cmd.Index, cmd.Field, slice, vals); err != nil { return errors.Wrap(err, "importing values") } } diff --git a/ctl/import_test.go b/ctl/import_test.go index 9b6dd3c6e..ba8a9dc6e 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -43,7 +43,7 @@ func TestImportCommand_Validation(t *testing.T) { t.Fatalf("Command not working, expect: %s, actual: '%s'", pilosa.ErrFieldRequired, err) } - cm.Frame = "f" + cm.Field = "f" err = cm.Run(context.Background()) if err.Error() != "path required" { t.Fatalf("Command not working, expect: %s, actual: '%s'", "path required", err) @@ -73,7 +73,7 @@ func TestImportCommand_Run(t *testing.T) { cm.Host = s.Host() cm.Index = "i" - cm.Frame = "f" + cm.Field = "f" cm.CreateSchema = true cm.Paths = []string{file.Name()} err = cm.Run(ctx) @@ -106,10 +106,10 @@ func TestImportCommand_RunValue(t *testing.T) { cm.Host = s.Host() http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i", strings.NewReader(""))) - http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i/frame/f", strings.NewReader(`{"options":{"type": "int", "min": 0, "max": 100}}`))) + http.DefaultClient.Do(MustNewHTTPRequest("POST", s.URL+"/index/i/field/f", strings.NewReader(`{"options":{"type": "int", "min": 0, "max": 100}}`))) cm.Index = "i" - cm.Frame = "f" + cm.Field = "f" cm.Paths = []string{file.Name()} err = cm.Run(ctx) if err != nil { @@ -133,7 +133,7 @@ func TestImportCommand_InvalidFile(t *testing.T) { cm := NewImportCommand(stdin, stdout, stderr) cm.Host = s.Host() cm.Index = "i" - cm.Frame = "f" + cm.Field = "f" file, err := ioutil.TempFile("", "import.csv") file.Write([]byte("a,2\n3,5\n5,6")) if err != nil { diff --git a/executor.go b/executor.go index d1e40d808..411039d40 100644 --- a/executor.go +++ b/executor.go @@ -26,9 +26,9 @@ import ( "github.com/pkg/errors" ) -// DefaultFrame is the frame used if one is not specified. +// DefaultField is the field used if one is not specified. const ( - DefaultFrame = "general" + DefaultField = "general" // MinThreshold is the lowest count to use in a Top-N operation when // looking for additional id/count pairs. @@ -174,8 +174,8 @@ func (e *Executor) validateCallArgs(c *pql.Call) error { // executeSum executes a Sum() call. func (e *Executor) executeSum(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { - if frame := c.Args["frame"]; frame == "" { - return ValCount{}, errors.New("Sum(): frame required") + if field := c.Args["field"]; field == "" { + return ValCount{}, errors.New("Sum(): field required") } if len(c.Children) > 1 { @@ -207,8 +207,8 @@ func (e *Executor) executeSum(ctx context.Context, index string, c *pql.Call, sl // executeMin executes a Min() call. func (e *Executor) executeMin(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { - if frame := c.Args["frame"]; frame == "" { - return ValCount{}, errors.New("Min(): frame required") + if field := c.Args["field"]; field == "" { + return ValCount{}, errors.New("Min(): field required") } if len(c.Children) > 1 { @@ -240,8 +240,8 @@ func (e *Executor) executeMin(ctx context.Context, index string, c *pql.Call, sl // executeMax executes a Max() call. func (e *Executor) executeMax(ctx context.Context, index string, c *pql.Call, slices []uint64, opt *ExecOptions) (ValCount, error) { - if frame := c.Args["frame"]; frame == "" { - return ValCount{}, errors.New("Max(): frame required") + if field := c.Args["field"]; field == "" { + return ValCount{}, errors.New("Max(): field required") } if len(c.Children) > 1 { @@ -312,8 +312,8 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C } else if err != nil { return nil, err } else { - frame, _ := c.Args["frame"].(string) - if fr := idx.Field(frame); fr != nil { + field, _ := c.Args["field"].(string) + if fr := idx.Field(field); fr != nil { rowID, _, err := c.UintArg(rowLabel) if err != nil { return nil, errors.Wrap(err, "getting row") @@ -367,19 +367,19 @@ func (e *Executor) executeSumCountSlice(ctx context.Context, index string, c *pq filter = row } - frameName, _ := c.Args["frame"].(string) + fieldName, _ := c.Args["field"].(string) - frame := e.Holder.Field(index, frameName) - if frame == nil { + field := e.Holder.Field(index, fieldName) + if field == nil { return ValCount{}, nil } - bsig := frame.bsiGroup(frameName) + bsig := field.bsiGroup(fieldName) if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + fragment := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -405,19 +405,19 @@ func (e *Executor) executeMinSlice(ctx context.Context, index string, c *pql.Cal filter = row } - frameName, _ := c.Args["frame"].(string) + fieldName, _ := c.Args["field"].(string) - frame := e.Holder.Field(index, frameName) - if frame == nil { + field := e.Holder.Field(index, fieldName) + if field == nil { return ValCount{}, nil } - bsig := frame.bsiGroup(frameName) + bsig := field.bsiGroup(fieldName) if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + fragment := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -443,19 +443,19 @@ func (e *Executor) executeMaxSlice(ctx context.Context, index string, c *pql.Cal filter = row } - frameName, _ := c.Args["frame"].(string) + fieldName, _ := c.Args["field"].(string) - frame := e.Holder.Field(index, frameName) - if frame == nil { + field := e.Holder.Field(index, fieldName) + if field == nil { return ValCount{}, nil } - bsig := frame.bsiGroup(frameName) + bsig := field.bsiGroup(fieldName) if bsig == nil { return ValCount{}, nil } - fragment := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + fragment := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if fragment == nil { return ValCount{}, nil } @@ -538,7 +538,7 @@ func (e *Executor) executeTopNSlices(ctx context.Context, index string, c *pql.C // executeTopNSlice executes a TopN call for a single slice. func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Call, slice uint64) ([]Pair, error) { - frame, _ := c.Args["frame"].(string) + field, _ := c.Args["field"].(string) n, _, err := c.UintArg("n") if err != nil { return nil, fmt.Errorf("executeTopNSlice: %v", err) @@ -570,12 +570,12 @@ func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Ca return nil, errors.New("TopN() can only have one input bitmap") } - // Set default frame. - if frame == "" { - frame = DefaultFrame + // Set default field. + if field == "" { + field = DefaultField } - f := e.Holder.Fragment(index, frame, ViewStandard, slice) + f := e.Holder.Fragment(index, field, ViewStandard, slice) if f == nil { return nil, nil } @@ -627,12 +627,12 @@ func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql. return nil, ErrIndexNotFound } - // Fetch frame & row label based on argument. - frame, _ := c.Args["frame"].(string) - if frame == "" { - frame = DefaultFrame + // Fetch field & row label based on argument. + field, _ := c.Args["field"].(string) + if field == "" { + field = DefaultField } - f := e.Holder.Field(index, frame) + f := e.Holder.Field(index, field) if f == nil { return nil, ErrFieldNotFound } @@ -645,7 +645,7 @@ func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql. return nil, fmt.Errorf("Bitmap() must specify %v", rowLabel) } - frag := e.Holder.Fragment(index, frame, ViewStandard, slice) + frag := e.Holder.Fragment(index, field, ViewStandard, slice) if frag == nil { return NewRow(), nil } @@ -681,10 +681,10 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C return e.executeBSIGroupRangeSlice(ctx, index, c, slice) } - // Parse frame, use default if unset. - frame, _ := c.Args["frame"].(string) - if frame == "" { - frame = DefaultFrame + // Parse field, use default if unset. + field, _ := c.Args["field"].(string) + if field == "" { + field = DefaultField } // Retrieve column label. @@ -693,8 +693,8 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C return nil, ErrIndexNotFound } - // Retrieve base frame. - f := idx.Field(frame) + // Retrieve base field. + f := idx.Field(field) if f == nil { return nil, ErrFieldNotFound } @@ -734,10 +734,10 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C return &Row{}, nil } - // Union bitmaps across all time-based subframes. + // Union bitmaps across all time-based views. row := &Row{} for _, view := range ViewsByTimeRange(ViewStandard, startTime, endTime, q) { - f := e.Holder.Fragment(index, frame, view, slice) + f := e.Holder.Fragment(index, field, view, slice) if f == nil { continue } @@ -757,17 +757,17 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // Extract conditional. - var frameName string + var fieldName string var cond *pql.Condition for k, v := range c.Args { vv, ok := v.(*pql.Condition) if !ok { return nil, fmt.Errorf("Range(): %q: expected condition argument, got %v", k, v) } - frameName, cond = k, vv + fieldName, cond = k, vv } - f := e.Holder.Field(index, frameName) + f := e.Holder.Field(index, fieldName) if f == nil { return nil, ErrFieldNotFound } @@ -782,13 +782,13 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, // Handle `!= null`. if cond.Op == pql.NEQ && cond.Value == nil { // Find bsiGroup. - bsig := f.bsiGroup(frameName) + bsig := f.bsiGroup(fieldName) if bsig == nil { return nil, ErrBSIGroupNotFound } // Retrieve fragment. - frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + frag := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -808,11 +808,11 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // The reason we don't just call: - // return f.RangeBetween(frameName, predicates[0], predicates[1]) + // return f.RangeBetween(fieldName, predicates[0], predicates[1]) // here is because we need the call to be slice-specific. // Find bsiGroup. - bsig := f.bsiGroup(frameName) + bsig := f.bsiGroup(fieldName) if bsig == nil { return nil, ErrBSIGroupNotFound } @@ -823,7 +823,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // Retrieve fragment. - frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + frag := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -845,7 +845,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // Find bsiGroup. - bsig := f.bsiGroup(frameName) + bsig := f.bsiGroup(fieldName) if bsig == nil { return nil, ErrBSIGroupNotFound } @@ -856,7 +856,7 @@ func (e *Executor) executeBSIGroupRangeSlice(ctx context.Context, index string, } // Retrieve fragment. - frag := e.Holder.Fragment(index, frameName, viewBSIGroupPrefix+frameName, slice) + frag := e.Holder.Fragment(index, fieldName, viewBSIGroupPrefix+fieldName, slice) if frag == nil { return NewRow(), nil } @@ -949,17 +949,17 @@ func (e *Executor) executeCount(ctx context.Context, index string, c *pql.Call, // executeClearBit executes a ClearBit() call. func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) (bool, error) { - frame, ok := c.Args["frame"].(string) + field, ok := c.Args["field"].(string) if !ok { - return false, errors.New("ClearBit() frame required") + return false, errors.New("ClearBit() field required") } - // Retrieve frame. + // Retrieve field. idx := e.Holder.Index(index) if idx == nil { return false, ErrIndexNotFound } - f := idx.Field(frame) + f := idx.Field(field) if f == nil { return false, ErrFieldNotFound } @@ -1014,17 +1014,17 @@ func (e *Executor) executeClearBitView(ctx context.Context, index string, c *pql // executeSetBit executes a SetBit() call. func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) (bool, error) { - frame, ok := c.Args["frame"].(string) + field, ok := c.Args["field"].(string) if !ok { - return false, errors.New("SetBit() field required: frame") + return false, errors.New("SetBit() field required: field") } - // Retrieve frame. + // Retrieve field. idx := e.Holder.Index(index) if idx == nil { return false, ErrIndexNotFound } - f := idx.Field(frame) + f := idx.Field(field) if f == nil { return false, ErrFieldNotFound } @@ -1101,27 +1101,27 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal // Copy args and remove reserved fields. args := pql.CopyArgs(c.Args) - // While frame could technically work as a ColumnAttr argument, we are treating it as a reserved word primarily to avoid confusion. - // Also, if we ever need to make ColumnAttrs frame-specific, then having this reserved word prevents backward incompatibility. + // While field could technically work as a ColumnAttr argument, we are treating it as a reserved word primarily to avoid confusion. + // Also, if we ever need to make ColumnAttrs field-specific, then having this reserved word prevents backward incompatibility. delete(args, columnLabel) // Set values. for name, value := range args { - // Retrieve frame. - frame := e.Holder.Field(index, name) - if frame == nil { + // Retrieve field. + field := e.Holder.Field(index, name) + if field == nil { return ErrFieldNotFound } switch value := value.(type) { case int64: - if _, err := frame.SetValue(columnID, value); err != nil { + if _, err := field.SetValue(columnID, value); err != nil { return err } default: return ErrInvalidBSIGroupValueType } - frame.Stats.Count("SetValue", 1, 1.0) + field.Stats.Count("SetValue", 1, 1.0) } // Do not forward call if this is already being forwarded. @@ -1151,14 +1151,14 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal // executeSetRowAttrs executes a SetRowAttrs() call. func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error { - frameName, ok := c.Args["frame"].(string) + fieldName, ok := c.Args["field"].(string) if !ok { - return errors.New("SetRowAttrs() frame required") + return errors.New("SetRowAttrs() field required") } - // Retrieve frame. - frame := e.Holder.Field(index, frameName) - if frame == nil { + // Retrieve field. + field := e.Holder.Field(index, fieldName) + if field == nil { return ErrFieldNotFound } @@ -1172,14 +1172,14 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql. // Copy args and remove reserved fields. attrs := pql.CopyArgs(c.Args) - delete(attrs, "frame") + delete(attrs, "field") delete(attrs, rowLabel) // Set attributes. - if err := frame.RowAttrStore().SetAttrs(rowID, attrs); err != nil { + if err := field.RowAttrStore().SetAttrs(rowID, attrs); err != nil { return err } - frame.Stats.Count("SetRowAttrs", 1, 1.0) + field.Stats.Count("SetRowAttrs", 1, 1.0) // Do not forward call if this is already being forwarded. if opt.Remote { @@ -1208,16 +1208,16 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql. // executeBulkSetRowAttrs executes a set of SetRowAttrs() calls. func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, calls []*pql.Call, opt *ExecOptions) ([]interface{}, error) { - // Collect attributes by frame/id. + // Collect attributes by field/id. m := make(map[string]map[uint64]map[string]interface{}) for _, c := range calls { - frame, ok := c.Args["frame"].(string) + field, ok := c.Args["field"].(string) if !ok { - return nil, errors.New("SetRowAttrs() frame required") + return nil, errors.New("SetRowAttrs() field required") } - // Retrieve frame. - f := e.Holder.Field(index, frame) + // Retrieve field. + f := e.Holder.Field(index, field) if f == nil { return nil, ErrFieldNotFound } @@ -1231,20 +1231,20 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal // Copy args and remove reserved fields. attrs := pql.CopyArgs(c.Args) - delete(attrs, "frame") + delete(attrs, "field") delete(attrs, rowLabel) - // Create frame group, if not exists. - frameMap := m[frame] - if frameMap == nil { - frameMap = make(map[uint64]map[string]interface{}) - m[frame] = frameMap + // Create field group, if not exists. + fieldMap := m[field] + if fieldMap == nil { + fieldMap = make(map[uint64]map[string]interface{}) + m[field] = fieldMap } // Set or merge attributes. - attr := frameMap[rowID] + attr := fieldMap[rowID] if attr == nil { - frameMap[rowID] = cloneAttrs(attrs) + fieldMap[rowID] = cloneAttrs(attrs) } else { for k, v := range attrs { attr[k] = v @@ -1252,19 +1252,19 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal } } - // Bulk insert attributes by frame. - for name, frameMap := range m { - // Retrieve frame. - frame := e.Holder.Field(index, name) - if frame == nil { + // Bulk insert attributes by field. + for name, fieldMap := range m { + // Retrieve field. + field := e.Holder.Field(index, name) + if field == nil { return nil, ErrFieldNotFound } // Set attributes. - if err := frame.RowAttrStore().SetBulkAttrs(frameMap); err != nil { + if err := field.RowAttrStore().SetBulkAttrs(fieldMap); err != nil { return nil, err } - frame.Stats.Count("SetRowAttrs", 1, 1.0) + field.Stats.Count("SetRowAttrs", 1, 1.0) } // Do not forward call if this is already being forwarded. @@ -1309,7 +1309,7 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p // Copy args and remove reserved fields. attrs := pql.CopyArgs(c.Args) delete(attrs, columnLabel) - delete(attrs, "frame") + delete(attrs, "field") // Set attributes. if err := idx.ColumnAttrStore().SetAttrs(col, attrs); err != nil { diff --git a/executor_test.go b/executor_test.go index bd965c325..01c99e9c5 100644 --- a/executor_test.go +++ b/executor_test.go @@ -42,9 +42,9 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { // Set bits. if _, err := e.Execute(context.Background(), "i", test.MustParse(``+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 10, 3)+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 10, SliceWidth+1)+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 20, SliceWidth+1), + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, 3)+ + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, SliceWidth+1)+ + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 20, SliceWidth+1), ), nil, nil); err != nil { t.Fatal(err) } @@ -52,7 +52,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { t.Fatal(err) } - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, nil); err != nil { t.Fatal(err) } else if bits := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(bits, []uint64{3, SliceWidth + 1}) { t.Fatalf("unexpected columns: %+v", bits) @@ -61,7 +61,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { } // Inhibit column attributes. - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeColumns: true}); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, &pilosa.ExecOptions{ExcludeColumns: true}); err != nil { t.Fatal(err) } else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{}) { t.Fatalf("unexpected columns: %+v", columns) @@ -70,7 +70,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { } // Inhibit row attributes. - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeRowAttrs: true}); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, &pilosa.ExecOptions{ExcludeRowAttrs: true}); err != nil { t.Fatal(err) } else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{3, SliceWidth + 1}) { t.Fatalf("unexpected columns: %+v", columns) @@ -91,9 +91,9 @@ func TestExecutor_Execute_Bitmap(t *testing.T) { // Set bits. if _, err := e.Execute(context.Background(), "i", test.MustParse(``+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 10, 3)+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 10, SliceWidth+1)+ - fmt.Sprintf("SetBit(frame=f, row=%d, col=%d)\n", 20, SliceWidth+1), + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, 3)+ + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, SliceWidth+1)+ + fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 20, SliceWidth+1), ), nil, nil); err != nil { t.Fatal(err) } @@ -225,7 +225,7 @@ func TestExecutor_Execute_Count(t *testing.T) { hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+2) e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, frame=f))`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil { t.Fatal(err) } else if res[0] != uint64(3) { t.Fatalf("unexpected n: %d", res[0]) @@ -243,7 +243,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) { t.Fatalf("unexpected bitmap count: %d", n) } - if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, frame=f, col=1)`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, field=f, col=1)`), nil, nil); err != nil { t.Fatal(err) } else { if !res[0].(bool) { @@ -254,7 +254,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) { if n := f.Row(11).Count(); n != 1 { t.Fatalf("unexpected bitmap count: %d", n) } - if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, frame=f, col=1)`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, field=f, col=1)`), nil, nil); err != nil { t.Fatal(err) } else { if res[0].(bool) { @@ -269,7 +269,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() - // Create frames. + // Create felds. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, @@ -347,7 +347,7 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() - // Create frames. + // Create fields. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) @@ -356,18 +356,18 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) { } // Set two attrs on f/10. - // Also set attrs on other bitmaps and frames to test isolation. + // Also set attrs on other bitmaps and fields to test isolation. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, frame=f, foo="bar")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) } - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=200, frame=f, YYY=1)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=200, field=f, YYY=1)`), nil, nil); err != nil { t.Fatal(err) } - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, frame=xxx, YYY=1)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=xxx, YYY=1)`), nil, nil); err != nil { t.Fatal(err) } - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, frame=f, baz=123, bat=true)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=f, baz=123, bat=true)`), nil, nil); err != nil { t.Fatal(err) } @@ -393,15 +393,15 @@ func TestExecutor_Execute_TopN(t *testing.T) { } else if _, err := idx.CreateField("other", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=f, row=0, col=0) - SetBit(frame=f, row=0, col=1) - SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth)+`) - SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+2)+`) - SetBit(frame=f, row=0, col=`+strconv.Itoa((5*SliceWidth)+100)+`) - SetBit(frame=f, row=10, col=0) - SetBit(frame=f, row=10, col=`+strconv.Itoa(SliceWidth)+`) - SetBit(frame=f, row=20, col=`+strconv.Itoa(SliceWidth)+`) - SetBit(frame=other, row=0, col=0) + SetBit(field=f, row=0, col=0) + SetBit(field=f, row=0, col=1) + SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth)+`) + SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth+2)+`) + SetBit(field=f, row=0, col=`+strconv.Itoa((5*SliceWidth)+100)+`) + SetBit(field=f, row=10, col=0) + SetBit(field=f, row=10, col=`+strconv.Itoa(SliceWidth)+`) + SetBit(field=f, row=20, col=`+strconv.Itoa(SliceWidth)+`) + SetBit(field=other, row=0, col=0) `), nil, nil); err != nil { t.Fatal(err) } @@ -411,7 +411,7 @@ func TestExecutor_Execute_TopN(t *testing.T) { hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 5).RecalculateCache() t.Run("Standard", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame=f, n=2)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=2)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], []pilosa.Pair{ {ID: 0, Count: 5}, @@ -436,7 +436,7 @@ func TestExecutor_Execute_TopN_fill(t *testing.T) { // Execute query. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame=f, n=1)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=1)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 0, Count: 4}, @@ -470,7 +470,7 @@ func TestExecutor_Execute_TopN_fill_small(t *testing.T) { // Execute query. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame=f, n=1)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=1)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 0, Count: 5}, @@ -505,7 +505,7 @@ func TestExecutor_Execute_TopN_Src(t *testing.T) { // Execute query. e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=100, frame=other), frame=f, n=3)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=100, field=other), field=f, n=3)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 20, Count: 3}, @@ -529,7 +529,7 @@ func TestExecutor_Execute_TopN_Attr(t *testing.T) { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 10, Count: 1}, @@ -552,7 +552,7 @@ func TestExecutor_Execute_TopN_Attr_Src(t *testing.T) { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=10,frame=f),frame="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=10,field=f),field="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{ {ID: 10, Count: 1}, @@ -585,11 +585,11 @@ func TestExecutor_Execute_MinMax(t *testing.T) { } if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=x, row=0, col=0) - SetBit(frame=x, row=0, col=3) - SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) - SetBit(frame=x, row=1, col=1) - SetBit(frame=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) + SetBit(field=x, row=0, col=0) + SetBit(field=x, row=0, col=3) + SetBit(field=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) + SetBit(field=x, row=1, col=1) + SetBit(field=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`) SetValue(f=20, col=0) SetValue(f=-5, col=1) @@ -610,16 +610,16 @@ func TestExecutor_Execute_MinMax(t *testing.T) { cnt int64 }{ {filter: ``, exp: -5, cnt: 2}, - {filter: `Bitmap(frame=x, row=0)`, exp: 10, cnt: 1}, - {filter: `Bitmap(frame=x, row=1)`, exp: -5, cnt: 1}, - {filter: `Bitmap(frame=x, row=2)`, exp: 40, cnt: 1}, + {filter: `Bitmap(field=x, row=0)`, exp: 10, cnt: 1}, + {filter: `Bitmap(field=x, row=1)`, exp: -5, cnt: 1}, + {filter: `Bitmap(field=x, row=2)`, exp: 40, cnt: 1}, } for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Min(frame=f)` + pql = `Min(field=f)` } else { - pql = fmt.Sprintf(`Min(%s, frame=f)`, tt.filter) + pql = fmt.Sprintf(`Min(%s, field=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -636,16 +636,16 @@ func TestExecutor_Execute_MinMax(t *testing.T) { cnt int64 }{ {filter: ``, exp: 60, cnt: 1}, - {filter: `Bitmap(frame=x, row=0)`, exp: 60, cnt: 1}, - {filter: `Bitmap(frame=x, row=1)`, exp: -5, cnt: 1}, - {filter: `Bitmap(frame=x, row=2)`, exp: 40, cnt: 1}, + {filter: `Bitmap(field=x, row=0)`, exp: 60, cnt: 1}, + {filter: `Bitmap(field=x, row=1)`, exp: -5, cnt: 1}, + {filter: `Bitmap(field=x, row=2)`, exp: 40, cnt: 1}, } for i, tt := range tests { var pql string if tt.filter == "" { - pql = `Max(frame=f)` + pql = `Max(field=f)` } else { - pql = fmt.Sprintf(`Max(%s, frame=f)`, tt.filter) + pql = fmt.Sprintf(`Max(%s, field=f)`, tt.filter) } if result, err := e.Execute(context.Background(), "i", test.MustParse(pql), nil, nil); err != nil { t.Fatal(err) @@ -696,8 +696,8 @@ func TestExecutor_Execute_Sum(t *testing.T) { } if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=x, row=0, col=0) - SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) + SetBit(field=x, row=0, col=0) + SetBit(field=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) SetValue(foo=20, col=0) SetValue(bar=2000, col=0) @@ -711,7 +711,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { } t.Run("NoFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(frame=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(field=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 200, Count: 5}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -719,7 +719,7 @@ func TestExecutor_Execute_Sum(t *testing.T) { }) t.Run("WithFilter", func(t *testing.T) { - if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(frame=x, row=0), frame=foo)`), nil, nil); err != nil { + if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(field=x, row=0), field=foo)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 80, Count: 2}) { t.Fatalf("unexpected result: %s", spew.Sdump(result)) @@ -736,7 +736,7 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { // Create index. index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) - // Create frame. + // Create field. if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), @@ -746,22 +746,22 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) { // Set columns. if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=f, row=1, col=2, timestamp="1999-12-31T00:00") - SetBit(frame=f, row=1, col=3, timestamp="2000-01-01T00:00") - SetBit(frame=f, row=1, col=4, timestamp="2000-01-02T00:00") - SetBit(frame=f, row=1, col=5, timestamp="2000-02-01T00:00") - SetBit(frame=f, row=1, col=6, timestamp="2001-01-01T00:00") - SetBit(frame=f, row=1, col=7, timestamp="2002-01-01T02:00") + SetBit(field=f, row=1, col=2, timestamp="1999-12-31T00:00") + SetBit(field=f, row=1, col=3, timestamp="2000-01-01T00:00") + SetBit(field=f, row=1, col=4, timestamp="2000-01-02T00:00") + SetBit(field=f, row=1, col=5, timestamp="2000-02-01T00:00") + SetBit(field=f, row=1, col=6, timestamp="2001-01-01T00:00") + SetBit(field=f, row=1, col=7, timestamp="2002-01-01T02:00") - SetBit(frame=f, row=1, col=2, timestamp="1999-12-30T00:00") - SetBit(frame=f, row=1, col=2, timestamp="2002-02-01T00:00") - SetBit(frame=f, row=10, col=2, timestamp="2001-01-01T00:00") + SetBit(field=f, row=1, col=2, timestamp="1999-12-30T00:00") + SetBit(field=f, row=1, col=2, timestamp="2002-02-01T00:00") + SetBit(field=f, row=10, col=2, timestamp="2001-01-01T00:00") `), nil, nil); err != nil { t.Fatal(err) } t.Run("Standard", func(t *testing.T) { - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(row=1, frame=f, start="1999-12-31T00:00", end="2002-01-01T03:00")`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(row=1, field=f, start="1999-12-31T00:00", end="2002-01-01T03:00")`), nil, nil); err != nil { t.Fatal(err) } else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{2, 3, 4, 5, 6, 7}) { t.Fatalf("unexpected columns: %+v", columns) @@ -817,8 +817,8 @@ func TestExecutor_Execute_Range(t *testing.T) { } if _, err := e.Execute(context.Background(), "i", test.MustParse(` - SetBit(frame=f, row=0, col=0) - SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) + SetBit(field=f, row=0, col=0) + SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`) SetValue(foo=20, col=50) SetValue(bar=2000, col=50) @@ -944,8 +944,8 @@ func TestExecutor_Execute_Range(t *testing.T) { } }) - t.Run("ErrFrameNotFound", func(t *testing.T) { - if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(bad_frame >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { + t.Run("ErrFieldNotFound", func(t *testing.T) { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`Range(bad_field >= 20)`), nil, nil); err != pilosa.ErrFieldNotFound { t.Fatal(err) } }) @@ -969,7 +969,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) { s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) { if index != "i" { t.Fatalf("unexpected index: %s", index) - } else if query.String() != `Bitmap(frame="f", row=10)` { + } else if query.String() != `Bitmap(field="f", row=10)` { t.Fatalf("unexpected query: %s", query.String()) } else if !reflect.DeepEqual(slices, []uint64{1}) { t.Fatalf("unexpected slices: %+v", slices) @@ -992,7 +992,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) { hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, (1*SliceWidth)+1) e := test.NewExecutor(hldr.Holder, c) - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, nil); err != nil { t.Fatal(err) } else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 2, 2*SliceWidth + 4}) { t.Fatalf("unexpected columns: %+v", columns) @@ -1027,7 +1027,7 @@ func TestExecutor_Execute_Remote_Count(t *testing.T) { hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(10, (2*SliceWidth)+2) e := test.NewExecutor(hldr.Holder, c) - if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, frame=f))`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil { t.Fatal(err) } else if res[0] != uint64(12) { t.Fatalf("unexpected n: %d", res[0]) @@ -1055,7 +1055,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) { s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) { if index != `i` { t.Fatalf("unexpected index: %s", index) - } else if query.String() != `SetBit(col=2, frame="f", row=10)` { + } else if query.String() != `SetBit(col=2, field="f", row=10)` { t.Fatalf("unexpected query: %s", query.String()) } remoteCalled = true @@ -1067,13 +1067,13 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) { defer hldr.Close() s.Handler.API.Holder = hldr.Holder - // Create frame. + // Create field. if _, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } e := test.NewExecutor(hldr.Holder, c) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, frame=f, col=2)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, field=f, col=2)`), nil, nil); err != nil { t.Fatal(err) } @@ -1107,7 +1107,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) { if index != `i` { t.Fatalf("unexpected index: %s", index) - } else if query.String() != `SetBit(col=2, frame="f", row=10, timestamp="2016-12-11T10:09")` { + } else if query.String() != `SetBit(col=2, field="f", row=10, timestamp="2016-12-11T10:09")` { t.Fatalf("unexpected query: %s", query.String()) } remoteCalled = true @@ -1119,7 +1119,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { defer hldr.Close() s.Handler.API.Holder = hldr.Holder - // Create frame. + // Create field. if f, err := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}).CreateField("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } else if err := f.SetTimeQuantum("Y"); err != nil { @@ -1127,7 +1127,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) { } e := test.NewExecutor(hldr.Holder, c) - if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, frame=f, col=2, timestamp="2016-12-11T10:09")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, field=f, col=2, timestamp="2016-12-11T10:09")`), nil, nil); err != nil { t.Fatal(err) } @@ -1168,11 +1168,11 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) { // slices and a second time to get the counts for a set of bitmaps. switch remoteExecN { case 0: - if query.String() != `TopN(frame="f", n=3)` { + if query.String() != `TopN(field="f", n=3)` { t.Fatalf("unexpected query(0): %s", query.String()) } case 1: - if query.String() != `TopN(frame="f", ids=[0,10,30], n=3)` { + if query.String() != `TopN(field="f", ids=[0,10,30], n=3)` { t.Fatalf("unexpected query(1): %s", query.String()) } default: @@ -1196,7 +1196,7 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) { hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 4).MustSetBits(30, (4*SliceWidth)+2) e := test.NewExecutor(hldr.Holder, c) - if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame=f, n=3)`), nil, nil); err != nil { + if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=3)`), nil, nil); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(res, []interface{}{[]pilosa.Pair{ {ID: 0, Count: 5}, @@ -1218,8 +1218,8 @@ func TestExecutor_Execute_ErrMaxWritesPerRequest(t *testing.T) { } } -// Ensure SetColumnAttrs doesn't save `frame` as an attribute -func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { +// Ensure SetColumnAttrs doesn't save `field` as an attribute +func TestExectutor_SetColumnAttrs_ExcludeField(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{}) @@ -1229,12 +1229,12 @@ func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { } e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - // SetColumnAttrs call should exclude the frame attribute - _, err := e.Execute(context.Background(), "i", test.MustParse("SetBit(frame='f', row=1, col=10)"), nil, nil) + // SetColumnAttrs call should exclude the field attribute + _, err := e.Execute(context.Background(), "i", test.MustParse("SetBit(field='f', row=1, col=10)"), nil, nil) if err != nil { t.Fatal(err) } - _, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(frame='f', col=10, foo='bar')"), nil, nil) + _, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(field='f', col=10, foo='bar')"), nil, nil) if err != nil { t.Fatal(err) } @@ -1246,8 +1246,8 @@ func TestExectutor_SetColumnAttrs_ExcludeFrame(t *testing.T) { t.Fatalf("%#v != %#v", targetAttrs, attrs) } - // SetColumnAttrs call should not break if frame is not specified - _, err = e.Execute(context.Background(), "i", test.MustParse("SetBit(frame='f', row=1, col=20)"), nil, nil) + // SetColumnAttrs call should not break if field is not specified + _, err = e.Execute(context.Background(), "i", test.MustParse("SetBit(field='f', row=1, col=20)"), nil, nil) if err != nil { t.Fatal(err) } diff --git a/fragment.go b/fragment.go index 94232bfa0..1dfa9d09f 100644 --- a/fragment.go +++ b/fragment.go @@ -1904,11 +1904,11 @@ func (s *FragmentSyncer) syncBlock(id int) error { // Only sync the standard block. for j := 0; j < len(set.ColumnIDs); j++ { - fmt.Fprintf(&(buffers[count/maxWrites]), "SetBit(frame=%q, row=%d, col=%d)\n", f.Field(), set.RowIDs[j], (f.Slice()*SliceWidth)+set.ColumnIDs[j]) + fmt.Fprintf(&(buffers[count/maxWrites]), "SetBit(field=%q, row=%d, col=%d)\n", f.Field(), set.RowIDs[j], (f.Slice()*SliceWidth)+set.ColumnIDs[j]) count++ } for j := 0; j < len(clear.ColumnIDs); j++ { - fmt.Fprintf(&(buffers[count/maxWrites]), "ClearBit(frame=%q, row=%d, col=%d)\n", f.Field(), clear.RowIDs[j], (f.Slice()*SliceWidth)+clear.ColumnIDs[j]) + fmt.Fprintf(&(buffers[count/maxWrites]), "ClearBit(field=%q, row=%d, col=%d)\n", f.Field(), clear.RowIDs[j], (f.Slice()*SliceWidth)+clear.ColumnIDs[j]) count++ } diff --git a/fragment_test.go b/fragment_test.go index 7f140e907..747602348 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -753,14 +753,14 @@ func TestFragment_TopN_CacheSize(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame. - frame, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) + // Create field. + field, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) if err != nil { t.Fatal(err) } // Create view. - view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard) + view, err := field.CreateViewIfNotExists(pilosa.ViewStandard) if err != nil { t.Fatal(err) } @@ -923,14 +923,14 @@ func TestFragment_RankCache_Persistence(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame. - frame, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) + // Create field. + field, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { t.Fatal(err) } // Create view. - view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard) + view, err := field.CreateViewIfNotExists(pilosa.ViewStandard) if err != nil { t.Fatal(err) } diff --git a/handler.go b/handler.go index dca880aba..083d40279 100644 --- a/handler.go +++ b/handler.go @@ -62,7 +62,7 @@ var externalPrefixFlag = map[string]bool{ "import": true, "export": true, "index": true, - "frame": true, + "field": true, "nodes": true, "version": true, } @@ -108,10 +108,10 @@ func (h *Handler) populateValidators() { h.validators["GetFragmentNodes"] = queryValidationSpecRequired("slice", "index") h.validators["GetSliceMax"] = queryValidationSpecRequired() h.validators["PostQuery"] = queryValidationSpecRequired().Optional("slices", "columnAttrs", "excludeRowAttrs", "excludeColumns") - h.validators["GetExport"] = queryValidationSpecRequired("index", "frame", "slice") - h.validators["GetFragmentData"] = queryValidationSpecRequired("index", "frame", "slice") - h.validators["PostFragmentData"] = queryValidationSpecRequired("index", "frame", "slice") - h.validators["GetFragmentBlocks"] = queryValidationSpecRequired("index", "frame", "slice") + h.validators["GetExport"] = queryValidationSpecRequired("index", "field", "slice") + h.validators["GetFragmentData"] = queryValidationSpecRequired("index", "field", "slice") + h.validators["PostFragmentData"] = queryValidationSpecRequired("index", "field", "slice") + h.validators["GetFragmentBlocks"] = queryValidationSpecRequired("index", "field", "slice") } func (h *Handler) queryArgValidator(next http.Handler) http.Handler { @@ -165,10 +165,10 @@ func NewRouter(handler *Handler) *mux.Router { router.HandleFunc("/index/{index}", handler.handlePostIndex).Methods("POST") router.HandleFunc("/index/{index}", handler.handleDeleteIndex).Methods("DELETE") router.HandleFunc("/index/{index}/attr/diff", handler.handlePostIndexAttrDiff).Methods("POST") - //router.HandleFunc("/index/{index}/frame", handler.handleGetFrames).Methods("GET") // Not implemented. - router.HandleFunc("/index/{index}/frame/{frame}", handler.handlePostFrame).Methods("POST") - router.HandleFunc("/index/{index}/frame/{frame}", handler.handleDeleteFrame).Methods("DELETE") - router.HandleFunc("/index/{index}/frame/{frame}/attr/diff", handler.handlePostFrameAttrDiff).Methods("POST") + //router.HandleFunc("/index/{index}/field", handler.handleGetFields).Methods("GET") // Not implemented. + router.HandleFunc("/index/{index}/field/{field}", handler.handlePostField).Methods("POST") + router.HandleFunc("/index/{index}/field/{field}", handler.handleDeleteField).Methods("DELETE") + router.HandleFunc("/index/{index}/field/{field}/attr/diff", handler.handlePostFieldAttrDiff).Methods("POST") router.HandleFunc("/index/{index}/query", handler.handlePostQuery).Methods("POST").Name("PostQuery") router.HandleFunc("/recalculate-caches", handler.handleRecalculateCaches).Methods("POST") @@ -502,22 +502,22 @@ type postIndexAttrDiffResponse struct { Attrs map[uint64]map[string]interface{} `json:"attrs"` } -// handlePostFrame handles POST /frame request. -func (h *Handler) handlePostFrame(w http.ResponseWriter, r *http.Request) { +// handlePostField handles POST /field request. +func (h *Handler) handlePostField(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] + fieldName := mux.Vars(r)["field"] // Decode request. - var req postFrameRequest + var req postFieldRequest err := json.NewDecoder(r.Body).Decode(&req) if err == io.EOF { - // If no data was provided (EOF), we still create the frame + // If no data was provided (EOF), we still create the field // with default values. } else if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } - _, err = h.API.CreateField(r.Context(), indexName, frameName, req.Options) + _, err = h.API.CreateField(r.Context(), indexName, fieldName, req.Options) if err != nil { switch errors.Cause(err) { case ErrIndexNotFound: @@ -530,30 +530,30 @@ func (h *Handler) handlePostFrame(w http.ResponseWriter, r *http.Request) { return } // Encode response. - if err := json.NewEncoder(w).Encode(postFrameResponse{}); err != nil { + if err := json.NewEncoder(w).Encode(postFieldResponse{}); err != nil { h.Logger.Printf("response encoding error: %s", err) } } -type _postFrameRequest postFrameRequest +type _postFieldRequest postFieldRequest -// Custom Unmarshal JSON to validate request body when creating a new frame. If there's new FrameOptions, -// adding it to validFrameOptions to make sure the new option is validated, otherwise the request will be failed -func (p *postFrameRequest) UnmarshalJSON(b []byte) error { +// Custom Unmarshal JSON to validate request body when creating a new field. If there's new FieldOptions, +// adding it to validFieldOptions to make sure the new option is validated, otherwise the request will be failed +func (p *postFieldRequest) UnmarshalJSON(b []byte) error { // m is an overflow map used to capture additional, unexpected keys. m := make(map[string]interface{}) if err := json.Unmarshal(b, &m); err != nil { return errors.Wrap(err, "unmarshaling unexpected keys") } - validFrameOptions := getValidOptions(FieldOptions{}) - err := validateOptions(m, validFrameOptions) + validFieldOptions := getValidOptions(FieldOptions{}) + err := validateOptions(m, validFieldOptions) if err != nil { return err } // Unmarshal expected values. - var _p _postFrameRequest + var _p _postFieldRequest if err := json.Unmarshal(b, &_p); err != nil { return errors.Wrap(err, "unmarshalling expected keys") } @@ -574,18 +574,18 @@ func getValidOptions(option interface{}) []string { return validOptions } -type postFrameRequest struct { +type postFieldRequest struct { Options FieldOptions `json:"options"` } -type postFrameResponse struct{} +type postFieldResponse struct{} -// handleDeleteFrame handles DELETE /frame request. -func (h *Handler) handleDeleteFrame(w http.ResponseWriter, r *http.Request) { +// handleDeleteField handles DELETE /field request. +func (h *Handler) handleDeleteField(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] + fieldName := mux.Vars(r)["field"] - err := h.API.DeleteField(r.Context(), indexName, frameName) + err := h.API.DeleteField(r.Context(), indexName, fieldName) if err != nil { if errors.Cause(err) == ErrIndexNotFound { if err := json.NewEncoder(w).Encode(deleteIndexResponse{}); err != nil { @@ -598,26 +598,26 @@ func (h *Handler) handleDeleteFrame(w http.ResponseWriter, r *http.Request) { } // Encode response. - if err := json.NewEncoder(w).Encode(deleteFrameResponse{}); err != nil { + if err := json.NewEncoder(w).Encode(deleteFieldResponse{}); err != nil { h.Logger.Printf("response encoding error: %s", err) } } -type deleteFrameResponse struct{} +type deleteFieldResponse struct{} -// handlePostFrameAttrDiff handles POST /frame/attr/diff requests. -func (h *Handler) handlePostFrameAttrDiff(w http.ResponseWriter, r *http.Request) { +// handlePostFieldAttrDiff handles POST /field/attr/diff requests. +func (h *Handler) handlePostFieldAttrDiff(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] - frameName := mux.Vars(r)["frame"] + fieldName := mux.Vars(r)["field"] // Decode request. - var req postFrameAttrDiffRequest + var req postFieldAttrDiffRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } - attrs, err := h.API.FieldAttrDiff(r.Context(), indexName, frameName, req.Blocks) + attrs, err := h.API.FieldAttrDiff(r.Context(), indexName, fieldName, req.Blocks) if err != nil { switch errors.Cause(err) { case ErrFragmentNotFound: @@ -629,18 +629,18 @@ func (h *Handler) handlePostFrameAttrDiff(w http.ResponseWriter, r *http.Request } // Encode response. - if err := json.NewEncoder(w).Encode(postFrameAttrDiffResponse{ + if err := json.NewEncoder(w).Encode(postFieldAttrDiffResponse{ Attrs: attrs, }); err != nil { h.Logger.Printf("response encoding error: %s", err) } } -type postFrameAttrDiffRequest struct { +type postFieldAttrDiffRequest struct { Blocks []AttrBlock `json:"blocks"` } -type postFrameAttrDiffResponse struct { +type postFieldAttrDiffResponse struct { Attrs map[uint64]map[string]interface{} `json:"attrs"` } @@ -839,7 +839,7 @@ func (h *Handler) handleGetExport(w http.ResponseWriter, r *http.Request) { func (h *Handler) handleGetExportCSV(w http.ResponseWriter, r *http.Request) { // Parse query parameters. q := r.URL.Query() - index, frame := q.Get("index"), q.Get("frame") + index, field := q.Get("index"), q.Get("field") slice, err := strconv.ParseUint(q.Get("slice"), 10, 64) if err != nil { @@ -847,7 +847,7 @@ func (h *Handler) handleGetExportCSV(w http.ResponseWriter, r *http.Request) { return } - if err = h.API.ExportCSV(r.Context(), index, frame, slice, w); err != nil { + if err = h.API.ExportCSV(r.Context(), index, field, slice, w); err != nil { switch errors.Cause(err) { case ErrFragmentNotFound: break @@ -915,7 +915,7 @@ func (h *Handler) handleGetFragmentBlocks(w http.ResponseWriter, r *http.Request return } - blocks, err := h.API.FragmentBlocks(r.Context(), q.Get("index"), q.Get("frame"), slice) + blocks, err := h.API.FragmentBlocks(r.Context(), q.Get("index"), q.Get("field"), slice) if err != nil { if errors.Cause(err) == ErrFragmentNotFound { http.Error(w, err.Error(), http.StatusNotFound) diff --git a/handler_internal_test.go b/handler_internal_test.go index 9adab16ac..837c456ca 100644 --- a/handler_internal_test.go +++ b/handler_internal_test.go @@ -55,23 +55,23 @@ func TestPostIndexRequestUnmarshalJSON(t *testing.T) { } } -// Test custom UnmarshalJSON for postFrameRequest object -func TestPostFrameRequestUnmarshalJSON(t *testing.T) { +// Test custom UnmarshalJSON for postFieldRequest object +func TestPostFieldRequestUnmarshalJSON(t *testing.T) { tests := []struct { json string - expected postFrameRequest + expected postFieldRequest err string }{ - {json: `{"options": {}}`, expected: postFrameRequest{Options: FieldOptions{}}}, + {json: `{"options": {}}`, expected: postFieldRequest{Options: FieldOptions{}}}, {json: `{"options": 4}`, err: "options is not map[string]interface{}"}, {json: `{"option": {}}`, err: "Unknown key: option:map[]"}, {json: `{"options": {"badKey": "test"}}`, err: "Unknown key: badKey:test"}, {json: `{"options": {"inverseEnabled": true}}`, err: "Unknown key: inverseEnabled:true"}, - {json: `{"options": {"cacheType": "type"}}`, expected: postFrameRequest{Options: FieldOptions{CacheType: "type"}}}, + {json: `{"options": {"cacheType": "type"}}`, expected: postFieldRequest{Options: FieldOptions{CacheType: "type"}}}, {json: `{"options": {"inverse": true, "cacheType": "type"}}`, err: "Unknown key: inverse:true"}, } for _, test := range tests { - actual := &postFrameRequest{} + actual := &postFieldRequest{} err := json.Unmarshal([]byte(test.json), actual) if err != nil { if test.err == "" || test.err != err.Error() { diff --git a/handler_test.go b/handler_test.go index bd6449862..036512de4 100644 --- a/handler_test.go +++ b/handler_test.go @@ -104,8 +104,8 @@ func TestHandler_Schema(t *testing.T) { h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", nil)) if w.Code != http.StatusOK { t.Fatalf("unexpected status code: %d", w.Code) - } else if body := w.Body.String(); body != `{"indexes":[{"name":"i0","frames":[{"name":"f0"},{"name":"f1","views":[{"name":"standard"}]}]},{"name":"i1","frames":[{"name":"f0","views":[{"name":"standard"}]}]}]}`+"\n" { - } else if body := w.Body.String(); body != `{"indexes":[{"name":"i0","frames":[{"name":"f0","options":{"cacheType":"ranked","cacheSize":50000}},{"name":"f1","options":{"cacheType":"ranked","cacheSize":50000},"views":[{"name":"standard"}]}]},{"name":"i1","frames":[{"name":"f0","options":{"cacheType":"ranked","cacheSize":50000},"views":[{"name":"standard"}]}]}]}`+"\n" { + } else if body := w.Body.String(); body != `{"indexes":[{"name":"i0","fields":[{"name":"f0"},{"name":"f1","views":[{"name":"standard"}]}]},{"name":"i1","fields":[{"name":"f0","views":[{"name":"standard"}]}]}]}`+"\n" { + } else if body := w.Body.String(); body != `{"indexes":[{"name":"i0","fields":[{"name":"f0","options":{"cacheType":"ranked","cacheSize":50000}},{"name":"f1","options":{"cacheType":"ranked","cacheSize":50000},"views":[{"name":"standard"}]}]},{"name":"i1","fields":[{"name":"f0","options":{"cacheType":"ranked","cacheSize":50000},"views":[{"name":"standard"}]}]}]}`+"\n" { t.Fatalf("unexpected body: %s", body) } } @@ -536,7 +536,7 @@ func TestHandler_Query_Pairs_JSON(t *testing.T) { } w := httptest.NewRecorder() - h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(frame=x, n=2)`))) + h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(field=x, n=2)`))) if w.Code != http.StatusOK { t.Fatalf("unexpected status code: %d", w.Code) } else if body := w.Body.String(); body != `{"results":[[{"id":1,"count":2},{"id":3,"count":4}]]}`+"\n" { @@ -560,7 +560,7 @@ func TestHandler_Query_Pairs_Protobuf(t *testing.T) { } w := httptest.NewRecorder() - r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(frame=x, n=2)`)) + r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(field=x, n=2)`)) r.Header.Set("Accept", "application/x-protobuf") h.ServeHTTP(w, r) if w.Code != http.StatusOK { @@ -611,7 +611,7 @@ func TestHandler_Query_Err_Protobuf(t *testing.T) { } w := httptest.NewRecorder() - r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(frame=x, n=2)`)) + r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`TopN(field=x, n=2)`)) r.Header.Set("Accept", "application/x-protobuf") h.ServeHTTP(w, r) if w.Code != http.StatusBadRequest { @@ -694,8 +694,8 @@ func TestHandler_Index_Delete(t *testing.T) { } } -// Ensure handler can delete a frame. -func TestHandler_DeleteFrame(t *testing.T) { +// Ensure handler can delete a field. +func TestHandler_DeleteField(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() i0 := hldr.MustCreateIndexIfNotExists("i0", pilosa.IndexOptions{}) @@ -707,13 +707,13 @@ func TestHandler_DeleteFrame(t *testing.T) { h.API.Holder = hldr.Holder h.API.Cluster = test.NewCluster(1) w := httptest.NewRecorder() - h.ServeHTTP(w, test.MustNewHTTPRequest("DELETE", "/index/i0/frame/f1", strings.NewReader(""))) + h.ServeHTTP(w, test.MustNewHTTPRequest("DELETE", "/index/i0/field/f1", strings.NewReader(""))) if w.Code != http.StatusOK { t.Fatalf("unexpected status code: %d", w.Code) } else if body := w.Body.String(); body != `{}`+"\n" { t.Fatalf("unexpected body: %s", body) } else if f := hldr.Index("i0").Field("f1"); f != nil { - t.Fatal("expected nil frame") + t.Fatal("expected nil field") } } @@ -766,8 +766,8 @@ func TestHandler_Index_AttrStore_Diff(t *testing.T) { } } -// Ensure the handler can return data in differing blocks for a frame. -func TestHandler_Frame_AttrStore_Diff(t *testing.T) { +// Ensure the handler can return data in differing blocks for a field. +func TestHandler_Field_AttrStore_Diff(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() @@ -801,7 +801,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) { // Send block checksums to determine diff. resp, err := http.Post( - s.URL+"/index/i/frame/meta/attr/diff", + s.URL+"/index/i/field/meta/attr/diff", "application/json", strings.NewReader(`{"blocks":`+string(test.MustMarshalJSON(blks))+`}`), ) diff --git a/holder.go b/holder.go index bbff69927..e8db140ce 100644 --- a/holder.go +++ b/holder.go @@ -209,14 +209,14 @@ func (h *Holder) MaxSlices() map[string]uint64 { return a } -// Schema returns schema information for all indexes, frames, and views. +// Schema returns schema information for all indexes, fields, and views. func (h *Holder) Schema() []*IndexInfo { var a []*IndexInfo for _, index := range h.Indexes() { di := &IndexInfo{Name: index.Name()} - for _, frame := range index.Fields() { - fi := &FieldInfo{Name: frame.Name(), Options: frame.Options()} - for _, view := range frame.Views() { + for _, field := range index.Fields() { + fi := &FieldInfo{Name: field.Name(), Options: field.Options()} + for _, view := range field.Views() { fi.Views = append(fi.Views, &ViewInfo{Name: view.Name()}) } sort.Sort(viewInfoSlice(fi.Views)) @@ -238,16 +238,16 @@ func (h *Holder) ApplySchema(schema *internal.Schema) error { if err != nil { return errors.Wrap(err, "creating index") } - // Create frames that don't exist. + // Create fields that don't exist. for _, f := range index.Fields { opt := decodeFieldOptions(f.Meta) - frame, err := idx.CreateFieldIfNotExists(f.Name, *opt) + field, err := idx.CreateFieldIfNotExists(f.Name, *opt) if err != nil { - return errors.Wrap(err, "creating frame") + return errors.Wrap(err, "creating field") } // Create views that don't exist. for _, v := range f.Views { - _, err := frame.CreateViewIfNotExists(v) + _, err := field.CreateViewIfNotExists(v) if err != nil { return errors.Wrap(err, "creating view") } @@ -399,18 +399,18 @@ func (h *Holder) Field(index, name string) *Field { return idx.Field(name) } -// View returns the view for an index, frame, and name. -func (h *Holder) View(index, frame, name string) *View { - f := h.Field(index, frame) +// View returns the view for an index, field, and name. +func (h *Holder) View(index, field, name string) *View { + f := h.Field(index, field) if f == nil { return nil } return f.View(name) } -// Fragment returns the fragment for an index, frame & slice. -func (h *Holder) Fragment(index, frame, view string, slice uint64) *Fragment { - v := h.View(index, frame, view) +// Fragment returns the fragment for an index, field & slice. +func (h *Holder) Fragment(index, field, view string, slice uint64) *Fragment { + v := h.View(index, field, view) if v == nil { return nil } @@ -435,8 +435,8 @@ func (h *Holder) monitorCacheFlush() { func (h *Holder) flushCaches() { for _, index := range h.Indexes() { - for _, frame := range index.Fields() { - for _, view := range frame.Views() { + for _, field := range index.Fields() { + for _, view := range field.Views() { for _, fragment := range view.Fragments() { select { case <-h.closing: @@ -606,9 +606,9 @@ func (s *HolderSyncer) SyncHolder() error { return nil } - // Sync frame row attributes. + // Sync field row attributes. if err := s.syncField(di.Name, fi.Name); err != nil { - return fmt.Errorf("frame sync error: index=%s, frame=%s, err=%s", di.Name, fi.Name, err) + return fmt.Errorf("field sync error: index=%s, field=%s, err=%s", di.Name, fi.Name, err) } for _, vi := range fi.Views { @@ -630,7 +630,7 @@ func (s *HolderSyncer) SyncHolder() error { // Sync fragment if own it. if err := s.syncFragment(di.Name, fi.Name, vi.Name, slice); err != nil { - return fmt.Errorf("fragment sync error: index=%s, frame=%s, slice=%d, err=%s", di.Name, fi.Name, slice, err) + return fmt.Errorf("fragment sync error: index=%s, field=%s, slice=%d, err=%s", di.Name, fi.Name, slice, err) } } } @@ -691,20 +691,20 @@ func (s *HolderSyncer) syncIndex(index string) error { // syncField synchronizes field attributes with the rest of the cluster. func (s *HolderSyncer) syncField(index, name string) error { - // Retrieve frame reference. + // Retrieve field reference. f := s.Holder.Field(index, name) if f == nil { return nil } indexTag := fmt.Sprintf("index:%s", index) - frameTag := fmt.Sprintf("frame:%s", name) + fieldTag := fmt.Sprintf("field:%s", name) // Read block checksums. blks, err := f.RowAttrStore().Blocks() if err != nil { return errors.Wrap(err, "getting blocks") } - s.Stats.CountWithCustomTags("RowAttrStoreBlocks", int64(len(blks)), 1.0, []string{indexTag, frameTag}) + s.Stats.CountWithCustomTags("RowAttrStoreBlocks", int64(len(blks)), 1.0, []string{indexTag, fieldTag}) // Sync with every other host. for _, node := range Nodes(s.Cluster.Nodes).FilterID(s.Node.ID) { @@ -714,13 +714,13 @@ func (s *HolderSyncer) syncField(index, name string) error { // Skip update and recomputation if no attributes have changed. m, err := client.RowAttrDiff(context.Background(), index, name, blks) if err == ErrFieldNotFound { - continue // frame not created remotely yet, skip + continue // field not created remotely yet, skip } else if err != nil { return errors.Wrap(err, "getting differing blocks") } else if len(m) == 0 { continue } - s.Stats.CountWithCustomTags("RowAttrDiff", int64(len(m)), 1.0, []string{indexTag, frameTag, node.ID}) + s.Stats.CountWithCustomTags("RowAttrDiff", int64(len(m)), 1.0, []string{indexTag, fieldTag, node.ID}) // Update local copy. if err := f.RowAttrStore().SetBulkAttrs(m); err != nil { @@ -738,9 +738,9 @@ func (s *HolderSyncer) syncField(index, name string) error { } // syncFragment synchronizes a fragment with the rest of the cluster. -func (s *HolderSyncer) syncFragment(index, frame, view string, slice uint64) error { - // Retrieve local frame. - f := s.Holder.Field(index, frame) +func (s *HolderSyncer) syncFragment(index, field, view string, slice uint64) error { + // Retrieve local field. + f := s.Holder.Field(index, field) if f == nil { return ErrFieldNotFound } @@ -806,8 +806,8 @@ func (c *HolderCleaner) CleanHolder() error { containedSlices := c.Cluster.ContainsSlices(index.Name(), index.MaxSlice(), c.Node) // Get the fragments registered in memory. - for _, frame := range index.Fields() { - for _, view := range frame.Views() { + for _, field := range index.Fields() { + for _, view := range field.Views() { for _, fragment := range view.Fragments() { fragSlice := fragment.Slice() // Ignore fragments that should be present. diff --git a/holder_test.go b/holder_test.go index 35e3b8e26..5f41cfab7 100644 --- a/holder_test.go +++ b/holder_test.go @@ -91,7 +91,7 @@ func TestHolder_Open(t *testing.T) { } }) - t.Run("ErrFramePermission", func(t *testing.T) { + t.Run("ErrFieldPermission", func(t *testing.T) { if os.Geteuid() == 0 { t.Skip("Skipping permissions test since user is root.") } @@ -127,11 +127,11 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } - if err := h.Reopen(); err == nil || !strings.Contains(err.Error(), "open index: name=foo, err=opening frames: open frame: name=bar, err=loading meta: unmarshaling: unexpected EOF") { + if err := h.Reopen(); err == nil || !strings.Contains(err.Error(), "open index: name=foo, err=opening fields: open field: name=bar, err=loading meta: unmarshaling: unexpected EOF") { t.Fatalf("unexpected error: %s", err) } }) - t.Run("ErrFrameAttrStoreCorrupt", func(t *testing.T) { + t.Run("ErrFieldAttrStoreCorrupt", func(t *testing.T) { h := test.MustOpenHolder() defer h.Close() @@ -145,7 +145,7 @@ func TestHolder_Open(t *testing.T) { t.Fatal(err) } - if err := h.Reopen(); err == nil || !strings.Contains(err.Error(), "open index: name=foo, err=opening frames: open frame: name=bar, err=opening attrstore: opening storage: invalid database") { + if err := h.Reopen(); err == nil || !strings.Contains(err.Error(), "open index: name=foo, err=opening fields: open field: name=bar, err=opening attrstore: opening storage: invalid database") { t.Fatalf("unexpected error: %s", err) } }) @@ -159,9 +159,9 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { + } else if field, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { + } else if _, err := field.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -183,9 +183,9 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { + } else if field, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if _, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { + } else if _, err := field.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) } else if err := h.Holder.Close(); err != nil { t.Fatal(err) @@ -208,9 +208,9 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { + } else if field, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { + } else if view, err := field.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) } else if _, err := view.SetBit(0, 0); err != nil { t.Fatal(err) @@ -231,9 +231,9 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { + } else if field, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { + } else if view, err := field.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) } else if _, err := view.SetBit(0, 0); err != nil { t.Fatal(err) @@ -257,9 +257,9 @@ func TestHolder_Open(t *testing.T) { if idx, err := h.CreateIndex("foo", pilosa.IndexOptions{}); err != nil { t.Fatal(err) - } else if frame, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { + } else if field, err := idx.CreateField("bar", pilosa.FieldOptions{}); err != nil { t.Fatal(err) - } else if view, err := frame.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { + } else if view, err := field.CreateViewIfNotExists(pilosa.ViewStandard); err != nil { t.Fatal(err) } else if _, err := view.SetBit(0, 0); err != nil { t.Fatal(err) @@ -391,11 +391,11 @@ func TestHolderSyncer_SyncHolder(t *testing.T) { cluster.Nodes[0].URI = test.NewURIFromHostPort("localhost", 0) cluster.Nodes[1].URI = *uri - // Create frames on nodes. + // Create fields on nodes. for _, hldr := range []*test.Holder{hldr0, hldr1} { - hldr.MustCreateFrameIfNotExists("i", "f") - hldr.MustCreateFrameIfNotExists("i", "f0") - hldr.MustCreateFrameIfNotExists("y", "z") + hldr.MustCreateFieldIfNotExists("i", "f") + hldr.MustCreateFieldIfNotExists("i", "f0") + hldr.MustCreateFieldIfNotExists("y", "z") } // Set data on the local holder. @@ -496,11 +496,11 @@ func TestHolderCleaner_CleanHolder(t *testing.T) { cluster.Nodes[0].URI = test.NewURIFromHostPort("localhost", 0) - // Create frames on nodes. + // Create fields on nodes. for _, hldr := range []*test.Holder{hldr0} { - hldr.MustCreateFrameIfNotExists("i", "f") - hldr.MustCreateFrameIfNotExists("i", "f0") - hldr.MustCreateFrameIfNotExists("y", "z") + hldr.MustCreateFieldIfNotExists("i", "f") + hldr.MustCreateFieldIfNotExists("i", "f0") + hldr.MustCreateFieldIfNotExists("y", "z") } // Set data on the local holder. diff --git a/index.go b/index.go index 72b9cc1e7..80a5c2eb8 100644 --- a/index.go +++ b/index.go @@ -28,7 +28,7 @@ import ( "github.com/pkg/errors" ) -// Index represents a container for frames. +// Index represents a container for fields. type Index struct { mu sync.RWMutex path string @@ -107,7 +107,7 @@ func (i *Index) Open() error { } if err := i.openFields(); err != nil { - return errors.Wrap(err, "opening frames") + return errors.Wrap(err, "opening fields") } if err := i.columnAttrStore.Open(); err != nil { @@ -117,7 +117,7 @@ func (i *Index) Open() error { return nil } -// openFields opens and initializes the frames inside the index. +// openFields opens and initializes the fields inside the index. func (i *Index) openFields() error { f, err := os.Open(i.path) if err != nil { @@ -140,7 +140,7 @@ func (i *Index) openFields() error { return ErrName } if err := fld.Open(); err != nil { - return fmt.Errorf("open frame: name=%s, err=%s", fld.Name(), err) + return fmt.Errorf("open field: name=%s, err=%s", fld.Name(), err) } i.fields[fld.Name()] = fld } @@ -189,7 +189,7 @@ func (i *Index) saveMeta() error { } */ -// Close closes the index and its frames. +// Close closes the index and its fields. func (i *Index) Close() error { i.mu.Lock() defer i.mu.Unlock() @@ -197,10 +197,10 @@ func (i *Index) Close() error { // Close the attribute store. i.columnAttrStore.Close() - // Close all frames. + // Close all fields. for _, f := range i.fields { if err := f.Close(); err != nil { - return errors.Wrap(err, "closing frame") + return errors.Wrap(err, "closing field") } } i.fields = make(map[string]*Field) @@ -237,7 +237,7 @@ func (i *Index) SetRemoteMaxSlice(newmax uint64) { // FieldPath returns the path to a field in the index. func (i *Index) FieldPath(name string) string { return filepath.Join(i.path, name) } -// Field returns a frame in the index by name. +// Field returns a field in the index by name. func (i *Index) Field(name string) *Field { i.mu.RLock() defer i.mu.RUnlock() @@ -260,10 +260,10 @@ func (i *Index) Fields() []*Field { return a } -// RecalculateCaches recalculates caches on every frame in the index. +// RecalculateCaches recalculates caches on every field in the index. func (i *Index) RecalculateCaches() { - for _, frame := range i.Fields() { - frame.RecalculateCaches() + for _, field := range i.Fields() { + field.RecalculateCaches() } } @@ -272,7 +272,7 @@ func (i *Index) CreateField(name string, opt FieldOptions) (*Field, error) { i.mu.Lock() defer i.mu.Unlock() - // Ensure frame doesn't already exist. + // Ensure field doesn't already exist. if i.fields[name] != nil { return nil, ErrFieldExists } @@ -284,7 +284,7 @@ func (i *Index) CreateFieldIfNotExists(name string, opt FieldOptions) (*Field, e i.mu.Lock() defer i.mu.Unlock() - // Find frame in cache first. + // Find field in cache first. if f := i.fields[name]; f != nil { return f, nil } @@ -294,7 +294,7 @@ func (i *Index) CreateFieldIfNotExists(name string, opt FieldOptions) (*Field, e func (i *Index) createField(name string, opt FieldOptions) (*Field, error) { if name == "" { - return nil, errors.New("frame name required") + return nil, errors.New("field name required") } else if opt.CacheType != "" && !IsValidCacheType(opt.CacheType) { return nil, ErrInvalidCacheType } @@ -304,18 +304,18 @@ func (i *Index) createField(name string, opt FieldOptions) (*Field, error) { return nil, errors.Wrap(err, "validating options") } - // Initialize frame. + // Initialize field. f, err := i.newField(i.FieldPath(name), name) if err != nil { return nil, errors.Wrap(err, "initializing") } - // Open frame. + // Open field. if err := f.Open(); err != nil { return nil, errors.Wrap(err, "opening") } - // Apply frame options. + // Apply field options. if err := f.applyOptions(opt); err != nil { f.Close() return nil, errors.Wrap(err, "applying options") @@ -326,7 +326,7 @@ func (i *Index) createField(name string, opt FieldOptions) (*Field, error) { return nil, errors.Wrap(err, "saving meta") } - // Add to index's frame lookup. + // Add to index's field lookup. i.fields[name] = f return f, nil @@ -338,7 +338,7 @@ func (i *Index) newField(path, name string) (*Field, error) { return nil, err } f.Logger = i.Logger - f.Stats = i.Stats.WithTags(fmt.Sprintf("frame:%s", name)) + f.Stats = i.Stats.WithTags(fmt.Sprintf("field:%s", name)) f.broadcaster = i.broadcaster f.rowAttrStore = i.NewAttrStore(filepath.Join(f.path, ".data")) return f, nil @@ -349,18 +349,18 @@ func (i *Index) DeleteField(name string) error { i.mu.Lock() defer i.mu.Unlock() - // Ignore if frame doesn't exist. + // Ignore if field doesn't exist. f := i.field(name) if f == nil { return nil } - // Close frame. + // Close field. if err := f.Close(); err != nil { return errors.Wrap(err, "closing") } - // Delete frame directory. + // Delete field directory. if err := os.RemoveAll(i.FieldPath(name)); err != nil { return errors.Wrap(err, "removing directory") } diff --git a/index_test.go b/index_test.go index 2272fd5bd..6f067f0e7 100644 --- a/index_test.go +++ b/index_test.go @@ -23,40 +23,40 @@ import ( "github.com/pilosa/pilosa/test" ) -// Ensure index can open and retrieve a frame. -func TestIndex_CreateFrameIfNotExists(t *testing.T) { +// Ensure index can open and retrieve a field. +func TestIndex_CreateFieldIfNotExists(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame. + // Create field. f, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f == nil { - t.Fatal("expected frame") + t.Fatal("expected field") } - // Retrieve existing frame. + // Retrieve existing field. other, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}) if err != nil { t.Fatal(err) } else if f.Field != other.Field { - t.Fatal("frame mismatch") + t.Fatal("field mismatch") } if f.Field != index.Field("f") { - t.Fatal("frame mismatch") + t.Fatal("field mismatch") } } -func TestIndex_CreateFrame(t *testing.T) { - // Ensure time quantum can be set appropriately on a new frame. +func TestIndex_CreateField(t *testing.T) { + // Ensure time quantum can be set appropriately on a new field. t.Run("TimeQuantum", func(t *testing.T) { t.Run("Explicit", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame with explicit quantum. + // Create field with explicit quantum. f, err := index.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeTime, TimeQuantum: pilosa.TimeQuantum("YMDH"), @@ -64,18 +64,18 @@ func TestIndex_CreateFrame(t *testing.T) { if err != nil { t.Fatal(err) } else if q := f.TimeQuantum(); q != pilosa.TimeQuantum("YMDH") { - t.Fatalf("unexpected frame time quantum: %s", q) + t.Fatalf("unexpected field time quantum: %s", q) } }) }) - // Ensure frame can include range columns. + // Ensure field can include range columns. t.Run("BSIFields", func(t *testing.T) { t.Run("OK", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame with schema and verify it exists. + // Create field with schema and verify it exists. if f, err := index.CreateField("f", pilosa.FieldOptions{ Type: pilosa.FieldTypeInt, Min: 10, @@ -95,13 +95,13 @@ func TestIndex_CreateFrame(t *testing.T) { }) // TODO: These errors don't apply here. Instead, we need these tests - // on frame creation FrameOptions validation. + // on field creation FieldOptions validation. /* t.Run("ErrRangeCacheAllowed", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ CacheType: pilosa.CacheTypeRanked, }); err != nil { t.Fatal(err) @@ -111,7 +111,7 @@ func TestIndex_CreateFrame(t *testing.T) { t.Run("BSIFieldsWithCacheTypeNone", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ CacheType: pilosa.CacheTypeNone, CacheSize: uint32(5), }); err != nil { @@ -119,11 +119,11 @@ func TestIndex_CreateFrame(t *testing.T) { } }) - t.Run("ErrFrameFieldsAllowed", func(t *testing.T) { + t.Run("ErrFieldFieldsAllowed", func(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ Fields: []*pilosa.Field{ {Name: "field0", Type: pilosa.FieldTypeInt}, }, @@ -136,7 +136,7 @@ func TestIndex_CreateFrame(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ Fields: []*pilosa.Field{ {Name: "", Type: pilosa.FieldTypeInt}, }, @@ -149,7 +149,7 @@ func TestIndex_CreateFrame(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ Fields: []*pilosa.Field{ {Name: "field0", Type: "bad_type"}, }, @@ -162,7 +162,7 @@ func TestIndex_CreateFrame(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - if _, err := index.CreateFrame("f", pilosa.FrameOptions{ + if _, err := index.CreateField("f", pilosa.FieldOptions{ Fields: []*pilosa.Field{ {Name: "field0", Type: pilosa.FieldTypeInt, Min: 100, Max: 50}, }, @@ -174,21 +174,21 @@ func TestIndex_CreateFrame(t *testing.T) { }) } -// Ensure index can delete a frame. -func TestIndex_DeleteFrame(t *testing.T) { +// Ensure index can delete a field. +func TestIndex_DeleteField(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - // Create frame. + // Create field. if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - // Delete frame & verify it's gone. + // Delete field & verify it's gone. if err := index.DeleteField("f"); err != nil { t.Fatal(err) } else if index.Field("f") != nil { - t.Fatal("expected nil frame") + t.Fatal("expected nil field") } // Delete again to make sure it doesn't error. @@ -197,7 +197,7 @@ func TestIndex_DeleteFrame(t *testing.T) { } } -// Ensure index can delete a frame. +// Ensure index can delete a field. func TestIndex_InvalidName(t *testing.T) { path, err := ioutil.TempDir("", "pilosa-index-") if err != nil { diff --git a/pilosa.go b/pilosa.go index 2c0a8502d..6a7e74dfb 100644 --- a/pilosa.go +++ b/pilosa.go @@ -50,7 +50,7 @@ var ( ErrInvalidView = errors.New("invalid view") ErrInvalidCacheType = errors.New("invalid cache type") - ErrName = errors.New("invalid index or frame's name, must match [a-z0-9_-]") + ErrName = errors.New("invalid index or field name, must match [a-z0-9_-]") ErrLabel = errors.New("invalid row or column label, must match [A-Za-z0-9_-]") // ErrFragmentNotFound is returned when a fragment does not exist. @@ -78,7 +78,7 @@ type BadRequestError struct { error } -// Regular expression to validate index and frame names. +// Regular expression to validate index and field names. var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,63}$`) // ColumnAttrSet represents a set of attributes for a vertical column in an index. diff --git a/pql/ast_test.go b/pql/ast_test.go index f5d75e9de..4b130c610 100644 --- a/pql/ast_test.go +++ b/pql/ast_test.go @@ -33,11 +33,11 @@ func TestCall_String(t *testing.T) { c := &pql.Call{ Name: "Range", Args: map[string]interface{}{ - "frame": "f", + "other": "f", "field0": &pql.Condition{Op: pql.GTE, Value: 10}, }, } - if s := c.String(); s != `Range(field0 >= 10, frame="f")` { + if s := c.String(); s != `Range(field0 >= 10, other="f")` { t.Fatalf("unexpected string: %s", s) } }) diff --git a/pql/parser_test.go b/pql/parser_test.go index 0e2a5c17d..411406815 100644 --- a/pql/parser_test.go +++ b/pql/parser_test.go @@ -135,7 +135,7 @@ func TestParser_Parse(t *testing.T) { // Parse with both child calls and arguments. t.Run("ChildrenAndArguments", func(t *testing.T) { - q, err := pql.ParseString(`TopN(Bitmap(id=100, frame=other), frame=f, n=3)`) + q, err := pql.ParseString(`TopN(Bitmap(id=100, field=other), field=f, n=3)`) if err != nil { t.Fatal(err) } else if !reflect.DeepEqual(q.Calls[0], @@ -143,9 +143,9 @@ func TestParser_Parse(t *testing.T) { Name: "TopN", Children: []*pql.Call{{ Name: "Bitmap", - Args: map[string]interface{}{"id": int64(100), "frame": "other"}, + Args: map[string]interface{}{"id": int64(100), "field": "other"}, }}, - Args: map[string]interface{}{"n": int64(3), "frame": "f"}, + Args: map[string]interface{}{"n": int64(3), "field": "f"}, }, ) { t.Fatalf("unexpected call: %#v", q.Calls[0]) @@ -154,14 +154,14 @@ func TestParser_Parse(t *testing.T) { // Parse a list argument. t.Run("ListArgument", func(t *testing.T) { - q, err := pql.ParseString(`TopN(frame="f", ids=[0,10,30])`) + q, err := pql.ParseString(`TopN(field="f", ids=[0,10,30])`) if err != nil { t.Fatal(err) } else if !reflect.DeepEqual(q.Calls[0], &pql.Call{ Name: "TopN", Args: map[string]interface{}{ - "frame": "f", + "field": "f", "ids": []interface{}{int64(0), int64(10), int64(30)}, }, }, diff --git a/server/cluster_test.go b/server/cluster_test.go index 9327befc0..3dfc6c4d9 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -42,7 +42,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Expected indexes and Frames + // Expected indexes and Fields expected := map[string][]string{ "i": []string{"f"}, } @@ -51,14 +51,14 @@ func TestMain_SendReceiveMessage(t *testing.T) { client0 := m0.Client() client1 := m1.Client() - // Create indexes and frames on one node. + // Create indexes and fields on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { t.Fatal(err) } - // Make sure node0 knows about the index and frame created. + // Make sure node0 knows about the index and field created. schema0, err := client0.Schema(context.Background()) if err != nil { t.Fatal(err) @@ -66,15 +66,15 @@ func TestMain_SendReceiveMessage(t *testing.T) { received0 := map[string][]string{} for _, idx := range schema0 { received0[idx.Name] = []string{} - for _, frame := range idx.Fields { - received0[idx.Name] = append(received0[idx.Name], frame.Name) + for _, field := range idx.Fields { + received0[idx.Name] = append(received0[idx.Name], field.Name) } } if !reflect.DeepEqual(received0, expected) { t.Fatalf("unexpected schema on node0: %s", received0) } - // Make sure node1 knows about the index and frame created. + // Make sure node1 knows about the index and field created. schema1, err := client1.Schema(context.Background()) if err != nil { t.Fatal(err) @@ -82,8 +82,8 @@ func TestMain_SendReceiveMessage(t *testing.T) { received1 := map[string][]string{} for _, idx := range schema1 { received1[idx.Name] = []string{} - for _, frame := range idx.Fields { - received1[idx.Name] = append(received1[idx.Name], frame.Name) + for _, field := range idx.Fields { + received1[idx.Name] = append(received1[idx.Name], field.Name) } } if !reflect.DeepEqual(received1, expected) { @@ -92,8 +92,8 @@ func TestMain_SendReceiveMessage(t *testing.T) { // Write data on first node. if _, err := m0.Query("i", "", ` - SetBit(row=1, frame="f", col=1) - SetBit(row=1, frame="f", col=2400000) + SetBit(row=1, field="f", col=1) + SetBit(row=1, field="f", col=2400000) `); err != nil { t.Fatal(err) } @@ -206,7 +206,7 @@ func TestClusterResize_AddNode(t *testing.T) { // Create a client for each node. client0 := m0.Client() - // Create indexes and frames on one node. + // Create indexes and fields on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { @@ -250,7 +250,7 @@ func TestClusterResize_AddNode(t *testing.T) { client0 := m0.Client() //client1 := m1.Client() - // Create indexes and frames on one node. + // Create indexes and fields on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { @@ -259,8 +259,8 @@ func TestClusterResize_AddNode(t *testing.T) { // Write data on first node. if _, err := m0.Query("i", "", ` - SetBit(row=1, frame="f", col=1) - SetBit(row=1, frame="f", col=1300000) + SetBit(row=1, field="f", col=1) + SetBit(row=1, field="f", col=1300000) `); err != nil { t.Fatal(err) } @@ -302,7 +302,7 @@ func TestClusterResize_AddNode(t *testing.T) { client0 := m0.Client() //client1 := m1.Client() - // Create indexes and frames on one node. + // Create indexes and fields on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { @@ -311,8 +311,8 @@ func TestClusterResize_AddNode(t *testing.T) { // Write data on first node. Note that no data is placed on slice 1. if _, err := m0.Query("i", "", ` - SetBit(row=1, frame="f", col=1) - SetBit(row=1, frame="f", col=2400000) + SetBit(row=1, field="f", col=1) + SetBit(row=1, field="f", col=2400000) `); err != nil { t.Fatal(err) } @@ -455,7 +455,7 @@ func TestClusterResize_RemoveNode(t *testing.T) { t.Run("ErrorRemoveWithoutReplicas", func(t *testing.T) { client0 := m0.Client() - // Create indexes and frames on one node. + // Create indexes and fields on one node. if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } else if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{}); err != nil { @@ -466,7 +466,7 @@ func TestClusterResize_RemoveNode(t *testing.T) { // TODO: Deterministic node IDs would ensure consistent results setColumns := "" for i := 0; i < 20; i++ { - setColumns += fmt.Sprintf("SetBit(row=1, frame=\"f\", col=%d) ", i*pilosa.SliceWidth) + setColumns += fmt.Sprintf("SetBit(row=1, field=\"f\", col=%d) ", i*pilosa.SliceWidth) } if _, err := m0.Query("i", "", setColumns); err != nil { diff --git a/server/server_test.go b/server/server_test.go index 495812cdf..4356ad241 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -54,17 +54,17 @@ func TestMain_Set_Quick(t *testing.T) { if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } - if err := client.CreateField(context.Background(), "i", cmd.Frame, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists { + if err := client.CreateField(context.Background(), "i", cmd.Field, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists { t.Fatal(err) } - if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, frame=%q, col=%d)`, cmd.ID, cmd.Frame, cmd.ColumnID)); err != nil { + if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, field=%q, col=%d)`, cmd.ID, cmd.Field, cmd.ColumnID)); err != nil { t.Fatal(err) } } // Validate data. - for frame, frameSet := range SetCommands(cmds).Frames() { - for id, columnIDs := range frameSet { + for field, fieldSet := range SetCommands(cmds).Fields() { + for id, columnIDs := range fieldSet { exp := MustMarshalJSON(map[string]interface{}{ "results": []interface{}{ map[string]interface{}{ @@ -73,7 +73,7 @@ func TestMain_Set_Quick(t *testing.T) { }, }, }) + "\n" - if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, frame=%q)`, id, frame)); err != nil { + if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, field=%q)`, id, field)); err != nil { t.Fatal(err) } else if res != exp { t.Fatalf("unexpected result:\n\ngot=%s\n\nexp=%s\n\n", res, exp) @@ -86,8 +86,8 @@ func TestMain_Set_Quick(t *testing.T) { } // Validate data after reopening. - for frame, frameSet := range SetCommands(cmds).Frames() { - for id, columnIDs := range frameSet { + for field, fieldSet := range SetCommands(cmds).Fields() { + for id, columnIDs := range fieldSet { exp := MustMarshalJSON(map[string]interface{}{ "results": []interface{}{ map[string]interface{}{ @@ -96,7 +96,7 @@ func TestMain_Set_Quick(t *testing.T) { }, }, }) + "\n" - if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, frame=%q)`, id, frame)); err != nil { + if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, field=%q)`, id, field)); err != nil { t.Fatal(err) } else if res != exp { t.Fatalf("unexpected result (reopen):\n\ngot=%s\n\nexp=%s\n\n", res, exp) @@ -119,7 +119,7 @@ func TestMain_SetRowAttrs(t *testing.T) { m := test.MustRunMain() defer m.Close() - // Create frames. + // Create fields. client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) @@ -131,37 +131,37 @@ func TestMain_SetRowAttrs(t *testing.T) { t.Fatal(err) } - // Set columns on different rows in different frames. - if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=100)`); err != nil { + // Set columns on different rows in different fields. + if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=100)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetBit(row=2, frame="x", col=100)`); err != nil { + } else if _, err := m.Query("i", "", `SetBit(row=2, field="x", col=100)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetBit(row=2, frame="z", col=100)`); err != nil { + } else if _, err := m.Query("i", "", `SetBit(row=2, field="z", col=100)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetBit(row=3, frame="neg", col=100)`); err != nil { + } else if _, err := m.Query("i", "", `SetBit(row=3, field="neg", col=100)`); err != nil { t.Fatal(err) } // Set row attributes. - if _, err := m.Query("i", "", `SetRowAttrs(row=1, frame="x", x=100)`); err != nil { + if _, err := m.Query("i", "", `SetRowAttrs(row=1, field="x", x=100)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetRowAttrs(row=2, frame="x", x=-200)`); err != nil { + } else if _, err := m.Query("i", "", `SetRowAttrs(row=2, field="x", x=-200)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetRowAttrs(row=2, frame="z", x=300)`); err != nil { + } else if _, err := m.Query("i", "", `SetRowAttrs(row=2, field="z", x=300)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetRowAttrs(row=3, frame="neg", x=-0.44)`); err != nil { + } else if _, err := m.Query("i", "", `SetRowAttrs(row=3, field="neg", x=-0.44)`); err != nil { t.Fatal(err) } // Query row x/1. - if res, err := m.Query("i", "", `Bitmap(row=1, frame="x")`); err != nil { + if res, err := m.Query("i", "", `Bitmap(row=1, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{"x":100},"columns":[100]}]}`+"\n" { t.Fatalf("unexpected result: %s", res) } // Query row x/2. - if res, err := m.Query("i", "", `Bitmap(row=2, frame="x")`); err != nil { + if res, err := m.Query("i", "", `Bitmap(row=2, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" { t.Fatalf("unexpected result: %s", res) @@ -172,19 +172,19 @@ func TestMain_SetRowAttrs(t *testing.T) { } // Query rows after reopening. - if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil { + if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{"x":100},"columns":[100]}]}`+"\n" { t.Fatalf("unexpected result(reopen): %s", res) } - if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=3, frame="neg")`); err != nil { + if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=3, field="neg")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{"x":-0.44},"columns":[100]}]}`+"\n" { t.Fatalf("unexpected result(reopen): %s", res) } // Query row x/2. - if res, err := m.Query("i", "", `Bitmap(row=2, frame="x")`); err != nil { + if res, err := m.Query("i", "", `Bitmap(row=2, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" { t.Fatalf("unexpected result: %s", res) @@ -196,7 +196,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { m := test.MustRunMain() defer m.Close() - // Create frames. + // Create fields. client := m.Client() if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) @@ -205,9 +205,9 @@ func TestMain_SetColumnAttrs(t *testing.T) { } // Set columns on row. - if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=100)`); err != nil { + if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=100)`); err != nil { t.Fatal(err) - } else if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=101)`); err != nil { + } else if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=101)`); err != nil { t.Fatal(err) } @@ -217,7 +217,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { } // Query row. - if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil { + if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" { t.Fatalf("unexpected result: %s", res) @@ -228,7 +228,7 @@ func TestMain_SetColumnAttrs(t *testing.T) { } // Query row after reopening. - if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil { + if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil { t.Fatal(err) } else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" { t.Fatalf("unexpected result(reopen): %s", res) @@ -287,14 +287,14 @@ func TestMain_RecalculateHashes(t *testing.T) { t.Fatal("create index:", err) } if err := client0.CreateField(context.Background(), "i", "f", pilosa.FieldOptions{CacheType: "ranked"}); err != nil { - t.Fatal("create frame:", err) + t.Fatal("create field:", err) } // Set some columns data := []string{} for rowID := 1; rowID < 10; rowID++ { for columnID := 1; columnID < 100; columnID++ { - data = append(data, fmt.Sprintf(`SetBit(row=%d, frame="f", col=%d)`, rowID, columnID)) + data = append(data, fmt.Sprintf(`SetBit(row=%d, field="f", col=%d)`, rowID, columnID)) } } if _, err := cluster[0].Query("i", "", strings.Join(data, "")); err != nil { @@ -311,7 +311,7 @@ func TestMain_RecalculateHashes(t *testing.T) { // Run a TopN query on all nodes. The result should be the same as the target. for _, m := range cluster { - res, err := m.Query("i", "", `TopN(frame="f")`) + res, err := m.Query("i", "", `TopN(field="f")`) if err != nil { t.Fatal(err) } @@ -325,37 +325,37 @@ func TestMain_RecalculateHashes(t *testing.T) { // SetCommand represents a command to set a column. type SetCommand struct { ID uint64 - Frame string + Field string ColumnID uint64 } type SetCommands []SetCommand -// Frames returns the set of column ids for each frame/row. -func (a SetCommands) Frames() map[string]map[uint64][]uint64 { +// Fields returns the set of column ids for each field/row. +func (a SetCommands) Fields() map[string]map[uint64][]uint64 { // Create a set of unique commands. m := make(map[SetCommand]struct{}) for _, cmd := range a { m[cmd] = struct{}{} } - // Build unique ids for each frame & row. - frames := make(map[string]map[uint64][]uint64) + // Build unique ids for each field & row. + fields := make(map[string]map[uint64][]uint64) for cmd := range m { - if frames[cmd.Frame] == nil { - frames[cmd.Frame] = make(map[uint64][]uint64) + if fields[cmd.Field] == nil { + fields[cmd.Field] = make(map[uint64][]uint64) } - frames[cmd.Frame][cmd.ID] = append(frames[cmd.Frame][cmd.ID], cmd.ColumnID) + fields[cmd.Field][cmd.ID] = append(fields[cmd.Field][cmd.ID], cmd.ColumnID) } // Sort each set of column ids. - for _, frame := range frames { - for id := range frame { - sort.Sort(uint64Slice(frame[id])) + for _, field := range fields { + for id := range field { + sort.Sort(uint64Slice(field[id])) } } - return frames + return fields } // GenerateSetCommands generates random SetCommand objects. @@ -364,7 +364,7 @@ func GenerateSetCommands(n int, rand *rand.Rand) []SetCommand { for i := range cmds { cmds[i] = SetCommand{ ID: uint64(rand.Intn(1000)), - Frame: "x", + Field: "x", ColumnID: uint64(rand.Intn(10)), } } diff --git a/server_test.go b/server_test.go index 5ea5653cc..6cbbe191e 100644 --- a/server_test.go +++ b/server_test.go @@ -21,7 +21,7 @@ func TestMonitorAntiEntropy(t *testing.T) { } err = client.CreateField(context.Background(), "balh", "fralh", pilosa.FieldOptions{}) if err != nil { - t.Fatalf("creating frame: %v", err) + t.Fatalf("creating field: %v", err) } time.Sleep(time.Millisecond * 2) diff --git a/stats_test.go b/stats_test.go index 806baa738..55e90a741 100644 --- a/stats_test.go +++ b/stats_test.go @@ -42,39 +42,39 @@ func TestMultiStatClient_Expvar(t *testing.T) { hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth+2) hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).ClearBit(0, 1) - if pilosa.Expvar.String() != `{"index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { + if pilosa.Expvar.String() != `{"index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } hldr.Stats.CountWithCustomTags("cc", 1, 1.0, []string{"foo:bar"}) - if pilosa.Expvar.String() != `{"cc": 1, "index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { + if pilosa.Expvar.String() != `{"cc": 1, "index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } // Gauge creates a unique key, subsequent Gauge calls will overwrite hldr.Stats.Gauge("g", 5, 1.0) hldr.Stats.Gauge("g", 8, 1.0) - if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { + if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } // Set creates a unique key, subsequent sets will overwrite hldr.Stats.Set("s", "4", 1.0) hldr.Stats.Set("s", "7", 1.0) - if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7"}` { + if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7"}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } // Record timing duration and a uniquely Set key/value dur, _ := time.ParseDuration("123us") hldr.Stats.Timing("tt", dur, 1.0) - if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7", "tt": 123µs}` { + if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7", "tt": 123µs}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } // Expvar histogram is implemented as a gauge hldr.Stats.Histogram("hh", 3, 1.0) - if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "hh": 3, "index:d": {"frame:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7", "tt": 123µs}` { + if pilosa.Expvar.String() != `{"cc": 1, "g": 8, "hh": 3, "index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}, "s": "7", "tt": 123µs}` { t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String()) } @@ -109,7 +109,7 @@ func TestStatsCount_TopN(t *testing.T) { called = true }, } - if _, err := e.Execute(context.Background(), "d", test.MustParse(`TopN(frame=f, n=2)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", test.MustParse(`TopN(field=f, n=2)`), nil, nil); err != nil { t.Fatal(err) } if !called { @@ -138,7 +138,7 @@ func TestStatsCount_Bitmap(t *testing.T) { called = true }, } - if _, err := e.Execute(context.Background(), "d", test.MustParse(`Bitmap(frame=f, row=0)`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", test.MustParse(`Bitmap(field=f, row=0)`), nil, nil); err != nil { t.Fatal(err) } if !called { @@ -155,12 +155,12 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) { called := false e := test.NewExecutor(hldr.Holder, test.NewCluster(1)) - frame := e.Holder.Field("d", "f") - if frame == nil { - t.Fatal("frame not found") + field := e.Holder.Field("d", "f") + if field == nil { + t.Fatal("field not found") } - frame.Stats = &MockStats{ + field.Stats = &MockStats{ mockCount: func(name string, value int64, rate float64) { if name != "SetRowAttrs" { t.Errorf("Expected SetRowAttrs, Results %s", name) @@ -168,7 +168,7 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) { called = true }, } - if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetRowAttrs(row=10, frame=f, foo="bar")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetRowAttrs(row=10, field=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) } if !called { @@ -199,7 +199,7 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) { called = true }, } - if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetColumnAttrs(col=10, frame=f, foo="bar")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetColumnAttrs(col=10, field=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) } if !called { @@ -257,7 +257,7 @@ func TestStatsCount_DeleteIndex(t *testing.T) { } } -func TestStatsCount_CreateFrame(t *testing.T) { +func TestStatsCount_CreateField(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() @@ -282,13 +282,13 @@ func TestStatsCount_CreateFrame(t *testing.T) { called = true }, } - http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i/frame/f", nil)) + http.DefaultClient.Do(test.MustNewHTTPRequest("POST", s.URL+"/index/i/field/f", nil)) if !called { t.Error("Count isn't called") } } -func TestStatsCount_DeleteFrame(t *testing.T) { +func TestStatsCount_DeleteField(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() @@ -313,7 +313,7 @@ func TestStatsCount_DeleteFrame(t *testing.T) { called = true }, } - http.DefaultClient.Do(test.MustNewHTTPRequest("DELETE", s.URL+"/index/i/frame/f", strings.NewReader(""))) + http.DefaultClient.Do(test.MustNewHTTPRequest("DELETE", s.URL+"/index/i/field/f", strings.NewReader(""))) if !called { t.Error("Count isn't called") } diff --git a/test/cluster.go b/test/cluster.go index ee87d51a2..6b1efe665 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -114,19 +114,19 @@ func (t *TestCluster) CreateIndex(name string) error { return nil } -func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FieldOptions) error { +func (t *TestCluster) CreateField(index, field string, opt pilosa.FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, pilosa.IndexOptions{}) if err != nil { return err } - if _, err := idx.CreateField(frame, opt); err != nil { + if _, err := idx.CreateField(field, opt); err != nil { return err } } return nil } -func (t *TestCluster) SetBit(index, frame, view string, rowID, colID uint64, x *time.Time) error { +func (t *TestCluster) SetBit(index, field, view string, rowID, colID uint64, x *time.Time) error { // Determine which node should receive the SetBit. c0 := t.Clusters[0] // use the first node's cluster to determine slice location. slice := colID / pilosa.SliceWidth @@ -137,9 +137,9 @@ func (t *TestCluster) SetBit(index, frame, view string, rowID, colID uint64, x * if c == nil { continue } - f := c.Holder.Field(index, frame) + f := c.Holder.Field(index, field) if f == nil { - return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) + return fmt.Errorf("index/field does not exist: %s/%s", index, field) } _, err := f.SetBit(view, rowID, colID, x) if err != nil { diff --git a/test/fragment.go b/test/fragment.go index 2e97d6f5d..1280d3801 100644 --- a/test/fragment.go +++ b/test/fragment.go @@ -31,7 +31,7 @@ type Fragment struct { } // NewFragment returns a new instance of Fragment with a temporary path. -func NewFragment(index, frame, view string, slice uint64, cacheType string) *Fragment { +func NewFragment(index, field, view string, slice uint64, cacheType string) *Fragment { file, err := ioutil.TempFile("", "pilosa-fragment-") if err != nil { panic(err) @@ -39,7 +39,7 @@ func NewFragment(index, frame, view string, slice uint64, cacheType string) *Fra file.Close() f := &Fragment{ - Fragment: pilosa.NewFragment(file.Name(), index, frame, view, slice), + Fragment: pilosa.NewFragment(file.Name(), index, field, view, slice), RowAttrStore: MustOpenAttrStore(), } f.Fragment.CacheType = cacheType @@ -48,11 +48,11 @@ func NewFragment(index, frame, view string, slice uint64, cacheType string) *Fra } // MustOpenFragment creates and opens an fragment at a temporary path. Panic on error. -func MustOpenFragment(index, frame, view string, slice uint64, cacheType string) *Fragment { +func MustOpenFragment(index, field, view string, slice uint64, cacheType string) *Fragment { if cacheType == "" { cacheType = pilosa.DefaultCacheType } - f := NewFragment(index, frame, view, slice, cacheType) + f := NewFragment(index, field, view, slice, cacheType) if err := f.Open(); err != nil { panic(err) diff --git a/test/holder.go b/test/holder.go index c0e8f1233..3cb0a8791 100644 --- a/test/holder.go +++ b/test/holder.go @@ -80,9 +80,9 @@ func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOption return &Index{Index: idx} } -// MustCreateFrameIfNotExists returns a given frame. Panic on error. -func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Field { - f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFieldIfNotExists(frame, pilosa.FieldOptions{}) +// MustCreateFieldIfNotExists returns a given field. Panic on error. +func (h *Holder) MustCreateFieldIfNotExists(index, field string) *Field { + f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFieldIfNotExists(field, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -90,9 +90,9 @@ func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Field { } // MustCreateFragmentIfNotExists returns a given fragment. Panic on error. -func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { +func (h *Holder) MustCreateFragmentIfNotExists(index, field, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFieldIfNotExists(frame, pilosa.FieldOptions{}) + f, err := idx.CreateFieldIfNotExists(field, pilosa.FieldOptions{}) if err != nil { panic(err) } @@ -108,9 +108,9 @@ func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice } // MustCreateRankedFragmentIfNotExists returns a given fragment with a ranked cache. Panic on error. -func (h *Holder) MustCreateRankedFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment { +func (h *Holder) MustCreateRankedFragmentIfNotExists(index, field, view string, slice uint64) *Fragment { idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}) - f, err := idx.CreateFieldIfNotExists(frame, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) + f, err := idx.CreateFieldIfNotExists(field, pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) if err != nil { panic(err) } diff --git a/time_test.go b/time_test.go index 233a2ae1a..3ab652455 100644 --- a/time_test.go +++ b/time_test.go @@ -65,7 +65,7 @@ func TestViewByTimeUnit(t *testing.T) { }) } -// Ensure all applicable frame names can be generated when mutating a time bit. +// Ensure all applicable field names can be generated when mutating a time bit. func TestViewsByTime(t *testing.T) { ts := time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC) @@ -84,66 +84,66 @@ func TestViewsByTime(t *testing.T) { }) } -// Ensure sets of frames can be returned for a given time range. +// Ensure sets of fields can be returned for a given time range. func TestViewsByTimeRange(t *testing.T) { t.Run("Y", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-01-01 00:00"), MustParseTime("2002-01-01 00:00"), MustParseTimeQuantum("Y")) if !reflect.DeepEqual(a, []string{"F_2000", "F_2001"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("YM", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-11-01 00:00"), MustParseTime("2003-03-01 00:00"), MustParseTimeQuantum("YM")) if !reflect.DeepEqual(a, []string{"F_200011", "F_200012", "F_2001", "F_2002", "F_200301", "F_200302"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("YMD", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-11-28 00:00"), MustParseTime("2003-03-02 00:00"), MustParseTimeQuantum("YMD")) if !reflect.DeepEqual(a, []string{"F_20001128", "F_20001129", "F_20001130", "F_200012", "F_2001", "F_2002", "F_200301", "F_200302", "F_20030301"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("YMDH", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-11-28 22:00"), MustParseTime("2002-03-01 03:00"), MustParseTimeQuantum("YMDH")) if !reflect.DeepEqual(a, []string{"F_2000112822", "F_2000112823", "F_20001129", "F_20001130", "F_200012", "F_2001", "F_200201", "F_200202", "F_2002030100", "F_2002030101", "F_2002030102"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("M", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-01-01 00:00"), MustParseTime("2000-03-01 00:00"), MustParseTimeQuantum("M")) if !reflect.DeepEqual(a, []string{"F_200001", "F_200002"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("MD", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-11-29 00:00"), MustParseTime("2002-02-03 00:00"), MustParseTimeQuantum("MD")) if !reflect.DeepEqual(a, []string{"F_20001129", "F_20001130", "F_200012", "F_200101", "F_200102", "F_200103", "F_200104", "F_200105", "F_200106", "F_200107", "F_200108", "F_200109", "F_200110", "F_200111", "F_200112", "F_200201", "F_20020201", "F_20020202"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("MDH", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-11-29 22:00"), MustParseTime("2002-03-02 03:00"), MustParseTimeQuantum("MDH")) if !reflect.DeepEqual(a, []string{"F_2000112922", "F_2000112923", "F_20001130", "F_200012", "F_200101", "F_200102", "F_200103", "F_200104", "F_200105", "F_200106", "F_200107", "F_200108", "F_200109", "F_200110", "F_200111", "F_200112", "F_200201", "F_200202", "F_20020301", "F_2002030200", "F_2002030201", "F_2002030202"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("D", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-01-01 00:00"), MustParseTime("2000-01-04 00:00"), MustParseTimeQuantum("D")) if !reflect.DeepEqual(a, []string{"F_20000101", "F_20000102", "F_20000103"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("DH", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-01-01 22:00"), MustParseTime("2000-03-01 02:00"), MustParseTimeQuantum("DH")) if !reflect.DeepEqual(a, []string{"F_2000010122", "F_2000010123", "F_20000102", "F_20000103", "F_20000104", "F_20000105", "F_20000106", "F_20000107", "F_20000108", "F_20000109", "F_20000110", "F_20000111", "F_20000112", "F_20000113", "F_20000114", "F_20000115", "F_20000116", "F_20000117", "F_20000118", "F_20000119", "F_20000120", "F_20000121", "F_20000122", "F_20000123", "F_20000124", "F_20000125", "F_20000126", "F_20000127", "F_20000128", "F_20000129", "F_20000130", "F_20000131", "F_20000201", "F_20000202", "F_20000203", "F_20000204", "F_20000205", "F_20000206", "F_20000207", "F_20000208", "F_20000209", "F_20000210", "F_20000211", "F_20000212", "F_20000213", "F_20000214", "F_20000215", "F_20000216", "F_20000217", "F_20000218", "F_20000219", "F_20000220", "F_20000221", "F_20000222", "F_20000223", "F_20000224", "F_20000225", "F_20000226", "F_20000227", "F_20000228", "F_20000229", "F_2000030100", "F_2000030101"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) t.Run("H", func(t *testing.T) { a := pilosa.ViewsByTimeRange("F", MustParseTime("2000-01-01 00:00"), MustParseTime("2000-01-01 02:00"), MustParseTimeQuantum("H")) if !reflect.DeepEqual(a, []string{"F_2000010100", "F_2000010101"}) { - t.Fatalf("unexpected frames: %#v", a) + t.Fatalf("unexpected fields: %#v", a) } }) } diff --git a/utils_test.go b/utils_test.go index 15053cd2b..6335d087f 100644 --- a/utils_test.go +++ b/utils_test.go @@ -104,20 +104,20 @@ func (t *ClusterCluster) CreateIndex(name string) error { return nil } -func (t *ClusterCluster) CreateFrame(index, frame string, opt FieldOptions) error { +func (t *ClusterCluster) CreateField(index, field string, opt FieldOptions) error { for _, c := range t.Clusters { idx, err := c.Holder.CreateIndexIfNotExists(index, IndexOptions{}) if err != nil { return err } - if _, err := idx.CreateField(frame, opt); err != nil { + if _, err := idx.CreateField(field, opt); err != nil { return err } } return nil } -func (t *ClusterCluster) SetBit(index, frame, view string, rowID, colID uint64, x *time.Time) error { +func (t *ClusterCluster) SetBit(index, field, view string, rowID, colID uint64, x *time.Time) error { // Determine which node should receive the SetBit. c0 := t.Clusters[0] // use the first node's cluster to determine slice location. slice := colID / SliceWidth @@ -128,9 +128,9 @@ func (t *ClusterCluster) SetBit(index, frame, view string, rowID, colID uint64, if c == nil { continue } - f := c.Holder.Field(index, frame) + f := c.Holder.Field(index, field) if f == nil { - return fmt.Errorf("index/frame does not exist: %s/%s", index, frame) + return fmt.Errorf("index/field does not exist: %s/%s", index, field) } _, err := f.SetBit(view, rowID, colID, x) if err != nil { diff --git a/view_test.go b/view_test.go index 5bef29ddd..217c4bbb4 100644 --- a/view_test.go +++ b/view_test.go @@ -30,14 +30,14 @@ type View struct { } // NewView returns a new instance of View with a temporary path. -func NewView(index, frame, name string) *View { +func NewView(index, field, name string) *View { path, err := ioutil.TempDir("", "pilosa-view-") if err != nil { panic(err) } v := &View{ - View: pilosa.NewView(path, index, frame, name, pilosa.DefaultCacheSize), + View: pilosa.NewView(path, index, field, name, pilosa.DefaultCacheSize), RowAttrStore: test.MustOpenAttrStore(), } v.View.RowAttrStore = v.RowAttrStore @@ -45,8 +45,8 @@ func NewView(index, frame, name string) *View { } // MustOpenView creates and opens an view at a temporary path. Panic on error. -func MustOpenView(index, frame, name string) *View { - v := NewView(index, frame, name) +func MustOpenView(index, field, name string) *View { + v := NewView(index, field, name) if err := v.Open(); err != nil { panic(err) } From 34cea8768360a25a8e6bf08dccd393b7a03c07b8 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 6 Jun 2018 11:44:16 -0500 Subject: [PATCH 51/52] Remove WebUI (now contained in a separate package) It now lives at https://github.com/pilosa/webui --- .travis.yml | 2 +- CONTRIBUTING.md | 8 +- Dockerfile | 2 +- Makefile | 16 +- docs/getting-started.md | 4 - docs/installation.md | 6 +- docs/webui.md | 22 +- filesystem.go | 42 -- handler.go | 23 +- handler_test.go | 29 -- server/server.go | 2 - statik/.gitignore | 1 - statik/filesystem.go | 37 -- webui/assets/chevron-down.png | Bin 3655 -> 0 bytes webui/assets/main.js | 594 ---------------------- webui/assets/nav-cluster-active.svg | 1 - webui/assets/nav-cluster.svg | 1 - webui/assets/nav-console-active.svg | 1 - webui/assets/nav-console.svg | 1 - webui/assets/nav-documentation-active.svg | 1 - webui/assets/nav-documentation.svg | 1 - webui/assets/nav_item1.svg | 1 - webui/assets/style.css | 336 ------------ webui/index.html | 123 ----- 24 files changed, 30 insertions(+), 1224 deletions(-) delete mode 100644 filesystem.go delete mode 100644 statik/.gitignore delete mode 100644 statik/filesystem.go delete mode 100644 webui/assets/chevron-down.png delete mode 100644 webui/assets/main.js delete mode 100644 webui/assets/nav-cluster-active.svg delete mode 100644 webui/assets/nav-cluster.svg delete mode 100644 webui/assets/nav-console-active.svg delete mode 100644 webui/assets/nav-console.svg delete mode 100644 webui/assets/nav-documentation-active.svg delete mode 100644 webui/assets/nav-documentation.svg delete mode 100644 webui/assets/nav_item1.svg delete mode 100644 webui/assets/style.css delete mode 100644 webui/index.html diff --git a/.travis.yml b/.travis.yml index 4d413ec3b..0e4f44d1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: - GOARCH=amd64 - GOARCH=amd64 ENTERPRISE=1 install: - - make install-dep install-statik vendor generate-statik + - make install-dep vendor script: - make test before_deploy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c991caeab..2ad9ab13d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,7 +78,7 @@ Pilosa includes a Makefile that automates several tasks: make install ``` -- Install build dependencies (dep, statik, and protoc): +- Install build dependencies (dep and protoc): ```sh make install-build-deps @@ -114,12 +114,6 @@ Pilosa includes a Makefile that automates several tasks: make release ``` -- Generate static assets for the WebUI: - - ```sh - make generate-statik - ``` - - Regenerate protocol buffer files in `internal/`: ```sh diff --git a/Dockerfile b/Dockerfile index 7cdb93cc0..2b83c71c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.10.2 as builder COPY . /go/src/github.com/pilosa/pilosa/ RUN cd /go/src/github.com/pilosa/pilosa \ - && CGO_ENABLED=0 make install-dep install-statik install FLAGS="-a" + && CGO_ENABLED=0 make install-dep install FLAGS="-a" FROM scratch diff --git a/Makefile b/Makefile index 3f17f0b2e..821ba33b6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build check-clean clean cover cover-viz default docker docker-build docker-test generate generate-protoc generate-statik install install-build-deps install-dep install-protoc install-protoc-gen-gofast install-statik prerelease prerelease-build prerelease-upload release release-build require-dep require-protoc require-protoc-gen-gofast require-statik test +.PHONY: build check-clean clean cover cover-viz default docker docker-build docker-test generate generate-protoc install install-build-deps install-dep install-protoc install-protoc-gen-gofast prerelease prerelease-build prerelease-upload release release-build require-dep require-protoc require-protoc-gen-gofast test CLONE_URL=github.com/pilosa/pilosa VERSION := $(shell git describe --tags 2> /dev/null || echo unknown) @@ -88,16 +88,12 @@ install: vendor generate-protoc: require-protoc require-protoc-gen-gofast go generate github.com/pilosa/pilosa/internal -# `go generate` statik assets (WebUI) -generate-statik: require-statik - go generate github.com/pilosa/pilosa/statik - # `go generate` stringers generate-stringer: go generate github.com/pilosa/pilosa # `go generate` all needed packages -generate: generate-protoc generate-statik generate-stringer +generate: generate-protoc generate-stringer # Create Docker image from Dockerfile docker: @@ -126,23 +122,17 @@ endef require-dep: $(call require,dep) -require-statik: - $(call require,statik) - require-protoc-gen-gofast: $(call require,protoc-gen-gofast) require-protoc: $(call require,protoc) -install-build-deps: install-dep install-statik install-protoc-gen-gofast install-protoc install-stringer +install-build-deps: install-dep install-protoc-gen-gofast install-protoc install-stringer install-dep: go get -u github.com/golang/dep/cmd/dep -install-statik: - go get -u github.com/rakyll/statik - install-stringer: go get -u golang.org/x/tools/cmd/stringer diff --git a/docs/getting-started.md b/docs/getting-started.md index c5383e81c..276b0bff9 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -112,10 +112,6 @@ Note that both the user IDs and the repository IDs were remapped to sequential i #### Make Some Queries -
-

Note the Pilosa server comes with a WebUI for constructing queries in a browser. In local development, it is available at localhost:10101.

-
- Which repositories did user 14 star: ``` request curl localhost:10101/index/repository/query \ diff --git a/docs/installation.md b/docs/installation.md index cf743721f..639293338 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -142,11 +142,10 @@ There are four ways to install Pilosa on MacOS: Use [Homebrew](https://brew.sh/) git clone https://github.com/pilosa/pilosa.git ``` -3. Build the Pilosa repo (the `make generate-statik` line isn't necessary but builds a nice [webUI](../webui/) into Pilosa): +3. Build the Pilosa repo: ``` cd $GOPATH/src/github.com/pilosa/pilosa make install-build-deps - make generate-statik make install ``` @@ -294,11 +293,10 @@ There are three ways to install Pilosa on Linux: download the binary (recommende git clone https://github.com/pilosa/pilosa.git ``` -3. Build the Pilosa repo (the `make generate-statik` line isn't necessary but builds a nice [webUI](../webui/) into Pilosa): +3. Build the Pilosa repo: ``` cd $GOPATH/src/github.com/pilosa/pilosa make install-build-deps - make generate-statik make install ``` diff --git a/docs/webui.md b/docs/webui.md index 07acd2ab4..94377fbe8 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -9,13 +9,27 @@ nav = [ ## WebUI -The Pilosa server comes packaged with in-browser WebUI. When you run a local Pilosa server on the default host, you can access it at [localhost:10101](http://localhost:10101). +A web-based app called Pilosa WebUI is available in a separate package. This can be used for constructing queries and viewing the cluster status. -This can be used for constructing queries and viewing the cluster status. +### Installation + +Releases are [available on Github](https://github.com/pilosa/webui/releases) as well as on [Homebrew](https://brew.sh/) for Mac. + +Installing on a Mac with Homebrew is simple; just run: + +``` +brew install pilosa-webui +``` + +You may also build from source by checking out the [repo on Github](https://github.com/pilosa/webui) and running: + +``` +make install +``` ### Console -The [Console view](http://localhost:10101/#console) allows you to enter [PQL](../query-language/) queries and run them against your locally running server. First you must select an Index with the Select index dropdown. +The Console view allows you to enter [PQL](../query-language/) queries and run them against your locally running server. First you must select an Index with the Select index dropdown. Each query's result will be displayed in the Output section along with the query time. @@ -39,4 +53,4 @@ Frame creation also supports options like `timeQuantum`. When creating a new fra ### Cluster Admin -Use the [Cluster Admin tab](http://localhost:10101/#admin) to view the current status of your cluster. This contains information on each node in the cluster, plus the list of Indexes and Frames. +Use the Cluster Admin tab to view the current status of your cluster. This contains information on each node in the cluster, plus the list of Indexes and Frames. diff --git a/filesystem.go b/filesystem.go deleted file mode 100644 index 5664f0987..000000000 --- a/filesystem.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pilosa - -import ( - "fmt" - "net/http" -) - -// Ensure nopFileSystem implements interface. -var _ FileSystem = &nopFileSystem{} - -// FileSystem represents an interface for a WebUI file system. -type FileSystem interface { - New() (http.FileSystem, error) -} - -func init() { - NopFileSystem = &nopFileSystem{} -} - -// NopFileSystem represents a FileSystem that returns an error if called. -var NopFileSystem FileSystem - -type nopFileSystem struct{} - -// New is a no-op implementation of FileSystem New method. -func (n *nopFileSystem) New() (http.FileSystem, error) { - return nil, fmt.Errorf("file system not implemented") -} diff --git a/handler.go b/handler.go index 083d40279..c4bb364ea 100644 --- a/handler.go +++ b/handler.go @@ -42,8 +42,6 @@ import ( type Handler struct { Handler http.Handler - FileSystem FileSystem - Logger Logger // Keeps the query argument validators for each handler @@ -87,8 +85,7 @@ func OptHandlerAllowedOrigins(origins []string) HandlerOption { // NewHandler returns a new instance of Handler with a default logger. func NewHandler(opts ...HandlerOption) (*Handler, error) { handler := &Handler{ - FileSystem: NopFileSystem, - Logger: NopLogger, + Logger: NopLogger, } handler.Handler = NewRouter(handler) handler.populateValidators() @@ -137,8 +134,7 @@ func (h *Handler) queryArgValidator(next http.Handler) http.Handler { // NewRouter creates a new mux http router. func NewRouter(handler *Handler) *mux.Router { router := mux.NewRouter() - router.HandleFunc("/", handler.handleWebUI).Methods("GET") - router.HandleFunc("/assets/{file}", handler.handleWebUI).Methods("GET") + router.HandleFunc("/", handler.handleHome).Methods("GET") router.HandleFunc("/cluster/message", handler.handlePostClusterMessage).Methods("POST") router.HandleFunc("/cluster/resize/set-coordinator", handler.handlePostClusterResizeSetCoordinator).Methods("POST") router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux).Methods("GET") @@ -226,19 +222,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } -func (h *Handler) handleWebUI(w http.ResponseWriter, r *http.Request) { - // If user is using curl, don't chuck HTML at them - if strings.HasPrefix(r.UserAgent(), "curl") { - http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the WebUI by visiting this URL in your browser.", http.StatusNotFound) - return - } - filesystem, err := h.FileSystem.New() - if err != nil { - _ = h.writeQueryResponse(w, r, &QueryResponse{Err: err}) - h.Logger.Printf("Pilosa WebUI is not available. Please run `make generate-statik` before building Pilosa with `make install`.") - return - } - http.FileServer(filesystem).ServeHTTP(w, r) +func (h *Handler) handleHome(w http.ResponseWriter, r *http.Request) { + http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information.", http.StatusNotFound) } // handleGetSchema handles GET /schema requests. diff --git a/handler_test.go b/handler_test.go index 036512de4..f9e490d9d 100644 --- a/handler_test.go +++ b/handler_test.go @@ -31,7 +31,6 @@ import ( "github.com/pilosa/pilosa" "github.com/pilosa/pilosa/internal" "github.com/pilosa/pilosa/pql" - "github.com/pilosa/pilosa/statik" "github.com/pilosa/pilosa/test" ) @@ -915,34 +914,6 @@ func TestHandler_RecalculateCaches(t *testing.T) { } -func TestHandler_WebUI(t *testing.T) { - hldr := test.MustOpenHolder() - defer hldr.Close() - - h := test.MustNewHandler() - h.API.Holder = hldr.Holder - h.API.Cluster = test.NewCluster(1) - h.FileSystem = &statik.FileSystem{} - - w := httptest.NewRecorder() - h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/", nil)) - if w.Code != http.StatusOK { - t.Fatalf("unexpected status code: %d", w.Code) - } - if !strings.Contains(w.Body.String(), "Pilosa WebUI") { - t.Fatalf("WebUI is not being served correctly.") - } - - // If curl is the client, the response should be different - w = httptest.NewRecorder() - req := test.MustNewHTTPRequest("GET", "/", nil) - req.Header.Add("User-Agent", "curl/7.54.0") - h.ServeHTTP(w, req) - if !strings.Contains(w.Body.String(), "try the WebUI") { - t.Fatalf("WebUI is not being served correctly.") - } -} - func TestHandler_CORS(t *testing.T) { hldr := test.MustOpenHolder() defer hldr.Close() diff --git a/server/server.go b/server/server.go index 345807ec2..bb75a1d2e 100644 --- a/server/server.go +++ b/server/server.go @@ -39,7 +39,6 @@ import ( "github.com/pilosa/pilosa/gcnotify" "github.com/pilosa/pilosa/gopsutil" "github.com/pilosa/pilosa/gossip" - "github.com/pilosa/pilosa/statik" "github.com/pilosa/pilosa/statsd" "github.com/pkg/errors" ) @@ -170,7 +169,6 @@ func (m *Command) SetupServer() error { return errors.Wrap(err, "wrapping handler") } handler.Logger = m.logger - handler.FileSystem = &statik.FileSystem{} handler.API = pilosa.NewAPI() handler.API.Logger = m.logger diff --git a/statik/.gitignore b/statik/.gitignore deleted file mode 100644 index 485c0c57d..000000000 --- a/statik/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/statik.go diff --git a/statik/filesystem.go b/statik/filesystem.go deleted file mode 100644 index e3bf95cb1..000000000 --- a/statik/filesystem.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 Pilosa Corp. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//go:generate statik -src=../webui -dest=.. -// -// Package statik contains static assets for the Web UI. `go generate` or -// `make generate-statik` will produce statik.go, which is ignored by git. -package statik - -import ( - "net/http" - - "github.com/pilosa/pilosa" - "github.com/rakyll/statik/fs" -) - -// Ensure nopFileSystem implements interface. -var _ pilosa.FileSystem = &FileSystem{} - -// FileSystem represents a static FileSystem. -type FileSystem struct{} - -// New is a statik implementation of FileSystem New method. -func (s *FileSystem) New() (http.FileSystem, error) { - return fs.New() -} diff --git a/webui/assets/chevron-down.png b/webui/assets/chevron-down.png deleted file mode 100644 index 3312489a21a768a90cb73633e3a596c792c6941b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3655 zcmc&%=Q|q?*KW0H)Tmae-BOjBMU9A24O;c6Q8k0w8WKdQtwyLI8k;CJ(x67|hSaE^ z6|2;a74t_Bd(?V7f5ZFXJ=b;4{pDQub)OICzRrm;eEE!(nV0#}rAw^3&$Wy%u=9V( zc3m3+?#C;WRNBP}*6USt8_amab zi^h;Is}+fy%21M@F?ele)cv1>K-vLyLy5L`@9Kq!|BqORPvUBg^Evj<4W(8q|CaQ; zfj-@C?_4rA8i1G*|KyrqU(f8R^Y;SmXTWXiW6t^`_&;3P^h6t$^@M78kW@#OmD7~* zC|u%g=y$tpBOr`mX;U|C2HN(p8G3T+?HtrD=b=rO-Q^KNT;89bpZvm4NJT6n*|)zE zH*h}*TEI5K>wi;9jDw5H`ChB_6Kz{gxvT1FGSkfq$ldWr2)fE&S+}zI7)X454~Nql zKY5qjkSG-Qtt929%76^%4{Wn64~11!O!B&4PgslhUG77Id-+HeIFwAv7n(TISXbMx zdVKnKav*z6;sq;e$qEU5_eW*2GbM5U>)3%OTO7~>FbY`KVRjM&&J<=Ip{(WQR7OzS z?|W9K_o~tI7#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(K+ekHT~=%#|{O2sYPn!$*2y~-r_I^!#DB;uki7l9x*wgB5w^d~1mc8^rr79f=P z9l-64^Ry?1ObR*0V)bUvcjkW0|m5CH9Ip${Ay_Bd$j)lW-=F*({6B$h}(qWM36| z@s@e0V$otv9TPr!=2Sg3Mq4H{x~ZGmc@935%hz$Aurh_tD&q3qUdlH?O646w;e!&O zY}`Vk{dNyb%#^S`HtC+`HmKRh>vbj>ysWF6ty_~s9>gKb@s&u7OiYzU4E@h+|Y~E#o^~cyP&no8D67>AS zYv}r=rB`M|S>GiSwPI^a)12Vi) zg~7jSVPreXjW*8EZTFv*5i@i3c=PuxWmrL~-}5c}A;Cm8QlK4*woup+lu+1&4)_!m zzC1BxD4v&Pl;@A(@~EDV9(rbLb+Lmb+%+V&>_aylKReZQX%R&2XI_ZGRH6X=ByOU` z$CJls!#IOcBCamO88I^7nAuYsPSz~!f%sO?LO4G#CH)qL&B*-dYI@GsWO*08*`g(J zD=eUu!WvX*=*uQf<(IB%2It+2CR%={xc=P=$ss0%o*qDRAB+peGK*?$nf?d+wZjFH zrwyv@u5|Eg)wkO7JFxd~48Q|=-e)}F@B%bOMRu4S)7O1A*LO*__9sFd)5z%a_?&>e zzgWjmg)7N-8Z-XoR50ARt~Qanb8xnj0>i!~E4|`T2ggQveuz8NE|`K#gb;YM6064F zPmElfSi)7WONW_dXkOlAGO9H%Uke&6*}#4W-uhNgvz}-dpBQ=n7OR*kz`X9hZQ=2K zYt%U}aB>EvO`Tj|RoIp&Ht2?5|1!Ht1n28rpMGPyM}*?#1KTM~B7uI^)h|P&Uq>`g zUgNxcX6>0_q2RraA%0A5Z1_B?Nu49xZCPFhhzEHbR6xIH+ajvm*0_0{eT!PU*auaX zzC6q|2S)ymaDuP5S8Uwf{Y*V-p!4Q4q;p9`;8$%O@7J^co#Xr4!<)9MkO~H{t&UCNKlt diff --git a/webui/assets/main.js b/webui/assets/main.js deleted file mode 100644 index 265f51997..000000000 --- a/webui/assets/main.js +++ /dev/null @@ -1,594 +0,0 @@ -class REPL { - constructor(input, output, button, completer) { - this.input = input - this.output = output - this.button = button - this.completer = completer - this.history = [] - this.history_index = 0 - this.history_buffer = '' - this.result_number = 0 - } - bind_events() { - var repl = this - var keys = { - TAB: 9, - ENTER: 13, - UP_ARROW: 38, - DOWN_ARROW: 40 - } - - this.input.addEventListener("keydown", function(e) { - if (e.keyCode == keys.UP_ARROW) { - e.preventDefault() - if (repl.input.value.substring(0, repl.input.selectionStart).indexOf('\n') == '-1') { - if (repl.history_index == 0) { - return - } else { - if (repl.history_index == repl.history.length) { - repl.history_buffer = repl.input.value - } - repl.history_index-- - repl.input.value = repl.history[repl.history_index] - repl.input.setSelectionRange(repl.input.value.length, repl.input.value.length) - } - } - } - if (e.keyCode == keys.DOWN_ARROW) { - e.preventDefault() - if (repl.input.value.substring(repl.input.selectionEnd, repl.input.length).indexOf('\n') == '-1') { - if (repl.history_index == repl.history.length) { - return - } else { - repl.history_index++ - if (repl.history_index == repl.history.length) { - repl.input.value = repl.history_buffer - } else { - repl.input.value = repl.history[repl.history_index] - } - repl.input.setSelectionRange(repl.input.value.length, repl.input.value.length) - } - } - } - if (e.keyCode == keys.ENTER && !e.shiftKey) { - e.preventDefault() - repl.submit(); - } - if (e.keyCode == keys.TAB) { - e.preventDefault() - repl.completer.complete() - } - }) - repl.button.onclick = function() { - repl.submit(); - }; - } - - submit() { - this.history_buffer = '' - this.history_index = this.history.length - this.history[this.history_index] = this.input.value - this.history_index++ - this.process_query(this.input.value) - this.input.value = "" - } - - process_query(query) { - var xhr = new XMLHttpRequest(); - var url, data, request, command_name; - var e = document.getElementById("index-dropdown"); - var indexname = e.options[e.selectedIndex].text; - var repl = this; - if (query.startsWith(":")) { - var parsed_query = parse_query(query, indexname); - if (Object.keys(parsed_query).length === 0) { - repl.create_single_output({ - "input": query, - "output": "invalid query", - "status": 400, - "indexname": indexname, - }); - return; - } else { - // set selectedIndex from dropdown list - if (parsed_query.command === "use") { - for (var i = 0; i < e.options.length; i++) { - if (e.options[i].text === parsed_query.command_name) { - e.selectedIndex = i; - break; - } - } - return; - } - url = parsed_query.url; - data = parsed_query.data; - request = parsed_query.request; - command_name = parsed_query.command_name; - } - } - else { - url = '/index/' + indexname + '/query' - request = "POST" - data = query - } - xhr.open(request, url); - xhr.setRequestHeader('Content-Type', 'application/text'); - - var start_time = new Date().getTime(); - xhr.onload = function () { - var end_time = new Date().getTime(); - repl.result_number++ - repl.create_single_output({ - "input": query, - "output": xhr.responseText, - "status": xhr.status, - "indexname": indexname, - "querytime_ms": end_time - start_time, - }); - }; - - xhr.send(data); - // Remove index from dropdown with delete index command - if (request === 'DELETE' && url === '/index/' + command_name){ - for (var i = 0; i < e.options.length; i++) { - if (e.options[i].text === command_name) { - e.remove(i); - break; - } - } - } - } - - create_single_output(res) { - var node = document.createElement("div"); - node.classList.add('output'); - var output_string = res['output'] - var result_class = "result-output" - var getting_started_errors = [ - 'index not found', - 'frame not found', - ] - var output_json; - if (isJSON(output_string)) { - output_json = JSON.parse(output_string) - } - // handle output formatting - if (res["status"] != 200) { - result_class = "result-error"; - if (output_json) { - if ("error" in output_json) { - if (getting_started_errors.indexOf(output_json['error']) >= 0) { - output_string += `
-
- Just getting started? Try this:
- :create index test
- :use test
- :create frame foo
- SetBit(rowID=0, columnID=0, frame=foo) # Use PQL to set a bit - ` - } - } - } - } - - - var markup =` -
-
-
-
-
Input
-        - Source: ${res.indexname} -
-
- ${res.input} -
-
-
-
-
output
-        - ${res.querytime_ms} ms -
-
- ${output_string} -
-
Expand
- -
-
-
- -
-
- ` - node.innerHTML = markup; - this.output.insertBefore(node, this.output.firstChild); - - // Expand when overflow - var element = this.output.firstChild.getElementsByClassName(result_class)[0]; - var expand = this.output.firstChild.getElementsByClassName("expand")[0]; - if (element.clientHeight < element.scrollHeight) { - expand.style.display = 'block'; - } else { - expand.style.display = 'none'; - } - expand.onclick = function () { - element.style.height = element.scrollHeight + "px"; - expand.style.display = 'none'; - return false; - }; - } - - populate_index_dropdown() { - var xhr = new XMLHttpRequest(); - xhr.open('GET', '/schema') - var select = document.getElementById('index-dropdown') - - xhr.onload = function() { - var schema = JSON.parse(xhr.responseText) - for(var i=0; i 0) { - select.value = 1; - } - } - xhr.send(null) - } - -} - -function populate_version() { - var xhr = new XMLHttpRequest(); - xhr.open('GET', '/version') - var node = document.getElementById('server-version') - - xhr.onload = function() { - var version = JSON.parse(xhr.responseText)['version'] - var version_major_minor = /v?(\d+\.\d+).*/.exec(version)[1] - var doc_link = document.getElementById('nav-documentation') - doc_link.onclick = function() { - window.open('https://www.pilosa.com/docs/v' + version_major_minor + '/introduction/') - } - node.innerHTML = "Pilosa v" + version - } - xhr.send(null) -} - -function handle_nav_click(e) { - // e.id = "nav-xxx" - name = e.id.substring(4) - set_active_pane_by_name(name) - window.location.hash = name -} - -function set_active_pane_by_name(name) { - // toggle the nav buttons - document.getElementsByClassName("nav-active")[0].classList.remove("nav-active") - document.getElementById("nav-" + name).classList.add("nav-active") - - // toggle the main interface content divs - document.getElementsByClassName("interface-active")[0].classList.remove("interface-active") - document.getElementById('interface-' + name).classList.add("interface-active") - - // hack hack - switch(name) { - case "cluster": - update_cluster_status() - break - case "documentation": - open_external_docs() - break - } -} - - -function update_cluster_status() { - var xhr = new XMLHttpRequest(); - xhr.open('GET', '/status') - xhr.onload = function() { - var status = JSON.parse(xhr.responseText) - render_status(status) - } - xhr.send(null) - - var xhrSchema = new XMLHttpRequest(); - xhrSchema.open('GET', '/schema') - xhrSchema.onload = function() { - var schema = JSON.parse(xhrSchema.responseText) - render_schema(schema) - } - xhrSchema.send(null) -} - -function render_status(status) { - // render node table - var nodes_div = document.getElementById("status-nodes") - while (nodes_div.firstChild) { - nodes_div.removeChild(nodes_div.firstChild); - } - - var nodes = status["nodes"] - table = document.createElement("table") - tbody = document.createElement("tbody") - table.appendChild(tbody) - var caption = document.createElement("caption") - caption.innerHTML = "(" + nodes.length + ")" - table.appendChild(caption) - - var header = document.createElement('tr') - markup = `Host - ID - Coordinator` - header.innerHTML = markup - tbody.appendChild(header) - for(var n=0; n${nodes[n]["uri"]["host"]}:${nodes[n]["uri"]["port"]} - ${nodes[n]["id"]} - ${nodes[n]["isCoordinator"]}` - row.innerHTML = markup - tbody.appendChild(row) - } - nodes_div.appendChild(table) -} - -function render_schema(schema) { - // render index tables - var indexes_div = document.getElementById("status-indexes") - while (indexes_div.firstChild) { - indexes_div.removeChild(indexes_div.firstChild); - } - - var indexes = schema["indexes"] // TODO currently comes from only node 0 - for(var n=0; nName - Cache Type - Cache Size` - header.innerHTML = markup - tbody.appendChild(header) - - var frames = indexes[n]["frames"] - if(frames) { - for(var m=0; m${frames[m]["name"]} - ${frames[m]["options"]["cacheType"]} - ${frames[m]["options"]["cacheSize"]}` - tbody.appendChild(row) - } - } - indexes_div.appendChild(table) - } - - // render slice tables - // TODO enable when Slices element is present in status response - /* - var slices_div = document.getElementById("status-slices") - data = "" - for(var n=0; n" - } - } - slices_div.innerHTML = data - */ - -} - -function open_external_docs() { - window.open("https://www.pilosa.com/docs"); -} - -function check_anchor_uri() { - var pane_names = {"console": 0, "cluster": 0, "documentation": 0} - var anchor = window.location.hash.substr(1); - if(anchor in pane_names) { - set_active_pane_by_name(anchor) - } -} - -Date.prototype.today = function () { - return this.getFullYear() +"/"+ (((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ ((this.getDate() < 10)?"0":"") + this.getDate(); -} - -Date.prototype.timeNow = function () { - return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); -} - -populate_version() - - -class Autocompleter { - constructor(input, output) { - this.input = input - this.output = output - this.keyword_map = this.static_keywords - this.init_dynamic_keywords() - } - - get static_keywords() { - return { - // keyword: length of substring that comes after cursor - "SetBit()": 1, - "ClearBit()": 1, - "SetRowAttrs()": 1, - "SetColumnAttrs()": 1, - "Bitmap()": 1, - "Union()": 1, - "Intersect()": 1, - "Difference()": 1, - "Count()": 1, - "Range()": 1, - "TopN()": 1, - "frame=": 0, - } - } - - complete() { - var completer = this - // extract word fragment ending at cursor. a word fragment: - // - starts with last nonalpha character before cursor (or beginning of string) - // - ends at cursor - var word_start = completer.input.selectionEnd-1 - while(word_start>0) { - var c = completer.input.value.charCodeAt(word_start) - if(!((c>64 && c<91) || (c>96 && c<123))) { - word_start++ - break - } - word_start-- - } - var input_word = completer.input.value.substring(word_start, completer.input.selectionEnd) - - // check for keyword match and insert if exactly one match - var matches = [] - for(var keyword in this.keyword_map) { - if(keyword.startsWith(input_word)){ - matches.push(keyword) - } - } - if(matches.length > 1) { - // completer.output.innerHTML = whatever - } - - if(matches.length == 1) { - // completer.output.innerHTML = "" - var cursor_pos = completer.input.selectionEnd - var completion = matches[0].substring(input_word.length) - var before = completer.input.value.substring(0, cursor_pos) - var after = completer.input.value.substring(cursor_pos) - completer.input.value = before + completion + after - var new_pos = cursor_pos + completion.length - this.keyword_map[matches[0]] - completer.input.setSelectionRange(new_pos, new_pos) - } - } - - init_dynamic_keywords() { - // hit /schema, parse indexes, frames, add to list - } - - add_keyword() { - // call when index or frame created in webui - } - - remove_keyword() { - // call when index or frame deleted in webui - // issue: if e.g. multiple indexes have same frame, removing one removes all. - // solution: maintain count. requires more elaborate representation of keywords. - } -} - -var input = document.getElementById('query') -var output = document.getElementById('outputs') -var button = document.getElementById('query-btn') -var autocomplete_output = document.getElementById('autocomplete-container') - -autocompleter = new Autocompleter(input, autocomplete_output) -repl = new REPL(input, output, button, autocompleter) -repl.populate_index_dropdown() -repl.bind_events() - -input.focus() - -check_anchor_uri() - -function isJSON(str) { - try { - JSON.parse(str) - } catch (e) { - return false - } - return true -} - -function parse_query(query, indexname) { - var keys = query.replace(/\s+/g, " ").split(" "); - var command = keys[0]; - var command_type = keys[1]; - var command_name = keys[2]; - var option_str = keys.slice(3, keys.length) - var options = parse_options(option_str); - if (command !== ":use") { - if (!command_name){ - return {} - } - } - - var parsed_query = {}; - parsed_query["command"] = command.substr(1, command.length); - parsed_query["command_name"] = command_name; - switch (command) { - case ":create": - parsed_query["request"] = "POST"; - if(Object.keys(options).length === 0) { - parsed_query["data"] = ""; - } else { - var opts = {"options":{}}; - for (var o in options) { - opts.options[o] = options[o] - } - parsed_query["data"] = JSON.stringify(opts); - } - switch (command_type){ - case "index": - parsed_query["url"] = '/index/' + command_name; - break; - case "frame": - parsed_query["url"] = '/index/' + indexname + '/frame/' + command_name; - break - } - break; - case ":delete": - parsed_query["request"] = "DELETE"; - switch (command_type){ - case "index": - parsed_query["url"] = '/index/' + command_name; - parsed_query["data"] = ""; - break; - case "frame": - parsed_query["url"] = '/index/' + indexname + '/frame/' + command_name; - parsed_query["data"] = ""; - break; - } - break; - case ":use": - parsed_query["command_name"] = keys[1]; - break; - default: - return {} - } - return parsed_query; -} - -function parse_options(option_str) { - var int_keys = ["cacheSize"]; - var options = {}; - for (var i = 0; i < option_str.length; i++) { - var parts = option_str[i].split('='); - if (int_keys.indexOf(parts[0]) !== -1 ){ - options[parts[0]] = Number(parts[1]) - } else { - options[parts[0]] = parts[1] - } - } - return options; -} diff --git a/webui/assets/nav-cluster-active.svg b/webui/assets/nav-cluster-active.svg deleted file mode 100644 index 871d6f2af..000000000 --- a/webui/assets/nav-cluster-active.svg +++ /dev/null @@ -1 +0,0 @@ -nav_cluster_1 diff --git a/webui/assets/nav-cluster.svg b/webui/assets/nav-cluster.svg deleted file mode 100644 index baf6310ea..000000000 --- a/webui/assets/nav-cluster.svg +++ /dev/null @@ -1 +0,0 @@ -nav_cluster_1 \ No newline at end of file diff --git a/webui/assets/nav-console-active.svg b/webui/assets/nav-console-active.svg deleted file mode 100644 index 2263c2a69..000000000 --- a/webui/assets/nav-console-active.svg +++ /dev/null @@ -1 +0,0 @@ -nav_console \ No newline at end of file diff --git a/webui/assets/nav-console.svg b/webui/assets/nav-console.svg deleted file mode 100644 index e9d2a9569..000000000 --- a/webui/assets/nav-console.svg +++ /dev/null @@ -1 +0,0 @@ -nav_console diff --git a/webui/assets/nav-documentation-active.svg b/webui/assets/nav-documentation-active.svg deleted file mode 100644 index b6e994980..000000000 --- a/webui/assets/nav-documentation-active.svg +++ /dev/null @@ -1 +0,0 @@ -documentation diff --git a/webui/assets/nav-documentation.svg b/webui/assets/nav-documentation.svg deleted file mode 100644 index 12cd2108c..000000000 --- a/webui/assets/nav-documentation.svg +++ /dev/null @@ -1 +0,0 @@ -documentation \ No newline at end of file diff --git a/webui/assets/nav_item1.svg b/webui/assets/nav_item1.svg deleted file mode 100644 index d6d7f779e..000000000 --- a/webui/assets/nav_item1.svg +++ /dev/null @@ -1 +0,0 @@ -nav_item1 \ No newline at end of file diff --git a/webui/assets/style.css b/webui/assets/style.css deleted file mode 100644 index 2cf65d086..000000000 --- a/webui/assets/style.css +++ /dev/null @@ -1,336 +0,0 @@ -*{ - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -body{ - font-family: sans-serif; - background-color: #fbfcfd; - margin: 0; - color: #102445; -} -h2{ - margin-bottom: 30px; -} - -h5{ - text-transform: uppercase; - letter-spacing: 2px; - line-height: 1.21; - margin: 0; -} -a{ - line-height: 1.38; - letter-spacing: 0.2px; - text-decoration: none; - color: #102445; -} - - -a:hover{ - color: #1db598; -} - -textarea{ - width: 100%; - margin-bottom: 10px; - border-radius: 2px; - background-color: #fbfcfd; - border: solid 1.5px #e4eff4; - font-family: monospace; - font-size: 16px; - line-height: 1.5; - letter-spacing: 1.1px; - outline: none; - padding: 30px; -} - - -select{ - /*-webkit-appearance: none; - -moz-appearance: none; - appearance: none; - background: url("img/chevron-down.png") no-repeat calc(100% - 10px) !important;*/ - border-radius: 3px; - background-color: #fbfcfd; - width: 187px; - height: 50px; - border: solid 1.5px #e4eff4; - font-size: 18px; - font-weight: bold; - line-height: 1.39; - letter-spacing: 0.2px; - color: #102445; - padding: 10.5px; - -} - -button{ - width: 165px; - height: 50px; - border-radius: 3px; - background-color: #1db598; - outline: none; - border: none; - font-size: 16px; - color: white; -} - -em{ - font-style: normal; - opacity: 0.5; - font-size: 14px; - font-weight: 500; - letter-spacing: 0.2px; - color: #102445; -} - -.header{ - height: 92px; - display: flex; - align-items: center; - justify-content: space-between; - width: 90%; - margin: auto; -} - -.container{ - display: flex; - height:100%; - min-height: 100vh; -} -.nav{ - color: white; - display: flex; - flex-direction: column; - width: 150px; - background: #3c5f8d; -} - -.nav-item{ - height:150px; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - border-bottom: 3px solid #2a4871; - cursor: pointer; -} - -.nav-active{ - background: #f2f7f9; - font-weight: bold; - color: #1db598; -} - -.nav-item > .nav-image { - display: flex; -} - -.nav-item > .nav-image-active { - display: none; -} - -.nav-active > .nav-image { - display: none; -} - -.nav-active > .nav-image-active { - display: flex; -} - - -.interface{ - display: none; - flex: 1; - flex-direction: column; - align-items: center; - background: #f2f7f9; -} - -.interface-active{ - display: flex; -} - -.query{ - margin-bottom: 30px; -} -.query, -.output-container, -.status-container{ - width: 75%; -} - -.output{ - margin-bottom: 30px; -} - -.input-controls{ - display: flex; - justify-content: flex-end; -} - -.tabs{ - display: flex; - background: #eaf2f6; -} -.active-tab{ - background: white; - font-weight: bold; - color: #1db598; - -} - -.tab{ - height:60px; - width: 100px; - border-top-right-radius: 5px; - display: flex; - align-items: center; - justify-content: center; - visibility: visible; - cursor: pointer; - -} - -.pane{ - background: white; - padding: 30px; - display: none; -} - -.active{ - display: block; -} - -.result-io-header{ - display: flex; - align-items: center; - margin-bottom: 15px; -} - -.result-input, -.result-output, -.result-error{ - height: 60px; - border-radius: 2px; - background-color: #fafafa; - border: solid 1.5px #e4eff4; - font-family: monospace; - font-size: 16px; - line-height: 1.5; - letter-spacing: 1.1px; - color: #102445; - padding: 15px; - margin-bottom: 15px; - word-break: break-all; - overflow-wrap: break-word; - overflow:hidden; -} - - -.result-output{ - background-color: #edf9f7; - border-left: solid 4px #1db598; -} - -.result-error{ - background-color: #fbf1f0; - border-left: solid 4px #fa3035; - color: #fa3035; -} - -.raw{ - height: 253px; - display: flex; - align-items: center; - justify-content: center; -} - - -.result-table > table { - border-left: solid 4px #1db598; -} - -table{ - border: solid 0.5px #e0e0e0; - width: 100%; - margin-bottom: 30px; - /*color:#3c5f8d;*/ -} -caption{ - text-align:left; - font-size: 16px; - font-weight: bold; - line-height: 1.21; - letter-spacing: 2px; - text-align: left; -} -th{ - font-size: 14px; - font-weight: bold; - line-height: 1.21; - letter-spacing: 2px; - color: #102445; - text-transform: uppercase; - text-align: left; - padding: 21px 30px; - background-color: white; -} -tr{ - border: solid 0.5px #e0e0e0; - background-color: white; -} -tr:nth-child(even) { - background-color: #f2f7f9; -} -td{ - padding: 21px 30px; -} - -.expand { - text-align: center; -} - -.query h2 { - display: inline-block; -} - -.query-tooltip { - position: relative; - display: inline; - color: #000; - margin-left: 5px; -} - -.query-tooltip:hover { - color: #000; -} - -.query-tooltip-content { - background-color: rgb(250, 250, 250); - border: solid 1.5px #e4eff4; - color: #102445; - border-radius: 2px; - padding: 15px; - margin-bottom: 15px; - - position: absolute; - left: 80px; - top: -30px; - z-index: 1; -} - -.query-tooltip-container { - position: relative; - visibility: hidden; -} - -.query-tooltip:hover+.query-tooltip-container{ - visibility: visible; -} - -.code{ - font-family: monospace; -} - diff --git a/webui/index.html b/webui/index.html deleted file mode 100644 index f6bc369de..000000000 --- a/webui/index.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - Pilosa WebUI - - - -
- -
-
-
- -
- -
-

Query

- ? -
-
-
PQL
-
- SetBit(frame=foo, row=0, col=0)
- ClearBit(frame=foo, row=0, col=0)
- SetRowAttrs(frame=foo, row=0, color="blue")
- SetColumnAttrs(frame=foo, col=0, shape="circle")
- SetFieldValue(frame=foo, col=0, age=30)
- Bitmap(frame=foo, row=0)
- Range(frame=foo, row=0, start="2010-01", end="2017-03")
- Count(<BITMAP_CALL>)
- TopN([BITMAP_CALL], frame=foo, n=20)
- Union([BITMAP_CALL, ...])
- Intersect(<BITMAP_CALL>, [BITMAP_CALL, ...])
- Difference(<BITMAP_CALL>, <BITMAP_CALL>)
- Xor([BITMAP_CALL, ...])
- Min([BITMAP_CALL], frame=foo, field=age)
- Max([BITMAP_CALL], frame=foo, field=age)
- Sum([BITMAP_CALL], frame=foo, field=age) -
-
-
Special commands
-
- :create index test
- :use test
- :create frame foo
- :delete index test
- :delete frame foo -
-
- <tab>: autocomplete
- <up>/<down>: history
-
-
- -
-
- -     - -
-
-
- -
-

Output

-
- -
-
- -
- -
-
-

Nodes

-
-
-
-
-

Indexes

-
-
-
-
- -
- -
- -
- docs! -
- -
- - - From 6f4c50a4b564529568b60ffb84a4fd64fdeb0920 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Wed, 6 Jun 2018 15:49:01 -0500 Subject: [PATCH 52/52] move fragment_test into the pilosa package (internal) --- attr.go | 53 +++ fragment_test.go => fragment_internal_test.go | 313 ++++++++++-------- index_internal_test.go | 46 +++ index_test.go | 3 + test/fragment.go | 103 ------ 5 files changed, 277 insertions(+), 241 deletions(-) rename fragment_test.go => fragment_internal_test.go (79%) create mode 100644 index_internal_test.go diff --git a/attr.go b/attr.go index 03ea4f43f..168ac0052 100644 --- a/attr.go +++ b/attr.go @@ -221,3 +221,56 @@ func DecodeAttrs(v []byte) (map[string]interface{}, error) { } return decodeAttrs(pb.GetAttrs()), nil } + +func newMemAttrStore() AttrStore { + return &memAttrStore{ + store: make(map[uint64]map[string]interface{}), + } +} + +// memAttrStore represents an in-memory implementation of the AttrStore interface. +type memAttrStore struct { + store map[uint64]map[string]interface{} +} + +// Path is an in-memory implementation of AttrStore Path method. +func (s *memAttrStore) Path() string { return "" } + +// Open is an in-memory implementation of AttrStore Open method. +func (s *memAttrStore) Open() error { + return nil +} + +// Close is an in-memory implementation of AttrStore Close method. +func (s *memAttrStore) Close() error { + return nil +} + +// Attrs returns a set of attributes by ID. +func (s *memAttrStore) Attrs(id uint64) (m map[string]interface{}, err error) { + return s.store[id], nil +} + +// SetAttrs sets attribute values for a given ID. +func (s *memAttrStore) SetAttrs(id uint64, m map[string]interface{}) error { + s.store[id] = m + return nil +} + +// SetBulkAttrs sets attribute values for a set of ids. +func (s *memAttrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error { + for id, v := range m { + s.store[id] = v + } + return nil +} + +// Blocks is an in-memory implementation of AttrStore Blocks method. +func (s *memAttrStore) Blocks() ([]AttrBlock, error) { + return nil, nil +} + +// BlockData is an in-memory implementation of AttrStore BlockData method. +func (s *memAttrStore) BlockData(i uint64) (map[uint64]map[string]interface{}, error) { + return nil, nil +} diff --git a/fragment_test.go b/fragment_internal_test.go similarity index 79% rename from fragment_test.go rename to fragment_internal_test.go index 747602348..20f3f7b6a 100644 --- a/fragment_test.go +++ b/fragment_internal_test.go @@ -12,20 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package pilosa_test +package pilosa import ( "bytes" "flag" + "io/ioutil" "math" "reflect" "testing" "testing/quick" "github.com/davecgh/go-spew/spew" - "github.com/pilosa/pilosa" "github.com/pilosa/pilosa/pql" - "github.com/pilosa/pilosa/test" ) // Test flags @@ -35,12 +34,9 @@ var ( FragmentPath = flag.String("fragment", "testdata/sample_view/0", "fragment path") ) -// SliceWidth is a helper reference to use when testing. -const SliceWidth = pilosa.SliceWidth - // Ensure a fragment can set a bit and retrieve it. func TestFragment_SetBit(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set bits on the fragment. @@ -60,7 +56,7 @@ func TestFragment_SetBit(t *testing.T) { } // Close and reopen the fragment & verify the data. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } else if n := f.Row(120).Count(); n != 2 { t.Fatalf("unexpected count (reopen): %d", n) @@ -71,7 +67,7 @@ func TestFragment_SetBit(t *testing.T) { // Ensure a fragment can clear a set bit. func TestFragment_ClearBit(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set and then clear bits on the fragment. @@ -89,7 +85,7 @@ func TestFragment_ClearBit(t *testing.T) { } // Close and reopen the fragment & verify the data. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } else if n := f.Row(1000).Count(); n != 1 { t.Fatalf("unexpected count (reopen): %d", n) @@ -99,7 +95,7 @@ func TestFragment_ClearBit(t *testing.T) { // Ensure a fragment can set & read a value. func TestFragment_SetValue(t *testing.T) { t.Run("OK", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set value. @@ -127,7 +123,7 @@ func TestFragment_SetValue(t *testing.T) { }) t.Run("Overwrite", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set value. @@ -155,7 +151,7 @@ func TestFragment_SetValue(t *testing.T) { }) t.Run("NotExists", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set value. @@ -185,7 +181,7 @@ func TestFragment_SetValue(t *testing.T) { values[i] = values[i] % (1 << bitDepth) } - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -223,7 +219,7 @@ func TestFragment_SetValue(t *testing.T) { func TestFragment_Sum(t *testing.T) { const bitDepth = 16 - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -248,7 +244,7 @@ func TestFragment_Sum(t *testing.T) { }) t.Run("WithFilter", func(t *testing.T) { - if sum, n, err := f.Sum(pilosa.NewRow(2000, 4000, 5000), bitDepth); err != nil { + if sum, n, err := f.Sum(NewRow(2000, 4000, 5000), bitDepth); err != nil { t.Fatal(err) } else if n != 2 { t.Fatalf("unexpected count: %d", n) @@ -262,7 +258,7 @@ func TestFragment_Sum(t *testing.T) { func TestFragment_MinMax(t *testing.T) { const bitDepth = 16 - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -284,16 +280,16 @@ func TestFragment_MinMax(t *testing.T) { t.Run("Min", func(t *testing.T) { tests := []struct { - filter *pilosa.Row + filter *Row exp uint64 cnt uint64 }{ {filter: nil, exp: 0, cnt: 1}, - {filter: pilosa.NewRow(2000, 4000, 5000), exp: 300, cnt: 2}, - {filter: pilosa.NewRow(2000, 4000), exp: 300, cnt: 2}, - {filter: pilosa.NewRow(1), exp: 0, cnt: 0}, - {filter: pilosa.NewRow(1000), exp: 382, cnt: 1}, - {filter: pilosa.NewRow(7000), exp: 0, cnt: 1}, + {filter: NewRow(2000, 4000, 5000), exp: 300, cnt: 2}, + {filter: NewRow(2000, 4000), exp: 300, cnt: 2}, + {filter: NewRow(1), exp: 0, cnt: 0}, + {filter: NewRow(1000), exp: 382, cnt: 1}, + {filter: NewRow(7000), exp: 0, cnt: 1}, } for i, test := range tests { if min, cnt, err := f.Min(test.filter, bitDepth); err != nil { @@ -308,16 +304,16 @@ func TestFragment_MinMax(t *testing.T) { t.Run("Max", func(t *testing.T) { tests := []struct { - filter *pilosa.Row + filter *Row exp uint64 cnt uint64 }{ {filter: nil, exp: 2818, cnt: 2}, - {filter: pilosa.NewRow(2000, 4000, 5000), exp: 2818, cnt: 1}, - {filter: pilosa.NewRow(2000, 4000), exp: 300, cnt: 2}, - {filter: pilosa.NewRow(1), exp: 0, cnt: 0}, - {filter: pilosa.NewRow(1000), exp: 382, cnt: 1}, - {filter: pilosa.NewRow(7000), exp: 0, cnt: 1}, + {filter: NewRow(2000, 4000, 5000), exp: 2818, cnt: 1}, + {filter: NewRow(2000, 4000), exp: 300, cnt: 2}, + {filter: NewRow(1), exp: 0, cnt: 0}, + {filter: NewRow(1000), exp: 382, cnt: 1}, + {filter: NewRow(7000), exp: 0, cnt: 1}, } for i, test := range tests { if max, cnt, err := f.Max(test.filter, bitDepth); err != nil { @@ -336,7 +332,7 @@ func TestFragment_Range(t *testing.T) { const bitDepth = 16 t.Run("EQ", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -359,7 +355,7 @@ func TestFragment_Range(t *testing.T) { }) t.Run("NEQ", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -382,7 +378,7 @@ func TestFragment_Range(t *testing.T) { }) t.Run("LT", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -430,7 +426,7 @@ func TestFragment_Range(t *testing.T) { }) t.Run("GT", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -478,7 +474,7 @@ func TestFragment_Range(t *testing.T) { }) t.Run("BETWEEN", func(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set values. @@ -528,7 +524,7 @@ func TestFragment_Range(t *testing.T) { // Ensure a fragment can snapshot correctly. func TestFragment_Snapshot(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set and then clear bits on the fragment. @@ -548,7 +544,7 @@ func TestFragment_Snapshot(t *testing.T) { } // Close and reopen the fragment & verify the data. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } else if n := f.Row(1000).Count(); n != 1 { t.Fatalf("unexpected count (reopen): %d", n) @@ -557,7 +553,7 @@ func TestFragment_Snapshot(t *testing.T) { // Ensure a fragment can iterate over all bits in order. func TestFragment_ForEachBit(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set bits on the fragment. @@ -586,42 +582,42 @@ func TestFragment_ForEachBit(t *testing.T) { // Ensure a fragment can return the top n results. func TestFragment_Top(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() // Set bits on the rows 100, 101, & 102. - f.MustSetBits(100, 1, 3, 200) - f.MustSetBits(101, 1) - f.MustSetBits(102, 1, 2) + f.mustSetBits(100, 1, 3, 200) + f.mustSetBits(101, 1) + f.mustSetBits(102, 1, 2) f.RecalculateCache() // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{N: 2}); err != nil { + if pairs, err := f.Top(TopOptions{N: 2}); err != nil { t.Fatal(err) } else if len(pairs) != 2 { t.Fatalf("unexpected count: %d", len(pairs)) - } else if pairs[0] != (pilosa.Pair{ID: 100, Count: 3}) { + } else if pairs[0] != (Pair{ID: 100, Count: 3}) { t.Fatalf("unexpected pair(0): %v", pairs[0]) - } else if pairs[1] != (pilosa.Pair{ID: 102, Count: 2}) { + } else if pairs[1] != (Pair{ID: 102, Count: 2}) { t.Fatalf("unexpected pair(1): %v", pairs[1]) } } // Ensure a fragment can filter rows when retrieving the top n rows. func TestFragment_Top_Filter(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() // Set bits on the rows 100, 101, & 102. - f.MustSetBits(100, 1, 3, 200) - f.MustSetBits(101, 1) - f.MustSetBits(102, 1, 2) + f.mustSetBits(100, 1, 3, 200) + f.mustSetBits(101, 1) + f.mustSetBits(102, 1, 2) f.RecalculateCache() // Assign attributes. - f.RowAttrStore.SetAttrs(101, map[string]interface{}{"x": uint64(10)}) - f.RowAttrStore.SetAttrs(102, map[string]interface{}{"x": uint64(20)}) + f.RowAttrStore.SetAttrs(101, map[string]interface{}{"x": int64(10)}) + f.RowAttrStore.SetAttrs(102, map[string]interface{}{"x": int64(20)}) // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{ + if pairs, err := f.Top(TopOptions{ N: 2, FilterName: "x", FilterValues: []interface{}{int64(10), int64(15), int64(20)}, @@ -629,32 +625,32 @@ func TestFragment_Top_Filter(t *testing.T) { t.Fatal(err) } else if len(pairs) != 2 { t.Fatalf("unexpected count: %d", len(pairs)) - } else if pairs[0] != (pilosa.Pair{ID: 102, Count: 2}) { + } else if pairs[0] != (Pair{ID: 102, Count: 2}) { t.Fatalf("unexpected pair(0): %v", pairs[0]) - } else if pairs[1] != (pilosa.Pair{ID: 101, Count: 1}) { + } else if pairs[1] != (Pair{ID: 101, Count: 1}) { t.Fatalf("unexpected pair(1): %v", pairs[1]) } } // Ensure a fragment can return top rows that intersect with an input row. func TestFragment_TopN_Intersect(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() // Create an intersecting input row. - src := pilosa.NewRow(1, 2, 3) + src := NewRow(1, 2, 3) // Set bits on various rows. - f.MustSetBits(100, 1, 10, 11, 12) // one intersection - f.MustSetBits(101, 1, 2, 3, 4) // three intersections - f.MustSetBits(102, 1, 2, 4, 5, 6) // two intersections - f.MustSetBits(103, 1000, 1001, 1002) // no intersection + f.mustSetBits(100, 1, 10, 11, 12) // one intersection + f.mustSetBits(101, 1, 2, 3, 4) // three intersections + f.mustSetBits(102, 1, 2, 4, 5, 6) // two intersections + f.mustSetBits(103, 1000, 1001, 1002) // no intersection f.RecalculateCache() // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{N: 3, Src: src}); err != nil { + if pairs, err := f.Top(TopOptions{N: 3, Src: src}); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(pairs, []pilosa.Pair{ + } else if !reflect.DeepEqual(pairs, []Pair{ {ID: 101, Count: 3}, {ID: 102, Count: 2}, {ID: 100, Count: 1}, @@ -669,11 +665,11 @@ func TestFragment_TopN_Intersect_Large(t *testing.T) { t.Skip("short mode") } - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() // Create an intersecting input row. - src := pilosa.NewRow( + src := NewRow( 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, ) @@ -681,15 +677,15 @@ func TestFragment_TopN_Intersect_Large(t *testing.T) { // Set bits on rows 0 - 999. Higher rows have higher bit counts. for i := uint64(0); i < 1000; i++ { for j := uint64(0); j < i; j++ { - f.MustSetBits(i, j) + f.mustSetBits(i, j) } } f.RecalculateCache() // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{N: 10, Src: src}); err != nil { + if pairs, err := f.Top(TopOptions{N: 10, Src: src}); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(pairs, []pilosa.Pair{ + } else if !reflect.DeepEqual(pairs, []Pair{ {ID: 999, Count: 19}, {ID: 998, Count: 18}, {ID: 997, Count: 17}, @@ -707,18 +703,18 @@ func TestFragment_TopN_Intersect_Large(t *testing.T) { // Ensure a fragment can return top rows when specified by ID. func TestFragment_TopN_IDs(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() // Set bits on various rows. - f.MustSetBits(100, 1, 2, 3) - f.MustSetBits(101, 4, 5, 6, 7) - f.MustSetBits(102, 8, 9, 10, 11, 12) + f.mustSetBits(100, 1, 2, 3) + f.mustSetBits(101, 4, 5, 6, 7) + f.mustSetBits(102, 8, 9, 10, 11, 12) // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil { + if pairs, err := f.Top(TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(pairs, []pilosa.Pair{ + } else if !reflect.DeepEqual(pairs, []Pair{ {ID: 101, Count: 4}, {ID: 100, Count: 3}, }) { @@ -728,18 +724,18 @@ func TestFragment_TopN_IDs(t *testing.T) { // Ensure a fragment return none if CacheTypeNone is set func TestFragment_TopN_NopCache(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeNone) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeNone) defer f.Close() // Set bits on various rows. - f.MustSetBits(100, 1, 2, 3) - f.MustSetBits(101, 4, 5, 6, 7) - f.MustSetBits(102, 8, 9, 10, 11, 12) + f.mustSetBits(100, 1, 2, 3) + f.mustSetBits(101, 4, 5, 6, 7) + f.mustSetBits(102, 8, 9, 10, 11, 12) // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil { + if pairs, err := f.Top(TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(pairs, []pilosa.Pair{}) { + } else if !reflect.DeepEqual(pairs, []Pair{}) { t.Fatalf("unexpected pairs: %s", spew.Sdump(pairs)) } } @@ -750,17 +746,17 @@ func TestFragment_TopN_CacheSize(t *testing.T) { cacheSize := uint32(3) // Create Index. - index := test.MustOpenIndex() + index := mustOpenIndex() defer index.Close() // Create field. - field, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked, CacheSize: cacheSize}) + field, err := index.CreateFieldIfNotExists("f", FieldOptions{CacheType: CacheTypeRanked, CacheSize: cacheSize}) if err != nil { t.Fatal(err) } // Create view. - view, err := field.CreateViewIfNotExists(pilosa.ViewStandard) + view, err := field.CreateViewIfNotExists(ViewStandard) if err != nil { t.Fatal(err) } @@ -773,38 +769,34 @@ func TestFragment_TopN_CacheSize(t *testing.T) { // Close the storage so we can re-open it without encountering a flock. frag.Close() - f := &test.Fragment{ - Fragment: frag, - RowAttrStore: test.MustOpenAttrStore(), - } - f.Fragment.RowAttrStore = f.RowAttrStore + f := frag if err := f.Open(); err != nil { panic(err) } defer f.Close() // Set bits on various rows. - f.MustSetBits(100, 1, 2, 3) - f.MustSetBits(101, 4, 5, 6, 7) - f.MustSetBits(102, 8, 9, 10, 11, 12) - f.MustSetBits(103, 8, 9, 10, 11, 12, 13) - f.MustSetBits(104, 8, 9, 10, 11, 12, 13, 14) - f.MustSetBits(105, 10, 11) + f.mustSetBits(100, 1, 2, 3) + f.mustSetBits(101, 4, 5, 6, 7) + f.mustSetBits(102, 8, 9, 10, 11, 12) + f.mustSetBits(103, 8, 9, 10, 11, 12, 13) + f.mustSetBits(104, 8, 9, 10, 11, 12, 13, 14) + f.mustSetBits(105, 10, 11) f.RecalculateCache() - p := []pilosa.Pair{ + p := []Pair{ {ID: 104, Count: 7}, {ID: 103, Count: 6}, {ID: 102, Count: 5}, } // Retrieve top rows. - if pairs, err := f.Top(pilosa.TopOptions{N: 5}); err != nil { + if pairs, err := f.Top(TopOptions{N: 5}); err != nil { t.Fatal(err) } else if len(pairs) > int(cacheSize) { t.Fatalf("TopN count cannot exceed cache size: %d", cacheSize) - } else if pairs[0] != (pilosa.Pair{ID: 104, Count: 7}) { + } else if pairs[0] != (Pair{ID: 104, Count: 7}) { t.Fatalf("unexpected pair(0): %v", pairs) } else if !reflect.DeepEqual(pairs, p) { t.Fatalf("Invalid TopN result set: %s", spew.Sdump(pairs)) @@ -813,14 +805,14 @@ func TestFragment_TopN_CacheSize(t *testing.T) { // Ensure fragment can return a checksum for its blocks. func TestFragment_Checksum(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Retrieve checksum and set bits. orig := f.Checksum() if _, err := f.SetBit(1, 200); err != nil { t.Fatal(err) - } else if _, err := f.SetBit(pilosa.HashBlockSize*2, 200); err != nil { + } else if _, err := f.SetBit(HashBlockSize*2, 200); err != nil { t.Fatal(err) } @@ -832,11 +824,11 @@ func TestFragment_Checksum(t *testing.T) { // Ensure fragment can return a checksum for a given block. func TestFragment_Blocks(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Retrieve initial checksum. - var prev []pilosa.FragmentBlock + var prev []FragmentBlock // Set first bit. if _, err := f.SetBit(0, 0); err != nil { @@ -870,7 +862,7 @@ func TestFragment_Blocks(t *testing.T) { // Ensure fragment returns an empty checksum if no data exists for a block. func TestFragment_Blocks_Empty(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set bits on a different block. @@ -888,7 +880,7 @@ func TestFragment_Blocks_Empty(t *testing.T) { // Ensure a fragment's cache can be persisted between restarts. func TestFragment_LRUCache_Persistence(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeLRU) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeLRU) defer f.Close() // Set bits on the fragment. @@ -899,19 +891,19 @@ func TestFragment_LRUCache_Persistence(t *testing.T) { } // Verify correct cache type and size. - if cache, ok := f.Cache().(*pilosa.LRUCache); !ok { + if cache, ok := f.Cache().(*LRUCache); !ok { t.Fatalf("unexpected cache: %T", f.Cache()) } else if cache.Len() != 1000 { t.Fatalf("unexpected cache len: %d", cache.Len()) } // Reopen the fragment. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } // Re-verify correct cache type and size. - if cache, ok := f.Cache().(*pilosa.LRUCache); !ok { + if cache, ok := f.Cache().(*LRUCache); !ok { t.Fatalf("unexpected cache: %T", f.Cache()) } else if cache.Len() != 1000 { t.Fatalf("unexpected cache len: %d", cache.Len()) @@ -920,17 +912,17 @@ func TestFragment_LRUCache_Persistence(t *testing.T) { // Ensure a fragment's cache can be persisted between restarts. func TestFragment_RankCache_Persistence(t *testing.T) { - index := test.MustOpenIndex() + index := mustOpenIndex() defer index.Close() // Create field. - field, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{CacheType: pilosa.CacheTypeRanked}) + field, err := index.CreateFieldIfNotExists("f", FieldOptions{CacheType: CacheTypeRanked}) if err != nil { t.Fatal(err) } // Create view. - view, err := field.CreateViewIfNotExists(pilosa.ViewStandard) + view, err := field.CreateViewIfNotExists(ViewStandard) if err != nil { t.Fatal(err) } @@ -949,22 +941,22 @@ func TestFragment_RankCache_Persistence(t *testing.T) { } // Verify correct cache type and size. - if cache, ok := f.Cache().(*pilosa.RankCache); !ok { + if cache, ok := f.Cache().(*RankCache); !ok { t.Fatalf("unexpected cache: %T", f.Cache()) } else if cache.Len() != 1000 { t.Fatalf("unexpected cache len: %d", cache.Len()) } // Reopen the index. - if err := index.Reopen(); err != nil { + if err := index.reopen(); err != nil { t.Fatal(err) } // Re-fetch fragment. - f = index.Field("f").View(pilosa.ViewStandard).Fragment(0) + f = index.Field("f").View(ViewStandard).Fragment(0) // Re-verify correct cache type and size. - if cache, ok := f.Cache().(*pilosa.RankCache); !ok { + if cache, ok := f.Cache().(*RankCache); !ok { t.Fatalf("unexpected cache: %T", f.Cache()) } else if cache.Len() != 1000 { t.Fatalf("unexpected cache len: %d", cache.Len()) @@ -973,7 +965,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) { // Ensure a fragment can be copied to another fragment. func TestFragment_WriteTo_ReadFrom(t *testing.T) { - f0 := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f0 := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f0.Close() // Set and then clear bits on the fragment. @@ -998,7 +990,7 @@ func TestFragment_WriteTo_ReadFrom(t *testing.T) { } // Read into another fragment. - f1 := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f1 := mustOpenFragment("i", "f", ViewStandard, 0, "") if rn, err := f1.ReadFrom(&buf); err != nil { t.Fatal(err) } else if wn != rn { @@ -1016,7 +1008,7 @@ func TestFragment_WriteTo_ReadFrom(t *testing.T) { } // Close and reopen the fragment & verify the data. - if err := f1.Reopen(); err != nil { + if err := f1.reopen(); err != nil { t.Fatal(err) } else if n := f1.Cache().Len(); n != 1 { t.Fatalf("unexpected cache size (reopen): %d", n) @@ -1031,7 +1023,7 @@ func BenchmarkFragment_Blocks(b *testing.B) { } // Open the fragment specified by the path. - f := pilosa.NewFragment(*FragmentPath, "i", "f", pilosa.ViewStandard, 0) + f := NewFragment(*FragmentPath, "i", "f", ViewStandard, 0) if err := f.Open(); err != nil { b.Fatal(err) } @@ -1047,7 +1039,7 @@ func BenchmarkFragment_Blocks(b *testing.B) { } func BenchmarkFragment_IntersectionCount(b *testing.B) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() f.MaxOpN = math.MaxInt32 @@ -1078,55 +1070,55 @@ func BenchmarkFragment_IntersectionCount(b *testing.B) { } func TestFragment_Tanimoto(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() - src := pilosa.NewRow(1, 2, 3) + src := NewRow(1, 2, 3) // Set bits on the rows 100, 101, & 102. - f.MustSetBits(100, 1, 3, 2, 200) - f.MustSetBits(101, 1, 3) - f.MustSetBits(102, 1, 2, 10, 12) + f.mustSetBits(100, 1, 3, 2, 200) + f.mustSetBits(101, 1, 3) + f.mustSetBits(102, 1, 2, 10, 12) f.RecalculateCache() - if pairs, err := f.Top(pilosa.TopOptions{TanimotoThreshold: 50, Src: src}); err != nil { + if pairs, err := f.Top(TopOptions{TanimotoThreshold: 50, Src: src}); err != nil { t.Fatal(err) } else if len(pairs) != 2 { t.Fatalf("unexpected count: %d", len(pairs)) - } else if pairs[0] != (pilosa.Pair{ID: 100, Count: 3}) { + } else if pairs[0] != (Pair{ID: 100, Count: 3}) { t.Fatalf("unexpected pair(0): %v", pairs[0]) - } else if pairs[1] != (pilosa.Pair{ID: 101, Count: 2}) { + } else if pairs[1] != (Pair{ID: 101, Count: 2}) { t.Fatalf("unexpected pair(1): %v", pairs[1]) } } func TestFragment_Zero_Tanimoto(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked) + f := mustOpenFragment("i", "f", ViewStandard, 0, CacheTypeRanked) defer f.Close() - src := pilosa.NewRow(1, 2, 3) + src := NewRow(1, 2, 3) // Set bits on the rows 100, 101, & 102. - f.MustSetBits(100, 1, 3, 2, 200) - f.MustSetBits(101, 1, 3) - f.MustSetBits(102, 1, 2, 10, 12) + f.mustSetBits(100, 1, 3, 2, 200) + f.mustSetBits(101, 1, 3) + f.mustSetBits(102, 1, 2, 10, 12) f.RecalculateCache() - if pairs, err := f.Top(pilosa.TopOptions{TanimotoThreshold: 0, Src: src}); err != nil { + if pairs, err := f.Top(TopOptions{TanimotoThreshold: 0, Src: src}); err != nil { t.Fatal(err) } else if len(pairs) != 3 { t.Fatalf("unexpected count: %d", len(pairs)) - } else if pairs[0] != (pilosa.Pair{ID: 100, Count: 3}) { + } else if pairs[0] != (Pair{ID: 100, Count: 3}) { t.Fatalf("unexpected pair(0): %v", pairs[0]) - } else if pairs[1] != (pilosa.Pair{ID: 101, Count: 2}) { + } else if pairs[1] != (Pair{ID: 101, Count: 2}) { t.Fatalf("unexpected pair(1): %v", pairs[1]) - } else if pairs[2] != (pilosa.Pair{ID: 102, Count: 2}) { + } else if pairs[2] != (Pair{ID: 102, Count: 2}) { t.Fatalf("unexpected pair(1): %v", pairs[2]) } } func TestFragment_Snapshot_Run(t *testing.T) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Set bits on the fragment. @@ -1144,7 +1136,7 @@ func TestFragment_Snapshot_Run(t *testing.T) { } // Close and reopen the fragment & verify the data. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } else if n := f.Row(1000).Count(); n != 2 { t.Fatalf("unexpected count (reopen): %d", n) @@ -1158,7 +1150,7 @@ func BenchmarkFragment_Snapshot(b *testing.B) { b.ReportAllocs() // Open the fragment specified by the path. - f := pilosa.NewFragment(*FragmentPath, "i", "f", pilosa.ViewStandard, 0) + f := NewFragment(*FragmentPath, "i", "f", ViewStandard, 0) if err := f.Open(); err != nil { b.Fatal(err) } @@ -1177,7 +1169,7 @@ func BenchmarkFragment_Snapshot(b *testing.B) { } func BenchmarkFragment_FullSnapshot(b *testing.B) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() // Generate some intersecting data. maxX := 1048576 / 2 @@ -1214,7 +1206,7 @@ func BenchmarkFragment_FullSnapshot(b *testing.B) { } func BenchmarkFragment_Import(b *testing.B) { - f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "") + f := mustOpenFragment("i", "f", ViewStandard, 0, "") defer f.Close() maxX := 1048576 * 5 * 2 sz := maxX @@ -1241,3 +1233,48 @@ func BenchmarkFragment_Import(b *testing.B) { } } } + +///////////////////////////////////////////////////////////////////// + +// mustOpenFragment returns a new instance of Fragment with a temporary path. +func mustOpenFragment(index, field, view string, slice uint64, cacheType string) *Fragment { + file, err := ioutil.TempFile("", "pilosa-fragment-") + if err != nil { + panic(err) + } + file.Close() + + if cacheType == "" { + cacheType = DefaultCacheType + } + + f := NewFragment(file.Name(), index, field, view, slice) + f.CacheType = cacheType + f.RowAttrStore = newMemAttrStore() + + if err := f.Open(); err != nil { + panic(err) + } + return f +} + +// Reopen closes the fragment and reopens it as a new instance. +func (f *Fragment) reopen() error { + if err := f.Close(); err != nil { + return err + } + if err := f.Open(); err != nil { + return err + } + return nil +} + +// mustSetBits sets columns on a row. Panic on error. +// This function does not accept a timestamp or quantum. +func (f *Fragment) mustSetBits(rowID uint64, columnIDs ...uint64) { + for _, columnID := range columnIDs { + if _, err := f.SetBit(rowID, columnID); err != nil { + panic(err) + } + } +} diff --git a/index_internal_test.go b/index_internal_test.go new file mode 100644 index 000000000..1e6d592ab --- /dev/null +++ b/index_internal_test.go @@ -0,0 +1,46 @@ +// Copyright 2017 Pilosa Corp. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pilosa + +import ( + "io/ioutil" +) + +// mustOpenIndex returns a new, opened index at a temporary path. Panic on error. +func mustOpenIndex() *Index { + path, err := ioutil.TempDir("", "pilosa-index-") + if err != nil { + panic(err) + } + index, err := NewIndex(path, "i") + if err != nil { + panic(err) + } + if err := index.Open(); err != nil { + panic(err) + } + return index +} + +// reopen closes the index and reopens it. +func (i *Index) reopen() error { + if err := i.Close(); err != nil { + return err + } + if err := i.Open(); err != nil { + return err + } + return nil +} diff --git a/index_test.go b/index_test.go index 6f067f0e7..5beb67f00 100644 --- a/index_test.go +++ b/index_test.go @@ -23,6 +23,9 @@ import ( "github.com/pilosa/pilosa/test" ) +// SliceWidth is a helper reference to use when testing. +const SliceWidth = pilosa.SliceWidth + // Ensure index can open and retrieve a field. func TestIndex_CreateFieldIfNotExists(t *testing.T) { index := test.MustOpenIndex() diff --git a/test/fragment.go b/test/fragment.go index 1280d3801..140d394a7 100644 --- a/test/fragment.go +++ b/test/fragment.go @@ -15,9 +15,6 @@ package test import ( - "io/ioutil" - "os" - "github.com/pilosa/pilosa" ) @@ -30,61 +27,6 @@ type Fragment struct { RowAttrStore pilosa.AttrStore } -// NewFragment returns a new instance of Fragment with a temporary path. -func NewFragment(index, field, view string, slice uint64, cacheType string) *Fragment { - file, err := ioutil.TempFile("", "pilosa-fragment-") - if err != nil { - panic(err) - } - file.Close() - - f := &Fragment{ - Fragment: pilosa.NewFragment(file.Name(), index, field, view, slice), - RowAttrStore: MustOpenAttrStore(), - } - f.Fragment.CacheType = cacheType - f.Fragment.RowAttrStore = f.RowAttrStore - return f -} - -// MustOpenFragment creates and opens an fragment at a temporary path. Panic on error. -func MustOpenFragment(index, field, view string, slice uint64, cacheType string) *Fragment { - if cacheType == "" { - cacheType = pilosa.DefaultCacheType - } - f := NewFragment(index, field, view, slice, cacheType) - - if err := f.Open(); err != nil { - panic(err) - } - return f -} - -// Close closes the fragment and removes all underlying data. -func (f *Fragment) Close() error { - defer os.Remove(f.Path()) - defer os.Remove(f.CachePath()) - defer f.RowAttrStore.Close() - return f.Fragment.Close() -} - -// Reopen closes the fragment and reopens it as a new instance. -func (f *Fragment) Reopen() error { - cacheType := f.Fragment.CacheType - path := f.Path() - if err := f.Fragment.Close(); err != nil { - return err - } - - f.Fragment = pilosa.NewFragment(path, f.Index(), f.Field(), f.View(), f.Slice()) - f.Fragment.CacheType = cacheType - f.Fragment.RowAttrStore = f.RowAttrStore - if err := f.Open(); err != nil { - return err - } - return nil -} - // MustSetBits sets columns on a row. Panic on error. // This function does not accept a timestamp or quantum. func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64) { @@ -94,48 +36,3 @@ func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64) { } } } - -// MustClearColumns clears columns on a row. Panic on error. -func (f *Fragment) MustClearColumns(rowID uint64, columnIDs ...uint64) { - for _, columnID := range columnIDs { - if _, err := f.ClearBit(rowID, columnID); err != nil { - panic(err) - } - } -} - -// RowAttrStore provides simple storage for attributes. -type RowAttrStore struct { - attrs map[uint64]map[string]interface{} -} - -// NewRowAttrStore returns a new instance of RowAttrStore. -func NewRowAttrStore() *RowAttrStore { - return &RowAttrStore{ - attrs: make(map[uint64]map[string]interface{}), - } -} - -// RowAttrs returns the attributes set to a row id. -func (s *RowAttrStore) RowAttrs(id uint64) (map[string]interface{}, error) { - return s.attrs[id], nil -} - -// SetRowAttrs assigns a set of attributes to a row id. -func (s *RowAttrStore) SetRowAttrs(id uint64, m map[string]interface{}) { - s.attrs[id] = m -} - -// GenerateImportFill generates a set of row/col pairs that evenly fill a fragment chunk. -func GenerateImportFill(rowN int, pct float64) (rowIDs, columnIDs []uint64) { - ipct := int(pct * 100) - for i := 0; i < SliceWidth*rowN; i++ { - if i%100 >= ipct { - continue - } - - rowIDs = append(rowIDs, uint64(i%SliceWidth)) - columnIDs = append(columnIDs, uint64(i/SliceWidth)) - } - return -}