Skip to content

/AWS1/IF_SGF=>BATCHWRITERECORD()

About BatchWriteRecord

Writes a batch of Records to one or more FeatureGroups. Use this API for bulk ingestion of records into the OnlineStore and OfflineStore.

You can set the ingested records to expire at a given time to live (TTL) duration after the record's event time by specifying the TtlDuration parameter. A request level TtlDuration applies to all entries that do not specify their own TtlDuration.

Method Signature

METHODS /AWS1/IF_SGF~BATCHWRITERECORD
  IMPORTING
    !IT_ENTRIES TYPE /AWS1/CL_SGFBATCHWRITERECENTRY=>TT_BATCHWRITERECORDENTRIES OPTIONAL
    !IO_TTLDURATION TYPE REF TO /AWS1/CL_SGFTTLDURATION OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sgfbatchwriterecrsp
  RAISING
    /AWS1/CX_SGFACCESSFORBIDDEN
    /AWS1/CX_SGFINTERNALFAILURE
    /AWS1/CX_SGFRESOURCENOTFOUND
    /AWS1/CX_SGFSERVICEUNAVAILABLE
    /AWS1/CX_SGFVALIDATIONERROR
    /AWS1/CX_SGFCLIENTEXC
    /AWS1/CX_SGFSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

it_entries TYPE /AWS1/CL_SGFBATCHWRITERECENTRY=>TT_BATCHWRITERECORDENTRIES TT_BATCHWRITERECORDENTRIES

A list of records to write. Each entry specifies the FeatureGroup, the record data, and optionally target stores and a TTL duration.

Optional arguments:

io_ttlduration TYPE REF TO /AWS1/CL_SGFTTLDURATION /AWS1/CL_SGFTTLDURATION

Time to live duration applied to all entries in the batch that do not specify their own TtlDuration; ExpiresAt = EventTime + TtlDuration. For information on HardDelete, see the DeleteRecord API in the Amazon SageMaker API Reference guide.

RETURNING

oo_output TYPE REF TO /aws1/cl_sgfbatchwriterecrsp /AWS1/CL_SGFBATCHWRITERECRSP

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->batchwriterecord(
  io_ttlduration = new /aws1/cl_sgfttlduration(
    iv_unit = |string|
    iv_value = 123
  )
  it_entries = VALUE /aws1/cl_sgfbatchwriterecentry=>tt_batchwriterecordentries(
    (
      new /aws1/cl_sgfbatchwriterecentry(
        io_ttlduration = new /aws1/cl_sgfttlduration(
          iv_unit = |string|
          iv_value = 123
        )
        it_record = VALUE /aws1/cl_sgffeaturevalue=>tt_record(
          (
            new /aws1/cl_sgffeaturevalue(
              it_valueasstringlist = VALUE /aws1/cl_sgfvalueasstrlist_w=>tt_valueasstringlist(
                ( new /aws1/cl_sgfvalueasstrlist_w( |string| ) )
              )
              iv_featurename = |string|
              iv_valueasstring = |string|
            )
          )
        )
        it_targetstores = VALUE /aws1/cl_sgftargetstores_w=>tt_targetstores(
          ( new /aws1/cl_sgftargetstores_w( |string| ) )
        )
        iv_featuregroupname = |string|
      )
    )
  )
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  LOOP AT lo_result->get_errors( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      lo_batchwriterecordentry = lo_row_1->get_entry( ).
      IF lo_batchwriterecordentry IS NOT INITIAL.
        lv_featuregroupnameorarn = lo_batchwriterecordentry->get_featuregroupname( ).
        LOOP AT lo_batchwriterecordentry->get_record( ) into lo_row_2.
          lo_row_3 = lo_row_2.
          IF lo_row_3 IS NOT INITIAL.
            lv_featurename = lo_row_3->get_featurename( ).
            lv_valueasstring = lo_row_3->get_valueasstring( ).
            LOOP AT lo_row_3->get_valueasstringlist( ) into lo_row_4.
              lo_row_5 = lo_row_4.
              IF lo_row_5 IS NOT INITIAL.
                lv_valueasstring = lo_row_5->get_value( ).
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDLOOP.
        LOOP AT lo_batchwriterecordentry->get_targetstores( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_targetstore = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
        lo_ttlduration = lo_batchwriterecordentry->get_ttlduration( ).
        IF lo_ttlduration IS NOT INITIAL.
          lv_ttldurationunit = lo_ttlduration->get_unit( ).
          lv_ttldurationvalue = lo_ttlduration->get_value( ).
        ENDIF.
      ENDIF.
      lv_valueasstring = lo_row_1->get_errorcode( ).
      lv_message = lo_row_1->get_errormessage( ).
    ENDIF.
  ENDLOOP.
  LOOP AT lo_result->get_unprocessedentries( ) into lo_row_8.
    lo_row_9 = lo_row_8.
    IF lo_row_9 IS NOT INITIAL.
      lv_featuregroupnameorarn = lo_row_9->get_featuregroupname( ).
      LOOP AT lo_row_9->get_record( ) into lo_row_2.
        lo_row_3 = lo_row_2.
        IF lo_row_3 IS NOT INITIAL.
          lv_featurename = lo_row_3->get_featurename( ).
          lv_valueasstring = lo_row_3->get_valueasstring( ).
          LOOP AT lo_row_3->get_valueasstringlist( ) into lo_row_4.
            lo_row_5 = lo_row_4.
            IF lo_row_5 IS NOT INITIAL.
              lv_valueasstring = lo_row_5->get_value( ).
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
      LOOP AT lo_row_9->get_targetstores( ) into lo_row_6.
        lo_row_7 = lo_row_6.
        IF lo_row_7 IS NOT INITIAL.
          lv_targetstore = lo_row_7->get_value( ).
        ENDIF.
      ENDLOOP.
      lo_ttlduration = lo_row_9->get_ttlduration( ).
      IF lo_ttlduration IS NOT INITIAL.
        lv_ttldurationunit = lo_ttlduration->get_unit( ).
        lv_ttldurationvalue = lo_ttlduration->get_value( ).
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.

Write records to multiple feature groups

Write records to multiple feature groups

DATA(lo_result) = lo_client->batchwriterecord(
  it_entries = VALUE /aws1/cl_sgfbatchwriterecentry=>tt_batchwriterecordentries(
    (
      new /aws1/cl_sgfbatchwriterecentry(
        it_record = VALUE /aws1/cl_sgffeaturevalue=>tt_record(
          (
            new /aws1/cl_sgffeaturevalue(
              iv_featurename = |customer_id|
              iv_valueasstring = |cust-001|
            )
          )
          (
            new /aws1/cl_sgffeaturevalue(
              iv_featurename = |age|
              iv_valueasstring = |25|
            )
          )
        )
        iv_featuregroupname = |my-feature-group|
      )
    )
  )
).