Exemplo n.º 1
0
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *pb.SplitQueryRequest) (response *pb.SplitQueryResponse, err error) {
	defer q.server.HandlePanic(&err)
	ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
		request.EffectiveCallerId,
		request.ImmediateCallerId,
	)
	reply := &proto.SplitQueryResult{}
	bq, err := proto.Proto3ToBoundQuery(request.Query)
	if err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	if err := q.server.SplitQuery(ctx, request.Target, &proto.SplitQueryRequest{
		Query:       *bq,
		SplitColumn: request.SplitColumn,
		SplitCount:  int(request.SplitCount),
		SessionID:   request.SessionId,
	}, reply); err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	qs, err := proto.QuerySplitsToProto3(reply.Queries)
	if err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	return &pb.SplitQueryResponse{Queries: qs}, nil
}
Exemplo n.º 2
0
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *pb.SplitQueryRequest) (response *pb.SplitQueryResponse, err error) {
	defer q.server.HandlePanic(&err)
	ctx = callinfo.GRPCCallInfo(ctx)

	reply := &proto.SplitQueryResult{}
	if sqErr := q.server.SplitQuery(ctx, &proto.SplitQueryRequest{
		Query:       *proto.Proto3ToBoundQuery(request.Query),
		SplitColumn: request.SplitColumn,
		SplitCount:  int(request.SplitCount),
		SessionID:   request.SessionId,
	}, reply); sqErr != nil {
		return &pb.SplitQueryResponse{
			Error: tabletserver.TabletErrorToRPCError(sqErr),
		}, nil
	}
	return &pb.SplitQueryResponse{
		Queries: proto.QuerySplitsToProto3(reply.Queries),
	}, nil
}