func createDomain(fields []string, in *pb.Domain) error { if len(fields) > 5 { return fmt.Errorf("Too many argumets, expected 4 got %d", len(fields)) } // FIXME make last 2 arguments optional capa, err := strconv.Atoi(fields[3]) if err != nil { return fmt.Errorf("Expected 3rd argument to be of type int: %q", err) } size, err := strconv.Atoi(fields[4]) if err != nil { return fmt.Errorf("Expected last argument to be of type int: %q", err) } types := []pb.SketchType{pb.SketchType_MEMB, pb.SketchType_FREQ, pb.SketchType_RANK, pb.SketchType_CARD} for _, ty := range types { sketch := &pb.Sketch{} sketch.Name = proto.String("") sketch.Type = &ty sketch.Properties = &pb.SketchProperties{ Size: proto.Int64(int64(size)), MaxUniqueItems: proto.Int64(int64(capa)), } in.Sketches = append(in.Sketches, sketch) } _, err = client.CreateDomain(context.Background(), in) return err }
func createDom(id string) *pb.Domain { dom := new(pb.Domain) dom.Name = utils.Stringp(id) types := []pb.SketchType{pb.SketchType_MEMB, pb.SketchType_FREQ, pb.SketchType_RANK, pb.SketchType_CARD} for _, ty := range types { sketch := &pb.Sketch{} sketch.Name = dom.Name sketch.Type = &ty sketch.Properties = &pb.SketchProperties{ Size: utils.Int64p(100), MaxUniqueItems: utils.Int64p(10), } dom.Sketches = append(dom.Sketches, sketch) } return dom }