Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public boolean hasNext() {
@Override
public Member[] next() {
final List<Member> next = tupleIterator.next();
return next.toArray(new Member[next.size()]);
return next.toArray(Member[]::new);
}

@Override
Expand All @@ -325,7 +325,7 @@ public static List<Member[]> asMemberArrayList(
@Override
public Member[] get(int index) {
final List<Member> tuple = tupleList.get(index);
return tuple.toArray(new Member[tuple.size()]);
return tuple.toArray(Member[]::new);
}

@Override
Expand Down
21 changes: 13 additions & 8 deletions common/src/main/java/org/eclipse/daanse/olap/fun/FunUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.eclipse.daanse.mdx.model.api.expression.operation.OperationAtom;
import org.eclipse.daanse.olap.api.CatalogReader;
import org.eclipse.daanse.olap.api.DataType;
Expand Down Expand Up @@ -100,6 +103,8 @@
*/
public class FunUtil extends Util {

private static final Logger LOGGER = LoggerFactory.getLogger(FunUtil.class);

public static final NullMember NullMember = new NullMember();


Expand Down Expand Up @@ -481,8 +486,8 @@ public static int compareValues( Object value0, Object value1 ) {
( (Number) value1 ).doubleValue() );
} else if ( value0 instanceof Date date) {
return date.compareTo( (Date) value1 );
} else if ( value0 instanceof OrderKey orderKey) {
return orderKey.compareTo( value1 );
} else if ( value0 instanceof OrderKey orderKey && value1 instanceof OrderKey orderKeyOther) {
return orderKey.compareTo( orderKeyOther);
} else {
throw Util.newInternal( "cannot compare " + value0 );
}
Expand Down Expand Up @@ -940,8 +945,8 @@ public static SetWrapper[] evaluateSet(
DoubleCalc calc = calcs[ i ];
SetWrapper retval = retvals[ i ];
Double o = calc.evaluate( evaluator );
if(o==null) {
System.out.println(calc);
if (o == null) {
LOGGER.debug("Calc evaluated to null: {}", calc);
}
if ( o == FunUtil.DOUBLE_NULL) {
retval.nullCount++;
Expand Down Expand Up @@ -1673,7 +1678,7 @@ private static Member getCorrespondingMember(


public static class SetWrapper {
public List v = new ArrayList();
public List<Object> v = new ArrayList<>();
public int errorCount = 0;
public int nullCount = 0;

Expand All @@ -1700,16 +1705,16 @@ public static class SetWrapper {
* Nulls compare last, exceptions (including the
* object which indicates the the cell is not in the cache yet) next, then numbers and strings are compared by value.
*/
public static class DescendingValueComparator implements Comparator {
public static class DescendingValueComparator implements Comparator<Object> {
/**
* The singleton.
*/
public static final DescendingValueComparator instance =
new DescendingValueComparator();

@Override
public int compare( Object o1, Object o2 ) {
return -FunUtil.compareValues( o1, o2 );
public int compare(Object o1, Object o2) {
return -FunUtil.compareValues(o1, o2);
}
}

Expand Down
56 changes: 27 additions & 29 deletions common/src/main/java/org/eclipse/daanse/olap/fun/sort/OrderKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,35 @@

import org.eclipse.daanse.olap.api.element.Member;

public class OrderKey implements Comparable<OrderKey> {

public class OrderKey implements Comparable {
final Member member;
final Member member;

public OrderKey( Member member ) {
super();
this.member = member;
}

@Override
public int compareTo( Object o ) {
assert o instanceof OrderKey;
OrderKey other = (OrderKey) o;
Member otherMember = other.member;
final boolean thisCalculated = this.member.isCalculatedInQuery();
final boolean otherCalculated = otherMember.isCalculatedInQuery();
if ( thisCalculated ) {
if ( !otherCalculated ) {
return 1;
}
} else {
if ( otherCalculated ) {
return -1;
}
public OrderKey(Member member) {
this.member = member;
}
final Comparable thisKey = this.member.getOrderKey();
final Comparable otherKey = otherMember.getOrderKey();
if ( ( thisKey != null ) && ( otherKey != null ) ) {
return thisKey.compareTo( otherKey );
} else {
return this.member.compareTo( otherMember );

@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public int compareTo(OrderKey other) {
Member otherMember = other.member;
final boolean thisCalculated = this.member.isCalculatedInQuery();
final boolean otherCalculated = otherMember.isCalculatedInQuery();
if (thisCalculated) {
if (!otherCalculated) {
return 1;
}
} else {
if (otherCalculated) {
return -1;
}
}
final Comparable thisKey = this.member.getOrderKey();
final Comparable otherKey = otherMember.getOrderKey();
if ((thisKey != null) && (otherKey != null)) {
return thisKey.compareTo(otherKey);
} else {
return this.member.compareTo(otherMember);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,8 @@ public static TupleList sortTuples(
tupleArrayList = tupleList;
}

@SuppressWarnings( { "unchecked" } )
List<Member>[] tuples =
tupleArrayList.toArray( new List[ tupleArrayList.size() ] );
@SuppressWarnings("unchecked")
List<Member>[] tuples = tupleArrayList.toArray(List[]::new);
final DelegatingTupleList result =
new DelegatingTupleList(
tupleIterable.getArity(),
Expand Down Expand Up @@ -645,8 +644,8 @@ public static int compareValues( Object value0, Object value1 ) {
return ( (Date) value0 ).compareTo( (Date) value1 );
} else if ( value0 instanceof LocalDateTime ) {
return ( (LocalDateTime) value0 ).compareTo( (LocalDateTime) value1 );
} else if ( value0 instanceof OrderKey ) {
return ( (OrderKey) value0 ).compareTo( value1 );
} else if ( value0 instanceof OrderKey orderKey0 && value0 instanceof OrderKey orderKey1 ) {
return orderKey0.compareTo( orderKey1);
} else {
throw newInternal( "cannot compare " + value0 );
}
Expand Down
Loading