Skip to content

Commit

Permalink
MONDRIAN: Oops, forgot to add ArrayHolder.
Browse files Browse the repository at this point in the history
    Fix incorrect copyright notices.

[git-p4: depot-paths = "//open/mondrian/": change = 8656]
  • Loading branch information
julianhyde committed Feb 5, 2007
1 parent 5a6a86f commit e54c219
Show file tree
Hide file tree
Showing 24 changed files with 284 additions and 374 deletions.
37 changes: 37 additions & 0 deletions src/main/mondrian/olap/fun/ArrayHolder.java
@@ -0,0 +1,37 @@
/*
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2007 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap.fun;

import java.util.Arrays;

/**
* Holds an array, so that {@link #equals} and {@link #hashCode} work.
*
* @author jhyde
* @version $Id$
*/
public class ArrayHolder<T> {
private final T[] a;

ArrayHolder(T[] a) {
this.a = a;
}

public int hashCode() {
return Arrays.hashCode(a);
}

public boolean equals(Object o) {
return o instanceof ArrayHolder &&
Arrays.equals(a, ((ArrayHolder) o).a);
}
}

// End ArrayHolder.java
5 changes: 1 addition & 4 deletions src/main/mondrian/olap/fun/CacheFunDef.java
Expand Up @@ -3,12 +3,9 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2002-2002 Kana Software, Inc.
// Copyright (C) 2002-2005 Julian Hyde and others
// Copyright (C) 2005-2007 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 26 February, 2002
*/
package mondrian.olap.fun;

Expand Down
106 changes: 41 additions & 65 deletions src/main/mondrian/olap/fun/CrossJoinFunDef.java
Expand Up @@ -3,37 +3,28 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2004-2002 Kana Software, Inc.
// Copyright (C) 2004-2006 Julian Hyde and others
// Copyright (C) 2002-2002 Kana Software, Inc.
// Copyright (C) 2003-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap.fun;

import mondrian.olap.*;
import mondrian.olap.type.Type;
import mondrian.olap.type.TupleType;
import mondrian.olap.type.SetType;
import mondrian.resource.MondrianResource;
import mondrian.calc.*;
import mondrian.calc.ExpCompiler.ResultStyle;
import mondrian.calc.impl.AbstractIterCalc;
import mondrian.calc.impl.AbstractListCalc;
import mondrian.mdx.*;
import mondrian.util.UnsupportedList;
import mondrian.mdx.MdxVisitorImpl;
import mondrian.mdx.ResolvedFunCall;
import mondrian.olap.*;
import mondrian.olap.type.SetType;
import mondrian.olap.type.TupleType;
import mondrian.olap.type.Type;
import mondrian.resource.MondrianResource;
import mondrian.util.Bug;
import mondrian.util.UnsupportedList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.ListIterator;
import java.util.Iterator;
import java.util.RandomAccess;
import java.util.List;
import java.util.Set;
import java.util.NoSuchElementException;
import java.util.ConcurrentModificationException;
import java.util.*;

/**
* Definition of the <code>CrossJoin</code> MDX function.
Expand Down Expand Up @@ -96,16 +87,16 @@ private static void addTypes(final Type type, List<Type> list) {
public Calc compileCall(final ResolvedFunCall call, ExpCompiler compiler) {
ResultStyle[] rs = compiler.getAcceptableResultStyles();
// What is the desired return type?
for (int i = 0; i < rs.length; i++) {
switch (rs[i]) {
case ITERABLE :
case ANY :
for (ResultStyle r : rs) {
switch (r) {
case ITERABLE:
case ANY:
// Consumer wants ITERABLE or ANY
if (! Util.PreJdk15) {
if (!Util.PreJdk15) {
// jdk14 does not use Iterable
return compileCallIterable(call, compiler);
}
case LIST :
}
case LIST:
// Consumer wants (immutable) LIST
return compileCallImmutableList(call, compiler);
case MUTABLE_LIST:
Expand All @@ -130,8 +121,10 @@ public Calc compileCall(final ResolvedFunCall call, ExpCompiler compiler) {
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

protected IterCalc compileCallIterable(final ResolvedFunCall call,
ExpCompiler compiler) {
protected IterCalc compileCallIterable(
final ResolvedFunCall call,
ExpCompiler compiler)
{
final Calc calc1 = toIter(compiler, call.getArg(0));
final Calc calc2 = toIter(compiler, call.getArg(1));
Calc[] calcs = new Calc[] {calc1, calc2};
Expand Down Expand Up @@ -341,9 +334,10 @@ protected List checkList(Evaluator evaluator, List list) {
return list;
}


protected Iterable<Member[]> makeIterableIterable(final Iterable it1,
final Iterable it2) {
protected Iterable<Member[]> makeIterableIterable(
final Iterable it1,
final Iterable it2)
{
// There is no knowledge about how large either it1 ore it2
// are or how many null members they might have, so all
// one can do is iterate across them:
Expand Down Expand Up @@ -412,9 +406,11 @@ private boolean hasNextO2() {

return iterable;
}
protected Iterable<Member[]> makeIterableList(final Iterable it1,
final List l2) {

protected Iterable<Member[]> makeIterableList(
final Iterable it1,
final List l2)
{
Iterable<Member[]> iterable = new Iterable<Member[]>() {
public Iterator<Member[]> iterator() {
return new Iterator<Member[]>() {
Expand Down Expand Up @@ -478,9 +474,11 @@ private boolean hasNextO2() {
};
return iterable;
}
protected Iterable<Member[]> makeListIterable(final List l1,
final Iterable it2) {

protected Iterable<Member[]> makeListIterable(
final List l1,
final Iterable it2)
{
Iterable<Member[]> iterable = new Iterable<Member[]>() {
public Iterator<Member[]> iterator() {
return new Iterator<Member[]>() {
Expand Down Expand Up @@ -545,9 +543,11 @@ private boolean hasNextO2() {

return iterable;
}
protected Iterable<Member[]> makeListList(final List l1,
final List l2) {

protected Iterable<Member[]> makeListList(
final List l1,
final List l2)
{
Iterable<Member[]> iterable = new Iterable<Member[]>() {
public Iterator<Member[]> iterator() {
return new Iterator<Member[]>() {
Expand Down Expand Up @@ -625,6 +625,7 @@ protected Member[] makeNext(Object o1, Object o2) {
return new Member[] {(Member) o1, (Member) o2};
}
}

// Member Member[]
static abstract class BaseMemberMemberArrayIterCalc
extends BaseIterCalc {
Expand All @@ -640,6 +641,7 @@ protected Member[] makeNext(Object o1, Object o2) {
return ma;
}
}

// Member[] Member
static abstract class BaseMemberArrayMemberIterCalc
extends BaseIterCalc {
Expand All @@ -655,6 +657,7 @@ protected Member[] makeNext(Object o1, Object o2) {
return ma;
}
}

// Member[] Member[]
static abstract class BaseMemberArrayMemberArrayIterCalc
extends BaseIterCalc {
Expand Down Expand Up @@ -1881,33 +1884,6 @@ public List<Member[]> subList(int fromIndex, int toIndex) {
///////////////////////////////////////////////////////////////////////////


public Calc compileCallOld(final ResolvedFunCall call, ExpCompiler compiler) {
final ListCalc listCalc1 = toList(compiler, call.getArg(0));
final ListCalc listCalc2 = toList(compiler, call.getArg(1));
return new AbstractListCalc(call, new Calc[] {listCalc1, listCalc2}) {
public List evaluateList(Evaluator evaluator) {
SchemaReader schemaReader = evaluator.getSchemaReader();
NativeEvaluator nativeEvaluator =
schemaReader.getNativeSetEvaluator(
call.getFunDef(), call.getArgs(), evaluator, this);
if (nativeEvaluator != null) {
return (List) nativeEvaluator.execute(
ResultStyle.LIST);
}

Evaluator oldEval = null;
assert (oldEval = evaluator.push()) != null;
final List list1 = listCalc1.evaluateList(evaluator);
assert oldEval.equals(evaluator) : "listCalc1 changed context";
if (list1.isEmpty()) {
return Collections.EMPTY_LIST;
}
final List list2 = listCalc2.evaluateList(evaluator.push());
assert oldEval.equals(evaluator) : "listCalc2 changed context";
return crossJoin(list1, list2, evaluator, call);
}
};
}

List crossJoin(
List list1,
Expand Down
5 changes: 1 addition & 4 deletions src/main/mondrian/rolap/aggmatcher/AggGen.java
Expand Up @@ -3,12 +3,9 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 12 August, 2001
*/

package mondrian.rolap.aggmatcher;
Expand Down
5 changes: 1 addition & 4 deletions src/main/mondrian/rolap/aggmatcher/AggStar.java
Expand Up @@ -3,12 +3,9 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 12 August, 2001
*/

package mondrian.rolap.aggmatcher;
Expand Down
1 change: 0 additions & 1 deletion src/main/mondrian/rolap/aggmatcher/AggTableManager.java
Expand Up @@ -3,7 +3,6 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2005-2002 Kana Software, Inc.
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
Expand Down
3 changes: 1 addition & 2 deletions src/main/mondrian/rolap/aggmatcher/DefaultRecognizer.java
Expand Up @@ -3,8 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down
1 change: 0 additions & 1 deletion src/main/mondrian/rolap/aggmatcher/DefaultRules.java
Expand Up @@ -3,7 +3,6 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2005-2002 Kana Software, Inc.
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
Expand Down
5 changes: 1 addition & 4 deletions src/main/mondrian/rolap/aggmatcher/ExplicitRecognizer.java
Expand Up @@ -3,12 +3,9 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 12 August, 2001
*/

package mondrian.rolap.aggmatcher;
Expand Down
3 changes: 1 addition & 2 deletions src/main/mondrian/rolap/aggmatcher/ExplicitRules.java
Expand Up @@ -3,8 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down
5 changes: 1 addition & 4 deletions src/main/mondrian/rolap/aggmatcher/Recognizer.java
Expand Up @@ -3,12 +3,9 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2006 Julian Hyde and others
// Copyright (C) 2005-2006 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 30 August, 2001
*/

package mondrian.rolap.aggmatcher;
Expand Down

0 comments on commit e54c219

Please sign in to comment.