Skip to content

Commit

Permalink
MONDRIAN: Add toString method for DenseDoubleSegmentBody;
Browse files Browse the repository at this point in the history
    use Arrays.toString where possible.

[git-p4: depot-paths = "//open/mondrian/": change = 14189]
  • Loading branch information
julianhyde committed Apr 6, 2011
1 parent 79e5ca6 commit d4efaa9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main/mondrian/rolap/FastBatchingCellReader.java
Expand Up @@ -376,10 +376,10 @@ public String toString() {
if (string == null) {
final StringBuilder buf = new StringBuilder();
buf.append("Batch {\n")
.append(" columns={").append(Arrays.asList(columns))
.append(" columns={").append(Arrays.toString(columns))
.append("}\n")
.append(" measures={").append(measuresList).append("}\n")
.append(" valueSets={").append(Arrays.asList(valueSets))
.append(" valueSets={").append(Arrays.toString(valueSets))
.append("}\n")
.append(" batchKey=").append(batchKey).append("}\n")
.append("}");
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapEvaluator.java
Expand Up @@ -452,7 +452,7 @@ public final void setContext(Member[] members) {
getLogger().debug(
"RolapEvaluator.setContext: "
+ "member == null, memberList: "
+ Arrays.asList(members));
+ Arrays.toString(members));
}
assert false;
continue;
Expand Down
30 changes: 22 additions & 8 deletions src/main/mondrian/rolap/agg/DenseDoubleSegmentBody.java
Expand Up @@ -9,8 +9,7 @@
*/
package mondrian.rolap.agg;

import java.util.BitSet;
import java.util.SortedSet;
import java.util.*;

/**
* Implementation of a segment body which stores the data inside
Expand All @@ -23,12 +22,13 @@ class DenseDoubleSegmentBody extends AbstractSegmentBody {
final double[] data;
private final int size;
private final BitSet nullIndicators;

DenseDoubleSegmentBody(
BitSet nullIndicators,
double[] dataToSave,
int size,
SortedSet<Comparable<?>>[] axisValueSets,
boolean[] nullAxisFlags)
BitSet nullIndicators,
double[] dataToSave,
int size,
SortedSet<Comparable<?>>[] axisValueSets,
boolean[] nullAxisFlags)
{
super(axisValueSets, nullAxisFlags);
this.size = size;
Expand All @@ -37,6 +37,7 @@ class DenseDoubleSegmentBody extends AbstractSegmentBody {
this.nullIndicators = new BitSet(nullIndicators.length());
this.nullIndicators.or(nullIndicators);
}

public SegmentDataset createSegmentDataset(Segment segment) {
DenseDoubleSegmentDataset ds =
new DenseDoubleSegmentDataset(segment, this.size);
Expand All @@ -45,5 +46,18 @@ public SegmentDataset createSegmentDataset(Segment segment) {
ds.nullIndicators.or(nullIndicators);
return ds;
}

@Override
public String toString() {
return "DenseDoubleSegmentBody(size=" + size
+ ", data=" + Arrays.toString(data)
+ ", nullIndicators=" + nullIndicators
+ ", axisValueSets=" + Arrays.toString(getAxisValueSets())
+ ", nullAxisFlags=" + Arrays.toString(getNullAxisFlags())
+ ", aVS[0]=" + getAxisValueSets()[0].getClass()
+ ", aVS[0][0]=" + getAxisValueSets()[0].iterator().next().getClass()
+ ")";
}
}
// End DenseDoubleSegmentBody.java

// End DenseDoubleSegmentBody.java
4 changes: 4 additions & 0 deletions testsrc/main/mondrian/rolap/agg/MockSegmentCache.java
Expand Up @@ -106,6 +106,10 @@ public Future<Boolean> put(
ObjectInputStream ois = new ObjectInputStream(in);
SegmentBody o = (SegmentBody) ois.readObject();
Util.discard(o);
} catch (NotSerializableException e) {
throw new RuntimeException(
"while serializing " + body,
e);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
10 changes: 5 additions & 5 deletions testsrc/main/mondrian/util/FormatTest.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// Copyright (C) 2006-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -562,21 +562,21 @@ public void testFrenchLocale() {
assertEquals("/", fr.dateSeparator);
assertEquals(
"[, dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]",
Arrays.asList(fr.daysOfWeekLong).toString());
Arrays.toString(fr.daysOfWeekLong));
assertEquals(
"[, dim., lun., mar., mer., jeu., ven., sam.]",
Arrays.asList(fr.daysOfWeekShort).toString());
Arrays.toString(fr.daysOfWeekShort));
assertEquals(
"[janvier, f" + I18nTest.EA + "vrier, mars, avril, mai, juin,"
+ " juillet, ao" + I18nTest.UC
+ "t, septembre, octobre, novembre, d"
+ I18nTest.EA + "cembre, ]",
Arrays.asList(fr.monthsLong).toString());
Arrays.toString(fr.monthsLong));
assertEquals(
"[janv., f" + I18nTest.EA + "vr., mars, avr., mai, juin,"
+ " juil., ao" + I18nTest.UC + "t, sept., oct., nov., d"
+ I18nTest.EA + "c., ]",
Arrays.asList(fr.monthsShort).toString());
Arrays.toString(fr.monthsShort));
assertEquals(',', fr.decimalPlaceholder);
assertEquals(I18nTest.Nbsp, fr.thousandSeparator);
assertEquals(":", fr.timeSeparator);
Expand Down

0 comments on commit d4efaa9

Please sign in to comment.