Interface DatamartContext.DataLoader

All Superinterfaces:
AutoCloseable
Enclosing interface:
DatamartContext

public static interface DatamartContext.DataLoader extends AutoCloseable
API for loading data into a DMDataFeed or DMTable from a formula context. Safe to use outside of a PA DataLoad context.

Example:


     def ctx = api.getDatamartContext()
     def df = ctx.getDataFeed("Contract_Log")
     def loader = ctx.newDataLoader(df, "ApprovalDate", "ApprovalUser",...)
     try {
         loader.addRow(approvalDate, approvalUser, ...)
         loader.flush() // force to flush the already added data in the data feed
         loader.addRow(approvalDate, approvalUser, ...)
         [...]
     } finally {
         loader.close() // ensure all added rows have been flushed, ensure indexes are up-to-date and release all the resources
     }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRow(Object... values)
    Adds a row to the data buffer that will ultimately be loaded in the feed table.
    void
    addRow(List<Object> rowAsList)
    Adds a row to the data buffer that will ultimately be loaded in the feed table.
    void
    addRow(Map<String,Object> rowAsMap)
    Adds a row to the data buffer that will ultimately be loaded in the feed table.
    void
    Ensure all already added row has been flushed and release all the resources.
    void
    Flushes the data to the DB.
    void
    When calling addRow(Map), maps the value for the given source fields to the corresponding target fields (the latter being the fields in the target FC being populated).
  • Method Details

    • addRow

      void addRow(Map<String,Object> rowAsMap)
      Adds a row to the data buffer that will ultimately be loaded in the feed table.
      Parameters:
      rowAsMap - Row to add in a map of (field,value) pairs format.
    • addRow

      void addRow(List<Object> rowAsList)
      Adds a row to the data buffer that will ultimately be loaded in the feed table.
      Parameters:
      rowAsList - Row to add as a list of values matching the header fields order.
    • addRow

      void addRow(Object... values)
      Adds a row to the data buffer that will ultimately be loaded in the feed table.
      Parameters:
      values - Row to add as an array of values matching the header fields order.
    • flush

      void flush()
      Flushes the data to the DB. This is in addition to the implicit flush that occurs when the internal buffer fills up. The internal buffer size is determined by the datamart.dataLoad.maxRowsPerBatch Pricefx node instance parameter, with a default value of 100k rows.
    • setMapping

      void setMapping(Map<String,String> mapping)
      When calling addRow(Map), maps the value for the given source fields to the corresponding target fields (the latter being the fields in the target FC being populated).
      Parameters:
      mapping - [sourceField.name → targetField.name] map
    • close

      void close()
      Ensure all already added row has been flushed and release all the resources. Once close has been called any subsequent call to addRow(List), addRow(Map), addRow(Object...), setMapping(Map) or flush() will raise an exception.
      Specified by:
      close in interface AutoCloseable