protected Operation filterEqForMappedAttribute(Attribute other)
    {
        MappedAttribute left = (MappedAttribute) this;
        if (other instanceof MappedAttribute)
        {
            MappedAttribute right = (MappedAttribute) other;
            if (left.getMapper().equals(right.getMapper()))
            {
                // condition (1) with common mapper
                return new MappedOperation(left.getMapper(), left.getWrappedAttribute().filterEqWithCheck(right.getWrappedAttribute()));
            }
            Mapper commonMapper = left.getMapper().getCommonMapper(right.getMapper());
            if (left.getMapper().equals(commonMapper))
            {
                // left is shorter than right. Condition (3) with common mapper
                return filterEqWithPartialCommon(left, right, commonMapper);
            }
            if (right.getMapper().equals(commonMapper))
            {
                // right is shorter than left. Condition (2) with common mapper
                return filterEqWithPartialCommon(right, left, commonMapper);
            }
            else
            {
                // condition 4
                Mapper mapper = this.constructEqualityMapper(other);
                mapper.setAnonymous(true);
                return new MappedOperation(mapper, new All(((MappedAttribute)other).getWrappedAttribute()));
            }
        }
        else
        {
            return other.filterEqWithCheck(this); // Condition (2) without common mapper
        }
    }
protected Operation filterEqForMappedAttribute ( Attribute other ) { MappedAttribute left = ( MappedAttribute ) this ; if ( other instanceof MappedAttribute ) { MappedAttribute right = ( MappedAttribute ) other ; if ( left . getMapper ( ) . equals ( right . getMapper ( ) ) ) { return new MappedOperation ( left . getMapper ( ) , left . getWrappedAttribute ( ) . filterEqWithCheck ( right . getWrappedAttribute ( ) ) ) ; } Mapper commonMapper = left . getMapper ( ) . getCommonMapper ( right . getMapper ( ) ) ; if ( left . getMapper ( ) . equals ( commonMapper ) ) { return filterEqWithPartialCommon ( left , right , commonMapper ) ; } if ( right . getMapper ( ) . equals ( commonMapper ) ) { return filterEqWithPartialCommon ( right , left , commonMapper ) ; } else { Mapper mapper = this . constructEqualityMapper ( other ) ; mapper . setAnonymous ( true ) ; return new MappedOperation ( mapper , new All ( ( ( MappedAttribute ) other ) . getWrappedAttribute ( ) ) ) ; } } else { return other . filterEqWithCheck ( this ) ; } }
/*
First reduce the left and right mappers to the common ancestor, then there are 4 possibilities here
1) leftReduced and rightReduced are not mapped. This is a plain filter operation with a common mapper on top
2) leftReduced is mapped, rightReduced is not mapped. equivalent to (3), just flipped.
3) leftReduced is not mapped, rightReduced is mapped. If the rightReduced mapper is one level, it's a join constraint. otherwise, it's a triangle join constraint
4) leftReduced and rightReduced are both mapped. This is a triangle join constraint.