Beispiel #1
0
  private void clearCache(RolapCube cube) {
    // Clear the cache for the Sales cube, so the query runs as if
    // for the first time. (TODO: Cleaner way to do this.)
    final Cube salesCube = getConnection().getSchema().lookupCube("Sales", true);
    RolapHierarchy hierarchy =
        (RolapHierarchy)
            salesCube.lookupHierarchy(new Id.NameSegment("Store", Id.Quoting.UNQUOTED), false);
    SmartMemberReader memberReader = (SmartMemberReader) hierarchy.getMemberReader();
    MemberCacheHelper cacheHelper = memberReader.cacheHelper;
    cacheHelper.mapLevelToMembers.cache.clear();
    cacheHelper.mapMemberToChildren.cache.clear();

    // Flush the cache, to ensure that the query gets executed.
    cube.clearCachedAggregations(true);

    CacheControl cacheControl = getConnection().getCacheControl(null);
    final CacheControl.CellRegion measuresRegion = cacheControl.createMeasuresRegion(cube);
    cacheControl.flush(measuresRegion);
  }