featurebase/cmd/import.go

46 lines
1.3 KiB
Go

package cmd
import (
"context"
"io"
"github.com/spf13/cobra"
"github.com/pilosa/pilosa/ctl"
)
func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
importer := ctl.NewImportCommand(stdin, stdout, stderr)
importCmd := &cobra.Command{
Use: "import",
Short: "Bulk load data into pilosa.",
Long: `Bulk imports one or more CSV files to a host's database and frame. The bits
of the CSV file are grouped by slice for the most efficient import.
The format of the CSV file is:
BITMAPID,PROFILEID,[TIME]
The file should contain no headers. The TIME column is optional and can be
omitted. If it is present then its format should be YYYY-MM-DDTHH:MM.
`,
RunE: func(cmd *cobra.Command, args []string) error {
importer.Paths = args
if err := importer.Run(context.Background()); err != nil {
return err
}
return nil
},
}
flags := importCmd.Flags()
flags.StringVarP(&importer.Host, "host", "", "localhost:15000", "host:port of Pilosa.")
flags.StringVarP(&importer.Database, "database", "d", "", "Pilosa database to import into.")
flags.StringVarP(&importer.Frame, "frame", "f", "", "Frame to import into.")
flags.IntVarP(&importer.BufferSize, "buffer-size", "s", 10000000, "Number of bits to buffer/sort before importing.")
return importCmd
}
func init() {
subcommandFns["import"] = NewImportCommand
}