ResultHandle

class ResultHandle()

This class represents an Array-like object that’s a handle on a job’s results.

It’s used to access the job’s results, or to query the scheduler to fetch results. Besides the properties and methods of this class, the following standard array methods are also available for accessing the available results: slice, filter, concat, find, findIndex, indexOf, map, reduce, includes, toString, and forEach. One can access the results by index (results[i]), but the class throws an error if the result for that index isn’t yet available.

Instantiated by Job() methods Job.exec() and Job.localExec().

Attributes

length

ResultHandle.length
Type:

number

The length of the array of available results.

Methods

entries

entries()

Returns an array of [input, output] pairs, in the same order the data appears in the input set. Each input is paired with its associated output produced from the slice it was used in.

Return type:

Array<any>

fromEntries

fromEntries()

Returns an Object associating entries()’s input with output, for all elements in the input set where input is an ES5 primitive type (other elements are silently excluded). Equivalent to Object.fromEntries(results.entries()).

Return type:

object

fetch

fetch(rangeObject, emitEvents)

Sends a request to the scheduler to fetch results corresponding to the slice numbers in rangeObject (or all results, if omitted). The results will then be stored in the ResultHandle() object.

Arguments:
  • rangeObject (RangeObject) – Optional. A RangeObject() (or the whole set, if omitted) selecting which slice numbers’ results to fetch.

  • emitEvents (boolean|string) – If true, result events are emitted for every slice that wasn’t already present in the result handle; if set to ‘all’, a result event is emitted for every slice, including ones already present.

list

list(rangeObject)

Local-only – no scheduler request is made. Returns a SparseRangeObject() of the slice numbers, within rangeObject (or the whole set, if omitted), whose results are already present in this result handle.

Arguments:
Return type:

SparseRangeObject

key

key(n)

Returns the nth input value in the input set.

Arguments:
  • n (number) – index of the desired input value in the input set.

Return type:

any

keys

keys()

Returns an array of all input values that have a completed result available.

Return type:

Array<any>

lookupValue

lookupValue(key)

Given an input value as a key from a completed slice, returns its associated result.

Arguments:
  • key (any) – Corresponds to a value in the job’s input set.

Return type:

any

values

values()

Results an array of all results received from the scheduler.

Return type:

Array<any>

Note

There is no delete() method. stat() also exists, but is an unconditional stub that always throws "ResultHandle.stat not implemented".