// GetLogsBytes gets logs binary data from shard specified by shardId according cursor.
// The logGroupMaxCount is the max number of logGroup could be returned.
// The nextCursor is the next curosr can be used to read logs at next time.

GetLogsBytes gets logs binary data from shard specified by shardId according cursor.
The logGroupMaxCount is the max number of logGroup could be returned.
The nextCursor is the next curosr can be used to read logs at next time.
// GetLogsBytes gets logs binary data from shard specified by shardId according cursor . // The logGroupMaxCount is the max number of logGroup could be returned . // The nextCursor is the next curosr can be used to read logs at next time .
func (s *LogStore) GetLogsBytes(shardId int, cursor string,
	logGroupMaxCount int) (out []byte, nextCursor string, err error) {
	h := map[string]string{
		"x-sls-bodyrawsize": "0",
		"Accept":            "application/x-protobuf",
		"Accept-Encoding":   "lz4",
	}
	uri := fmt.Sprintf("/logstores/%v/shards/%v?type=logs&cursor=%v&count=%v",
		s.Name, shardId, cursor, logGroupMaxCount)
	r, err := request(s.project, "GET", uri, h, nil)
	if err != nil {
		return
	}
	buf, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return
	}
	if r.StatusCode != http.StatusOK {
		errMsg := &errorMessage{}
		err = json.Unmarshal(buf, errMsg)
		if err != nil {
			err = fmt.Errorf("failed to get cursor")
			dump, _ := httputil.DumpResponse(r, true)
			fmt.Println(dump)
			return
		}
		err = fmt.Errorf("%v:%v", errMsg.Code, errMsg.Message)
		return
	}
	v, ok := r.Header["X-Sls-Compresstype"]
	if !ok || len(v) == 0 {
		err = fmt.Errorf("can't find 'x-sls-compresstype' header")
		return
	}
	if v[0] != "lz4" {
		err = fmt.Errorf("unexpected compress type:%v", v[0])
		return
	}
	v, ok = r.Header["X-Sls-Cursor"]
	if !ok || len(v) == 0 {
		err = fmt.Errorf("can't find 'x-sls-cursor' header")
		return
	}
	nextCursor = v[0]
	v, ok = r.Header["X-Sls-Bodyrawsize"]
	if !ok || len(v) == 0 {
		err = fmt.Errorf("can't find 'x-sls-bodyrawsize' header")
		return
	}
	bodyRawSize, err := strconv.Atoi(v[0])
	if err != nil {
		return
	}
	out = make([]byte, bodyRawSize)
	err = lz4.Uncompress(buf, out)
	if err != nil {
		return
	}
	return
}
func ( s * LogStore ) GetLogsBytes ( shardId int , cursor string , logGroupMaxCount int ) ( out [ ] byte , nextCursor string , err error ) { h := map [ string ] string { " " : " " , " " : " " , " " : " " , } uri := fmt . Sprintf ( " " , s . Name , shardId , cursor , logGroupMaxCount ) r , err := request ( s . project , " " , uri , h , nil ) if err != nil { return } buf , err := ioutil . ReadAll ( r . Body ) if err != nil { return } if r . StatusCode != http . StatusOK { errMsg := & errorMessage { } err = json . Unmarshal ( buf , errMsg ) if err != nil { err = fmt . Errorf ( " " ) dump , _ := httputil . DumpResponse ( r , true ) fmt . Println ( dump ) return } err = fmt . Errorf ( " " , errMsg . Code , errMsg . Message ) return } v , ok := r . Header [ " " ] if ! ok || len ( v ) == 0 { err = fmt . Errorf ( " " ) return } if v [ 0 ] != " " { err = fmt . Errorf ( " " , v [ 0 ] ) return } v , ok = r . Header [ " " ] if ! ok || len ( v ) == 0 { err = fmt . Errorf ( " " ) return } nextCursor = v [ 0 ] v , ok = r . Header [ " " ] if ! ok || len ( v ) == 0 { err = fmt . Errorf ( " " ) return } bodyRawSize , err := strconv . Atoi ( v [ 0 ] ) if err != nil { return } out = make ( [ ] byte , bodyRawSize ) err = lz4 . Uncompress ( buf , out ) if err != nil { return } return }
GetLogsBytes gets logs binary data from shard specified by shardId according cursor.
GetLogsBytes gets logs binary data from shard specified by shardId according cursor .