You can use this function to export the data of a trajectory object to a folder in an Object Storage Service (OSS) bucket.

Syntax

trajectory ST_ExportTo(trajectory traj, text path, text config);

Parameters

Parameter Description
traj The trajectory object.
path The string that specifies the folder in which you want to store the data of the specified trajectory object. Only folders in OSS are supported. The format of the parameter value is 'OSS://<AccessKey ID>:< AccessKey secret>@<Endpoint>/<Bucket>/<Directory>'. The data of the specified trajectory object is stored in a .gtf file in the specified folder.
config A JSON string. The following list describes the parameter in this string:
  • Parameter: compress
  • Default value: none
  • Valid values: none, lz4, lzo, zstd, snappy, and zlib

Description

This function stores the time, space, event, and property information of a specified trajectory object to the specified folder in OSS.

Replace <Endpoint> with the endpoint that you use to access OSS in the region where the trajectory data is stored. To ensure import performance, make sure that the PolarDB database is deployed in the same region as the OSS bucket. For more information, see OSS domain names.

The binary data of the trajectory object is appended to a .gtf file in the specified folder. The format of the .gtf file name is <Sequence number of the file>_0_1.gtf. The .gtf files in a folder are sorted in descending order by sequence number. The size of a single file is approximately 2 GB. The size is specified by the ganos.trajectory.ext_storage_block_size parameter.

If a .gtf file that stores the data of the specified trajectory object already exists in the specified folder, the system appends the data of the trajectory object to the existing .gtf file. If the data of the specified trajectory object is stored in a folder in OSS and the system detects that the trajectory data is already stored in the specified folder, the system does not write the data to the folder again. If the system detects that the trajectory data is not stored in the specified folder, the system reads the data and then writes the data to the folder.

If you delete or update the data in the database that stores the trajectory data, the data in the OSS file is not updated. If you update the data in the OSS file, the data in the database can become unavailable.

You can choose a compression algorithm based on your business requirements. The zlib algorithm provides the highest compression ratio. The zstd algorithm provides the highest overall efficiency.

Examples

update trajs
set traj = ST_exportTo(traj, 'OSS://<access key>:<access secret>@oss-cn-beijing-internal/<bucket>/<directory>', '{}');
UPDATE 113395