// Next creates and returns the next version for the given key.
181937
func (f *VersionFactory) Next(key string) *Version {
	f.latest[key]++
	return &Version{
		Scalar: f.latest[key],
		PID:    f.pid,
	}
}
262170
func (kvr *Reader) Next(key, val sophie.SophieReader) error {
	var l sophie.VInt
	if err := (&l).ReadFrom(&kvr.reader, -1); err != nil {
		return errorsp.WithStacksAndMessage(err, "reading key length failed")
	}
	posEnd := kvr.reader.Pos + int64(l)
	if err := key.ReadFrom(&kvr.reader, int(l)); err != nil {
		if errorsp.Cause(err) == io.EOF {
			return errorsp.WithStacksAndMessage(io.ErrUnexpectedEOF, "Unexpected EOF reading key")
		}
		return errorsp.WithStacksAndMessage(err, "reading key %v failed", key)
	}
	if kvr.reader.Pos != posEnd {
		return errorsp.WithStacksAndMessage(sophie.ErrBadFormat, "PosEnd wrong after reading key(len = %d) %v: exp %d, act %d", l, key, posEnd, kvr.reader.Pos)
	}

	if err := (&l).ReadFrom(&kvr.reader, -1); err != nil {
		if errorsp.Cause(err) == io.EOF {
			return errorsp.WithStacksAndMessage(io.ErrUnexpectedEOF, "Unexpected EOF reading val length for key %v", key)
		}
		return err
	}
	posEnd = kvr.reader.Pos + int64(l)
	if err := val.ReadFrom(&kvr.reader, int(l)); err != nil {
		if errorsp.Cause(err) == io.EOF {
			return errorsp.WithStacksAndMessage(io.ErrUnexpectedEOF, "Unexpected EOF reading val for key %v", key)
		}
		return errorsp.WithStacksAndMessage(err, "reading value for key %v failed", key)
	}
	if kvr.reader.Pos != posEnd {
		return errorsp.WithStacksAndMessage(sophie.ErrBadFormat, "PosEnd wrong after reading key %v, value %v: exp %d, act %d",
			key, val, posEnd, kvr.reader.Pos)
	}
	return nil
}
1142885
func (r *Reader) Next(n int) []byte {
	oldI := r.i
	r.i += n
	return r.s[oldI:r.i]
}
669179
func (itr *combinedIterator) Next() (statedb.QueryResult, error) {
	if itr.dbItem == nil && itr.updatesItem == nil {
		logger.Debugf("dbItem and updatesItem both are nil.")
		return itr.serveEndKeyIfNeeded()
	}
	var moveDBItr bool
	var moveUpdatesItr bool
	var selectedItem statedb.QueryResult
	compResult := compareKeys(itr.dbItem, itr.updatesItem)
	logger.Debugf("compResult=%d", compResult)
	switch compResult {
	case -1:
		// dbItem is smaller
		selectedItem = itr.dbItem
		moveDBItr = true
	case 0:
		//both items are same so, choose the updatesItem (latest)
		selectedItem = itr.updatesItem
		moveUpdatesItr = true
		moveDBItr = true
	case 1:
		// updatesItem is smaller
		selectedItem = itr.updatesItem
		moveUpdatesItr = true
	}
	var err error
	if moveDBItr {
		if itr.dbItem, err = itr.dbItr.Next(); err != nil {
			return nil, err
		}
	}

	if moveUpdatesItr {
		if itr.updatesItem, err = itr.updatesItr.Next(); err != nil {
			return nil, err
		}
	}
	if isDelete(selectedItem) {
		return itr.Next()
	}
	logger.Debugf("Returning item=%#v. Next dbItem=%#v, Next updatesItem=%#v", selectedItem, itr.dbItem, itr.updatesItem)
	return selectedItem, nil
}
1350965
func (iter *dbCacheIterator) Next() bool {
	// Nothing to return if cursor is exhausted.
	if iter.currentIter == nil {
		return false
	}

	// Move the current iterator to the next entry and choose the iterator
	// that is both valid and has the smaller key.
	iter.currentIter.Next()
	return iter.chooseIterator(true)
}
641856
func (i *Int) Next() int {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}
1041296
func (wu *WaitUntil) Next(nextState MachineState) MachineState {
	wu.next = nextState
	return wu
}
1053633
func (li *TemplateVersionsIterator) Next(ctx context.Context, items *[]TemplateVersion) bool {
	if li.err != nil {
		return false
	}
	li.err = li.fetch(ctx, li.Paging.Next)
	if li.err != nil {
		return false
	}
	cpy := make([]TemplateVersion, len(li.Template.Versions))
	copy(cpy, li.Template.Versions)
	*items = cpy
	if len(li.Template.Versions) == 0 {
		return false
	}
	return true
}
202141
func (itr *pvtdataResultsItr) Next() (commonledger.QueryResult, error) {
	queryResult, err := itr.dbItr.Next()
	if err != nil {
		return nil, err
	}
	if queryResult == nil {
		return nil, nil
	}
	versionedQueryRecord := queryResult.(*statedb.VersionedKV)
	return &queryresult.KV{
		Namespace: itr.ns,
		Key:       versionedQueryRecord.Key,
		Value:     versionedQueryRecord.Value,
	}, nil
}
1269800
func (i *Int64) Next() int64 {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}
556568
func (itr *tagBlockKeyIterator) Next() TagKeyElem {
	// Exit when there is no data left.
	if len(itr.keyData) == 0 {
		return nil
	}

	// Unmarshal next element & move data forward.
	itr.e.unmarshal(itr.keyData, itr.blk.data)
	itr.keyData = itr.keyData[itr.e.size:]

	assert(len(itr.e.Key()) > 0, "invalid zero-length tag key")
	return &itr.e
}
735728
func (c *C) Next() {
	c.index++
	s := int8(len(c.handlers))
	if c.index < s {
		c.handlers[c.index](c)
	}
}
872632
func (it *iterator4List) Next() Row {
	if it.chkCursor >= it.li.NumChunks() {
		it.chkCursor = it.li.NumChunks() + 1
		return it.End()
	}
	chk := it.li.GetChunk(it.chkCursor)
	row := chk.GetRow(it.rowCursor)
	it.rowCursor++
	if it.rowCursor == chk.NumRows() {
		it.rowCursor = 0
		it.chkCursor++
	}
	return row
}
815058
func (t *batchIter) next() (kind internalKeyKind, ukey []byte, value []byte, ok bool) {
	p := *t
	if len(p) == 0 {
		return 0, nil, nil, false
	}
	kind, *t = internalKeyKind(p[0]), p[1:]
	if kind > internalKeyKindMax {
		return 0, nil, nil, false
	}
	ukey, ok = t.nextStr()
	if !ok {
		return 0, nil, nil, false
	}
	if kind != internalKeyKindDelete {
		value, ok = t.nextStr()
		if !ok {
			return 0, nil, nil, false
		}
	}
	return kind, ukey, value, true
}
385545
func (e *HashAggExec) Next(ctx context.Context, req *chunk.RecordBatch) error {
	if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
		span1 := span.Tracer().StartSpan("hashagg.Next", opentracing.ChildOf(span.Context()))
		defer span1.Finish()
	}
	if e.runtimeStats != nil {
		start := time.Now()
		defer func() { e.runtimeStats.Record(time.Since(start), req.NumRows()) }()
	}
	req.Reset()
	if e.isUnparallelExec {
		return e.unparallelExec(ctx, req.Chunk)
	}
	return e.parallelExec(ctx, req.Chunk)
}
261271
func (nfei *NotFoundErrorIterator) Next() (*cb.Block, cb.Status) {
	return nil, cb.Status_NOT_FOUND
}
1028241
func (iter *Iterator) Next() bool {
	if iterExhausted(iter) {
		return false
	}
	iter.index++
	if iter.index >= len(iter.entries.entries) {
		next := iter.xfastIterator.Next()
		if !next {
			iter.index = iteratorExhausted
			return false
		}
		var ok bool
		iter.entries, ok = iter.xfastIterator.Value().(*entriesWrapper)
		if !ok {
			iter.index = iteratorExhausted
			return false
		}
		iter.index = 0
	}

	return true
}