com.sas.storage.olap.sasmdx
Class Metadata

com.sas.storage.olap.sasmdx.Metadata
All Implemented Interfaces:
MetadataInterface

public class Metadata
implements MetadataInterface

Contains the client side implementation for com.sas.storage.olap.MetadataInterface. This implementation uses the IOM/OLAP interfaces provided by the SAS OLAP server. This class uses a cache by default to decrease the calls to the server and increase the response time. The cache can be turned on and off, can be sized and can be emptied too. A getMembers() call stores into the cache only the returned Members as long there's enough room in the cache, while any call different from getMembers() will store into the cache all the available info for the involved cube except the Members. The default cache parameter values (sizes) are

bufferSize = 1024 lookAhead = 1024 maxFilters = 5

where

maxFilters is the maximum number of getMembers() call results storable in the cache

bufferSize is the max number of members storable in the cache for each getMembers() call

lookAhead is the max number of members that a getMembers() call gets from the server if you requested less than lookAhead

To set the cache properties you use a com.sas.storage.olap.MetadataPerfomanceTuning object

To turn the cache off

 MetadataPerfomanceTuning pf =  metadata.getPerformanceTuning();
 pf.useCache(false);
 metadata.setPerformanceTuning(pf);
 

if you want to change the bufferSize leaving the other parameters unchanged

 MetadataPerfomanceTuning pf =  metadata.getPerformanceTuning();
 pf.setCacheParms(2048,-1,-1);
 metadata.setPerformanceTuning(pf);
 

if you want to change the lookAhead leaving the other parameters unchanged

 MetadataPerfomanceTuning pf =  metadata.getPerformanceTuning();
 pf.setCacheParms(-1,2048,-1);
 metadata.setPerformanceTuning(pf);
 

if you want to change the maxFilters leaving the other parameters unchanged

 MetadataPerfomanceTuning pf =  metadata.getPerformanceTuning();
 pf.setCacheParms(-1,-1,10);
 metadata.setPerformanceTuning(pf);
 

To empty the cache you can:

Empty all the caches

 metadata.clearCache(iSession, metadata.ALL_CACHE);
 

Empty all the cache related to getMembers() calls

 metadata.clearCache(iSession, metadata.MEMBER_CACHE);
 

Empty all the cache not related to getMembers() calls

 metadata.clearCache(iSession, metadata.NON_MEMBER_CACHE);
 

Empty all the caches that match a specific Filter

 metadata.clearCache( filter, iSession, metadata.ALL_CACHE);
 

Empty the cache related to getMembers() calls that matches a specific Filter

 metadata.clearCache(filter, iSession, metadata.MEMBER_CACHE);
 

Empty the cache not related to getMembers() calls that matches a specific Filter

 metadata.clearCache(filter, iSession, metadata.NON_MEMBER_CACHE);
 

Notes

The cache is shared among the users of the same VM.

Jan 28, 05 - Because of security issues, the cache was changed to be OLAP session based. So all the clear cache methods now require a session object or null if session is not known

lookAhead <= bufferSize, there's no point in having lookAhead > bufferSize because the cache would store less items than the ones got from the server

getMembers() calls requesting many members You will typically increase both the lookAhead and the bufferSize to minimize the server accesses Given a getMembers() call, if the bufferSize is large enough to hold all the members coming from the server you usually get the best response times.

When the cache is completely filled, it takes 3145728 bytes (for each accessed cube) + maxFilters*bufferSize*24576 bytes

Few users and high member cardinality You will typically decrease the maxFilters and increase the bufferSize

Many users and low member cardinality You will typically increase the maxFilters and decrease the bufferSize

Many users and high member cardinality You will typically increase both the maxFilters and the bufferSize


Field Summary
static int ALL_CACHE
           
static int MEMBER_CACHE
           
static int NON_MEMBER_CACHE
           
 
Constructor Summary
Metadata()
           
Metadata(com.sas.iom.SASMDX.IMDXServer connection)
           
Metadata(com.sas.iom.SASMDX.IMDXServer connection, java.util.Locale locale)
           
Metadata(com.sas.iom.SASMDX.ISession session)
           
Metadata(java.lang.String host, int port, java.lang.String username, java.lang.String password)
           
Metadata(java.lang.String host, int port, java.lang.String username, java.lang.String password, java.util.Locale locale)
           
 
Method Summary
static void clearCache(Filter filter, java.lang.Object connObject, int cacheType)
          Clear the cache that matches the filter and cache type.
static void clearCache(java.lang.Object connObject, int cacheType)
          Clear either member cache, non member cache or all caches.
 java.lang.Object getConnection()
          The connection returned will be an com.sas.iom.SASMDX.IMDXServer IMDXServer or com.sas.iom.SASMDX.ISession.
 CubeInterface getCube(Filter filter)
          Returns the cube(s) with the appropriate restrictions
 CubeInterface[] getCubes(Filter filter)
          Returns the cube(s) with the appropriate restrictions
 DimensionInterface getDimension(Filter filter)
          Returns the dimension with the appropriate restrictions
 DimensionInterface[] getDimensions(Filter filter)
          Returns the dimension(s) with the appropriate restrictions
 HierarchyInterface[] getHierarchies(Filter filter)
          Returns the hierarchies(s) with the appropriate restrictions
 HierarchyInterface getHierarchy(Filter filter)
          Returns the hierarchy with the appropriate restrictions
 LevelInterface getLevel(Filter filter)
          Returns the level with the appropriate restrictions
 LevelInterface[] getLevels(Filter filter)
          Returns the level(s) with the appropriate restrictions
 java.util.Locale getLocale()
          Return the locale used to create a session object
 MeasureInterface getMeasure(Filter filter)
          Returns the measure(s) with the appropriate restrictions
 MeasureInterface[] getMeasures(Filter filter)
          Returns the measure(s) with the appropriate restrictions
 MemberInterface[] getMembers(Filter filter, int start, int count)
          Returns a count number of members(s) with the appropriate restrictions
 MetadataPerformanceTuning getPerformanceTuning()
          Return a performanceTuning object that can be used to improve the performance of a metadata query.
 PropertyInterface[] getProperties(Filter filter)
          Returns the properties with the appropriate restrictions
 PropertyInterface getProperty(Filter filter)
          Returns the properties with the appropriate restrictions
 SchemaInterface getSchema(Filter filter)
          Return the schema that match the filter restriction
 SchemaInterface[] getSchemas()
          Return all the schemas for this connection
 SchemaInterface[] getSchemas(Filter filter)
          Return the schemas that match the filter restriction
 void setConnection(java.lang.Object con)
          The connection type for this implementation is the com.sas.iom.SASMDX.IMDXServer or the connection type is com.sas.iom.ISession.
 void setLocale(java.util.Locale locale)
          Set the Locale used to create the session.
 void setPerformanceTuning(MetadataPerformanceTuning performanceTuning)
          Set the performance tuning object on the metadata.
 

Field Detail

MEMBER_CACHE

public static final int MEMBER_CACHE
See Also:
Constant Field Values

NON_MEMBER_CACHE

public static final int NON_MEMBER_CACHE
See Also:
Constant Field Values

ALL_CACHE

public static final int ALL_CACHE
See Also:
Constant Field Values
Constructor Detail

Metadata

public Metadata()
         throws OLAPException
Throws:
OLAPException

Metadata

public Metadata(com.sas.iom.SASMDX.IMDXServer connection)
         throws OLAPException
Throws:
OLAPException

Metadata

public Metadata(java.lang.String host,
                int port,
                java.lang.String username,
                java.lang.String password)
         throws OLAPException
Throws:
OLAPException

Metadata

public Metadata(com.sas.iom.SASMDX.ISession session)
         throws OLAPException
Throws:
OLAPException

Metadata

public Metadata(com.sas.iom.SASMDX.IMDXServer connection,
                java.util.Locale locale)
         throws OLAPException
Throws:
OLAPException

Metadata

public Metadata(java.lang.String host,
                int port,
                java.lang.String username,
                java.lang.String password,
                java.util.Locale locale)
         throws OLAPException
Throws:
OLAPException
Method Detail

getPerformanceTuning

public MetadataPerformanceTuning getPerformanceTuning()
                                               throws OLAPException
Return a performanceTuning object that can be used to improve the performance of a metadata query. The metadata has a default performance tuning object. A user should get the default object and change the value on it and set it back on the metadata

Returns:
a performance tuning object to tune this metadata
Throws:
OLAPException

setPerformanceTuning

public void setPerformanceTuning(MetadataPerformanceTuning performanceTuning)
                          throws OLAPException
Set the performance tuning object on the metadata.

Parameters:
performanceTuning - object to tune this metadata
Throws:
OLAPException

clearCache

public static void clearCache(java.lang.Object connObject,
                              int cacheType)
                       throws OLAPException
Clear either member cache, non member cache or all caches.

Parameters:
connObject - ISession object that was used o create this metadata or null if not known. The cache will clear the cache for matching session or all the items that match the cacheType if null specified.
cacheType - the types of cache are MEMBER_CACHE, NON_MEMBER_CACHE and ALL_CACHE.
Throws:
OLAPException

clearCache

public static void clearCache(Filter filter,
                              java.lang.Object connObject,
                              int cacheType)
                       throws OLAPException
Clear the cache that matches the filter and cache type.

Parameters:
filter - the filter used to query the metadata or a filter that matches all the condition set on the filter
connObject - ISession object that was used to create this metadata or null if not known. This will clear the cache of items that match the session or all the items (based on cacheType and filter) if null specified.
cacheType - clear the specified type of cache. The types can be either member, non member or all.
Throws:
OLAPException

getConnection

public java.lang.Object getConnection()
                               throws OLAPException
The connection returned will be an com.sas.iom.SASMDX.IMDXServer IMDXServer or com.sas.iom.SASMDX.ISession.

Specified by:
getConnection in interface MetadataInterface
Returns:
Connection or a Session object depending on which one is set. This will return a connection object if session is not used to create an instance of this class.
Throws:
OLAPException - if a database error occurs

setConnection

public void setConnection(java.lang.Object con)
                   throws OLAPException
The connection type for this implementation is the com.sas.iom.SASMDX.IMDXServer or the connection type is com.sas.iom.ISession. This defines a connection to the SAS OLAP server.

Specified by:
setConnection in interface MetadataInterface
Parameters:
con - an object that can be a session or the connection to the server.
Throws:
OLAPException - if a database error occurs

setLocale

public void setLocale(java.util.Locale locale)
               throws OLAPException
Set the Locale used to create the session. Setting the Locale after the connection has been established will not take effect until the connection is closed and recreated. If not locale is set, the connection will use the default locale.

Specified by:
setLocale in interface MetadataInterface
Parameters:
locale - the locale used to create the session
Throws:
OLAPException - if a database error occurs

getLocale

public java.util.Locale getLocale()
                           throws OLAPException
Return the locale used to create a session object

Specified by:
getLocale in interface MetadataInterface
Returns:
Locale used to create the session object or null if the connection is not established and locale is not set by the user.
Throws:
OLAPException - if a database error occurs

getSchemas

public SchemaInterface[] getSchemas()
                             throws OLAPException
Return all the schemas for this connection

Specified by:
getSchemas in interface MetadataInterface
Returns:
Schemas for this connection
Throws:
OLAPException - if a database error occurs

getSchemas

public SchemaInterface[] getSchemas(Filter filter)
                             throws OLAPException
Return the schemas that match the filter restriction

Specified by:
getSchemas in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The schema(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs

getSchema

public SchemaInterface getSchema(Filter filter)
                          throws OLAPException
Return the schema that match the filter restriction

Specified by:
getSchema in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The schema with the appropriate restrictions
Throws:
OLAPException - if a database error occurs

getCubes

public CubeInterface[] getCubes(Filter filter)
                         throws OLAPException
Returns the cube(s) with the appropriate restrictions

Specified by:
getCubes in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The cube(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getCube

public CubeInterface getCube(Filter filter)
                      throws OLAPException
Returns the cube(s) with the appropriate restrictions

Specified by:
getCube in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The cube with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getDimensions

public DimensionInterface[] getDimensions(Filter filter)
                                   throws OLAPException
Returns the dimension(s) with the appropriate restrictions

Specified by:
getDimensions in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The dimension(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getDimension

public DimensionInterface getDimension(Filter filter)
                                throws OLAPException
Description copied from interface: MetadataInterface
Returns the dimension with the appropriate restrictions

Specified by:
getDimension in interface MetadataInterface
Parameters:
filter - The filter defines the restrictions to be applied for this metadata query. The following restrictions are applicable for this type of Metadata object:
   catalogName
   schemaName
   cubeName
   dimensionName
   uniqueDimensionName
Returns:
The dimension with the appropriate restrictions
Throws:
OLAPException - if a database error occurs

getHierarchies

public HierarchyInterface[] getHierarchies(Filter filter)
                                    throws OLAPException
Returns the hierarchies(s) with the appropriate restrictions

Specified by:
getHierarchies in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The hierarchies with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getHierarchy

public HierarchyInterface getHierarchy(Filter filter)
                                throws OLAPException
Description copied from interface: MetadataInterface
Returns the hierarchy with the appropriate restrictions

Specified by:
getHierarchy in interface MetadataInterface
Parameters:
filter - The filter defines the restrictions to be applied for this metadata query. The following restrictions are applicable for this type of Metadata object:
   catalogName
   schemaName
   cubeName
   uniqueDimensionName
   hierarchyName
   uniqueHierarchyName
Returns:
The hierarchy with the appropriate restrictions
Throws:
OLAPException - if a database error occurs

getLevels

public LevelInterface[] getLevels(Filter filter)
                           throws OLAPException
Returns the level(s) with the appropriate restrictions

Specified by:
getLevels in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The level(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getLevel

public LevelInterface getLevel(Filter filter)
                        throws OLAPException
Description copied from interface: MetadataInterface
Returns the level with the appropriate restrictions

Specified by:
getLevel in interface MetadataInterface
Parameters:
filter - The filter defines the restrictions to be applied for this metadata query. The following restrictions are applicable for this type of Metadata object:
   catalogName
   schemaName
   cubeName
   uniqueDimensionName
   uniqueHierarchyName
   levelName
   uniqueLevelName
Returns:
The level with the appropriate restrictions
Throws:
OLAPException - if a database error occurs

getMeasures

public MeasureInterface[] getMeasures(Filter filter)
                               throws OLAPException
Returns the measure(s) with the appropriate restrictions

Specified by:
getMeasures in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The measure(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getMeasure

public MeasureInterface getMeasure(Filter filter)
                            throws OLAPException
Returns the measure(s) with the appropriate restrictions

Specified by:
getMeasure in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The measure with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getProperties

public PropertyInterface[] getProperties(Filter filter)
                                  throws OLAPException
Returns the properties with the appropriate restrictions

Specified by:
getProperties in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The properties with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getProperty

public PropertyInterface getProperty(Filter filter)
                              throws OLAPException
Returns the properties with the appropriate restrictions

Specified by:
getProperty in interface MetadataInterface
Parameters:
filter - a set of restriction
Returns:
The property with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface

getMembers

public MemberInterface[] getMembers(Filter filter,
                                    int start,
                                    int count)
                             throws OLAPException
Returns a count number of members(s) with the appropriate restrictions

Specified by:
getMembers in interface MetadataInterface
Parameters:
filter - a set of restriction
start - start index
count - The number of members to return from the resulting set of members, where -1 returns all members meeting the above criteria.
Returns:
The member(s) with the appropriate restrictions
Throws:
OLAPException - if a database error occurs
See Also:
MetadataInterface



Copyright © 2009 SAS Institute Inc. All Rights Reserved.