Ejemplo n.º 1
0
    def one(self):
        """See details in :method:`gremlin_python.driver.resultset.ResultSet.one`"""
        # avoid circular import
        from graphscope.framework.context import ResultDAGNode

        op = fetch_gremlin_result(self, "one")
        return ResultDAGNode(self, op)
Ejemplo n.º 2
0
    def all(self):
        """See details in :method:`gremlin_python.driver.resultset.ResultSet.all`

        Note that this method is equal to `ResultSet.all().result()`
        """
        # avoid circular import
        from graphscope.framework.context import ResultDAGNode

        op = fetch_gremlin_result(self, "all")
        return ResultDAGNode(self, op)
Ejemplo n.º 3
0
    def to_numpy(self, selector, vertex_range=None):
        """Select some elements of the graph and output to numpy.

        Args:
            selector (str): Select a portion of graph as a numpy.ndarray.
            vertex_range(dict, optional): Slice vertices. Defaults to None.

        Returns:
            :class:`graphscope.framework.context.ResultDAGNode`:
                A result holds the `numpy.ndarray`, evaluated in eager mode.
        """
        # avoid circular import
        from graphscope.framework.context import ResultDAGNode

        check_argument(self.graph_type == graph_def_pb2.ARROW_PROPERTY)
        vertex_range = utils.transform_vertex_range(vertex_range)
        op = dag_utils.graph_to_numpy(self, selector, vertex_range)
        return ResultDAGNode(self, op)
Ejemplo n.º 4
0
    def to_dataframe(self, selector, vertex_range=None):
        """Select some elements of the graph and output as a pandas.DataFrame

        Args:
            selector (dict): Select some portions of graph.
            vertex_range (dict, optional): Slice vertices. Defaults to None.

        Returns:
            :class:`graphscope.framework.context.ResultDAGNode`:
                A result holds the `pandas.DataFrame`, evaluated in eager mode.
        """
        # avoid circular import
        from graphscope.framework.context import ResultDAGNode

        check_argument(self.graph_type == graph_def_pb2.ARROW_PROPERTY)
        check_argument(
            isinstance(selector, Mapping),
            "selector of to dataframe must be a dict",
        )
        selector = json.dumps(selector)
        vertex_range = utils.transform_vertex_range(vertex_range)
        op = dag_utils.graph_to_dataframe(self, selector, vertex_range)
        return ResultDAGNode(self, op)