1. tbrugz
  2. sqldump

Commits

tbrugz  committed 9305504

mdxqueries: using DataDump by default ; added prop 'sqldump.mdxqueries.dumpsyntaxes'

  • Participants
  • Parent commits 1a79945
  • Branches default

Comments (0)

Files changed (3)

File sqldump.template.properties

View file
 # depends on previous 'mondrianschema.Olap4jConnector' processor
 # MDX queries ids
 #sqldump.mdxqueries.ids=q1
-# output file pattern ; pattern [tablename] may be used 
+# datadump syntaxes
+#sqldump.mdxqueries.dumpsyntaxes=csv, html
+#
+# use olap4j's RectangularCellSetFormatter (default is false, i.e., using CellSetResultSetAdapter + DataDump processor) 
+#sqldump.mdxqueries.use-cellset-formatter=true
+# output file pattern ; pattern [tablename] may be used (if using RectangularCellSetFormatter)
+# (if not pattern 'sqldump.datadump.outfilepattern' will be used)
 #sqldump.mdxqueries.outfilepattern=${outputdir}/[tablename].txt
-# use olap4j's RectangularCellSetFormatter (default is false, i.e., using CellSetResultSetAdapter) 
-#sqldump.mdxqueries.use-cellset-formatter=true
 # RectangularCellSetFormatter's compact mode (false/true) 
 #sqldump.mdxqueries.x-compactmode=true
+#
 # MDX queries
 #sqldump.mdxqueries.q1.query=SELECT NON EMPTY {Hierarchize({[Measures].[factcount]})} ON COLUMNS, NON EMPTY {Hierarchize({{[DIM_OS].[OS_FAMILY].Members}, {[DIM_OS].[DIM_OS].Members}})} ON ROWS FROM [HTTP_LOGS]
 #sqldump.mdxqueries.q1.name=query1

File src_mondrian/tbrugz/sqldump/mondrianschema/Olap4jMDXQueries.java

View file
 import org.olap4j.mdx.parser.MdxValidator;
 import org.olap4j.metadata.Hierarchy;
 
+import tbrugz.sqldump.datadump.DataDump;
+import tbrugz.sqldump.datadump.DumpSyntax;
 import tbrugz.sqldump.def.AbstractSQLProc;
 import tbrugz.sqldump.def.Defs;
 import tbrugz.sqldump.def.ProcessingException;
 	static final String SUFFIX_MDXQUERIES_NAME = ".name";
 	static final String SUFFIX_MDXQUERIES_OUTFILEPATTERN = ".outfilepattern";
 	static final String SUFFIX_MDXQUERIES_VALIDATE = ".validate";
+	static final String SUFFIX_MDXQUERIES_SYNTAXES = ".dumpsyntaxes";
 	static final String SUFFIX_MDXQUERIES_USE_CELLSET_FORMATTER = ".use-cellset-formatter";
 	static final String SUFFIX_MDXQUERIES_X_COMPACT = ".x-compactmode";
+	
+	static final int ROW_LIMIT = 10000;
 
 	OlapConnection olapConnection = null;
 	MdxParser parser = null;
 					dumpQueryCellSetFormatter(qid, cellset, w);
 					CategorizedOut.closeWriter(w);
 				}
+				/*
 				else {
 					// using cellset->resultset adapter 
 					//dumpQueryResultSetAdapter(qid, cellset);
 					dumpQueryResultSetAdapter(qid, cellset, w);
 					CategorizedOut.closeWriter(w);
 				}
+				*/
+				else {
+					dumpQueryResultSetAdapterDD(id, qid, cellset);
+				}
 				
 				count++;
 			}
 		log.info("query '"+id+"' dumped [ResultSetAdapter;elapsed="+(System.currentTimeMillis()-initTime)+"ms]");
 	}
 	
+	void dumpQueryResultSetAdapterDD(String id, String qname, CellSet cellSet) throws SQLException, IOException {
+		long initTime = System.currentTimeMillis();
+		CellSetResultSetAdapter csrsad = new CellSetResultSetAdapter(cellSet);
+		List<String> syntaxes = Utils.getStringListFromProp(prop, PREFIX_MDXQUERIES+SUFFIX_MDXQUERIES_SYNTAXES, ",");
+		if(syntaxes==null) {
+			csrsad.close();
+			throw new ProcessingException("datadump syntax list must be defined [prop '"+PREFIX_MDXQUERIES+SUFFIX_MDXQUERIES_SYNTAXES+"']");
+		}
+		DataDump dd = new DataDump();
+		List<DumpSyntax> ds = DataDump.getSyntaxList(prop, syntaxes.toArray(new String[]{}));
+		dd.dumpResultSet(csrsad, prop, id, /*tableOrQueryName*/ qname, /*charset*/ null,
+				/*rowlimit*/ ROW_LIMIT, /*syntaxList*/ ds, /*partitionByPatterns*/ null, /*keyColumns*/ null, /*importedFKs*/ null,
+				/*uniqueKeys*/ null, /*rsDecoratorFactory*/ null, initTime);
+		log.info("query '"+id+"' dumped [ResultSetAdapter/DataDump;elapsed="+(System.currentTimeMillis()-initTime)+"ms]");
+	}
+	
 	void logCellSetInfo(CellSet cellSet) {
 		List<CellSetAxis> axis = cellSet.getAxes();
 		log.info("axis: "+axis);

File src_test/tbrugz/sqldump/mondrianschema/mondrian2.properties

View file
 
 sqldump.mdxqueries.outfilepattern=${baseoutdir}/[tablename].txt
 sqldump.mdxqueries.ids=q1
+sqldump.mdxqueries.dumpsyntaxes=ffc
 
 sqldump.mdxqueries.q1.query=select [DEPT].members on columns, [Measures].ID on rows from PROJ