From f39285313417a713fd0a5230ddd51ccc9d2bf77a Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Tue, 16 May 2017 11:11:11 -0500 Subject: [PATCH] update sliceMaxByIndex by view --- client.go | 9 ++++++++- cmd/backup.go | 6 +++--- ctl/export.go | 8 +++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 058d6d836..6a4e29641 100644 --- a/client.go +++ b/client.go @@ -474,7 +474,14 @@ func (c *Client) BackupTo(ctx context.Context, w io.Writer, index, frame, view s tw := tar.NewWriter(w) // Find the maximum number of slices. - maxSlices, err := c.MaxSliceByIndex(ctx) + var maxSlices map[string]uint64 + var err error + if view == ViewStandard { + maxSlices, err = c.MaxSliceByIndex(ctx) + } else if view == ViewInverse { + maxSlices, err = c.MaxInverseSliceByIndex(ctx) + } + if err != nil { return fmt.Errorf("slice n: %s", err) } diff --git a/cmd/backup.go b/cmd/backup.go index 548781ca6..1dd3a50d6 100644 --- a/cmd/backup.go +++ b/cmd/backup.go @@ -43,9 +43,9 @@ Backs up the view from across the cluster into a single file. } flags := backupCmd.Flags() flags.StringVarP(&Backuper.Host, "host", "", "localhost:10101", "host:port of Pilosa.") - flags.StringVarP(&Backuper.Index, "index", "i", "", "Pilosa index to backup into.") - flags.StringVarP(&Backuper.Frame, "frame", "f", "", "Frame to backup into.") - flags.StringVarP(&Backuper.View, "view", "v", "", "View to backup into.") + flags.StringVarP(&Backuper.Index, "index", "i", "", "Pilosa index to backup.") + flags.StringVarP(&Backuper.Frame, "frame", "f", "", "Frame to backup.") + flags.StringVarP(&Backuper.View, "view", "v", "", "View to backup.") flags.StringVarP(&Backuper.Path, "output-file", "o", "", "File to write backup to - default stdout") return backupCmd diff --git a/ctl/export.go b/ctl/export.go index 7da310623..fa6277f16 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -79,7 +79,13 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { } // Determine slice count. - maxSlices, err := client.MaxSliceByIndex(ctx) + var maxSlices map[string]uint64 + if cmd.View == pilosa.ViewStandard { + maxSlices, err = client.MaxSliceByIndex(ctx) + } else if cmd.View == pilosa.ViewInverse { + maxSlices, err = client.MaxInverseSliceByIndex(ctx) + } + if err != nil { return err }