Skip to main content

Compiling and Building Cubes

This page describes how to compile and build Business Intelligence cubes.

Note:

During the build process, users cannot execute queries. (However, if a query is currently running, you can build the cube.)

When to Recompile and Rebuild

Note:

Upon upgrade from a previous version of InterSystems IRIS, it is best practice to recompile all cube and subject area classes, to take advantage of any new optimizations.

If you make any change to a cube class or a subject area class, you must recompile that class before those changes take effect. For many changes to a cube, you must also rebuild the cube before those changes take effect.

The following table lists the required actions after changes:

Element Type Type of Change Required Actions
Cube (root element) Edits to Name or Source class Recompile and rebuild
Filter Value Other changes that apply to the cube but not to specific elements in the cube Recompile
Measure Edits to the following options of an existing measure (many other elements have some or all of these common options).
  • Disabled

  • Hidden

  • Display name

  • Description

  • Format string

Recompile
Deleting measures Recompile
All other changes, including adding measures Recompile and perform a selective build for the changed measure(s), or recompile and perform a full cube rebuild
Dimension (not a computed dimension) Edits to the following options of an existing dimension:
  • Common options as listed in Measure

  • Enable the All level for this dimension

  • Caption for All member

  • Display name for All member

Recompile
Deleting dimensions Recompile
All other changes, including adding dimensions Recompile and perform a selective build for the levels that make up the changed dimension(s), or recompile and perform a full cube rebuild
Computed dimension All changes Recompile
NLP dimension All changes Recompile
Hierarchy Edits to the common options of an existing hierarchy (as listed in Measure) Recompile
Hierarchy All other changes, including adding and deleting hierarchies Recompile
Level Edits to the following options of an existing level:
  • Common options as listed in Measure

  • Null replacement string

  • Sort option

Recompile
Deleting levels Recompile
All other changes, including adding levels* Recompile and perform a selective build for the changed level(s), or recompile and perform a full cube rebuild
Property Edits to the following options of an existing property:
  • Common options as listed in Measure

  • Sort members by property value

Recompile
Property All other changes, including adding and deleting properties Recompile and rebuild
Listing All changes Recompile
Calculated member All changes Recompile
Named set All changes Recompile
Subject area All changes Recompile
Compound cube (a kind of subject area) All changes Recompile (after recompiling all cubes used in the compound cube)
Quality measure All changes Recompile the quality measure class
KPI or plug-in All changes Recompile the KPI or plug-in class

*The current server locale determines the names of members of a time dimension. (See Using the Locale to Control the Names of Time Members.) If you change the locale, it is necessary to recompile and rebuild the cube.

When you delete a dimension or a level and recompile, that does not delete the associated level tables and indexes. Rebuilding the cube also does not delete the no-longer-needed level tables and indexes.

Compiling a Cube

To compile a cube class in the Architect:

  1. Click Compile.

    The system starts to compile the class and displays a dialog box that shows progress.

    If you have made changes that you have not yet saved, the system saves them before compiling the cube.

  2. Click OK.

Or open the cube class in an IDE and compile it in the same way that you compile other classes.

When you compile a cube class, the system automatically generates the fact table and all related classes if needed. If the fact table already exists, the system regenerates it only if it is necessary to make a structural change.

If there are any cached results for this cube, the system purges them.

Building a Cube

The phrase building a cube refers to two tasks: adding data to the fact table and other tables and building the indexes used to access this data.

To perform a full cube build in the Architect:

  1. Click Build.

    The system displays a dialog box.

    Note that the Build option may be greyed out. In this case, you must compile the cube before performing a build.

  2. Optionally specify a value for Maximum Number of Records to Build.

    By default, the system iterates through all records in the source table and builds the same number of records to the fact table. You can override this behavior when you build the cube. If you specify the Maximum Number of Records to Build option, the system iterates through only that number of records. The result is a smaller fact table that the system builds more quickly.

    If the Maximum Number of Records to Build field is initialized with a number, that means that the cube class overrides the default behavior. (For details, see the maxFacts attribute for <cube> in Reference Information for Cube Classes.) In this case, you can either use the value provided by the cube class or enter a smaller value.

  3. Select Build Everything in the Build Option section of the dialog box.

  4. Click Build.

    The system starts to build the cube and displays progress as it does so. The Compile button is deactivated (greyed out) for the duration of the build.

    Note:

    Clicking the Close button during the build process does not interrupt the build process. You may reopen it at any time to see the current state of any build which is currently in progress. If the build completes while the dialog is closed, the dialog will reappear to notify the user of build completion.

  5. Click Done.

The cube is then available for use as described in Using the Analyzer.

Using Selective Build

You can use the Selective Build feature to build certain elements in a cube without rebuilding the entire cube and experiencing the attendant downtime. For example, if you recently made changes to a specific dimension or have source data changes that affect only one dimension, you can use Selective Build to build the relevant levels in that dimension. You can also use Selective Build to build a recently added level, measure, or relationship.

You can use Selective Build to build specific levels, measures, or relationships in a cube. More specifically, when you use Selective Build, columns in the fact tables (which each correspond to a level, measure, or relationship) are built. Using Selective Build on a cube does not trigger a need to update that cube’s dependent cubes.

A cube may inherit elements of its definition from another cube. When Selective Build is enabled for a cube inherited by another, the inheriting cube is able to read the designated factNumbers in the supercube definition and assign factNumbers to the subcube definition accordingly. The subcube does not assume that the factNumbers of the supercube remain the same, and therefore regenerates all of its own factNumbers. This protects the current cube from any changes in the supercube that might have been assigned a factNumber that conflicts with a compiled factNumber in the current cube.

Implications of Selective Build

When a selective build is taking place, only the cube elements that are being built are unavailable for queries. Selective Build and cube synchronization cannot happen simultaneously, so while the cube is not entirely inactive as in a full build, cube synchronization is unavailable while a selective build is taking place, and vice versa. Any significant build operation can block a planned synchronize. Furthermore, selective builds take longer than full builds, so budget time accordingly.

Important:

Selective build attempts to synchronize the cube at the end of the main build procedure. Synchronization prevents any mismatch between your current source data and any columns in the fact table which you excluded from the selective build.

For this reason, InterSystems recommends using selective build only for cubes where synchronization is possible. If you perform a selective build on a cube where synchronization is not possible, you must subsequently perform a full build to ensure the accuracy of columns which were excluded from the selective build.

Multiple selective builds may run at the same time. In this case, each selective build will only build its selected cube elements. You can build multiple columns at once with Selective Build, but you cannot build any column more than once at the same time.

The system handles Selective Build errors the same way it handles errors for full cube builds.

If you implement %OnProcessFact() to process facts in a cube conditionally based on the value of a certain level or measure, that level or measure must be included in a Selective Build of that cube. Otherwise, the Selective Build will yield errors.

Using Selective Build in the Architect

Selective Build is automatically enabled for all cubes. You must compile your cube before you can use Selective Build.

The following procedure provides an example of using the Selective Build feature:

  1. Navigate to the Analyzer and open the HoleFoods cube.

  2. In the Model Contents pane, expand the Outlet dimension, then expand the Region level. Drag the Region level over to the Rows area. Observe the resulting pivot table.

  3. Next, open the Architect. Click the Region level of the Outlet dimension in the Model Viewer.

  4. In the Details Area to the right, under Source Values, select Expression. Enter the following in the Expression text box:

    %source.Outlet.Country.Region.%ID _ "-" _ %source.Outlet.Country.Region.Name
    
  5. Compile the HoleFoods cube.

  6. Click Build. When the Build Cube dialog appears, note that the system automatically detects that the [Outlet].[H1].[Region] level has changed and preselects a Selective Build for [Outlet].[H1].[Region]. Click Build.

  7. Navigate back to the Analyzer. In the Model Contents pane, expand the Outlet dimension, then expand the Region level. Drag the Region level over to the Rows area. Observe that the resulting pivot table and note the differences for the Region level.

Building the Cube Programmatically

To build the cube programmatically, execute the %BuildCube()Opens in a new tab class method of the %DeepSee.UtilsOpens in a new tab class. This method has the following signature:

classmethod %BuildCube(pCubeName As %String, pAsync As %Boolean = 1,  pVerbose As %Boolean = 1, 
                        pIndexOnly As %Boolean = 1, pMaxFacts As %Boolean = 0, pTracking As %Boolean = 0, 
                        ByRef pBuildStatistics As %String = "", pFactList As %String) as %Status

Where:

  • pCubeName is the logical name of the cube as given in its XData block; this is not case-sensitive.

  • pAsync controls whether the system performs the build in multiple background processes. If this argument is true, the system uses multiple processes and does not return until they are all complete. If this argument is false, the system uses a single process and does not return until it is complete.

    Note:

    If you have specified the cube option Initial build order, the system ignores the value of pAsync and uses a single process to build the cube. These options are described in Specifying Cube Options.

    Caution:

    Custom code for build processes must not invoke HALT. Terminating a DeepSee agent may cause a cascade of lower priority agent terminations and result in the build hanging due to a lack of available agents for new tasks.

  • pVerbose controls whether the method writes status information. If this argument is 1, the system writes status updates to the command line. (This argument does not affect whether the method writes build errors or other logging information.)

  • pIndexOnly controls whether the method only updates the indexes. If this argument is 1, the system only updates the indexes of the fact table.

  • pMaxFacts specifies the maximum number of rows in the fact table. This determines the number of rows of the base table that the system uses when building the cube.

    If pMaxFacts is 0, the default, all rows of the base table are processed.

  • pTracking is for internal use.

  • pBuildStatistics returns an array of information about the cube build. This array has the following nodes:

    Node Value
    pBuildStatistics(“elapsedTime”) Elapsed build time, in seconds.
    pBuildStatistics(“errors”) Number of build errors.
    pBuildStatistics(“factCount”) Number of facts that were built and indexed.
    pBuildStatistics(“missingReferences”) Number of missing references.
    pBuildStatistics(“expressionTime”) Time spent processing sourceExpressions to build the cube elements.
    pBuildStatistics(“iKnowTime”) Time spent building NLP indexes.
  • pFactList is a list of specific Property names in the cube's fact class. If pFactList is supplied, the build will only update the columns listed in that fact list. This list can have either comma-delimited or $LB format. The specific facts being updated will be individually marked as unavailable for queries and queries referencing dimensions based on those facts will throw an error on prepare.

This method returns a status. If errors occur during the cube build, the status code indicates the number of build errors.

For example:

 set status = ##class(%DeepSee.Utils).%BuildCube("patients")

This method writes output that indicates the following information:

  • Number of processors used.

  • Total elapsed time taken by the build process

  • Total amount of time spent evaluating source expressions, summed across all processors.

For example:

 
Building cube [patients]
Existing cube deleted.
Fact table built:        1,000 fact(s) (2 core(s) used)
Fact indexes built:      1,000 fact(s) (2 core(s) used)
Complete
Elapsed time:                  1.791514s
Source expression time:        0.798949s

If Source expression time seems too high, you should re-examine your source expressions to be sure that they are as efficient as possible; in particular, if the expressions use SQL queries, double-check that you have the appropriate indexes on the tables that the queries use.

Cube Build Status

If there is a build in progress, you can monitor its progress using the %BuildStatus()Opens in a new tab method. In the Terminal, call:

  DO ##class(%DeepSee.Utils).%BuildStatus("cubeName")

%BuildStatus() reports on the progress of a build regardless of whether you initiated the build programmatically or using the Architect. If there is no build in progress, %BuildStatus() displays the timestamp of the most recent build: There is no build in progress. Last build was finished on 06/23/2020 11:31:07.

The build dialog in the Architect also reports on the progress of builds which are initiated programmatically.

Minimizing Cube Size During Development

While you are developing a cube, you typically recompile and rebuild it frequently. If you are using a large data set, you might want to limit the number of facts in the fact table, in order to force the cube to be rebuilt more quickly. To do this, do one of the following:

Note that all these options are ignored during a selective build.

Using Parallel Processing During a Cube Build

If all the following items are true, the system uses multiple cores to perform the build:

When you build a cube asynchronously, the system sets up %SYSTEM.WorkMgrOpens in a new tab agents to do the work, if it is possible to use parallel processing.

Note:

These agents are also used to execute queries.

On rare occasions, you might need to reset these agents. To do so, use the %Reset()Opens in a new tab method of %DeepSee.UtilsOpens in a new tab. This method also clears any pending tasks and clears the result cache for the current namespace, which would have an immediate impact on any users. This method is intended for use only during development.

Build Errors

When you build a cube, pay attention to any error messages and to the number of facts that it builds and indexes. This section discusses the following topics:

For more information on troubleshooting options, see the InterSystems Developer CommunityOpens in a new tab.

Seeing Build Errors

When you build a cube in the Architect or in the Terminal, the system indicates if there are any build errors but does not show all of them. To see all the recorded build errors, do either of the following:

  • Look for the log file install-dir/mgr/DeepSeeUpdate_cube_name_NAMESPACE.log, where cube_name is the name of the cube, and NAMESPACE is the namespace in which this cube is defined.

    The time stamp in this file uses $NOW to write the local date and time, ignoring daylight saving time.

  • Use the %PrintBuildErrors()Opens in a new tab method of %DeepSee.UtilsOpens in a new tab, as follows:

    do ##class(%DeepSee.Utils).%PrintBuildErrors(cubename)
    

    Where cubename is the logical name of the cube, in quotes.

    This method displays information about all build errors. For example (with added line breaks):

    SAMPLES>do ##class(%DeepSee.Utils).%PrintBuildErrors("holefoods")
        1 Source ID: 100000
          Time: 05/09/2019 14:12:52
          ERROR #5002: ObjectScript error: <DIVIDE>%UpdateFacts+106^HoleFoods.Cube.Fact.1
        2 Source ID: 200000
          Time: 05/09/2019 14:12:41
          ERROR #5002: ObjectScript error: <DIVIDE>%UpdateFacts+106^HoleFoods.Cube.Fact.1
        3 Source ID: 300000
          Time: 05/09/2019 14:13:13
          ERROR #5002: ObjectScript error: <DIVIDE>%UpdateFacts+106^HoleFoods.Cube.Fact.1
        ...
        10 build error(s) for 'holefoods'
    
Important:

In some cases, the system might not generate an error, so it is important to also check the fact count as discussed in the next section.

Checking the Fact Count

When you build a cube, the system reports the number of facts that it builds and indexes.

Each fact is a record in the fact table. The fact table should have the same as the number of records in the base table, except in the following cases:

Also, when the system builds the indexes, the index count should equal the number of records in the fact table. For example, the Architect should show the same number for Building facts and for Building indexes. If there is a discrepancy between these numbers, check the log files.

Possible Causes of Build Errors

If you see build errors or unexplained discrepancies in the fact count, do the following:

  1. Examine any levels that use range expressions, and verify that these levels do not drop records. See Validating Your Levels.

    An error of this kind affects the index count but not the fact count.

  2. Try disabling selected dimensions or measures. Then recompile and rebuild to isolate the dimension or measure that is causing the problem.

<STORE> Errors

In some cases, the build log might include errors like the following:

ERROR #5002: ObjectScript error: <STORE>%ConstructIndices+44^Cube.cube_name.Fact.1

This error can occur when a level has a very large number of members. By default, when the system builds the indexes, it uses local memory to store the indexes in chunks and then write these to disk. If a level has a very large number of members, it is possible to run out of local memory, which causes the <STORE> errors.

To avoid such errors, try either of the following:

  • Build the cube with a single process. To do so, use %BuildCube() in the Terminal, and use 0 for its second argument.

  • In the <cube> element, specify bitmapChunkInMemory="false" (this is the default). When this cube is built using background processes, the system will use process-private globals instead of local variables (and will not be limited by local memory).

Missing Reference Errors

If your cubes have relationships to other cubes, the build log might include errors like the following:

ERROR #5001: Missing relationship reference in RelatedCubes/Patients: source ID 1 missing reference to RxHomeCity 4

This error can mean that you have built the cubes in the wrong order. See Building Cubes That Have Relationships. Note that if you use the Cube Manager, the Cube Manager determines an appropriate build order.

The missing relationship reference error can also occur when new source data becomes available during the cube build process — that is, after only some of the cubes have been built. For example, consider the sample cubes RelatedCubes/Cities and RelatedCubes/Patients (which are available in the SAMPLES namespace). Suppose that you build the cube RelatedCubes/Cities, and after that, the source table for RelatedCubes/Patients receives a record that uses a new city. When you build the cube RelatedCubes/Patients, there will be a missing relationship reference error.

If you are certain that you have built the cubes in the correct order, see the next section for information on recovering from the errors.

Recovering from Build Errors

The system provides a way to rebuild only the records that previously generated build errors, rather than rebuilding the entire cube. To do this:

  1. Correct the issues that cause these errors.

  2. Use the %FixBuildErrors()Opens in a new tab method of %DeepSee.UtilsOpens in a new tab, as follows:

    set sc=##class(%DeepSee.Utils).%FixBuildErrors(cubename)
    

    Where cubename is the logical name of the cube, in quotes. This method accepts a second argument, which specifies whether to display progress messages; for this argument, the default is true.

    For example:

    Fact '100' corrected
    Fact '500' corrected
    Fact '700' corrected
     
     
    3 fact(s) corrected for 'patients'
    0 error(s) remaining for 'patients'
    

    Or rebuild the entire cube.

Business Intelligence Task Log

The system creates an additional log file (apart from the previously described build logs). After it builds the cube or tries to build the cube, the system also writes the DeepSeeTasks_NAMESPACE.log file to the directory install-dir/mgr. You can use the %SetLoggingOptions method of the %DeepSee.WorkMgrOpens in a new tab class to turn on logging for background agents that the system used during the build process. To do so, make a call like the following:

do ##class(%DeepSee.WorkMgr).%SetLoggingOptions(,,1)

To see this file from the Management Portal, select Analytics > Admin > Logs.

Tip:

This file also contains information about runtime errors of various kinds such as listing errors and KPI errors.

The time stamps in this files use the local date and time (taking daylight saving time into account).

FeedbackOpens in a new tab