Package net.pricefx.formulaengine
Interface DatamartContext.DataLoader
- All Superinterfaces:
AutoCloseable
- Enclosing interface:
DatamartContext
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 TypeMethodDescriptionvoid
Adds a row to the data buffer that will ultimately be loaded in the feed table.void
Adds a row to the data buffer that will ultimately be loaded in the feed table.void
Adds a row to the data buffer that will ultimately be loaded in the feed table.void
close()
Ensure all already added row has been flushed and release all the resources.void
flush()
Flushes the data to the DB.void
setMapping
(Map<String, String> mapping) When callingaddRow(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
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
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
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
When callingaddRow(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 toaddRow(List)
,addRow(Map)
,addRow(Object...)
,setMapping(Map)
orflush()
will raise an exception.- Specified by:
close
in interfaceAutoCloseable
-