RemoteDataSet

class RemoteDataSet()

Wraps a list of URIs so that compute.for()/compute.do() can tell them apart from a plain Array of data. When a RemoteDataSet is used as the input set, each slice’s work function receives the fetched contents of the corresponding URI, not the URI itself.

Constructor

Form 1

new RemoteDataSet(uri1, uri2 /* , ..., uriN */);

Arguments:

  • uri (string|URL|DcpURL) - One or more URIs, passed as separate arguments. Each may be a regular URL string, a data: URL string, or a URL/DcpURL instance.

Form 2

new RemoteDataSet([uri1, uri2 /* , ..., uriN */]);

Identical to Form 1, except the URIs are passed as a single Array instead of separate arguments.

Both forms throw a DCPError if any URI isn’t a string, or a URL/DcpURL instance.

new is optional – RemoteDataSet(...) and new RemoteDataSet(...) behave identically.

Properties

length

RemoteDataSet.length
Type:

number

The number of URIs in the set. Each URI is also available as its own indexed, own-enumerable property (0, 1, … length - 1), matching the Array-like convention used elsewhere in the Compute API.

Example

const { RemoteDataSet } = require('dcp/compute');

const uris = ['http://abc.com/1.json', 'http://def.com/two.json'];

// Either form works:
const dataSet = new RemoteDataSet(...uris);
// const dataSet = new RemoteDataSet(uris);

const job = compute.for(dataSet, function (contents) {
  console.log(contents);
});
job.on('console', console.log);
await job.exec();