use of org.olap4j.impl.CoordinateIterator in project mondrian by pentaho.
the class TestContext method cellIter.
/**
* Returns an iterator over cells in an olap4j cell set.
*/
static Iterable<org.olap4j.Cell> cellIter(final CellSet cellSet) {
return new Iterable<org.olap4j.Cell>() {
public Iterator<org.olap4j.Cell> iterator() {
int[] axisDimensions = new int[cellSet.getAxes().size()];
int k = 0;
for (CellSetAxis axis : cellSet.getAxes()) {
axisDimensions[k++] = axis.getPositions().size();
}
final CoordinateIterator coordIter = new CoordinateIterator(axisDimensions);
return new Iterator<org.olap4j.Cell>() {
public boolean hasNext() {
return coordIter.hasNext();
}
public org.olap4j.Cell next() {
final int[] ints = coordIter.next();
final List<Integer> list = new AbstractList<Integer>() {
public Integer get(int index) {
return ints[index];
}
public int size() {
return ints.length;
}
};
return cellSet.getCell(list);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
use of org.olap4j.impl.CoordinateIterator in project mondrian by pentaho.
the class TestContext method cellIter.
/**
* Returns an iterator over cells in a result.
*/
static Iterable<Cell> cellIter(final Result result) {
return new Iterable<Cell>() {
public Iterator<Cell> iterator() {
int[] axisDimensions = new int[result.getAxes().length];
int k = 0;
for (Axis axis : result.getAxes()) {
axisDimensions[k++] = axis.getPositions().size();
}
final CoordinateIterator coordIter = new CoordinateIterator(axisDimensions);
return new Iterator<Cell>() {
public boolean hasNext() {
return coordIter.hasNext();
}
public Cell next() {
final int[] ints = coordIter.next();
return result.getCell(ints);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
use of org.olap4j.impl.CoordinateIterator in project pentaho-kettle by pentaho.
the class CellSetFormatter method cellIter.
/**
* Returns an iterator over cells in a result.
*/
private static Iterable<Cell> cellIter(final int[] pageCoords, final CellSet cellSet) {
return new Iterable<Cell>() {
public Iterator<Cell> iterator() {
final int[] axisDimensions = new int[cellSet.getAxes().size() - pageCoords.length];
assert pageCoords.length <= axisDimensions.length;
for (int i = 0; i < axisDimensions.length; i++) {
final CellSetAxis axis = cellSet.getAxes().get(i);
axisDimensions[i] = axis.getPositions().size();
}
final CoordinateIterator coordIter = new CoordinateIterator(axisDimensions, true);
return new Iterator<Cell>() {
public boolean hasNext() {
return coordIter.hasNext();
}
public Cell next() {
final int[] ints = coordIter.next();
final AbstractList<Integer> intList = new AbstractList<Integer>() {
@Override
public Integer get(final int index) {
return index < ints.length ? ints[index] : pageCoords[index - ints.length];
}
@Override
public int size() {
return pageCoords.length + ints.length;
}
};
return cellSet.getCell(intList);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
Aggregations