// Returns the firstmost (by task index) error as
// discovered by all previous Reap() calls.
763414
func (trs *TaskResultSet) FirstError() error {
	for _, result := range trs.results {
		if result.Error != nil {
			return result.Error
		}
	}
	return nil
}
433968
func (t *SecondaryTree) SeekFirst() (e *SecondaryEnumerator, err error) {
	q := t.first
	if q == nil {
		return nil, io.EOF
	}

	return btEPool2.get(nil, true, 0, q.d[0].k, q, t, atomic.LoadUint64(&t.ver)), nil
}
635651
func (r *raftLog) FirstIndex() (uint64, error) {
	r.RLock()
	idx, err := r.getIndex(true)
	r.RUnlock()
	return idx, err
}
223172
func (s *globalTaskService) TaskInspect(taskID int) *types.Task {
	s.RLock()
	defer s.RUnlock()
	if t, ok := s.tasks[taskID]; ok {
		return &t.Task
	}
	return nil
}
777008
func WrapRetryableError(err error, errorList []*regexp.Regexp, errorCreator ErrorCreator) error {
	if err == nil {
		return nil
	}
	for _, errorRegex := range errorList {
		if errorRegex.MatchString(err.Error()) {
			return errorCreator(err)
		}
	}
	return err
}
245433
func (c *Cursor) First() (key []byte, value []byte) {
	_assert(c.bucket.tx.db != nil, "tx closed")
	c.stack = c.stack[:0]
	p, n := c.bucket.pageNode(c.bucket.root)
	c.stack = append(c.stack, elemRef{page: p, node: n, index: 0})
	c.first()

	// If we land on an empty page then move to the next value.
	// https://github.com/boltdb/bolt/issues/450
	if c.stack[len(c.stack)-1].count() == 0 {
		c.next()
	}

	k, v, flags := c.keyValue()
	if (flags & uint32(bucketLeafFlag)) != 0 {
		return k, nil
	}
	return k, v

}
164243
func (r *GormWorkItemRepository) FindFirstItem(ctx context.Context, spaceID uuid.UUID, id uuid.UUID) (*float64, error) {
	res := WorkItemStorage{}
	tx := r.db.Model(WorkItemStorage{}).Where("id=? and space_id=?", id, spaceID).First(&res)
	if tx.RecordNotFound() {
		return nil, errors.NewNotFoundError("work item", id.String())
	}
	if tx.Error != nil {
		return nil, errors.NewInternalError(ctx, tx.Error)
	}
	return &res.ExecutionOrder, nil
}
1346816
func (d *HashAggIntermData) getPartialResultBatch(sc *stmtctx.StatementContext, prs [][]aggfuncs.PartialResult, aggFuncs []aggfuncs.AggFunc, maxChunkSize int) (_ [][]aggfuncs.PartialResult, groupKeys []string, reachEnd bool) {
	keyStart := d.cursor
	for ; d.cursor < len(d.groupKeys) && len(prs) < maxChunkSize; d.cursor++ {
		prs = append(prs, d.partialResultMap[d.groupKeys[d.cursor]])
	}
	if d.cursor == len(d.groupKeys) {
		reachEnd = true
	}
	return prs, d.groupKeys[keyStart:d.cursor], reachEnd
}
384672
func getTask(res *http.Response, e error) (*Task, error) {
	if e != nil {
		return nil, e
	}
	var task Task
	err := json.NewDecoder(res.Body).Decode(&task)
	if err != nil {
		return nil, err
	}
	if task.State == "ERROR" {
		// Critical: return task as well, so that it can be examined
		// for error details.
		return &task, TaskError{task.ID, getFailedStep(&task)}
	}
	return &task, nil
}
504023
func (doc PluginDocument) GetRST() string {
	result := ""

	// Print top comment
	result += ".. Autogenerated by Gollum RST generator (docs/generator/*.go)\n\n"

	// Print heading
	result += doc.PluginName + "\n"
	result += strings.Repeat("=", len(doc.PluginName)) + "\n"

	// Print description
	result += "\n"
	result += docBulletsToRstBullets(doc.Description) + "\n"
	result += "\n"

	// Print native metadata
	if len(doc.Metadata.slice) > 0 {
		result += formatRstHeading("Metadata")
		result += doc.Metadata.getRST(false, 0)
	}

	// Print inherited metadata
	for _, parentName := range sortInheritedKeys(doc.InheritedMetadata) {
		if len(doc.InheritedMetadata[parentName].slice) == 0 {
			// Skip title for empty sets
			continue
		}
		result += formatRstHeading(
			"Metadata (from " + /* strings.TrimPrefix(*/ parentName /*, "core.") */ + ")")

		result += doc.InheritedMetadata[parentName].getRST(false, 0)
	}

	// Print native parameters
	if len(doc.Parameters.slice) > 0 {
		result += formatRstHeading("Parameters")
		result += doc.Parameters.getRST(true, 0)
	}

	// Print inherited parameters
	for _, parentName := range sortInheritedKeys(doc.InheritedParameters) {
		if len(doc.InheritedParameters[parentName].slice) == 0 {
			// Skip title for empty param sets
			continue
		}
		result += formatRstHeading(
			"Parameters (from " + /* strings.TrimPrefix(*/ parentName /*, "core.") */ + ")")
		result += doc.InheritedParameters[parentName].getRST(true, 0)
	}

	// Print config example
	if len(doc.Example) > 0 {
		result += formatRstHeading("Examples")
		codeBlock := false

		for _, line := range strings.Split(doc.Example, "\n") {

			if strings.Index(line, " ") == 0 {
				if !codeBlock {
					result += ".. code-block:: yaml\n\n"
					codeBlock = true
				}
			} else {
				if codeBlock {
					result += "\n"
					codeBlock = false
				}
			}

			if codeBlock {
				result += "\t" + line + "\n"
			} else {
				result += line + "\n"
			}
		}
	}

	return result
}
678713
func (tr *TaskRunner) handleTaskExitResult(result *drivers.ExitResult) (retryWait bool) {
	if result == nil {
		return false
	}

	if result.Err == bstructs.ErrPluginShutdown {
		dn := tr.Task().Driver
		tr.logger.Debug("driver plugin has shutdown; attempting to recover task", "driver", dn)

		// Initialize a new driver handle
		if err := tr.initDriver(); err != nil {
			tr.logger.Error("failed to initialize driver after it exited unexpectedly", "error", err, "driver", dn)
			return false
		}

		// Try to restore the handle
		tr.stateLock.RLock()
		h := tr.localState.TaskHandle
		net := tr.localState.DriverNetwork
		tr.stateLock.RUnlock()
		if !tr.restoreHandle(h, net) {
			tr.logger.Error("failed to restore handle on driver after it exited unexpectedly", "driver", dn)
			return false
		}

		tr.logger.Debug("task successfully recovered on driver", "driver", dn)
		return true
	}

	// Emit Terminated event
	tr.emitExitResultEvent(result)

	return false
}
1325783
func GetErrorAllDescriptors() []ErrorDescriptor {
	result := []ErrorDescriptor{}

	for _, group := range GetGroupNames() {
		result = append(result, GetErrorCodeGroup(group)...)
	}
	sort.Sort(byValue(result))
	return result
}
201175
func Wrap(task string, err error) Err {
	if err == nil {
		return nil
	}

	return NewError(task, err)
}
798074
func (e MultiError) LastError() error {
	if e.err == nil {
		return nil
	}
	return e.err
}
389113
func (a *allocNameIndex) Highest(n uint) map[string]struct{} {
	h := make(map[string]struct{}, n)
	for i := a.b.Size(); i > uint(0) && uint(len(h)) < n; i-- {
		// Use this to avoid wrapping around b/c of the unsigned int
		idx := i - 1
		if a.b.Check(idx) {
			a.b.Unset(idx)
			h[structs.AllocName(a.job, a.taskGroup, idx)] = struct{}{}
		}
	}

	return h
}
676896
func IndexRect(a string) (min, max []float64) {
	r := grect.Get(a)
	return r.Min, r.Max
}
447197
func (q *LinkedBlockingDeque) PeekFirst() interface{} {
	var result interface{}
	q.lock.Lock()
	if q.first == nil {
		result = nil
	} else {
		result = q.first.item
	}
	q.lock.Unlock()
	return result
}