/AWS1/IF_TSW=>WRITERECORDS()¶
About WriteRecords¶
Enables you to write your time-series data into Timestream. You can specify a single data point or a batch of data points to be inserted into the system. Timestream offers you a flexible schema that auto detects the column names and data types for your Timestream tables based on the dimension names and data types of the data points you specify when invoking writes into the database.
Timestream supports eventual consistency read semantics. This means that when you query data immediately after writing a batch of data into Timestream, the query results might not reflect the results of a recently completed write operation. The results may also include some stale data. If you repeat the query request after a short time, the results should return the latest data. Service quotas apply.
See code sample for details.
Upserts
You can use the Version parameter in a WriteRecords request to
update data points. Timestream tracks a version number with each record.
Version defaults to 1 when it's not specified for the record
in the request. Timestream updates an existing record’s measure value along with
its Version when it receives a write request with a higher
Version number for that record. When it receives an update request where
the measure value is the same as that of the existing record, Timestream still
updates Version, if it is greater than the existing value of
Version. You can update a data point as many times as desired, as long as
the value of Version continuously increases.
For example, suppose you write a new record without indicating Version in
the request. Timestream stores this record, and set Version to
1. Now, suppose you try to update this record with a
WriteRecords request of the same record with a different measure value but,
like before, do not provide Version. In this case, Timestream will
reject this update with a RejectedRecordsException since the updated record’s
version is not greater than the existing value of Version.
However, if you were to resend the update request with Version set to
2, Timestream would then succeed in updating the record’s value,
and the Version would be set to 2. Next, suppose you sent a
WriteRecords request with this same record and an identical measure value,
but with Version set to 3. In this case, Timestream
would only update Version to 3. Any further updates would need to
send a version number greater than 3, or the update requests would receive a
RejectedRecordsException.
Method Signature¶
METHODS /AWS1/IF_TSW~WRITERECORDS
IMPORTING
!IV_DATABASENAME TYPE /AWS1/TSWRESOURCENAME OPTIONAL
!IV_TABLENAME TYPE /AWS1/TSWRESOURCENAME OPTIONAL
!IO_COMMONATTRIBUTES TYPE REF TO /AWS1/CL_TSWRECORD OPTIONAL
!IT_RECORDS TYPE /AWS1/CL_TSWRECORD=>TT_RECORDS OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_tswwriterecordsrsp
RAISING
/AWS1/CX_TSWACCESSDENIEDEX
/AWS1/CX_TSWINTERNALSERVEREX
/AWS1/CX_TSWINVALIDENDPOINTEX
/AWS1/CX_TSWREJECTEDRECORDSEX
/AWS1/CX_TSWRESOURCENOTFOUNDEX
/AWS1/CX_TSWTHROTTLINGEX
/AWS1/CX_TSWVALIDATIONEX
/AWS1/CX_TSWCLIENTEXC
/AWS1/CX_TSWSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_databasename TYPE /AWS1/TSWRESOURCENAME /AWS1/TSWRESOURCENAME¶
The name of the Timestream database.
iv_tablename TYPE /AWS1/TSWRESOURCENAME /AWS1/TSWRESOURCENAME¶
The name of the Timestream table.
it_records TYPE /AWS1/CL_TSWRECORD=>TT_RECORDS TT_RECORDS¶
An array of records that contain the unique measure, dimension, time, and version attributes for each time-series data point.
Optional arguments:¶
io_commonattributes TYPE REF TO /AWS1/CL_TSWRECORD /AWS1/CL_TSWRECORD¶
A record that contains the common measure, dimension, time, and version attributes shared across all the records in the request. The measure and dimension attributes specified will be merged with the measure and dimension attributes in the records object when the data is written into Timestream. Dimensions may not overlap, or a
ValidationExceptionwill be thrown. In other words, a record must contain dimensions with unique names.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_tswwriterecordsrsp /AWS1/CL_TSWWRITERECORDSRSP¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->writerecords(
io_commonattributes = new /aws1/cl_tswrecord(
it_dimensions = VALUE /aws1/cl_tswdimension=>tt_dimensions(
(
new /aws1/cl_tswdimension(
iv_dimensionvaluetype = |string|
iv_name = |string|
iv_value = |string|
)
)
)
it_measurevalues = VALUE /aws1/cl_tswmeasurevalue=>tt_measurevalues(
(
new /aws1/cl_tswmeasurevalue(
iv_name = |string|
iv_type = |string|
iv_value = |string|
)
)
)
iv_measurename = |string|
iv_measurevalue = |string|
iv_measurevaluetype = |string|
iv_time = |string|
iv_timeunit = |string|
iv_version = 123
)
it_records = VALUE /aws1/cl_tswrecord=>tt_records(
(
new /aws1/cl_tswrecord(
it_dimensions = VALUE /aws1/cl_tswdimension=>tt_dimensions(
(
new /aws1/cl_tswdimension(
iv_dimensionvaluetype = |string|
iv_name = |string|
iv_value = |string|
)
)
)
it_measurevalues = VALUE /aws1/cl_tswmeasurevalue=>tt_measurevalues(
(
new /aws1/cl_tswmeasurevalue(
iv_name = |string|
iv_type = |string|
iv_value = |string|
)
)
)
iv_measurename = |string|
iv_measurevalue = |string|
iv_measurevaluetype = |string|
iv_time = |string|
iv_timeunit = |string|
iv_version = 123
)
)
)
iv_databasename = |string|
iv_tablename = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lo_recordsingested = lo_result->get_recordsingested( ).
IF lo_recordsingested IS NOT INITIAL.
lv_integer = lo_recordsingested->get_total( ).
lv_integer = lo_recordsingested->get_memorystore( ).
lv_integer = lo_recordsingested->get_magneticstore( ).
ENDIF.
ENDIF.