当前位置: 首页>>代码示例>>Python>>正文


Python Common.computeCacheKeys方法代码示例

本文整理汇总了Python中common.Common.computeCacheKeys方法的典型用法代码示例。如果您正苦于以下问题:Python Common.computeCacheKeys方法的具体用法?Python Common.computeCacheKeys怎么用?Python Common.computeCacheKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Common的用法示例。


在下文中一共展示了Common.computeCacheKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: op_eq

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import computeCacheKeys [as 别名]
def op_eq(left,right, cacheJoins=False, bc = None):
    '''
    :param left:
    :type left: :class:`~ExprArg`
    :param right:
    :type right: :class:`~ExprArg`
    :returns: :class:`~BoolArg` 
    
    Ensures that the left = right.
    '''
    assert isinstance(left, ExprArg)
    assert isinstance(right, ExprArg)
    if cacheJoins and bc:
        #TODO CLEAN
        left_key = None
        right_key = None
        keys = []
        #asil allocation speedup, if both sides are sets, we can perform expression substitution in other constraints
        #bc is the bracketed constraint to put the cache
        
        for i in [left,right]:
            if isinstance(i, JoinArg):
                newkeys = Common.computeCacheKeys(i.flattenJoin())
                
                #print(tuple(key))
                keys = keys + newkeys
                #need to return all keys during the progress of join, add flag?
                #get the all keys
                all_keys = i.checkIfJoinIsComputed(nonsupered=True, getAllKeys = True)
                #print(keys)
                #print(all_keys)
                keys = keys+all_keys
                #sys.exit()
                #print()
            #print("GGGG right" + str(right.__class__))
            #print(right.clafers)
        if len(left.clafers) != len(right.clafers):
            minJoinVal = left.clafers if len(left.clafers) < len(right.clafers) else right.clafers
            for i in keys:
                #TODO make more robust (e.g. if multiple equalities exist for the same join key, aggregate expressions
                bc.cache[i] = ExprArg(minJoinVal)
                #print(i)
                #print(minJoinVal)
                #print(str(len(minJoinVal)) + "  " + str(len(left.clafers)) + "  " + str(len(right.clafers)))
        #print(str(len(left.clafers)) + " " + str(len(right.clafers)))
    
    cond = []
    #int equality case
    lints = [(e,c) for (e,c) in left.getInts() if str(c) != "False"]
    rints = [(e,c) for (e,c) in right.getInts() if str(c) != "False"]
    if lints or rints:
        for (e,c) in lints:
            #exists r in R s.t. e == r
            expr = mOr(*[mAnd(rc, SMTLib.SMT_EQ(e,r)) for (r,rc) in rints]) 
            if str(c) != "True":
                expr = SMTLib.SMT_Implies(c, expr)
            cond.append(expr)        
        for (e,c) in rints:
            #exists l in L s.t. e == l
            expr = mOr(*[mAnd(lc, SMTLib.SMT_EQ(e,l)) for (l,lc) in lints]) 
            if str(c) != "True":
                expr = SMTLib.SMT_Implies(c, expr)
            cond.append(expr)    
    #clafer-set equality case
    matches = getSetInstancePairs(left,right)
    for ((lexpr, lpol),(rexpr, rpol)) in matches.values():
        if lpol == Common.DEFINITELY_OFF and rpol == Common.DEFINITELY_OFF:
            continue
        elif lpol == Common.DEFINITELY_OFF:
            cond.append(SMTLib.createNot(rexpr))
        elif rpol == Common.DEFINITELY_OFF:
            cond.append(SMTLib.createNot(lexpr))
        else:
            cond.append(SMTLib.SMT_Implies(lexpr, rexpr))
            cond.append(SMTLib.SMT_Implies(rexpr, lexpr))
    return BoolArg(mAnd(*cond))
开发者ID:gsdlab,项目名称:ClaferSMT,代码行数:78,代码来源:Set.py


注:本文中的common.Common.computeCacheKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。