ActivePivot

ActivePivot

  • 5.10.4
  • Other Versions
  • User Guide
  • Technical Documentation
  • Support

›Data Querying

Introduction

  • Overview
  • What's new in ActivePivot

Getting Started

  • Overview
  • AP in a Nutshell
  • Development Environment
  • Download
  • Sandbox Project

Concepts

  • Overview
  • AP Concepts in a Nutshell
  • Data Versioning (MVCC)
  • Dimensions and Hierarchies
  • Partitioning and NUMA
  • Other Concepts

Data Loading

  • Overview
  • Datastore

    • Datastore Configuration
    • Datastore Transactions
    • Store Indexing

    ETL

    • Overview
    • CSV Source
    • JDBC Source
    • Parquet Source

    Loading data from the cloud

    • Cloud Source
    • Amazon S3 Cloud Source
    • Azure Cloud Source
    • Google Cloud Source

    Specific data types

    • Handling Dates
    • Vectors

Aggregation & Analytics

  • Overview
  • Cube Configuration
  • Copper API

    • Introduction
    • API
    • Measures
    • Hierarchies
    • Publication
    • Join operations
    • Advanced topics

    Streaming API

    • Continuous Queries Overview
    • Streaming Overview
    • Continuous Query Engine
    • Continuous Handlers

    Advanced APIs

    • Cube Locations
    • Post-Processors
    • Cube Filters
    • Member Properties
    • Context Values

Data Querying

  • Overview
  • Business Frontends
  • Server Endpoints

    • XMLA
    • Datastore REST API
    • Cube REST API
    • Cube Websocket API

    MDX

    • MDX Engine Configuration
    • MDX Functions
    • MDX Operators
    • MDX Formats
    • MDX Filtering
    • MDX Snippets
    • MDX Cellsets
  • Datastore Queries
  • Location-Based Queries
  • Drillthrough Extensions

Configuration

  • Overview
  • ContentServer

    • Content Server
    • ContentServer REST API
    • CS Websocket API
  • ActivePivot Properties
  • Internationalization

Security

  • Overview
  • Client/Server Communication

    • Authentication
    • Authorization & Entitlements

    Data Access Control

    • Datastore Access Control
    • ActivePivot Access Control
    • Branch Permission Manager

Distributed Architecture

  • Overview
  • Communication Flows
  • Post-Processors
  • Security
  • What-If
  • Recommendations
  • Distribution Properties

Operations

  • Overview
  • Monitoring

    • Health Dispatcher
    • Query Execution Plan
    • Monitoring Query Execution
    • JMX monitoring
    • Off-Heap Memory Export
    • Tracing REST API
  • Troubleshooting
  • Performance
  • High Availability

Release & Migration Notes

  • Changelog
  • Migration notes
  • Deprecated features

Reference

  • Javadoc
  • REST APIs

Location-Based Queries

An ActivePivot cube can be queried in multiple ways, including - most commonly - via the MDX query language.

MDX is suitable for most business use cases, but behind the scene the ActivePivot MDX engine interprets MDX queries and decomposes them into more "primitive" queries that are defined in terms of cube locations.

This article describes the low-level API that supports the location-based queries implemented in ActivePivot.

Throughout this article, we assume that a cube instance is accessible through a variable named pivot (we don't discuss the type of cube instance we are dealing with or how to get it, as this is not the focus of this article). It is also assumed that the cube includes four hierarchies: Currency (AllMember enabled), Date (AllMember disabled), Trader (AllMember enabled) and Maturity (AllMember enabled).

GetAggregatesQuery

The goal of the GetAggregatesQuery (GAQ) is to retrieve all the aggregates that are defined by a set of locations and aggregated measures.

The following code block illustrates a GAQ querying all the locations with "EUR" as currency, and requesting the aggregated measures "Quantity.SUM" and "PositionValue.SUM". The queryResults contains the locations with the aggregated measures (together with their values) for each location.

//measures we want to focus on
Collection<String> measures= Arrays.asList("Quantity.SUM", "PositionValue.SUM");
//create the location to query all the locations content with EUR as currency
List<ILocation> locations = new ArrayList<ILocation>();
Object[][] arrayLocation =  new Object[][]{{ILevel.ALLMEMBER,"EUR"},{null},{ILevel.ALLMEMBER},{ILevel.ALLMEMBER}};
ILocation location = new Location(arrayLocation);
locations.add(location);
//execute the query
IGetAggregatesQuery aggregatesQuery = Registry.create(IGetAggregatesQuery.class, locations, measures);
ICellSet queryResults =  pivot.execute(aggregatesQuery);

DrillthroughQuery

A drillthrough query returns all the facts that have contributed to a range of selected locations.

In the example below, we query all the projections that contributed to all "EUR" locations.

//create the location to query the content of all the locations with EUR as currency
List<ILocation> locations = new ArrayList<ILocation>();
Object[][] arrayLocation =  new Object[][]{{ILevel.ALLMEMBER,"EUR"},{null},{ILevel.ALLMEMBER},{ILevel.ALLMEMBER}};
ILocation location = new Location(arrayLocation);
locations.add(location);
//execute the query
IDrillthroughQuery drillthroughQuery = Registry.create(IDrillthroughQuery.class, locations);
List<IDrillthroughRow> queryResults =  pivot.execute(drillthroughQuery);

Local Registration of a Location-Based Continuous Query

A GetAggregatesQuery or a DrillthroughQuery can be registered as a continuous query:

pivot.registerContinuousQuery("myQueryName", aggregatesQuery, null, Collections.singleton(listener));

The listener(s) specified on registration must be compatible with the type of query. Namely, IGetAggregatesContinuousQueryListener (shortcut for IContinuousQueryListener<ICellSet, IVersionedContinuousQueryUpdate<ICellSet>>) for a GetAggregatesQuery, or IContinuousQueryListener<List<IDrillthroughRow>, IContinuousQueryUpdate<List<IDrillthroughRow>>> for a DrillthroughQuery.

Here is an example of a simple printing listener for a GetAggregatesQuery:

final IGetAggregatesContinuousQueryListener listener = new IGetAggregatesContinuousQueryListener() {
    @Override
    public void viewUpdated(final IVersionedContinuousQueryUpdate<ICellSet> update) {
        System.out.println(
                "Received an update for version " + update.getVersion().getEpochId() +
                        " caused by the event " + update.getEvent() +
                        " for the query " + update.getContinuousQuery().getQuery());
        if (update.getRefreshed() != null) {
            // Print the new complete cellset
            System.out.println("Full refresh of the cellset: " + update.getRefreshed());
            return;
        }
        // Print the updated cells
        final ICellSet updatedAggregates = update.getAdded();
        if (updatedAggregates != null) {
            System.out.println("Updates aggregates: " + updatedAggregates);
        }
        // Print the removed aggregates (i.e. the values that disappeared from the cube)
        if (update.getRemoved() != null) {
            System.out.println("Removed aggregates: " + update.getRemoved());
        }
    }
    @Override
    public void registration(IContinuousQuery<? extends ICellSet, ? extends IVersionedContinuousQueryUpdate<ICellSet>> continuousQuery) {}
    @Override
    public void deregistration(IContinuousQuery<? extends ICellSet, ? extends IVersionedContinuousQueryUpdate<ICellSet>> continuousQuery) {}
};

The query name specified at registration time can be used to unregister the continuous query.

pivot.unregisterContinuousQuery("myQueryName");

← Datastore QueriesDrillthrough Extensions →
  • GetAggregatesQuery
  • DrillthroughQuery
  • Local Registration of a Location-Based Continuous Query
ActivePivot
Community
Stack OverflowLinkedinTwitter
More
Blog
Copyright © 2021 ActiveViam