Skip to content

Commit

Permalink
Fix bug with hierarchically comparing arrays. "Cache Bug" problem sol…
Browse files Browse the repository at this point in the history
…ved hereby.

Enable debug output redirection to file.

[git-p4: depot-paths = "//open/mondrian/": change = 444]
  • Loading branch information
hhaas committed Apr 25, 2003
1 parent 79d2c12 commit 00b025d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/mondrian/olap/MondrianProperties.java
Expand Up @@ -116,6 +116,9 @@ public int getTraceLevel() {
/** Property {@value}. */
public static final String TraceLevel = "mondrian.trace.level";

/** Property {@value}. */
public static final String DebugOutFile = "mondrian.debug.out.file";

/** Retrieves the value of the {@link #JdbcDrivers} property,
* default value {@link #JdbcDrivers_Default}. */
public String getJdbcDrivers() {
Expand Down
9 changes: 6 additions & 3 deletions src/main/mondrian/olap/fun/FunUtil.java
Expand Up @@ -1077,19 +1077,22 @@ class HierarchicalArrayComparator extends ArrayExpComparator {
this.desc = desc;
}
protected int compare(Member[] a1, Member[] a2) {
int c = 0;
evaluator = evaluator.push();
for (int i = 0; i < arity; i++) {
Member m1 = a1[i],
m2 = a2[i];
int c = compareHierarchicallyButSiblingsByValue(m1, m2);
c = compareHierarchicallyButSiblingsByValue(m1, m2);
if (c != 0) {
return c;
break;
}
// compareHierarchicallyButSiblingsByValue imposes a total order
//Util.assertTrue(m1 == m2);
Util.assertTrue(m1.equals(m2));
evaluator.setContext(m1);
}
return 0;
evaluator = evaluator.pop();
return c;
}
protected int compareHierarchicallyButSiblingsByValue(Member m1, Member m2) {
if (FunUtil.equals(m1, m2)) {
Expand Down
31 changes: 27 additions & 4 deletions src/main/mondrian/rolap/RolapUtil.java
Expand Up @@ -16,6 +16,7 @@

import java.io.*;
import java.lang.reflect.Array;
import java.net.URI;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand All @@ -34,7 +35,7 @@
**/
public class RolapUtil {
static final RolapMember[] emptyMemberArray = new RolapMember[0];
public static PrintWriter debugOut;
public static PrintWriter debugOut = null;
private static Semaphore querySemaphore;
/** Special cell value indicates that the value is not in cache yet. **/
static RuntimeException valueNotReadyException = new RuntimeException(
Expand Down Expand Up @@ -150,12 +151,34 @@ static Object[] addElement(Object[] a, Object o)
* Enables tracing if "mondrian.trace.level" &gt; 0.
*/
public static void checkTracing() {
int trace = MondrianProperties.instance().getTraceLevel();
if (trace > 0) {
debugOut = new PrintWriter(System.out, true);
if ( debugOut == null ) {
int trace = MondrianProperties.instance().getTraceLevel();
if (trace > 0) {
String debugOutFile =
MondrianProperties.instance().getProperty(MondrianProperties.DebugOutFile);
if ( debugOutFile != null ) {
File f;
try {
f = new File(debugOutFile);
debugOut = new PrintWriter(new FileOutputStream(f), true);
} catch (Exception e) {
// don't care, use System.out
}
}
if ( debugOut == null )
debugOut = new PrintWriter(System.out, true);
}
}
}

/**
* redirect debug output to another PrintWriter
* @param pw
*/
static public void setDebugOut( PrintWriter pw) {
debugOut = pw;
}

/**
* Executes a query, printing to the trace log if tracing is enabled.
* If the query fails, it throws the same {@link SQLException}, and closes
Expand Down

0 comments on commit 00b025d

Please sign in to comment.