예제 #1
0
    def add_column(self, results, selector):
        """Add the results as a column to the graph. Modification rules are given by the selector.

        Args:
            results (:class:`Context`): A `Context` that created by doing a query.
            selector (dict): Select results to add as column. Format is similar to selectors in `Context`

        Returns:
            :class:`Graph`: A new `Graph` with new columns.
        """
        self._ensure_loaded()
        check_argument(isinstance(selector, Mapping),
                       "selector of add column must be a dict")
        check_argument(self.graph_type == types_pb2.ARROW_PROPERTY)
        self._check_unmodified()
        selector = {
            key: results._transform_selector(value)
            for key, value in selector.items()
        }
        selector = json.dumps(selector)
        op = dag_utils.add_column(self, results, selector)
        return Graph(self._session, op)
예제 #2
0
    def add_column(self, results, selector):
        """Add the results as a column to the graph. Modification rules are given by the selector.

        Args:
            results: A instance of concrete class derive from (:class:`graphscope.framework.context.BaseContextDAGNode`):
                A context that created by doing an app query on a graph, and holds the corresponding results.
            selector (dict): Select results to add as column.
                Format is similar to selectors in :class:`graphscope.framework.context.Context`

        Returns:
            :class:`graphscope.framework.graph.GraphDAGNode`:
                A new graph with new columns, evaluated in eager mode.
        """
        check_argument(isinstance(selector, Mapping),
                       "selector of add column must be a dict")
        for key, value in selector.items():
            results._check_selector(value)
        selector = json.dumps(selector)
        op = dag_utils.add_column(self, results, selector)
        graph_dag_node = GraphDAGNode(self._session, op)
        graph_dag_node._base_graph = self
        return graph_dag_node