From: Julian H. <jul...@sp...> - 2005-11-23 21:23:55
|
There are some issues with virtual cubes and measures, but I do not recall exact details. The issues are described the forums/bug database/mailing list archives, if you want to search for them. > -----Original Message----- > From: mon...@li... > [mailto:mon...@li...] On Behalf > Of Douglas Baigrie > Sent: Wednesday, November 23, 2005 02:04 > To: mon...@li... > Subject: RE: [Fwd: RE: [Mondrian-devel] Virtual measures > fromcalculatedmeasures] > > Hi Julian, > > I am unsure what the issue with shared dimensions is that you are > referring to. I have tried to create some test cases using shared > dimensions but I have yet to see any adverse effects of doing so. > Everything seems to behave the same as if it were a 'real' cube. I > think the evaluator does not treat the re-created calculated > members any > different from how it treats them in a real cube. As the Formula's > Members all have dimensional ordinals which exist in the virtual cube, > be they a reference to a particular cube's dimension or a shared > dimension, the Evaluator seems to process these without issue > and in the > correct context. > > Am I missing something here? I know you are very busy just now with > your move to Pentaho. I am sorry to keep asking questions but I feel > that I may be overlooking an important issue that you may be aware of > already. > > Douglas > > On Wed, 2005-11-23 at 09:27 +0000, Douglas Baigrie wrote: > > Hi Julian, > > > > Thanks for the reply. I have a working hack put together but I just > > wanted an opinion on where to put a more workable solution in. > > > > I will let you know how I progress with the changes. > > > > Douglas > > > > On Tue, 2005-11-22 at 23:17 -0800, Julian Hyde wrote: > > > Douglas, > > > > > > Virtual cubes are a bit of a hairball right now and if I > knew an easy fix then I would have done it. As I mentioned > earlier, the > > > problem is disambiguating members of shared dimensions. I > am working on a fix but it is an architectural change, > probably several > > > months away. > > > > > > If you want to try fixing the code for yourself, then > RolapCube and in particular its inner class > RolapCubeSchemaReader are the > > > places to start. You will probably have to do some magic > to RolapEvaluator too. If you get something working, please > send me the > > > code and I'll look it over before checking it in. > > > > > > Julian > > > > > > > -----Original Message----- > > > > From: mon...@li... > > > > [mailto:mon...@li...] On Behalf > > > > Of Douglas Baigrie > > > > Sent: Tuesday, November 22, 2005 08:38 > > > > To: mon...@li... > > > > Subject: Re: [Fwd: RE: [Mondrian-devel] Virtual measures from > > > > calculatedmeasures] > > > > > > > > Hi All, > > > > > > > > I turns out the little hack I made fixed the problem. > It is just that > > > > the formatting property is not getting set so the > values are being > > > > rounded to single digits in my percentage division. > > > > > > > > Now that I know what the problem is and how to fix it, > I would like to > > > > implement a more permanent and less hackish solution. > > > > > > > > The issue is that calculated members need to be created for > > > > the virtual > > > > cube and not just a reference to the 'real' cube's > calculated measure. > > > > This is because of dimension ordinals in the Formula's > Members not > > > > existing in the virtual cube. > > > > > > > > I think that perhaps the place to put this code should > be near the > > > > schema level. This is because it is difficult to obtain the > > > > information > > > > required to recreate the CalculatedMembers by referencing > > > > CalculatedMembers which are already created in the 'real' > > > > cube. I think > > > > that if the implementation was near the schema level it > would not be > > > > difficult to extend it to allow PROPER CalculatedMembers not > > > > VirtualCalculatedMembers in a Virtual Cube. I believe > that both of > > > > these things are on the TODO list or Roadmap for Mondrian. > > > > > > > > I think perhaps the best place may be in > RolapSchemaReader with a few > > > > minor changes to RolapCube but I am open to suggestions. > > > > > > > > Let me know your thoughts please. > > > > > > > > Douglas Baigrie > > > > > > > > On Mon, 2005-11-21 at 15:12 +0000, Douglas Baigrie wrote: > > > > > Due to a lack of response I am posting this again. > > > > > > > > > > PLEASE can someone give me their opinions/feedback. Even > > > > if it is just > > > > > to shoot me down and tell me that the approach i am taking > > > > is completely > > > > > wrong. I know you are all busy and the quality of my > test code > > > > > certainly does not match with yours but some guidance and > > > > feedback is > > > > > needed if I am to solve this problem and become competent > > > > in Mondrian's > > > > > API. Mondrian is a complex product and learning how it > > > > works internally > > > > > with little or no documentation is not easy. I want > to help fix the > > > > > problem with Virtual Cube referring to calculated > measures but I am > > > > > struggling to do so without information. I hope to > > > > contribute to this > > > > > great project but I need some guidance. > > > > > > > > > > Please all I ask is a short moment of your time for a few > > > > comments and > > > > > pointers. > > > > > > > > > > Douglas Baigrie > > > > > > > > > > -------- Forwarded Message -------- > > > > > From: Douglas Baigrie <dou...@pa...> > > > > > Reply-To: mon...@li... > > > > > To: mon...@li... > > > > > Subject: RE: [Mondrian-devel] Virtual measures from > > > > calculated measures > > > > > Date: Wed, 16 Nov 2005 12:39:12 +0000 > > > > > > > > > > Hi All, > > > > > > > > > > After much investigation and a steep learning curve I > > > > discovered that > > > > > the incorrect ordinal was because it was resolving the Measure > > > > > (CalculatedMember) to its component formula which was > made up of the > > > > > original 'real' cube's formula. This of course meant that > > > > the arguments > > > > > of the Formula were Members which belonged to the 'real' > > > > cube and not > > > > > members belonging to the virtual cube. > > > > > > > > > > After a bit of work and a lot of trial and error I managed > > > > to recreate > > > > > the calculated measures for the virtual cube. This > means that the > > > > > dimensional ordinals are now resolved to the virtual cube > > > > which solves > > > > > the problem of the ArrayIndexOuOfBoundsException I was > > > > having. However, > > > > > The Evaluator is not calculating the values correctly. I > > > > am unsure if > > > > > this is due to me incorrectly initialising the > > > > CalculatedMembers or if > > > > > (which I think it may be) a problem with the cache. > It would appear > > > > > that the database is being queried for the data required to > > > > perform the > > > > > calculation but the result it is not being calculated. I > > > > think this may > > > > > be to do with the fact that the data is not in the cache. > > > > This causes > > > > > the data to be loaded but, and I could be wrong with this, > > > > it is then > > > > > never re-visited. > > > > > > > > > > I would appreciate any opinions, points of view, > discussions or > > > > > suggestions as to where to look to resolve this new issue. > > > > > > > > > > What follows is the modified RolapCube constructor for > > > > virtual cubes: > > > > > > > > > > /** > > > > > * Creates a <code>RolapCube</code> from a virtual cube. > > > > > **/ > > > > > RolapCube(RolapSchema schema, > > > > > MondrianDef.Schema xmlSchema, > > > > > MondrianDef.VirtualCube xmlVirtualCube) { > > > > > this(schema, xmlSchema, xmlVirtualCube.name, true, > > > > > null, xmlVirtualCube.dimensions); > > > > > > > > > > > > > > > // since MondrianDef.Measure and > > > > MondrianDef.VirtualCubeMeasure > > > > > // can not be treated as the same, measure creation > > > > can not be > > > > > // done in a common constructor. > > > > > this.measuresHierarchy.newLevel("MeasuresLevel", 0); > > > > > > > > > > // Modified to recreate CalculatedMembers as > the original > > > > > members point to incorrect dimensional ordinals for > the virtual cube > > > > > // Douglas Baigrie - 15/11/2005 > > > > > List calculatedMembersList=new ArrayList(); > > > > > List measuresList = new ArrayList(); > > > > > for (int i = 0; i < > xmlVirtualCube.measures.length; i++) { > > > > > // Lookup a measure in an existing cube. > > > > > MondrianDef.VirtualCubeMeasure xmlMeasure = > > > > > xmlVirtualCube.measures[i]; > > > > > RolapCube cube = (RolapCube) > > > > > schema.lookupCube(xmlMeasure.cubeName); > > > > > Member[] cubeMeasures = cube.getMeasures(); > > > > > boolean found=false; > > > > > for (int j = 0; j < cubeMeasures.length; j++) { > > > > > > > > > > if(cubeMeasures[j].getUniqueName().equals(xmlMeasure.name)) { > > > > > found=true; > > > > > if(cubeMeasures[j] instanceof > > > > RolapCalculatedMember) > > > > > { > > > > > // We have a calulated member! > > > > > // The dimensional ordinals will be > > > > incorrect > > > > > for evaluating the expression so we need to recreate > this member > > > > > // This is a total hack. Sorry! > > > > > for(int > > > > y=0;y<cube.calculatedMembers.length;y++) > > > > > { > > > > > > > > > > > > > > if(cube.calculatedMembers[y].getMdxMember().getUniqueName().eq > > > > uals(xmlMeasure.name)) { > > > > > String > > > > > calcMemberMdx=cube.calculatedMembers[y].toMdx(); > > > > > MondrianDef.CalculatedMember > > > > > calcMember=new MondrianDef.CalculatedMember(); > > > > > > > > > > calcMember.name=cubeMeasures[j].getName(); > > > > > > > > > > calcMember.caption=cubeMeasures[j].getCaption(); > > > > > > > > > > calcMember.dimension=cubeMeasures[j].getDimension().getName(); > > > > > > calcMember.visible=new Boolean(! > > > > > cubeMeasures[j].isHidden()); // Is this correct? > > > > > > > > > > > > > > calcMember.formatString=cubeMeasures[j].getPropertyFormattedVa > > > > lue(Property.FORMAT_STRING.toString()); > > > > > // I am not sure how > to recreate the > > > > > properties yet so I am commenting this for now > > > > > // List > calcMemberPropertiesList=new > > > > > ArrayList(); > > > > > // Property > > > > > calculatedMemberProperties[]=cubeMeasures[j].getProperties(); > > > > > // for(int > > > > > z=0;z<calculatedMemberProperties.length;z++) { > > > > > // > > > > > MondrianDef.CalculatedMemberProperty property=new > > > > > MondrianDef.CalculatedMemberProperty(); > > > > > // > > > > > property.name=calculatedMemberProperties[z].getName(); > > > > > // > > > > > property.caption=calculatedMemberProperties[z].getCaption(); > > > > > // > > > > > property.value=calculatedMemberProperties[z].; > > > > > // } > > > > > // > > > > if(calcMemberPropertiesList.size()>0) > > > > > // > > > > > > calcMember.memberProperties=(MondrianDef.CalculatedMemberProperty[]) > > > > > calculatedMembersList.toArray(new > > > > > > MondrianDef.CalculatedMemberProperty[calculatedMembersList.size()]); > > > > > // else > > > > > > calcMember.memberProperties=new > > > > > MondrianDef.CalculatedMemberProperty[0]; > > > > > // This next bit of code is > > > > very brittle > > > > > but I could not get the Parser/StringScanner to do the job > > > > easily nor > > > > > could I > > > > > // find another way > to obtain this > > > > > information. > > > > > int > > > > > formatStringIndex=calcMemberMdx.indexOf("FORMAT_STRING"); > > > > > int > > > > asIndex=calcMemberMdx.indexOf("as > > > > > "); > > > > > if(asIndex==-1) { > > > > > > > > > getLogger().error("RolapCube.<init>: > > > > > Could not find \"as\" keyword for virtual cube > calculated member > > > > > creation in MDX:\n\t"+calcMemberMdx); > > > > > throw > > > > Util.newInternal("Could not > > > > > find \"as\" keyword for virtual cube calculated member > > > > creation in MDX: > > > > > \n\t"+calcMemberMdx+"\nin virtual cube: > "+xmlMeasure.cubeName); > > > > > } > > > > > String > > > > > formulaMdx=calcMemberMdx.substring(asIndex+3, > formatStringIndex! > > > > > =-1?formatStringIndex:calcMemberMdx.length()).trim(); > > > > > // remove the single quotes > > > > > > formulaMdx=formulaMdx.substring(1, > > > > > formulaMdx.length()-2); > > > > > > getLogger().debug("RolapCube.<init>: > > > > > Virtual cube calculated member MDX:\n\t"+formulaMdx); > > > > > > > > > > calcMember.formula=formulaMdx; > > > > > > > > > calculatedMembersList.add(calcMember); > > > > > break; > > > > > } > > > > > } > > > > > } else { > > > > > // This is the a standard measure > > > > (Don't know > > > > > whether it > > > > > // will confuse things that this > > > > measure still > > > > > points to its 'real' > > > > > // cube.) > > > > > measuresList.add(cubeMeasures[j]); > > > > > } > > > > > break; > > > > > } > > > > > } > > > > > if (!found) { > > > > > throw Util.newInternal( > > > > > "could not find measure '" + > xmlMeasure.name + > > > > > "' in cube '" + > xmlMeasure.cubeName + "'"); > > > > > } > > > > > } > > > > > > > > > > RolapMeasure measures[]; > > > > > if(measuresList.size()>0) > > > > > measures=(RolapMeasure[]) measuresList.toArray(new > > > > > RolapMeasure[measuresList.size()]); > > > > > else > > > > > measures=new RolapMeasure[0]; > > > > > this.measuresHierarchy.memberReader = new > CacheMemberReader( > > > > > new MeasureMemberSource(this.measuresHierarchy, > > > > measures)); > > > > > > > > > > init(xmlVirtualCube.dimensions); > > > > > if(calculatedMembersList.size()>0) > > > > > > > > > > createCalcMembersAndNamedSets((MondrianDef.CalculatedMember[]) > > > > > calculatedMembersList.toArray(new > > > > > > MondrianDef.CalculatedMember[calculatedMembersList.size()]), new > > > > > MondrianDef.NamedSet[0], new ArrayList(), new ArrayList()); > > > > > // End of changes - Douglas Baigrie - 15/11/2005 > > > > > > > > > > // Note: virtual cubes do not get aggregate > > > > > } > > > > > > > > > > > > > > > Douglas Baigrie > > > > > > > > > > On Thu, 2005-11-03 at 09:21 +0000, Douglas Baigrie wrote: > > > > > > Hi Julian, > > > > > > > > > > > > Thanks for the information. > > > > > > > > > > > > By Virtual Measure I meant the same definition as in the > > > > schema, i.e. A > > > > > > reference to a measure in a real cube to be part of the > > > > virtual cube. > > > > > > The problem I am having exists in using a 'virtual > > > > measure' when it > > > > > > refers to a calculated measure in a 'real' cube. > > > > > > > > > > > > I will investigate the problem further and let you know > > > > how I get on. > > > > > > > > > > > > Douglas > > > > > > > > > > > > On Wed, 2005-11-02 at 20:49 -0800, Julian Hyde wrote: > > > > > > > I'm not sure what you mean by 'virtual measure'. If you > > > > are referring to calcualted measures based upon virtual > > > > cubes, I am aware > > > > > > > that there are some problems in that area, but have not > > > > gotten to the bottom of them. > > > > > > > > > > > > > > The evaluator is basically an evaluation context. It > > > > holds the current member for each of the dimensions in the > > > > cube. Initially the > > > > > > > current member is the default member of each hierarchy; > > > > on top of that is supserimposed the values in the slicer; and > > > > on top of > > > > > > > that, the current member on each axis. If an MDX > > > > expression switches context to another member, then the > > > > evaluator will 'push' the > > > > > > > old evaluator onto the stack, create a new evaluator > > > > with a new context, and use this evaluator to evaluate > the expression. > > > > > > > > > > > > > > The evaluator is a visitor pattern, which allows it to > > > > evaluate all kinds of expression (literal, function > call, etc.) in a > > > > > > > straightforward way. > > > > > > > > > > > > > > It is a feature of the MDX language that some > > > > expressions are intended to be evaluated as scalar > > > > expressions. For example, in > > > > > > > 'Order([Store].members, [Gender].CurrentMember)', > > > > [Gender].CurrentMember is intended to be evaluated to a > > > > scalar value, namely the > > > > > > > sales to customers of the current gender in that store. > > > > In another context, say '[Gender].CurrentMember.Name', the > > > > expression is > > > > > > > intended to be evaluated to yield a member. This is > > > > what evaluateScalar does. > > > > > > > > > > > > > > The evaluator is well tested, so the problem is > > > > probably not there. The first place you should look is to > > > > shared dimensions or > > > > > > > dimensions in a virtual cube (if you're using these). > > > > Sometimes the cache can get confused when you try to access a > > > > cell using a > > > > > > > member of dimension D when it expected to see a member > > > > of shared dimension D1. > > > > > > > > > > > > > > I think there's also a problem in virtual cubes when > > > > you have a measure depends upon a dimension which is present > > > > in one of the > > > > > > > constituent cubes but not the other. Mondrian sets the > > > > dimension to its 'all' value, whereas I believe that the MSAS > > > > reference > > > > > > > implementation sets the dimension to 'null' in this case. > > > > > > > > > > > > > > That's a lot of information -- hope this helps. The I > > > > haven't had time to fully look into the problems I describe > > > > above, and I still > > > > > > > don't have time to fully solve them, so you'll have to > > > > use your initiative! > > > > > > > > > > > > > > Julian > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: mon...@li... > > > > > > > > > [mailto:mon...@li...] On Behalf > > > > > > > > Of Douglas Baigrie > > > > > > > > Sent: Wednesday, November 02, 2005 03:48 > > > > > > > > To: mon...@li... > > > > > > > > Subject: [Mondrian-devel] Virtual measures from > > > > calculated measures > > > > > > > > > > > > > > > > I have done some more investigation work into > the problem. > > > > > > > > > > > > > > > > It appears that the problem exists no matter what > > > > operator is used in > > > > > > > > the formula. The formula i was originally > working with was a > > > > > > > > percentage > > > > > > > > based [Dimension].[All Members].[Level > > > > > > > > Member]/[Dimension].[All Members] > > > > > > > > however I have tried + and - and the problem still > > > > exists. Both > > > > > > > > dimensions are the same and the Level Member is a > > > > particular instance > > > > > > > > member at that level. > > > > > > > > > > > > > > > > I created the same calculation using MDX's WITH > > > > MEMBER clause and this > > > > > > > > correctly returns the results I am looking for with > > > > the same formula. > > > > > > > > This leads me to believe that the calculation is > > > > evaluated differently > > > > > > > > for MDX than it is for the virtual measure which is > > > > supported by some > > > > > > > > debugging output. > > > > > > > > > > > > > > > > I would really appreciate some pointers as to > where I should > > > > > > > > be looking > > > > > > > > to fix this issue. The Evaluator is quite complex > > > > and I believe that > > > > > > > > the problem exists either in RolapEvaluator or > > > > RolapCube with possibly > > > > > > > > some issues in FunTableImpl. However, I am > still trying to > > > > > > > > get my head > > > > > > > > around the code and any input or suggestions would be > > > > great. Even a > > > > > > > > brief description of cube/virtual cube creation from > > > > the point of view > > > > > > > > of Rolap and how the evaluator walks a formula would > > > > be very helpful. > > > > > > > > > > > > > > > > Douglas > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > > > SF.Net email is sponsored by: > > > > > > > > Tame your development challenges with Apache's > Geronimo App > > > > > > > > Server. Download > > > > > > > > it for free - -and be entered to win a 42" plasma tv > > > > or your very own > > > > > > > > Sony(tm)PSP. Click here to play: > > > > http://sourceforge.net/geronimo.php > > > > > > > > _______________________________________________ > > > > > > > > mondrian-devel mailing list > > > > > > > > mon...@li... > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > > SF.Net email is sponsored by: > > > > > > > Tame your development challenges with Apache's Geronimo > > > > App Server. Download > > > > > > > it for free - -and be entered to win a 42" plasma tv or > > > > your very own > > > > > > > Sony(tm)PSP. Click here to play: > > > > http://sourceforge.net/geronimo.php > > > > > > > _______________________________________________ > > > > > > > mondrian-devel mailing list > > > > > > > mon...@li... > > > > > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > SF.Net email is sponsored by: > > > > > > Tame your development challenges with Apache's Geronimo > > > > App Server. Download > > > > > > it for free - -and be entered to win a 42" plasma tv or > > > > your very own > > > > > > Sony(tm)PSP. Click here to play: > > > > http://sourceforge.net/geronimo.php > > > > > > _______________________________________________ > > > > > > mondrian-devel mailing list > > > > > > mon...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > This SF.Net email is sponsored by the JBoss Inc. Get > > > > Certified Today > > > > > Register for a JBoss Training Course. Free Certification Exam > > > > > for All Training Attendees Through End of 2005. For > more info visit: > > > > > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > > > > > _______________________________________________ > > > > > mondrian-devel mailing list > > > > > mon...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > This SF.Net email is sponsored by the JBoss Inc. Get > > > > Certified Today > > > > > Register for a JBoss Training Course. Free Certification Exam > > > > > for All Training Attendees Through End of 2005. For > more info visit: > > > > > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > > > > > _______________________________________________ > > > > > mondrian-devel mailing list > > > > > mon...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.Net email is sponsored by the JBoss Inc. Get > Certified Today > > > > Register for a JBoss Training Course. Free Certification Exam > > > > for All Training Attendees Through End of 2005. For > more info visit: > > > > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > > > > _______________________________________________ > > > > mondrian-devel mailing list > > > > mon...@li... > > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by the JBoss Inc. Get > Certified Today > > > Register for a JBoss Training Course. Free Certification Exam > > > for All Training Attendees Through End of 2005. For more > info visit: > > > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > > > _______________________________________________ > > > mondrian-devel mailing list > > > mon...@li... > > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by the JBoss Inc. Get > Certified Today > > Register for a JBoss Training Course. Free Certification Exam > > for All Training Attendees Through End of 2005. For more info visit: > > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > > _______________________________________________ > > mondrian-devel mailing list > > mon...@li... > > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > Register for a JBoss Training Course. Free Certification Exam > for All Training Attendees Through End of 2005. For more info visit: > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > _______________________________________________ > mondrian-devel mailing list > mon...@li... > https://lists.sourceforge.net/lists/listinfo/mondrian-devel > > |