Пример #1
0
def p_union_block_0(p):
    """
    union_block : pjoin_block rest_union_block POINT pjoin_block 
    """
    punion = [JoinBlock(p[1])] + p[2]
    pjoin = [UnionBlock(punion)] + p[4]
    p[0] = [JoinBlock(pjoin)]
Пример #2
0
def p_bgp_00(p):
    """
    bgp : LKEY bgp  UNION bgp rest_union_block  RKEY
    """
    (jb1,filters1) = p[2]
    (jb3,filters3) = p[4]
    ggp = [JoinBlock(jb1,filters1)] + [JoinBlock(jb3,filters3)] + p[5]
    ggp1 = [UnionBlock(ggp)]
    p[0]=(ggp1,[])
Пример #3
0
def p_bgp_01(p):
    """
    bgp : bgp  UNION bgp rest_union_block 
    """
    (jb1,filters1) = p[1]
    (jb3,filters3) = p[3]
    ggp = [JoinBlock(jb1,filters1)] + [JoinBlock(jb3,filters3)] + p[4]
    ggp1 = [UnionBlock(ggp)]
    p[0]=(ggp1,[])
Пример #4
0
def p_union_block_1(p):
    """
    union_block : pjoin_block rest_union_block pjoin_block 
    """
    punion = [JoinBlock(p[1])] + p[2]
    if (p[3] != []):
        pjoin = [UnionBlock(punion)] + p[3]
        p[0] = [JoinBlock(pjoin)]
    else:
        p[0] = [JoinBlock(p[1])] + p[2]
Пример #5
0
def p_join_block_service_0(p):
    """
    join_block_service : LKEY bgp_service rest_join_block_service RKEY rest_join_block_service
    """
    jb_list = [p[2]]+ p[3]
    if (p[5]!=[] and isinstance(p[5][0],Filter)):
      p[0] = [UnionBlock([JoinBlock(jb_list)])] + p[5]
    elif isinstance(p[2],UnionBlock):
      p[0] =  [p[2]]+ p[3] + p[5]
    else:
      p[0] = [UnionBlock([JoinBlock(jb_list)])] + p[5]
Пример #6
0
def p_bgp_6(p):
    """
    bgp : LKEY join_block RKEY
    """
    if (len(p[2]) == 1):
        p[0] = p[2][0]
    else:
        p[0] = JoinBlock(p[2])
Пример #7
0
def p_bgp_6(p):
    """
    bgp : LKEY join_block RKEY
    """
    (jb,filters)=p[2]
    if (len(jb)==1):
       p[0] = (jb,filters)
    else:
       p[0] = ([JoinBlock(jb,filters)],[])
Пример #8
0
def p_join_block_0(p):
    """
    join_block : LKEY union_block RKEY rest_join_block 
    """
    if (p[4] != [] and isinstance(p[4][0], Filter)):
        p[0] = [UnionBlock(p[2])] + p[4]
    elif (p[4] != []):
        p[0] = [UnionBlock(p[2])] + [JoinBlock(p[4])]
    else:
        p[0] = [UnionBlock(p[2])]
Пример #9
0
def decomposeJoinBlock(jb, l, genPred, prefixes, decomposition, c):
    # jb == joinblock
    # l == list de endpoints
    tl = []
    sl = []
    fl = []
    #print "len jb.triples" + str(len(jb.triples))

    for bgp in jb.triples:
        if isinstance(bgp, Triple):
            tl.append(bgp)
        elif isinstance(bgp, Filter):
            fl.append(bgp)
        elif isinstance(bgp, Optional):
            sl.append(
                Optional(
                    decomposeUnionBlock(bgp.bgg, l, genPred, prefixes,
                                        decomposition, c)))
        elif isinstance(bgp, UnionBlock):
            pub = decomposeUnionBlock(bgp, l, genPred, prefixes, decomposition,
                                      c)
            if pub:
                sl.append(pub)
        elif isinstance(bgp, JoinBlock):
            pub = decomposeJoinBlock(bgp, l, genPred, prefixes, decomposition,
                                     c)
            if pub:
                sl.append(pub)
    #print 'fl'
    #print fl
    if tl:
        gs = getGroups(l, tl, genPred, prefixes, decomposition, c)
        #print 'gs'
        #print gs
        if gs:
            gs.extend(sl)
            sl = gs
        else:
            return None

    fl1 = includeFilter(sl, fl)
    fl = list(set(fl) - set(fl1))
    #print "sl" + str(sl) + str(len(sl))
    #print "fl" + str(fl)
    if sl:
        if (len(sl) == 1 and isinstance(sl[0], UnionBlock) and fl != []):
            sl[0] = updateFilters(sl[0], fl)
        j = JoinBlock(sl, filters=fl)
        #print "filters" + str(j.filters)
        return j
    else:
        return None
Пример #10
0
def getExclusiveGroups(l, tl, prefixes):
    (qcl0, qcl1) = assignEndpoint2(tl, l, prefixes)
    views0 = []
    views1 = []
    for cl in qcl0:
        l0 = qcl0[cl]
        serv = Service(cl, l0)
        views0 = views0 + [serv]
    for t in qcl1:
        eps = qcl1[t]
        elems = [JoinBlock([Service(ep, t)]) for ep in eps]
        ub = UnionBlock(elems)
        views1 = views1 + [ub]
    return (views0, views1)
Пример #11
0
def getUnitaryStars(l, tl, genPred, prefixes):
    (qcl0, qcl1) = assignEndpoint(tl, l, genPred, prefixes)

    views0 = []
    views1 = []
    for cl in qcl0:
        l0 = qcl0[cl]
        vs = formStars2(l0)
        serv = [Service(cl, view) for view in vs]
        views0 = views0 + serv
    for t in qcl1:
        eps = qcl1[t]
        elems = [JoinBlock([Service(ep, t)]) for ep in eps]
        ub = UnionBlock(elems)
        views1 = views1 + [ub]
    return (views0, views1)
Пример #12
0
def getStarsM(l, tl, genPred, prefixes, c):
    (qcl0, qcl1) = assignEndpointM(tl, l, genPred, prefixes, c)
    views0 = []
    views1 = []
    #print qcl0
    #print qcl1
    for cl in qcl0:
        l0 = qcl0[cl]
        vs = formStars(l0)
        serv = [Service(cl, view) for view in vs]
        views0 = views0 + serv
    for t in qcl1:
        eps = qcl1[t]
        elems = [JoinBlock([Service(ep, t)]) for ep in eps]
        ub = UnionBlock(elems)
        views1 = views1 + [ub]
    return (postp2(views0), views1)
Пример #13
0
def makePlanJoinBlock(jb, plan):
    sl = []
    ol = []
    for bgp in jb.triples:
        if type(bgp) == list:
            sl.extend(bgp)
        elif isinstance(bgp, Optional):
            ol.append(Optional(makePlanUnionBlock(bgp.bgg, plan)))
        elif isinstance(bgp, UnionBlock):
            sl.append(makePlanUnionBlock(bgp, plan))
        elif isinstance(bgp, Service):
            sl.append(bgp)

    pl = makePlanAux(sl, plan)
    if ol:
        pl = [pl]
        pl.extend(ol)
    return JoinBlock(pl)
Пример #14
0
def decomposeJoinBlock(jb, l, genPred, prefixes, decomposition, c):
    # jb == joinblock
    # l == list de endpoints
    tl = []
    sl = []
    fl = []

    for bgp in jb.triples:
        # print bgp
        if isinstance(bgp, Triple):
            tl.append(bgp)
        elif isinstance(bgp, Filter):
            fl.append(bgp)
        elif isinstance(bgp, Optional):
            sl.append(
                Optional(
                    decomposeUnionBlock(bgp.bgg, l, genPred, prefixes,
                                        decomposition, c)))
        elif isinstance(bgp, UnionBlock):
            pub = decomposeUnionBlock(bgp, l, genPred, prefixes, decomposition,
                                      c)
            if pub:
                sl.append(pub)
    # print 'tl'
    # print tl
    if tl:
        gs = getGroups(l, tl, genPred, prefixes, decomposition, c)
        # print 'gs'
        # print gs
        if gs:
            gs.extend(sl)
            sl = gs
        else:
            return None

    includeFilter(sl, fl)
    # print 'sl'
    # print sl
    if sl:
        return JoinBlock(sl)
    else:
        return None
Пример #15
0
def p_rest_union_block_service_1(p):
    """
    rest_union_block_service : UNION LKEY join_block_service rest_union_block_service RKEY rest_union_block_service
    """
    p[0] = [JoinBlock(p[3])] + p[4] + p[6]
Пример #16
0
def p_bgp_01(p):
    """
    bgp : bgp UNION bgp rest_union_block 
    """
    ggp = [JoinBlock([p[1]])] + [JoinBlock([p[3]])] + p[4]
    p[0] = UnionBlock(ggp)
Пример #17
0
def p_bgp_0(p):
    """
    bgp :  LKEY bgp UNION bgp rest_union_block RKEY
    """
    ggp = [JoinBlock([p[2]])] + [JoinBlock([p[4]])] + p[5]
    p[0] = UnionBlock(ggp)
Пример #18
0
def p_bgp_service_02(p):
    """
    bgp_service :  join_block_service UNION join_block_service rest_union_block_service 
    """
    ggp = [JoinBlock(p[1])] + [JoinBlock(p[3])] + p[4]
    p[0] = UnionBlock(ggp)
Пример #19
0
def p_rest_union_block_1(p):
    """
    rest_union_block : UNION LKEY join_block rest_union_block RKEY rest_union_block
    """
    p[0] = [JoinBlock(p[3])] + p[4] + p[6]
Пример #20
0
def p_union_block_2(p):
    """
    union_block : pjoin_block rest_union_block
    """
    p[0] = [JoinBlock(p[1])] + p[2]
Пример #21
0
def p_rest_union_block_1(p):
    """
    rest_union_block : UNION join_block rest_union_block
    """
    p[0] = [JoinBlock(p[2])] + p[3]
Пример #22
0
def p_bgp_service_5(p):
    """
    bgp_service : LKEY join_block_service rest_union_block_service RKEY
    """
    bgp_arg = p[2] + p[3]
    p[0] = UnionBlock(JoinBlock(bgp_arg))
Пример #23
0
def p_bgp_service_01(p):
    """
    bgp_service :  LKEY join_block_service UNION join_block_service rest_union_block_service RKEY
    """
    ggp = [JoinBlock(p[2])] + [JoinBlock(p[4])] + p[5]
    p[0] = UnionBlock(ggp)
Пример #24
0
def p_union_block_0(p):
    """
    union_block : join_block rest_union_block
    """
    (jb,filters) = p[1]
    p[0] = [JoinBlock(jb,filters)] + p[2]
Пример #25
0
def p_rest_union_block_1(p):
    """
    rest_union_block : UNION LKEY join_block rest_union_block RKEY rest_union_block
    """
    (jb,filters) = p[3]
    p[0] = [JoinBlock(jb,filters)] + p[4] + p[6]
Пример #26
0
def p_union_block_service_0(p):
    """
    union_block_service : join_block_service rest_union_block_service
    """
    p[0] = [JoinBlock(p[1])] + p[2]