// Split blocks into chunks of the desired size, or less. This implementation assumes a fixed block size at the source.
347514
func (r *FixedSizeBlockResolver) SplitBlockRangeToDesiredSize(startBlockID, endBlockID uint) []QueuedRequest {

	if r.MaxDesiredRequestSize == 0 {
		return []QueuedRequest{
			QueuedRequest{
				StartBlockID: startBlockID,
				EndBlockID:   endBlockID,
			},
		}
	}

	maxSize := r.MaxDesiredRequestSize
	if r.MaxDesiredRequestSize < r.BlockSize {
		maxSize = r.BlockSize
	}

	// how many blocks is the desired size?
	blockCountPerRequest := uint(maxSize / r.BlockSize)

	requests := make([]QueuedRequest, 0, (endBlockID-startBlockID)/blockCountPerRequest+1)
	currentBlockID := startBlockID

	for {
		maxEndBlock := currentBlockID + blockCountPerRequest

		if maxEndBlock > endBlockID {
			requests = append(
				requests,
				QueuedRequest{
					StartBlockID: currentBlockID,
					EndBlockID:   endBlockID,
				},
			)

			return requests
		} else {
			requests = append(
				requests,
				QueuedRequest{
					StartBlockID: currentBlockID,
					EndBlockID:   maxEndBlock - 1,
				},
			)

			currentBlockID = maxEndBlock
		}
	}
}
990874
func Split(sep, str cty.Value) (cty.Value, error) {
	return SplitFunc.Call([]cty.Value{sep, str})
}
353792
func (pb *Block) Chunks() (ChunkReader, error) {
	if err := pb.startRead(); err != nil {
		return nil, err
	}
	return blockChunkReader{ChunkReader: pb.chunkr, b: pb}, nil
}
862393
func Split(data []byte, atEOF bool) (advance int, token []byte, err error) {
	return split(false, data, atEOF)
}
594756
func (hpt *hostParamTransformer) split(s, sep string) []string {
	slice := []string{}
	n := strings.Count(s, sep) + 1
	c := sep[0]
	start := 0

	var a []string
	if cap(slice) == n {
		a = slice
	} else {
		a = make([]string, n)
	}

	na := 0
	for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
		if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) && (i == 0 || s[i-1] != '\\') {
			a[na] = s[start:i]
			na++
			start = i + len(sep)
			i += len(sep) - 1
		}
	}
	a[na] = s[start:]
	slice = a[0 : na+1]
	return slice
}
32877
func (p *point) Split(size int) []Point {
	if p.time.IsZero() || p.StringSize() <= size {
		return []Point{p}
	}

	// key string, timestamp string, spaces
	size -= len(p.key) + len(strconv.FormatInt(p.time.UnixNano(), 10)) + 2

	var points []Point
	var start, cur int

	for cur < len(p.fields) {
		end, _ := scanTo(p.fields, cur, '=')
		end, _ = scanFieldValue(p.fields, end+1)

		if cur > start && end-start > size {
			points = append(points, &point{
				key:    p.key,
				time:   p.time,
				fields: p.fields[start : cur-1],
			})
			start = cur
		}

		cur = end + 1
	}

	points = append(points, &point{
		key:    p.key,
		time:   p.time,
		fields: p.fields[start:],
	})

	return points
}
106114
func (i *Index) Chunks(ref string, beg, end int) ([]bgzf.Chunk, error) {
	id, ok := i.nameMap[ref]
	if !ok {
		return nil, index.ErrNoReference
	}
	chunks, err := i.idx.Chunks(id, beg, end)
	if err != nil {
		return nil, err
	}
	return adjacent(chunks), nil
}
380986
func ComputeBlockSize(fileSize int64, blockIndex int64) int64 {
	if BigBlockSize*(blockIndex+1) > fileSize {
		return fileSize % BigBlockSize
	}
	return BigBlockSize
}
1175455
func (b *block) resize(n int) {
	if n > cap(b.data) {
		b.reserve(n)
	}
	b.data = b.data[0:n]
}
600251
func SplitList(b []byte) (content, rest []byte, err error) {
	k, content, rest, err := Split(b)
	if err != nil {
		return nil, b, err
	}
	if k != List {
		return nil, b, ErrExpectedList
	}
	return content, rest, nil
}
639610
func (n *node) split(pageSize int) []*node {
	var nodes []*node

	node := n
	for {
		// Split node into two.
		a, b := node.splitTwo(pageSize)
		nodes = append(nodes, a)

		// If we can't split then exit the loop.
		if b == nil {
			break
		}

		// Set node to b so it gets split on the next iteration.
		node = b
	}

	return nodes
}
1335061
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block {
	block := &Block{
		Header: Header{
			Height: height,
			NumTxs: int64(len(txs)),
		},
		Data: Data{
			Txs: txs,
		},
		Evidence:   EvidenceData{Evidence: evidence},
		LastCommit: lastCommit,
	}
	block.fillHeader()
	return block
}
978063
func splitAfterNewline(p []byte) ([][]byte, []byte) {
	chunk := p
	var lines [][]byte

	for len(chunk) > 0 {
		idx := bytes.Index(chunk, newLine)
		if idx == -1 {
			return lines, chunk
		}

		lines = append(lines, chunk[:idx+1])

		if idx == len(chunk)-1 {
			chunk = nil
			break
		}

		chunk = chunk[idx+1:]
	}

	return lines, chunk
}
916998
func Split(sql, separator string) []string {
	if len(separator) == 0 || len(sql) < len(separator) {
		return []string{sql}
	}
	l := &lexer{
		Sql: sql,
		Sep: separator,
		At:  0,
	}
	state := stateWhitespace
	for state != nil {
		state = state(l)
	}
	l.AddCurrent(1)
	return l.Batch
}
1017259
func getSliceSize(blockSize, bufSize, dataSize int) int {
	size := bufSize
	if bufSize > dataSize {
		size = dataSize
	}
	size = size - (size % blockSize) - blockSize
	if size <= 0 {
		size = blockSize
	}

	return size
}
856605
func (ca *CoreAdmin) Split(core string, targetCore ...string) (*SolrResponse, error) {
	if len(targetCore) < 2 {
		return nil, fmt.Errorf("You must specify at least 2 target cores")
	}
	params := &url.Values{}
	params.Add("core", core)
	for _, target := range targetCore {
		params.Add("targetCore", target)
	}
	return ca.Action("SPLIT", params)
}
1164077
func NewSplitBytes(buf []byte, delim byte) *SplitBytes {
	return &SplitBytes{
		buf:   buf,
		delim: delim,
	}
}