GuidesTypeScript API ReferencePython v2 API Reference
Guides

How to get partition metadata from an index layer

This example shows how to read partition metadata and partition data from an index layer on Node.js using HERE Data SDK for TypeScript.

Build and run an app on Node.js

Before you build an app, make sure that you installed all of the dependencies.

To build and run an app on Node.js:

  1. Create an npm project.
mkdir example-app && cd example-app && npm init
  1. Initialize a TypeScript project.
tsc --init
  1. Install node types.
npm install --save-dev @types/node
  1. Install the SDK modules.
npm install --save @here/olp-sdk-authentication @here/olp-sdk-dataservice-read @here/olp-sdk-dataservice-api

Now, everything is set to create the app. 5. Create the index.ts file and app skeleton.

/**
 * Example of the Node.js app used for reading an index layer from the datastore.
 */

class App {
  run() {
    console.log("App works!");
  }
}

const app = new App();
app.run();
  1. Compile and run the app.
tsc && node .

After a successful run, the console displays the following message:

App works!

Create IndexLayerClient

You can use the IndexLayerClient object to request any data and partition metadata from an index layer.

To create the IndexLayerClient object:

  1. Create the OlpClientSettings object.

For instructions, see Create platform client settings.

  1. Create a IndexLayerClient instance with IndexLayerClientParams that contains the HERE Resource Name (HRN) of the catalog that contains the layer, layer ID, and platform client settings from step 1.
  const indexLayerClient = await new IndexLayerClient({
    catalogHrn: HRN.fromString("your-catalog-hrn"),
    layerId: "your-layer-id",
    settings: olpClientSettings,
  });

Get partition metadata from an index layer

Partition metadata from an index layer consists of the following information about the partition:

  • ID (data handle)
  • Data size
  • Checksum
  • Metadata
  • Timestamp

To get partition metadata from the index layer:

  1. Create the IndexLayerClient object.
  2. Create the IndexQueryRequest object with the RSQL query string and, if the query string is huge, set the huge boolean parameter to true.
📘

Note

The huge parameter is optional, and its default value is false.

const request = new IndexQueryRequest()
  .withQueryString("RSQL string query")
  .withHugeResponse(true);
  1. Call the getPartitions method with the IndexQueryRequest parameter.
const partitions = await indexLayerClient.getPartitions(request);

You get the partition metadata filtered by the RSQL query.

In browser and Node.js, to abort requests before they have completed, you can create the AbortController object, and then add the AbortController.signal property to your requests. For more information, see the AbortController documentation.

Example:

const abortController = new AbortController();
const partitions = await indexLayerClient.getPartitions(request),
  abortController.signal
);

Get data from an index layer

For more information, see How to get data from an index layer.