func (r *RowIterator) Next() (*Row, error) {
	if r.err != nil {
		return nil, r.err
	}
	for len(r.rows) == 0 && r.streamd.next() {
		r.rows, r.err = r.rowd.add(r.streamd.get())
		if r.err != nil {
			return nil, r.err
		}
	}
	if len(r.rows) > 0 {
		row := r.rows[0]
		r.rows = r.rows[1:]
		return row, nil
	}
	if err := r.streamd.lastErr(); err != nil {
		r.err = toSpannerError(err)
	} else if !r.rowd.done() {
		r.err = errEarlyReadEnd()
	} else {
		r.err = iterator.Done
	}
	return nil, r.err
}
Next returns the next result. Its second return value is iterator.Done if
there are no more results. Once Next returns Done, all subsequent calls
will return Done.
package spanner
import (
	"bytes"
	"io"
	"sync/atomic"
	"time"
	log "github.com/golang/glog"
	proto "github.com/golang/protobuf/proto"
	proto3 "github.com/golang/protobuf/ptypes/struct"
	"golang.org/x/net/context"
	"google.golang.org/api/iterator"
	sppb "google.golang.org/genproto/googleapis/spanner/v1"
	"google.golang.org/grpc/codes"
)
type streamingReceiver interface {
	Recv() (*sppb.PartialResultSet, error)
}
func errEarlyReadEnd() error {
	return spannerErrorf(codes.FailedPrecondition, "read completed with active stream")
}
func stream(ctx context.Context, rpc func(ct context.Context, resumeToken []byte) (streamingReceiver, error), release func(time.Time, error)) *RowIterator {
	ctx, cancel := context.WithCancel(ctx)
	return &RowIterator{
		streamd: newResumableStreamDecoder(ctx, rpc),
		rowd:    &partialResultSetDecoder{},
		release: release,
		cancel:  cancel,
	}
}
type RowIterator struct {
	streamd *resumableStreamDecoder
	rowd    *partialResultSetDecoder
	release func(time.Time, error)
	cancel  func()
	err     error
	rows    []*Row
}