Spring Java configuration for cubes
The cube configuration is now performed with Java.
Cube tuning
The partial providers and the cache configurations are available on the class AggregateProviderConfig
. This class is intended to be modified or overridden to customize this configuration. There is one function per cube. The cubes are defined by the @Qualifier
on each function declaration.
Adding hierarchies
Adding a single field to a datastore
A single field can be added to any store by overriding the class DatastoreCustomisations
with this kind of code :
DatastoreHelper.appendField(IMA_DRC_STORE_NAME, new CustomField("dummy", DOUBLE));
Adding an extra store
To add an extra store you must override the DatastoreConfig
class. For instance, to add a "Sample" store :
@Configuration @Import(value = { MyDatastoreConfig.MyConcreteDatastoreConfig.class, DatastoreConfig.DummyDatastoreConfig.class }) public class MyDatastoreConfig { @Configuration @Profile("!" + FRTBEnvConstants.SP_PROFILE__QUERY_NODE) // Do not forget it public static class MyConcreteDatastoreConfig extends DatastoreConfig.ConcreteDatastoreConfig { @Bean public IStoreDescription SampleStore() { return new StoreDescriptionBuilder() .withStoreName("Sample") .withField(AS_OF_DATE, STORE_DATE_FIELD_FORMAT).asKeyField() // Must have it .withField("ID").asKeyField() .withField("value") .build(); } private IReferenceDescription getSampleReference() { return ReferenceDescription .builder() .fromStore(IMADatastoreConfig.IMA_TRADES_STORE_NAME) .toStore("Sample") .withName("dummyLink") .withMapping(AS_OF_DATE, AS_OF_DATE) .withMapping(IMADatastoreConfig.IMA_TRADES_STORE_TRADE_ID, "ID") .build(); } @Override // @Bean // the overridden method already have it ... public IDatastoreSchemaDescription schemaDescription() { IDatastoreSchemaDescription desc = super.schemaDescription(); ((Collection<IStoreDescription>)desc.getStoreDescriptions()).add(SampleStore()); ((Collection<IReferenceDescription>)desc.getReferenceDescriptions()).add(getSampleReference()); return desc; } } }
You also need to populate the store by defining the ETL:
@Profile("!" + FRTBEnvConstants.SP_PROFILE__QUERY_NODE) // Must have it @Configuration public class MySourceConfig extends SourceConfig { //@Bean // the overridden method already have it ... //@DependsOn({ "startManager" }) // the overridden method already have it ... @Override public Void populateStoreLists() { super.populateStoreLists(); STORES.add(new ChannelParameters("Sample", "Sample","Sample.file-pattern", null)); // Sample.file-pattern return null; } }
The schema selection description
In order for a cube to use a field, that field must be on the cube's selection. By default, you make a selection by selecting all but the unnecessary fields of a store. Adding a field to a store will automatically put it on the selection.
To add an entire store to the selection, you must define a bean with the following signature that describes the fields to add :
@Qualifier("SchemaSelection[...theCubeName...]") @Bean UnaryOperator<CanUseOtherReference> extraSchemaSelections() { return builder -> builder .usingReference(...) .withAllFields() .except(...); }
Adding extra dimensions to a cube
An extra dimension can be added to any cube by defining a specific bean with the following signature and a specific qualifier :
@Qualifier("Dimensions[...theCubeName...]") @Bean public DimensionsAdder dimensions() { return builder -> builder .withDimension(...) ... ... }
All cube dimensions are defined in the java configuration file CubesDimensionsConfig
.
Disabling a cube
Each cube is defined by a specific bean:
-
SACubeConfigurer
-
IMACubeConfigurer
-
IMASummaryCubeConfigurer
-
IMADRCCubeConfigurer
-
IMADRCSummaryCubeConfigurer
-
PLCubeConfigurer
-
PLSummaryCubeConfigurer
-
CombinedCubeConfigurer
To remove a cube, remove its configuration from the FRTBConfig
list of included spring configuration.
The combined cube case
A disabled cube should be removed from the combined cube. To do so, you must remove the disabled cube's reference from the application list defined in the function protected Map CombinedCubeConfigurer.getDistributedApps()
.
Some metrics of the combined cube may depend on the disabled data cube and its removal may make the combined cube fail. Those metrics are defined in the combined cube metrics configuration file : CombinedMeasureBuilder
.
Adding KPIs
A KPI can be defined as a bean with the following format :
@Bean @Qualifier("kpi[...theCubeName...]") public IKpiDescription myKpiTest() { return StartBuilding.kpi() .withName(...) ... .build(); }
Pre-defined KPIs are located in the KpiProviderConfig
class .
Copyright © 2022 ActiveViam Ltd. All rights reserved.