ST_ExportTo

Updated at:
Copy as MD

Exports 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

ParameterDescription
trajThe trajectory object to export.
pathThe OSS folder path where the trajectory data is stored. Only OSS folders are supported. Format: 'OSS://<AccessKey ID>:<AccessKey secret>@<Endpoint>/<Bucket>/<Directory>'. The data is written to a .gtf file in the specified folder.
configA JSON string that configures the export behavior. See the following table for supported parameters.

config parameters

ParameterDefaultValid valuesDescription
compressnonenone, lz4, lzo, zstd, snappy, zlibThe compression algorithm for the exported data. zlib provides the highest compression ratio. zstd provides the highest overall efficiency.

Description

ST_ExportTo writes the time, space, event, and property data of a trajectory object to the specified OSS folder.

Endpoint configuration

Replace <Endpoint> with the OSS endpoint for the region where the trajectory data is stored. For best performance, deploy the ApsaraDB RDS for PostgreSQL instance in the same region as the OSS bucket. For a list of OSS endpoints, see OSS domain names.

Output file behavior

The binary data of a trajectory object is appended to a .gtf file in the specified folder. File names follow the format <sequence_number>_0_1.gtf, and files are sorted in descending order by sequence number. Each file is approximately 2 GB. To adjust the file size limit, set the ganos.trajectory.ext_storage_block_size parameter.

Append and deduplication logic

  • If a .gtf file already exists in the specified folder, the trajectory data is appended to that file.

  • If the trajectory data is already present in the specified OSS folder, the function skips the write and does not duplicate the data.

  • If the trajectory data is not present in the specified folder, the function reads the data from the database and writes it to the folder.

Data sync behavior

Deleting or updating trajectory data in the database does not update the corresponding OSS file. Conversely, modifying the OSS file directly can make the database data unavailable.

Examples

Export trajectory data from the trajs table to an OSS folder with no compression:

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