preql_queries.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:SynthDB 作者: shawnrushefsky 项目源码 文件源码
def graph_filter(self, g_id, dbid, head, conn):
    body = pickle.loads(cherrypy.request.body.read())
    filters = body['filter']
    if 'nodes' in filters and filters['nodes'] is not None:
        nf_name = str(uuid4())
        nfn = node_property_map(g_id, nf_name, 'bool', filters['nodes'], conn)['property_map']
        nf = property_maps[g_id][nfn]
    else:
        nf = None
    if 'links' in filters and filters['links'] is not None:
        lf_name = str(uuid4())
        lfn = link_property_map(g_id, lf_name, 'bool', filters['links'], conn)['property_map']
        lf = property_maps[g_id][lfn]
    else:
        lf = None
    if 'directed' in filters and filters['directed'] is not None:
        directed = filters['directed']
    else:
        directed = None
    if 'reversed' in filters and filters['reversed'] is not None:
        rev = filters['reversed']
    else:
        rev = False
    if 'filter_id' in filters and filters['filter_id'] is not None:
        g2_id = filters['filter_id']
    else:
        g2_id = str(uuid4()).replace('-', '_')
    g2 = gt.GraphView(graphs[g_id], vfilt=nf, efilt=lf, directed=directed, reversed=rev)
    graphs[g2_id] = g2
    prep_pm(g2_id)
    for pm in property_maps[g_id]:
        property_maps[g2_id][pm] = property_maps[g_id][pm]
    for nda in ndarrays[g_id]:
        ndarrays[g2_id][nda] = ndarrays[g_id][nda]
    return json.dumps({'subgraph': g2_id})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号