Skip to content

Commit

Permalink
MONDRIAN: Expose query timeout for benefit of olap4j driver; throw an…
Browse files Browse the repository at this point in the history
… error if requested cell is out of bounds.

[git-p4: depot-paths = "//open/mondrian/": change = 10204]
  • Loading branch information
julianhyde committed Nov 18, 2007
1 parent cabc8f1 commit 464f1f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -109,7 +109,7 @@ public class Query extends QueryPart {
/**
* Query timeout, in milliseconds
*/
private final int queryTimeout;
private long queryTimeout;

/**
* If true, cancel this query
Expand Down Expand Up @@ -220,6 +220,17 @@ public Query(
resolve();
}

/**
* Sets the timeout in milliseconds of this Query.
*
* <p>Zero means no timeout.
*
* @param queryTimeoutMillis Timeout in milliseconds
*/
public void setQueryTimeoutMillis(long queryTimeoutMillis) {
this.queryTimeout = queryTimeoutMillis;
}

/**
* Checks whether the property name is present in the query.
*/
Expand Down Expand Up @@ -357,7 +368,7 @@ public void checkCancelOrTimeout() {
long currTime = System.currentTimeMillis();
if ((currTime - startTime) >= queryTimeout) {
throw MondrianResource.instance().QueryTimeout.ex(
(long) queryTimeout / 1000);
queryTimeout / 1000);
}
}
if (outOfMemoryMsg != null) {
Expand Down Expand Up @@ -655,15 +666,11 @@ public Object[] getChildren() {
// Chidren are axes, slicer, and formulas (in that order, to be
// consistent with replaceChild).
List<QueryPart> list = new ArrayList<QueryPart>();
for (QueryAxis axis : axes) {
list.add(axis);
}
list.addAll(Arrays.asList(axes));
if (slicerAxis != null) {
list.add(slicerAxis);
}
for (Formula formula : formulas) {
list.add(formula);
}
list.addAll(Arrays.asList(formulas));
return list.toArray();
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/mondrian/rolap/RolapResult.java
Expand Up @@ -663,6 +663,12 @@ public Cell getCell(int[] pos) {

CellInfo ci = cellInfos.lookup(pos);
if (ci.value == null) {
for (int i = 0; i < pos.length; i++) {
int po = pos[i];
if (po < 0 || po >= axes[i].getPositions().size()) {
throw Util.newError("coordinates out of range");
}
}
ci.value = Util.nullValue;
}

Expand Down

0 comments on commit 464f1f1

Please sign in to comment.