The API
ActivePivot cube builder
Copper calculations are specified in the withCalculations(Consumer<ICopperContext>)
method available in the cube builder.
The entry point of Copper API is the "Copper context" or simply the "context", which is aware of the already defined measures and hierarchies. Copper measures and hierarchies are created with the API and then published to the context like so:
.withCalculations(context -> {
// Here you can describe your calculations with the context
})
The above snippet shows that all the Copper measures are defined in a single lambda method. For the sake of brevity, all examples from now on only show its body.
Once you have specified your calculations in the lambda, the new measures and hierarchies are added to the pivot description before it is started.
The Copper class provides all the static methods that serve as an entry point for measure and hierarchy creation. All created measures are objects that implement the same interface CopperMeasure
, representing the basic bricks of Copper calculations that give you access to methods to build more complex calculations.
Inside the lambda itself, you may also reuse previously published measures or hierarchies for subsequent Copper calculations (pseudo-code):
CopperMeasure m1 = Copper.method(); // Create a measure with a static method from the Copper class
m1.publish(context);
// m1 is now available in following calculations
CopperMeasure m2 = m1.function(); // Apply function() on m1 to create a new measure
m2.publish(context);
// m2 is now available in following calculations
All your measures can be declared within this lambda, in Copper, at the same place and in the same way. This includes CopperMeasures
, but also native measures, aggregated measures, as well as legacy post-processors.
Copper and distributed environments
For more information about ActivePivot's distributed architecture and its concepts, please refer to the following article about distribution. Currently, measures and hierarchies defined through the Copper API can only be defined on data cubes. Query-cube specific measures must be defined through other means such as the Post-processor API.
Copper-made measures can however be queried from any query node if these measures are defined on the underlying data nodes and exposed to the query node through the configuration of the cluster.