func (c *Client) GetCardinality(name string) (int64, error) {
	rs := pb.Sketch{Name: &name, Type: &typeCard}
	reply, err := c.client.GetCardinality(context.Background(), &pb.GetRequest{Sketches: []*pb.Sketch{&rs}})
	if err != nil {
		return 0, err
	}
	return reply.GetResults()[0].GetCardinality(), nil
}
GetCardinality queries the sketch for the cardinality of items.
package skizze
import (
	"fmt"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	pb "github.com/skizzehq/goskizze/protobuf"
)
var (
	typeMemb = pb.SketchType_MEMB
	typeFreq = pb.SketchType_FREQ
	typeRank = pb.SketchType_RANK
	typeCard = pb.SketchType_CARD
)
type Client struct {
	opts Options
	conn   *grpc.ClientConn
	client pb.SkizzeClient
}
func Dial(address string, opts Options) (*Client, error) {
	var gOpts []grpc.DialOption
	if opts.Insecure == true {
		gOpts = append(gOpts, grpc.WithInsecure())
	}
	conn, err := grpc.Dial(address, gOpts...)
	if err != nil {
		return nil, fmt.Errorf("Unable to dial Skizze at %v: %v", address, err)
	}
	return &Client{
		opts:   opts,
		conn:   conn,
		client: pb.NewSkizzeClient(conn),
	}, nil
}
func (c *Client) Close() {
	if c.conn != nil {
		c.conn.Close()
	}
}
func (c *Client) ListAll() (ret []*Sketch, err error) {
	reply, err := c.client.ListAll(context.Background(), &pb.Empty{})
	if err != nil {
		return nil, err
	}
	for _, sketch := range reply.GetSketches() {
		ret = append(ret, newSketchFromRaw(sketch))
	}
	return ret, err
}
func (c *Client) ListSketches(t SketchType) (ret []*Sketch, err error) {
	rt := getRawSketchForSketchType(t)
	reply, err := c.client.List(context.Background(), &pb.ListRequest{Type: &rt})
	if err != nil {
		return nil, err
	}
	for _, sketch := range reply.GetSketches() {
		ret = append(ret, newSketchFromRaw(sketch))
	}
	return ret, err
}
func (c *Client) ListDomains() (ret []string, err error) {
	reply, err := c.client.ListDomains(context.Background(), &pb.Empty{})
	if err != nil {
		return nil, err
	}
	return reply.GetNames(), nil
}
func (c *Client) CreateDomain(name string) (*Domain, error) {
	rd := &pb.Domain{Name: &name}
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name: &name,
		Type: &typeMemb,
		Properties: &pb.SketchProperties{
			MaxUniqueItems: &defaultMembUnique,
			ErrorRate:      &defaultMembErrorRate,
		},
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name: &name,
		Type: &typeFreq,
		Properties: &pb.SketchProperties{
			MaxUniqueItems: &defaultFreqUnique,
			ErrorRate:      &defaultFreqErrorRate,
		},
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name: &name,
		Type: &typeRank,
		Properties: &pb.SketchProperties{
			Size: &defaultRankSize,
		},
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name: &name,
		Type: &typeCard,
	})
	reply, err := c.client.CreateDomain(context.Background(), rd)
	if err != nil {
		return nil, err
	}
	return newDomainFromRaw(reply), nil
}
func (c *Client) CreateDomainWithProperties(name string, props *DomainProperties) (*Domain, error) {
	rd := &pb.Domain{Name: &name}
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name:       &name,
		Type:       &typeMemb,
		Properties: newRawPropertiesFromProperties(&props.MembershipProperties),
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name:       &name,
		Type:       &typeFreq,
		Properties: newRawPropertiesFromProperties(&props.FrequencyProperties),
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name:       &name,
		Type:       &typeRank,
		Properties: newRawPropertiesFromProperties(&props.RankingsProperties),
	})
	rd.Sketches = append(rd.Sketches, &pb.Sketch{
		Name: &name,
		Type: &typeCard,
	})
	reply, err := c.client.CreateDomain(context.Background(), rd)
	if err != nil {
		return nil, err
	}
	return newDomainFromRaw(reply), nil
}
func (c *Client) DeleteDomain(name string) error {
	rd := &pb.Domain{Name: &name}
	_, err := c.client.DeleteDomain(context.Background(), rd)
	if err != nil {
		return err
	}
	return nil
}
func (c *Client) GetDomain(name string) (*Domain, error) {
	rd := &pb.Domain{Name: &name}
	reply, err := c.client.GetDomain(context.Background(), rd)
	if err != nil {
		return nil, err
	}
	return newDomainFromRaw(reply), nil
}
func (c *Client) CreateSketch(name string, t SketchType, p *Properties) (*Sketch, error) {
	rt := getRawSketchForSketchType(t)
	rd := &pb.Sketch{Name: &name, Type: &rt, Properties: newRawPropertiesFromProperties(p)}
	reply, err := c.client.CreateSketch(context.Background(), rd)
	if err != nil {
		return nil, err
	}
	return newSketchFromRaw(reply), nil
}
func (c *Client) DeleteSketch(name string, t SketchType) error {
	rt := getRawSketchForSketchType(t)
	rd := &pb.Sketch{Name: &name, Type: &rt}
	_, err := c.client.DeleteSketch(context.Background(), rd)
	if err != nil {
		return err
	}
	return nil
}
func (c *Client) GetSketch(name string, t SketchType) (*Sketch, error) {
	rt := getRawSketchForSketchType(t)
	rd := &pb.Sketch{Name: &name, Type: &rt}
	reply, err := c.client.GetSketch(context.Background(), rd)
	if err != nil {
		return nil, err
	}
	return newSketchFromRaw(reply), nil
}
func (c *Client) AddToSketch(name string, t SketchType, values ...string) error {
	rt := getRawSketchForSketchType(t)
	rs := pb.Sketch{Name: &name, Type: &rt}
	_, err := c.client.Add(context.Background(), &pb.AddRequest{Sketch: &rs, Values: values})
	return err
}
func (c *Client) AddToDomain(name string, values ...string) error {
	rd := pb.Domain{Name: &name}
	_, err := c.client.Add(context.Background(), &pb.AddRequest{Domain: &rd, Values: values})
	return err
}
func (c *Client) GetMembership(name string, values ...string) (ret []*MembershipResult, err error) {
	rs := pb.Sketch{Name: &name, Type: &typeMemb}
	reply, err := c.client.GetMembership(context.Background(), &pb.GetRequest{Sketches: []*pb.Sketch{&rs}, Values: values})
	if err != nil {
		return nil, err
	}
	for _, m := range reply.GetResults()[0].GetMemberships() {
		ret = append(ret, &MembershipResult{Value: m.GetValue(), IsMember: m.GetIsMember()})
	}
	return ret, nil
}
func (c *Client) GetMultiMembership(names []string, values ...string) (ret [][]*MembershipResult, err error) {
	req := &pb.GetRequest{Values: values}
	for i := range names {
		req.Sketches = append(req.Sketches, &pb.Sketch{Name: &names[i], Type: &typeMemb})
	}
	reply, err := c.client.GetMembership(context.Background(), req)
	if err != nil {
		return nil, err
	}
	for _, result := range reply.GetResults() {
		r := []*MembershipResult{}
		for _, m := range result.GetMemberships() {
			r = append(r, &MembershipResult{Value: m.GetValue(), IsMember: m.GetIsMember()})
		}
		ret = append(ret, r)
	}
	return ret, nil
}
func (c *Client) GetFrequency(name string, values ...string) (ret []*FrequencyResult, err error) {
	rs := pb.Sketch{Name: &name, Type: &typeFreq}
	reply, err := c.client.GetFrequency(context.Background(), &pb.GetRequest{Sketches: []*pb.Sketch{&rs}, Values: values})
	if err != nil {
		return nil, err
	}
	for _, m := range reply.GetResults()[0].GetFrequencies() {
		ret = append(ret, &FrequencyResult{Value: m.GetValue(), Count: m.GetCount()})
	}
	return ret, nil
}
func (c *Client) GetMultiFrequency(names []string, values ...string) (ret [][]*FrequencyResult, err error) {
	req := &pb.GetRequest{Values: values}
	for i := range names {
		req.Sketches = append(req.Sketches, &pb.Sketch{Name: &names[i], Type: &typeFreq})
	}
	reply, err := c.client.GetFrequency(context.Background(), req)
	if err != nil {
		return nil, err
	}
	for _, result := range reply.GetResults() {
		r := []*FrequencyResult{}
		for _, m := range result.GetFrequencies() {
			r = append(r, &FrequencyResult{Value: m.GetValue(), Count: m.GetCount()})
		}
		ret = append(ret, r)
	}
	return ret, nil
}
func (c *Client) GetRankings(name string) (ret []*RankingsResult, err error) {
	rs := pb.Sketch{Name: &name, Type: &typeRank}
	reply, err := c.client.GetRankings(context.Background(), &pb.GetRequest{Sketches: []*pb.Sketch{&rs}})
	if err != nil {
		return nil, err
	}
	for _, m := range reply.GetResults()[0].GetRankings() {
		ret = append(ret, &RankingsResult{Value: m.GetValue(), Count: m.GetCount()})
	}
	return ret, nil
}
func (c *Client) GetMultiRankings(names []string) (ret [][]*RankingsResult, err error) {
	req := &pb.GetRequest{}
	for i := range names {
		req.Sketches = append(req.Sketches, &pb.Sketch{Name: &names[i], Type: &typeRank})
	}
	reply, err := c.client.GetRankings(context.Background(), req)
	for _, result := range reply.GetResults() {
		r := []*RankingsResult{}
		for _, m := range result.GetRankings() {
			r = append(r, &RankingsResult{Value: m.GetValue(), Count: m.GetCount()})
		}
		ret = append(ret, r)
	}
	return ret, nil
}