private void addAdditionalAttributes( CellGroup cellGroup, TupleOID originalOIDForConclusionValue, Tuple tuple, Dependency egd) { for (AttributeRef additionalAttribute : egd.getAdditionalAttributes()) { for (Cell additionalCell : tuple.getCells()) { AttributeRef unaliasedAttribute = ChaseUtility.unAlias(additionalCell.getAttributeRef()); if (!unaliasedAttribute.equals(additionalAttribute)) { continue; } TupleOID originalOIDForCell = new TupleOID(ChaseUtility.getOriginalOid(tuple, additionalCell.getAttributeRef())); if (!originalOIDForCell.equals(originalOIDForConclusionValue)) { continue; } CellGroupCell additionalCellGroupCell = new CellGroupCell( originalOIDForCell, unaliasedAttribute, additionalCell.getValue(), null, LunaticConstants.TYPE_ADDITIONAL, null); cellGroup.addAdditionalCell(additionalAttribute, additionalCellGroupCell); } } }
private void addTuple( Tuple tuple, EquivalenceClassForSymmetricEGD equivalenceClass, CostManagerConfiguration costManagerConfiguration, IDatabase deltaDB, String stepId, Scenario scenario) { if (logger.isDebugEnabled()) logger.trace("Adding tuple " + tuple + " to equivalence class: " + equivalenceClass); AttributeRef conclusionAttribute = equivalenceClass.getConclusionAttribute(); Cell cellToChangeForForwardChasing = tuple.getCell(conclusionAttribute); if (logger.isDebugEnabled()) logger.trace( "Attribute: " + conclusionAttribute + " - Cell: " + cellToChangeForForwardChasing); IValue conclusionValue = cellToChangeForForwardChasing.getValue(); TupleOID originalOid = new TupleOID(ChaseUtility.getOriginalOid(tuple, conclusionAttribute)); CellRef cellRef = new CellRef(originalOid, ChaseUtility.unAlias(conclusionAttribute)); CellGroupCell targetCell = new CellGroupCell(cellRef, conclusionValue, null, LunaticConstants.TYPE_OCCURRENCE, null); CellGroup forwardCellGroup = new CellGroup(conclusionValue, true); forwardCellGroup.addOccurrenceCell(targetCell); addAdditionalAttributes(forwardCellGroup, originalOid, tuple, equivalenceClass.getEGD()); CellGroup enrichedCellGroup = this.occurrenceHandler.enrichCellGroups(forwardCellGroup, deltaDB, stepId, scenario); EGDEquivalenceClassTuple tupleCells = new EGDEquivalenceClassTuple(enrichedCellGroup); for (BackwardAttribute backwardAttribute : equivalenceClass.getAttributesToChangeForBackwardChasing()) { AttributeRef attributeForBackwardChasing = backwardAttribute.getAttributeRef(); Cell cellForBackward = tuple.getCell(attributeForBackwardChasing); TupleOID tupleOid = new TupleOID(ChaseUtility.getOriginalOid(tuple, attributeForBackwardChasing)); Cell backwardCell = new Cell( tupleOid, ChaseUtility.unAlias(attributeForBackwardChasing), cellForBackward.getValue()); IValue value = backwardCell.getValue(); CellGroup backwardCellGroup = new CellGroup(value, true); backwardCellGroup.addOccurrenceCell( new CellGroupCell(backwardCell, null, LunaticConstants.TYPE_OCCURRENCE, null)); CellGroup enrichedBackwardCellGroup = this.occurrenceHandler.enrichCellGroups(backwardCellGroup, deltaDB, stepId, scenario); tupleCells.setCellGroupForBackwardAttribute(backwardAttribute, enrichedBackwardCellGroup); } equivalenceClass.addTupleCells(tupleCells); equivalenceClass.addTupleCellsForValue(conclusionValue, tupleCells); if (costManagerConfiguration.isDoBackwardOnDependency(equivalenceClass.getEGD())) { indexCells(tupleCells, equivalenceClass); } if (logger.isDebugEnabled()) logger.trace("Equivalence class: " + equivalenceClass); }