Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Flushing one cube form schema

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Default Flushing one cube form schema

    Hi there,

    I'm using latest version of Mondrian ( 3.5.2 ) and I want to flush just one cube from the schema. There are a few right now and soon I might have to add some more, so using individual schemas isn't an option.
    To be precise I need to flush all members from the member cache, not just the measures.
    Using the Cache Control API I managed to do something like this:
    Code:
            CacheControl cacheControl = connection.getCacheControl(null);
            Cube cube = connection.getSchema().lookupCube(cubeName, true);
            SchemaReader schemaReader = cube.getSchemaReader(null).withLocus();
    
            cacheControl.flush(cacheControl.createMeasuresRegion(cube));
            for (Dimension dimension : cube.getDimensions()) {
                for (Hierarchy hierarchy : dimension.getHierarchies()) {
                    for (Level level : hierarchy.getLevels()) {
                        for (Member member : schemaReader.getLevelMembers(level,
                                false)) {
                            if (!member.isMeasure() && !member.isAll()) {
                                cacheControl.flush(cacheControl.createMemberSet(
                                        member, false));
                            }
                        }
                    }
                    Member allMember = hierarchy.getAllMember();
                    if(allMember != null)
                        cacheControl.flush(cacheControl.createMemberSet(hierarchy.getAllMember(), false));
                }
            }
    This code forces mondrian to fetch all members on all dimensions from the database, which I'm not sure is needed. And it doesn't work very well, using some functions like LastPeriods start throwing exceptions after flush.
    Code:
    Caused by: mondrian.olap.MondrianException: Mondrian Error:Internal error: member [Time.Date].[2012-11-10] not found among its siblings
        at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:969)
        at mondrian.olap.Util.newInternal(Util.java:2393)
        at mondrian.rolap.NoCacheMemberReader$SiblingIterator.<init>(NoCacheMemberReader.java:386)
        at mondrian.rolap.NoCacheMemberReader.getLeadMember(NoCacheMemberReader.java:221)
        at mondrian.rolap.RolapSchemaReader.getLeadMember(RolapSchemaReader.java:529)
        at mondrian.olap.DelegatingSchemaReader.getLeadMember(DelegatingSchemaReader.java:175)
        at mondrian.olap.fun.LastPeriodsFunDef.lastPeriods(LastPeriodsFunDef.java:124)
        at mondrian.olap.fun.LastPeriodsFunDef$1.evaluateList(LastPeriodsFunDef.java:84)
        at mondrian.calc.impl.AbstractListCalc.evaluate(AbstractListCalc.java:65)
        at mondrian.rolap.RolapResult.evaluateExp(RolapResult.java:919)
        at mondrian.rolap.RolapNamedSetEvaluator.ensureList(RolapNamedSetEvaluator.java:88)
        at mondrian.rolap.RolapNamedSetEvaluator.evaluateTupleIterable(RolapNamedSetEvaluator.java:61)
        at mondrian.mdx.NamedSetExpr$1.evaluateIterable(NamedSetExpr.java:98)
        at mondrian.olap.fun.OrderFunDef$CalcImpl.evaluateList(OrderFunDef.java:201)
        at mondrian.calc.impl.AbstractListCalc.evaluate(AbstractListCalc.java:65)
        at mondrian.rolap.RolapResult.evaluateExp(RolapResult.java:919)
        at mondrian.rolap.RolapNamedSetEvaluator.ensureList(RolapNamedSetEvaluator.java:88)
        at mondrian.rolap.RolapNamedSetEvaluator.evaluateTupleIterable(RolapNamedSetEvaluator.java:61)
        at mondrian.mdx.NamedSetExpr$1.evaluateIterable(NamedSetExpr.java:98)
        at mondrian.rolap.RolapResult.executeAxis(RolapResult.java:817)
        at mondrian.rolap.RolapResult.evalLoad(RolapResult.java:642)
        at mondrian.rolap.RolapResult.loadMembers(RolapResult.java:598)
        at mondrian.rolap.RolapResult.<init>(RolapResult.java:286)
        at mondrian.rolap.RolapConnection.executeInternal(RolapConnection.java:680)
        ... 8 more
    Implementing DataSourceChangeListener isn't an option in my set up too.

    Now I'm thinking about compiling my own mondrian where i make accessible MemberCacheHelper#flushCache from the Hierarchy interface. So that I can do something like:
    Code:
            Cube cube = connection.getSchema().lookupCube(cubeName, true);
            
            for (Dimension dimension : cube.getDimensions()) {
                for (Hierarchy hierarchy : dimension.getHierarchies()) {
    
                    hierarchy.flushHierarchy();
                }
             }
    Is there any other way to flush all members in a cube?

    Thank you for your time and happy holidays!

  2. #2
    Join Date
    Mar 2007
    Posts
    142

    Default

    Try this.

    Code:
        Connection connection;
        CacheControl cacheControl = connection.getCacheControl(null);
        for (Cube cube : connection.getSchema().getCubes()) {
        cacheControl.flush(
                 cacheControl.createMeasuresRegion(cube));
        }
    Luc Boudreau
    aka. Luc le Magnifique
    aka. Monsieur Oui Oui

    Lead Engineer, Pentaho Corporation
    Web: http://devdonkey.blogspot.com
    Twitter: luclemagnifique
    IRC: Monsieur_Oui_Oui@freenode

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.