MyEclipse 10
saiku2.5源码
saiku-server-foodmart-2.5.zip
type=OLAP
name=testdatasource
driver=mondrian.olap4j.MondrianOlap4jDriver
location=jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/testdatasource;Catalog=res:testdatasource/testdatasource.xml;
username=root
password=111111
解释下上面一条的的参数
type=OLAP就不多说了,先按固定的来
name=testdatasource 数据源名称
driver=mondrian.olap4j.MondrianOlap4jDriver 可以理解为固定的,Mondrian的
- 修改内容为如下(重点是红色内容):
- InputStream in = readVirtualFile(catalogUrl);
- try {
- return IOUtils.toString(in,"utf-8"); //-----------------此行为红色行
- } finally {
- IOUtils.closeQuietly(in);
- }
- 或者按照网上说的另外一种方式,整体替换为如下内容,也可以,不过下面的编码必须写你的schema文件的编码:
- try {
- final byte[] bytes = Util. readFully(in, 1024);
- final char[] chars = new char[bytes. length];
- for ( int i = 0; i < chars. length; i++) {
- chars[i] = ( char) bytes[i];
- }
- String str = new String(bytes,"utf-8").replace("\ufeff" , "" );//加replace("\ufeff", "")是为了过滤"UTF-8无BOM格式文件"的开头
- return str;
- } finally {
- if (in != null) {
- in.close();
- }
- }
2、再找到文件 mondrian.rolap.RolapSchema.lo
1、根据文档中,比较费解,没有看太懂(并且部分文档的方法无法使用):http://mondrian.pentaho.com/documentation/cache_control.php
2、本来打算使用文档中的另一个方法
但是最终发现我完全从外部调用,哪里获取RolapConnection呢,于是,此方法宣告失败
- public boolean clearCache() throws Exception {
- if ( olapConnection.isWrapperFor( RolapConnection.class ) ) {
- System.out.println( "Clearing cache" );
- RolapConnection rcon = olapConnection.unwrap( RolapConnection.class );
- rcon.getCacheControl( null ).flushSchemaCache();
- }
- return true;
- }
3、经过努力,找到别人的方法,此方法可行,原文是
- java.util.Iterator<mondrian.rolap.RolapSchema> schemaIterator = mondrian.rolap.RolapSchema.getRolapSchemas();
- while(schemaIterator.hasNext()){
- mondrian.rolap.RolapSchema schema = schemaIterator.next();
- mondrian.olap.CacheControl cacheControl = schema.getInternalConnection().getCacheControl(null);
- for (mondrian.olap.Cube cube : schema.getCubes()) {
- cacheControl.flush(cacheControl.createMeasuresRegion(cube));
- }
- }
但是对于我用的版本不对应,会报无法转换为Iterator,然后做了稍微修改,如下
- List<mondrian.rola
解决办法,需要修改4个地方的编码:
修改 xml = new String( (byte[]) f.getEntity());为 xml = new String( (byte[]) f.getEntity(),"utf-8");
修改 InputSource source = new InputSource( ( new ByteArrayInputStream( xml.getBytes() ) ) );为 InputSource source = new InputSource( ( new ByteArrayInputStream( xml.getBytes("UTF-8") ) ) );
修改 InputStreamReader reader = new InputStreamReader(repoFile.getContent().getInputStream());为 InputStreamReader reader = new InputStreamReader(repoFile.getContent().getInputStream(),"UTF-8");
修改 OutputStreamWriter ow = new OutputStreamWriter(repoFile.getContent().getOutputStream());为 OutputStreamW
1、Setting.js中有个配置项:'saiku.olap.query.automatic_execution': 'true',
- 1、Setting.js中有个配置项:'saiku.olap.query.automatic_execution': 'true',
2、在Repository界面双击saiku文件查询不自动,需要在Workspace.js文件的410行附近,修改如下代码,将其中调用query.run的代码注释
- if (typeof isNew != "undefined") {
- //this.query.run(false);
- }
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(防止爬虫):http://blog.liuyingguang.cn
OpenBI问答社区:http://openbi.liuyingguang.cn/