Datastore Customisation Examples

This page collects common patterns for customising the Atoti CVA Risk Capital datastore. Each example uses the IDatastoreConfigurator instance API on the configurator passed to addModifications(). The techniques shown can be combined and adapted to any project-specific need.

Where customisations live

All project-specific customisations are defined in the addModifications() method of DatastoreCustomisationsConfig at cvarc-application/src/main/java/com/activeviam/cvarc/application/cfg/DatastoreCustomisationsConfig.java. This class lives in your project’s cvarc-application module and is intended to be edited directly.

@Override
public void addModifications(IDatastoreConfigurator configurator) {
    // Field, reference, and store-configuration customisations go here.
}

IDatastoreConfigurator exposes three families of operations:

  • Field customisations — insert, append, update, and remove fields on existing stores.
  • Reference mapping customisations — add or remove field mappings on existing references.
  • Store configuration customisations — partitioning, chunk sizes, indexes, NUMA selector, duplicate-key handling, and other per-store settings.

Each method has two overloads: one that takes a schema name as the first argument (scoping the modification to a single schema), and one that applies the modification to any matching store across all enabled schemas.

The order of precedence for store configuration is: per-store config > multi-store config > default config. Conflicts between modifications are resolved chronologically — the last call wins. Indexing and partitioning calls are keyed by the input fields, so multiple distinct indexes/partitions on different field sets coexist.

Field customisations

Insert two fields into a store, after named fields

Map<String, CustomField> customFields = new HashMap<>();
customFields.put("TradeId",  new CustomField("TradeLeg", ILiteralType.STRING).asKeyField());
customFields.put("TradeLeg", new CustomField("Theta",    ILiteralType.DOUBLE).asNullable());

configurator.insertFields("TradeStore", customFields);

The map keys are the names of the existing fields after which each new field should be inserted. Use DatastoreConfigurator.PREPEND as the key to insert at the beginning of the store.

Append a vector field to the end of a store

configurator.appendField(
        "Delta",
        new CustomField("Interpolated Delta", ILiteralType.DOUBLE, new double[]{-1.0})
                .asVectorField()
                .swap());

Remove a field from a store

configurator.removeField("TradePnLs", "RiskClass");

Update a field’s type or attributes

configurator.updateField(
        "TradeStore",
        new CustomField("TradeLeg", ILiteralType.DOUBLE).asKeyField());

Reference mapping customisations

References between stores are created in the schema model classes (e.g. SADatastoreModelConfig.createReferences(...)). Use the configurator to add or remove individual mappings on those existing references — no need to redeclare the reference itself.

Add a field mapping to an existing reference

configurator.addReferenceMapping(
        "TradeStore",
        "MarketDataStore",
        new FieldMapping("TradeLeg", "TradeLeg"));

FieldMapping (com.activeviam.database.api.schema.ITableJoin.FieldMapping) takes the source field name and the target field name. FieldMapping.fromPair(IPair) is also available if you already have an IPair.

Remove field mappings from an existing reference

List<FieldMapping> mappingsToRemove = List.of(
        new FieldMapping("RiskClass",   "RiskClass"),
        new FieldMapping("RiskMeasure", "RiskMeasure"));

configurator.removeReferenceMappings("TradeBase", "Delta", mappingsToRemove);

Store configuration customisations

IMutableStore (typically instantiated via MutableStoreConfig) holds per-store configuration settings — indexes, chunk size, partitioning, NUMA selector, duplicate-key handler, etc. — to be merged with the store’s default configuration.

Per-store configuration with a global override

IMutableStore tradeAttributesConfig = new MutableStoreConfig();
tradeAttributesConfig
        .withIndexOn(StoreFieldNames.INSTRUMENT_CLASS, StoreFieldNames.AS_OF_DATE)
        .withChunkSize(2048);

IMutableStore globalConfig = new MutableStoreConfig();
globalConfig.withChunkSize(1024);

// per-store config — applies only to TRADE_ATTRIBUTE_STORE_NAME
configurator.addConfiguration(StoreNames.TRADE_ATTRIBUTE_STORE_NAME, tradeAttributesConfig);

// multi-store config — applies to every store named in the list
configurator.addConfiguration(List.of("StoreA", "StoreB"), globalConfig);

Per-store config wins over multi-store config when both touch the same property; multi-store config wins over the store’s default settings. Indexes and partitioning calls are merged across configurations rather than overridden, because they are keyed by the field set they target.

For more usage examples and the full reference of supported configuration options, see the Customising Schema with Configurator page in the Datastore Helper documentation.