예제 #1
0
파일: core.py 프로젝트: noisyboiler/py2neo
 def stream(self, batch):
     response = self.post(batch)
     try:
         for i, result_data in grouped(response):
             result = JobResult.hydrate(assembled(result_data), batch)
             log.info("<<< %s", result)
             yield result
     finally:
         response.close()
예제 #2
0
파일: core.py 프로젝트: zrg1993/py2neo
 def stream(self, batch):
     response = self.post(batch)
     try:
         for i, result_data in grouped(response):
             result = JobResult.hydrate(assembled(result_data), batch)
             log.info("<<< %s", result)
             yield result
     finally:
         response.close()
예제 #3
0
    def stream(self, batch):
        """ Execute a collection of jobs and yield results as received.

        :arg batch: A :class:`.Batch` of jobs.
        :rtype: generator

        """
        response = self.post(batch)
        try:
            for i, result_data in grouped(response):
                result = JobResult.hydrate(assembled(result_data), batch)
                log.info("< %s", result)
                yield result
        finally:
            response.close()
예제 #4
0
파일: core.py 프로젝트: Spanarchie/Heroku
    def stream(self, batch):
        """ Execute a collection of jobs and yield results as received.

        :arg batch: A :class:`.Batch` of jobs.
        :rtype: generator

        """
        response = self.post(batch)
        try:
            for i, result_data in grouped(response):
                result = JobResult.hydrate(assembled(result_data), batch)
                log.info("< %s", result)
                yield result
        finally:
            response.close()
예제 #5
0
    def get(self, key, value):
        """ Fetch a list of all entities from the index which are associated
        with the `key`:`value` pair supplied::

            # obtain a reference to the "People" node index and
            # get all nodes where `family_name` equals "Smith"
            people = graph.get_or_create_index(neo4j.Node, "People")
            smiths = people.get("family_name", "Smith")

        ..
        """
        return [
            self.graph.hydrate(assembled(result))
            for i, result in grouped(self._searcher.expand(key=key, value=value).get())
        ]
예제 #6
0
    def get(self, key, value):
        """ Fetch a list of all entities from the index which are associated
        with the `key`:`value` pair supplied::

            # obtain a reference to the "People" node index and
            # get all nodes where `family_name` equals "Smith"
            people = graph.get_or_create_index(neo4j.Node, "People")
            smiths = people.get("family_name", "Smith")

        ..
        """
        return [
            self.graph.hydrate(assembled(result)) for i, result in grouped(
                self._searcher.expand(key=key, value=value).get())
        ]
예제 #7
0
    def query(self, query):
        """ Query the index according to the supplied query criteria, returning
        a list of matched entities::

            # obtain a reference to the "People" node index and
            # get all nodes where `family_name` equals "Smith"
            people = graph.get_or_create_index(neo4j.Node, "People")
            s_people = people.query("family_name:S*")

        The query syntax used should be appropriate for the configuration of
        the index being queried. For indexes with default configuration, this
        should be Apache Lucene query syntax.
        """
        resource = self._query_template.expand(query=query)
        for i, result in grouped(resource.get()):
            yield self.graph.hydrate(assembled(result))
예제 #8
0
    def query(self, query):
        """ Query the index according to the supplied query criteria, returning
        a list of matched entities::

            # obtain a reference to the "People" node index and
            # get all nodes where `family_name` equals "Smith"
            people = graph.get_or_create_index(neo4j.Node, "People")
            s_people = people.query("family_name:S*")

        The query syntax used should be appropriate for the configuration of
        the index being queried. For indexes with default configuration, this
        should be Apache Lucene query syntax.
        """
        resource = self._query_template.expand(query=query)
        for i, result in grouped(resource.get()):
            yield self.graph.hydrate(assembled(result))
예제 #9
0
 def _query_with_score(self, query, order):
     resource = self._query_template.expand(query=query, order=order)
     for i, result in grouped(resource.get()):
         meta = assembled(result)
         yield self.graph.hydrate(meta), meta["score"]
예제 #10
0
 def __iter__(self):
     for i, response in grouped(self.__response):
         yield BatchResponse.hydrate(assembled(response),
                                     self.body_hydrator)
     self.close()
예제 #11
0
 def _query_with_score(self, query, order):
     resource = self._query_template.expand(query=query, order=order)
     for i, result in grouped(resource.get()):
         meta = assembled(result)
         yield self.graph.hydrate(meta), meta["score"]
예제 #12
0
 def __iter__(self):
     for i, response in grouped(self.__response):
         yield BatchResponse.hydrate(assembled(response), self.body_hydrator)
     self.close()