44# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55"""Contains implementations of database retrieveing objects"""
66from gitdb .util import (
7- pool ,
87 join ,
98 LazyMixin ,
109 hex_to_bin
1514 AmbiguousObjectName
1615)
1716
18- from async import (
19- ChannelThreadTask
20- )
21-
2217from itertools import chain
2318from functools import reduce
2419
@@ -41,47 +36,18 @@ def has_object(self, sha):
4136 binary sha is contained in the database"""
4237 raise NotImplementedError ("To be implemented in subclass" )
4338
44- def has_object_async (self , reader ):
45- """Return a reader yielding information about the membership of objects
46- as identified by shas
47- :param reader: Reader yielding 20 byte shas.
48- :return: async.Reader yielding tuples of (sha, bool) pairs which indicate
49- whether the given sha exists in the database or not"""
50- task = ChannelThreadTask (reader , str (self .has_object_async ), lambda sha : (sha , self .has_object (sha )))
51- return pool .add_task (task )
52-
5339 def info (self , sha ):
5440 """ :return: OInfo instance
5541 :param sha: bytes binary sha
5642 :raise BadObject:"""
5743 raise NotImplementedError ("To be implemented in subclass" )
5844
59- def info_async (self , reader ):
60- """Retrieve information of a multitude of objects asynchronously
61- :param reader: Channel yielding the sha's of the objects of interest
62- :return: async.Reader yielding OInfo|InvalidOInfo, in any order"""
63- task = ChannelThreadTask (reader , str (self .info_async ), self .info )
64- return pool .add_task (task )
65-
6645 def stream (self , sha ):
6746 """:return: OStream instance
6847 :param sha: 20 bytes binary sha
6948 :raise BadObject:"""
7049 raise NotImplementedError ("To be implemented in subclass" )
7150
72- def stream_async (self , reader ):
73- """Retrieve the OStream of multiple objects
74- :param reader: see ``info``
75- :param max_threads: see ``ObjectDBW.store``
76- :return: async.Reader yielding OStream|InvalidOStream instances in any order
77-
78- **Note:** depending on the system configuration, it might not be possible to
79- read all OStreams at once. Instead, read them individually using reader.read(x)
80- where x is small enough."""
81- # base implementation just uses the stream method repeatedly
82- task = ChannelThreadTask (reader , str (self .stream_async ), self .stream )
83- return pool .add_task (task )
84-
8551 def size (self ):
8652 """:return: amount of objects in this database"""
8753 raise NotImplementedError ()
@@ -129,27 +95,6 @@ def store(self, istream):
12995 :raise IOError: if data could not be written"""
13096 raise NotImplementedError ("To be implemented in subclass" )
13197
132- def store_async (self , reader ):
133- """
134- Create multiple new objects in the database asynchronously. The method will
135- return right away, returning an output channel which receives the results as
136- they are computed.
137-
138- :return: Channel yielding your IStream which served as input, in any order.
139- The IStreams sha will be set to the sha it received during the process,
140- or its error attribute will be set to the exception informing about the error.
141-
142- :param reader: async.Reader yielding IStream instances.
143- The same instances will be used in the output channel as were received
144- in by the Reader.
145-
146- **Note:** As some ODB implementations implement this operation atomic, they might
147- abort the whole operation if one item could not be processed. Hence check how
148- many items have actually been produced."""
149- # base implementation uses store to perform the work
150- task = ChannelThreadTask (reader , str (self .store_async ), self .store )
151- return pool .add_task (task )
152-
15398 #} END edit interface
15499
155100
0 commit comments