protected CellRequest createRequest( final String cube, final String measureName, final String[] tables, final String[] columns, final String[] values, CellRequestConstraint aggConstraint) { RolapStar.Measure starMeasure = getMeasure(cube, measureName); CellRequest request = createRequest(cube, measureName, tables, columns, values); final RolapStar star = starMeasure.getStar(); request.addAggregateList(aggConstraint.getBitKey(star), aggConstraint.toPredicate(star)); return request; }
protected CellRequest createRequest( final String cube, final String measureName, final String[] tables, final String[] columns, final String[] values) { RolapStar.Measure starMeasure = getMeasure(cube, measureName); CellRequest request = new CellRequest(starMeasure, false, false); final RolapStar star = starMeasure.getStar(); for (int i = 0; i < tables.length; i++) { String table = tables[i]; if (table != null && table.length() > 0) { String column = columns[i]; String value = values[i]; final RolapStar.Column storeTypeColumn = star.lookupColumn(table, column); request.addConstrainedColumn( storeTypeColumn, new ValueColumnPredicate(storeTypeColumn, value)); } } return request; }
/** * Sets the value of a cell. * * @param connection Connection (not currently used) * @param members Coordinates of cell * @param newValue New value * @param currentValue Current value * @param allocationPolicy Allocation policy * @param allocationArgs Additional arguments of allocation policy */ public void setCellValue( Connection connection, List<RolapMember> members, double newValue, double currentValue, AllocationPolicy allocationPolicy, Object[] allocationArgs) { Util.discard(connection); // for future use assert allocationPolicy != null; assert allocationArgs != null; switch (allocationPolicy) { case EQUAL_ALLOCATION: case EQUAL_INCREMENT: if (allocationArgs.length != 0) { throw Util.newError( "Allocation policy " + allocationPolicy + " takes 0 arguments; " + allocationArgs.length + " were supplied"); } break; default: throw Util.newError("Allocation policy " + allocationPolicy + " is not supported"); } // Compute the set of columns which are constrained by the cell's // coordinates. // // NOTE: This code is very similar to code in // RolapAggregationManager.makeCellRequest. Consider creating a // CellRequest then mining it. It will work better in the presence of // calculated members, compound members, parent-child hierarchies, // hierarchies whose default member is not the 'all' member, and so // forth. final RolapStoredMeasure measure = (RolapStoredMeasure) members.get(0); final RolapCube baseCube = measure.getCube(); final RolapStar.Measure starMeasure = (RolapStar.Measure) measure.getStarMeasure(); assert starMeasure != null; int starColumnCount = starMeasure.getStar().getColumnCount(); final BitKey constrainedColumnsBitKey = BitKey.Factory.makeBitKey(starColumnCount); Object[] keyValues = new Object[starColumnCount]; for (int i = 1; i < members.size(); i++) { Member member = members.get(i); for (RolapCubeMember m = (RolapCubeMember) member; m != null && !m.isAll(); m = m.getParentMember()) { final RolapCubeLevel level = m.getLevel(); RolapStar.Column column = level.getBaseStarKeyColumn(baseCube); if (column != null) { final int bitPos = column.getBitPosition(); keyValues[bitPos] = m.getKey(); constrainedColumnsBitKey.set(bitPos); } if (level.areMembersUnique()) { break; } } } // Squish the values down. We want the compactKeyValues[i] to correspond // to the i'th set bit in the key. This is the same format used by // CellRequest. Object[] compactKeyValues = new Object[constrainedColumnsBitKey.cardinality()]; int k = 0; for (int bitPos : constrainedColumnsBitKey) { compactKeyValues[k++] = keyValues[bitPos]; } // Record the override. // // TODO: add a mechanism for persisting the overrides to a file. // // FIXME: make thread-safe writebackCells.add( new WritebackCell( baseCube, new ArrayList<RolapMember>(members), constrainedColumnsBitKey, compactKeyValues, newValue, currentValue, allocationPolicy)); }
public PeekResponse call() { final RolapStar.Measure measure = request.getMeasure(); final RolapStar star = measure.getStar(); final RolapSchema schema = star.getSchema(); final AggregationKey key = new AggregationKey(request); final List<SegmentHeader> headers = indexRegistry .getIndex(star) .locate( schema.getName(), schema.getChecksum(), measure.getCubeName(), measure.getName(), star.getFactTable().getAlias(), request.getConstrainedColumnsBitKey(), request.getMappedCellValues(), AggregationKey.getCompoundPredicateStringList( star, key.getCompoundPredicateList())); final Map<SegmentHeader, Future<SegmentBody>> headerMap = new HashMap<SegmentHeader, Future<SegmentBody>>(); final Map<List, SegmentBuilder.SegmentConverter> converterMap = new HashMap<List, SegmentBuilder.SegmentConverter>(); // Is there a pending segment? (A segment that has been created and // is loading via SQL.) for (final SegmentHeader header : headers) { final Future<SegmentBody> bodyFuture = indexRegistry.getIndex(star).getFuture(header); if (bodyFuture != null) { // Check if the DataSourceChangeListener wants us to clear // the current segment if (star.getChangeListener() != null && star.getChangeListener().isAggregationChanged(key)) { /* * We can't satisfy this request, and we must clear the * data from our cache. We clear it from the index * first, then queue up a job in the background * to remove the data from all the caches. */ indexRegistry.getIndex(star).remove(header); Util.safeGet( cacheExecutor.submit( new Runnable() { public void run() { try { compositeCache.remove(header); } catch (Throwable e) { LOGGER.warn("remove header failed: " + header, e); } } }), "SegmentCacheManager.peek"); } converterMap.put( SegmentCacheIndexImpl.makeConverterKey(header), getConverter(star, header)); headerMap.put(header, bodyFuture); } } return new PeekResponse(headerMap, converterMap); }